DBMS Assignment
DBMS Assignment
DBMS Assignment
LAB FILE
ON
DBMS (BCST-402)
Submitted
For
DBGI Dehradun
(Department of Computer Science)
Dev Bhoomi Institute of Technology, Dehradun
Prepared BY Submitted To
Name: Kajal Mr. Rahul Bhatt
Univ Roll No: 190080101059 Assistant Professor
Year:2nd DBIMS Dehradun
Semester:4th
INDEX
S.NO Practical Name Assigned Submission Remarks Signature
Date Date
How to create the 09/06/2021 16/06/2021
1 database, restore the
database and attach
the database.
How to create the 09/06/2021 16/06/2021
2 table in database.
How to insert the 09/06/2021 16/06/2021
3 data in table.
DELETE ,DROP 11/06/2021 16/06/2021
4 &TRUNCATE
10
LAB NO: 01
01
02 Program NO: 01
Objective: How to create the database , restore the database and attach the
database.
Description:
Here to create database we use syntax CREATE DATABASE database_name.
To restore database from the .bak file,we use the command RESTORE
DATABASE FROM DISK = ‘\’ GO make sure to replace database name with
the name of database you wish to restore. Also replace ‘backupfilepath’ with the
path of your database backup file and ‘BackupFileName’ with the name of your
.bak file. For restoring a specific file from the .bak file, use a command that
resembles the following: RESTORE DATABASE FILE = FROM DISK =’\’ GO,
Replace ‘FileName’ with the name of the file you wwant to restore.
To attach the database first of all create the new database like I created database
named as [Teacher] then come to the object explorer right click on the database
which you have created,select task and click DETACH then after few step the
created database will be detached. Now change the location of detached file from
their original location along with its log file to another drive.
Now to attach the database we use the syntax CREATE
DATABASE[database_name] ON
(FILENAME = ‘location of primary data file’),
(FILENAME = ‘location of secondary data file’),
FOR ATTACH
GO
Code: CREATE DATABASE Student;
RESTORE DATABASE [Student2] FROM DISK = N
‘D:\sql\Student.bak’ WITH FILE = 2, MOVE N ‘Student’ TO N
‘C:\Program Files\Microsoft SQL
Server\MSSQL.MSSQLSERVER\MSSQL\DATA\Student2.mdf’, MOVE
N ‘Student’ TO N ‘C:\Program Files\Microsoft SQL
Server\MSSQL.MSSQLSERVER\MSSQL\DATA\Student2_log,ldf’,
NOUNLOAD, STATS = 5
GO
USE [master]
GO
CREATE DATABASE [Teacher] ON
(FILENAME = N ‘D:\sql\Teacher.mdf’ ),
(FILENAME = N ‘D:\sql\Teacher_log.ldf’ ),
FOR ATTACH
GO
Output:
Create database Restore Attach
RUN
LAB NO: 01
01
02 Program NO: 02
Output:
STATUS REMARKS SIGNATURE
RUN
LAB NO: 01
01
02 Program NO: 02
Output:
STATUS REMARKS SIGNATURE
RUN
LAB NO: 02
01
02 Program NO: 01
RUN
LAB NO: 02
01
02 Program NO: 02
RUN