You are on page 1of 22

LAPORAN PRAKTIKUM

SISTEM MENEJEMEN BASIS DATA

JOBSHEET-2: BEKERJA
DENGAN DATABASE

Oleh :

Farid Aziz Wicaksono


1841720094
TI-2E

PROGRAM STUDI TEKNIK INFORMATIKA


JURUSAN TEKNOLOGI INFORMASI
POLITEKNIK NEGERI MALANG
FEBRUARI 2020
Praktikum
Working with tempdb
1
. Step 1: Open Object Explorer, expand the Proseware, expand Databases, expand System
Databases, right-click tempdb and click properties. Select the Files tab and review the
initial size of tempdb and its log file. Also review the Autogrowth settings.

Step 2: Change the initial value of the tempdev database file to 20MB and click OK to increase
the size of tempdb.

Step 3: Right-click tempdb in Object Explorer again and select Reports -> Standard Reports ->
Disk Usage and note that the size of tempdb has changed and that the tempdb data file is
almost empty. (In the pie chart, this is shown as "Unallocated")
Step 4: Highlight and execute the following code against the master database.

Step 5: Right click tempdb in Object Explorer and select Reports -> Standard Reports -> Disk
Usage and note that the size of tempdb has changed and that tempdb data file is full.
Expand Data/Log File Autogrow/Autoshrink Events to view the autogrow events that
happened.
Step 6: Restart the Proseware server (In Object Explorer right-click the Proseware server, and
click Restart. In the Microsoft SQL Server Management Studio dialog window, click
Yes. In the Next Microsoft SQL Server Management Studio dialog window, click Yes).

Step 7: Right click tempdb in Object Explorer and select Reports -> Standard Reports -> Disk
Usage and note that the size of tempdb has changed back to the previous configured size
of 20MB.
Creating Databases
1. Step 1: Open Object Explorer, expand Proseware, right-click Databases and click New Database.
Step 2: In the new database dialog type NewDB as the database name. Review the default initial
sizes for data and log file sizes that will be created and keep the values as provided and
click OK.

Step 3: Right-click NewDB in Object Explorer, select Properties and review the database
created. (On the general tab, note the size and space available and how that relates to
the sizes shown on the Files tab. close the Database Properties - NewDB window)
Step 4: Create a database using T-SQL

Step 5: Review databases and their state using T-SQL


Step 6: Review files that are used by the new Branch database

Altering Databases
1. Step 1: Add a new file to the NewDB database created before.

Step 2: Create a table and add data.


Step 3: Right-click NewDB in Object Explorer and select Reports -> Standard Reports -> Disk
Usage and expand the Disk Space Used by Data Files. Note that the data is distributed
evenly across the two files. Expand Data/Log File Autogrow/Autoshrink Events and
note how many autogrowths have already occurred because the initial sizes of the files
were too small.

File groups
1. Step 1: Add a Filegroup and data file to the Branch database created before. (Right-click
Databases in Object Explorer and click Refresh. Right-click the Branch database and
click Properties. Select the Files tab and click Add. In the new line that is added, enter
Branch_dat2 as the Logical Name, and choose <New Filegroup> for the Filegroup. In
the popup window, enter Data_FG as the name of the new filegroup and click OK, then
click OK to save the database properties)
Step 2: Create a new table.

Step 3: Check the filegroup that the table was created in.

The table was created in the PRIMARY filegroup as it is declared as the default filegroup
of the database. Note that it is best practice that the PRIMARY filegroup is only used for system
objects and not user data,when several filegroups are used in the database.
Step 4: Drop the table and create it in the Data_FG filegroup.

Step 5: Check the filegroup that the table was created in.

Step 6: Change the default filegroup


Step 7: Create a new table without specifying a filegroup and check where it was created. Note
that the table was created in Data_FG which is now the new default filegroup.
Detach and Attach
1 Step 1: Close all tabs except this tab
.

Step 2: Create a new database called CurrencyEval

Step 3: Detach the CurrencyEval database.


(Expand Proseware in Object Explorer, right-click Databases and click Refresh.
Expand Databases, right-click CurrencyEval, click Tasks, click Detach and click OK
Step 4: In windows explorer, move the following files as specified
- D:\MKTG\CurrencyEval.mdf --> D:\MSSQLSERVER\CurrencyEval.mdf
- L:\MKTG\CurrencyEval.ldf --> L:\MSSQLSERVER\CurrencyEval.ldf

Step 5: Connect to the AdventureWorks server and expand Databases


- (In Object Explorer, click Connect and click Database Engine. In the Connect to
Server window, enter AdventureWorks as the servername and click Connect.
- Expand AdventureWorks, expand Databases). Note that the database CurrencyEval
is not present.

Step 6: Attach the CurrencyEval database to the AdventureWorks server.


(Right-click Databases in Object Explorer, and click Attach. Click Add, navigate to the
file D:\MSSQLSERVER\CurrencyEval.mdf and click OK).

Step 7: Note that the log file is shown as missing.

Step 8: Locate the log file.


(Click the ellipsis beside the Current File Path for the log entry and navigate to the file
L:\MSSQLSERVER\CurrencyEval.ldf and click OK) Note that the message about the
log file not being found has now gone.

Step 9: Click OK to attach the database


and note that CurrencyEval now appears in the list of databases in Object Explorer.

Moving and Reconfiguring tempdb


1 Step 1: Using Windows Explorer,
. create new folders for the log files (Create the folders D:\TEMPDB and L:\TEMPDB)

Step 2: Move the existing default tempdb files to the new location.
Note the message that tells you that the change will be applied on the next restart.

Step 3: In Windows Explorer, navigate to D:\TEMPDB and note that the files have not moved
yet.
Step 4: Add three new data files to tempdb

Step 5: In Windows Explorer,


navigate to D:\TEMPDB and note that the files have been created in the folder but that
the original file has not yet moved.

Step 6: Restart the Proseware server


In Object Explorer right-click the Proseware server, and click Restart. In the Microsoft SQL
Server Management Studio dialog window, click Yes.
In the Next Microsoft SQL Server Management Studio dialog window, click Yes).

