0% found this document useful (0 votes)
23 views2 pages

SQL Training Data Answers

The document contains instructions for creating, modifying, and dropping databases and tables in SQL Server. It includes commands to create a database called training_db, alter its collation and rename it to maple_training_db. It also creates a snapshot database of maple_training_db and later drops the snapshot database. Additional commands create tables with columns, primary keys, foreign keys, check constraints and alter tables by adding, dropping and modifying columns.

Uploaded by

gk.mobm33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

SQL Training Data Answers

The document contains instructions for creating, modifying, and dropping databases and tables in SQL Server. It includes commands to create a database called training_db, alter its collation and rename it to maple_training_db. It also creates a snapshot database of maple_training_db and later drops the snapshot database. Additional commands create tables with columns, primary keys, foreign keys, check constraints and alter tables by adding, dropping and modifying columns.

Uploaded by

gk.mobm33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ANSWERS

1. USE master;
GO
CREATE DATABASE training_db
COLLATE French_CI_AI ;
2. USE master;
GO
ALTER DATABASE training_db
COLLATE SQL_Latin1_General_CP1_CI_AS;
GO
3. USE master;
GO
ALTER DATABASE training_db Modify Name = maple_training_db;
GO
4. USE master;
GO
CREATE DATABASE maple_training_db_snapshot0600 ON
( NAME = SPri1_dat, FILENAME = 'D:\SalesData\SPri1dat_0600.ss'),
( NAME = SPri2_dat, FILENAME = 'D:\SalesData\SPri2dt_0600.ss'),
( NAME = SGrp1Fi1_dat, FILENAME = 'D:\SalesData\SG1Fi1dt_0600.ss'),
( NAME = SGrp1Fi2_dat, FILENAME = 'D:\SalesData\SG1Fi2dt_0600.ss'),
( NAME = SGrp2Fi1_dat, FILENAME = 'D:\SalesData\SG2Fi1dt_0600.ss'),
( NAME = SGrp2Fi2_dat, FILENAME = 'D:\SalesData\SG2Fi2dt_0600.ss')
AS SNAPSHOT OF maple_training_db;
GO

5. DROP DATABASE maple_training_db_snapshot0600;


6. DROP DATABASE Sales, NewSales;
7. CREATE TABLE dbo. tbl_empmaster
(
EID int NOT NULL IDENTITY(1,1),
rankid smallint NOT NULL,
Salary decimal(18,2) NULL,
doj datetime NULL,
dob nvarchar(50) NULL,
PRIMARY KEY (EID),
FOREIGN KEY (SalesPersonID) REFERENCES SalesPerson(SalesPersonID)
);

8. CREATE TABLE dbo.tbl_empmaster


(
EID int NOT NULL IDENTITY(1,1),
Name nvarchar(50) NULL,
SALARY money NULL,
Age int NOT NULL,
CONSTRAINT CHK_Person CHECK (Age>=21 AND Age<=35),
PRIMARY KEY (PurchaseOrderID)
);
9. ALTER TABLE Persons DROP CONSTRAINT CHK_Person;
10. ALTER TABLE tbl_empmaster ADD address nvarchar(MAX);
11. ALTER TABLE tbl_empmaster DROP address nvarchar(MAX);
12. ALTER TABLE tbl_empmaster ALTER COLUMN dob datetime;
13. ALTER TABLE tbl_empmaster ADD CONSTRAINT FK_empmaster
FOREIGN KEY (tbl_departmentmaster) REFERENCES Persons(DeptID);
14. ALTER TABLE tbl_empmaster DROP CONSTRAINT FK_empmaster;

You might also like