Step 7: Navigate to D:\TEMPDB and note that the file has now been moved.
Also navigate to D:\MKTG and L:\MKTG and note that the original files are still there and
should be deleted, to avoid confusion.

Tugas: Working with Databases


Lab Setup
1. Click Microsoft SQL Server 2012, Click SQL Server Management Studio, hubungkan
ke Server Window, Buka Project/Solution 10775A_04_PRJ.ssmssqlproj
2. Pada view menu, click Solution Explorer. Buka dan eksekusi 00-Setup.sql skrip dalam
Solution Explorer

Lab Scenario
1. Sebagai database administrator anda diharapkan bisa mengkonfigurasi basisdata. Anda
harus membuat basisdata baru pada server, sesuai dengan spesifikasi kebutuhan
aplikasi yang dibutuhkan oleh vendor (tabel). Klien mengirimkan basisdata yang akan
diinstal pada instance server baru. Selain mengirimkan backup, klient juga
mengirimkan basisdata yang telah detach dan log file. Anda perlu untuk meng attach
(memasang) basisdata tersebut pada instance server yang baru.

Konsultan memberikan rekomendasi untuk konfigurasi dalam pembuatan tempdb,


sehingga anda perlu untukmereview dan mengimplementasikan apa yang telah
konsultan rekomendasikan.

Berikut adalah supporting document:

Tempdb Size Requirement :


File Size (MB)
Data 30
Log 10

RateTracking Database Specification


Item Requirement
DatabaseName RateTracking
Primary Data File Logical name = RateTracking_dat
File name = RateTracking.mdf
Folder = D:\MKTG
Initial size = 10MB
Maximum file size = 100MB
Autogrowth amount = 10MB
Filegroup = PRIMARY
Log File Logical name = RateTracking_log
File name = RateTracking.ldf
Folder = L:\MKTG
Initial size = 20MB
Maximum file size = unlimited
Autogrowth amount = 20MB
Filegroup = Not Applicable
Secondary Data File Logical name = RateTracking_dat_1
#1 File name = RateTracking_1.ndf
Folder = D:\MKTG
Initial size = 20MB
Maximum file size = 100MB
Autogrowth amount = 10MB
Filegroup = USERDATA
Secondary Data File #2 Logical name =
RateTracking_dat_2
File name = RateTracking_2.ndf
Folder = D:\MKTG
Initial size = 20MB
Maximum file size = 100MB
Autogrowth amount = 10MB
Filegroup = USERDATA
Secondary Data File Logical name = RateTracking_dat_3
#3 File name = RateTracking_3.ndf
Folder = D:\MKTG
Initial size = 200MB
Maximum file size = 500MB
Autogrowth amount = 50MB
Filegroup = ARCHIVE
Secondary Data File #4 Logical name =
RateTracking_dat_4
File name = RateTracking_4.ndf
Folder = D:\MKTG
Initial size = 200MB
Maximum file size = 500MB
Autogrowth amount = 50MB
Filegroup = ARCHIVE
Default Filegroup USERDATA

Requirement Tempdb dari konsultan


Filename Requirements
Secondary Data File Logical name = tempdev2
#1 File name = tempdb_file2.ndf
Folder = D:\MKTG
Initial size = 20MB
Maximum file size = unlimited
Autogrowth amount = 10MB
Secondary Data File Logical name = tempdev3
#2 File name = tempdb_file3.ndf
Folder = D:\MKTG
Initial size = 20MB
Maximum file size = unlimited
Autogrowth amount = 10MB
Secondary Data File Logical name = tempdev4
#3 File name = tempdb_file4.ndf
Folder = D:\MKTG
Initial size = 20MB
Maximum file size = unlimited
Autogrowth amount = 10MB
Latihan 1: Sesuaikan Konfigurasi tempdb
Tugas 1: Sesuaikan ukuran tempdb
1.

Tugas 2: Periksa bahwa ukuran tempdb masih benar setelah di restart


1.
Latihan 2: Buat Database RateTracking
Tugas 1: Buat database
1
.

Tugas 2: Buat grup dan file yang diperlukan


1
.

Tugas 3: Ubah grup-grup default untuk basis data


1
.

Latihan 3: Attach Database OldProspects


Tugas 1: Salin file database
1.

Tugas 2: Lampirkan database ke instance MKTG


1.

You might also like