0% found this document useful (0 votes)
7 views

COMP 2605 LAB 1

The document outlines a series of SQL tasks for creating and populating database tables related to a university's enterprise database systems course. It includes specifications for creating tables such as 'Department', 'Employees', 'Vendor', and 'Product', along with insert statements for populating these tables with sample data. Additionally, it covers creating sequences and modifying tables with new columns and constraints.

Uploaded by

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

COMP 2605 LAB 1

The document outlines a series of SQL tasks for creating and populating database tables related to a university's enterprise database systems course. It includes specifications for creating tables such as 'Department', 'Employees', 'Vendor', and 'Product', along with insert statements for populating these tables with sample data. Additionally, it covers creating sequences and modifying tables with new columns and constraints.

Uploaded by

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

The University of the West Indies

St. Augustine
Department of Computing and Information Technology
COMP 2605 – Enterprise Database Systems
ORACLE LAB # 1

1. Write an SQL create table statement to create a new table called Department with the following
specifications

Attribute Data type Constraint


NOT NULL, PRIMARY
DeptNum Number; Size: 3 KEY
Dname Varchar2; size: 12 NOT NULL
Loc Varchar2;size:12 NOT NULL

2. Write SQL insert statements to insert the following data into the Department table

DEPTNUM DNAME LOC


10 Accounting New York
20 Research Dallas
30 Sales Chicago
40 Operations Boston

3. Write an SQL create table statement to create a new table called Employees with the following
specifications

Attribute Data type Constraint


NOT NULL,
EmpNum Number, Size : 5 PRIMARY KEY
Ename Varchar2, Size:15 NOT NULL
Job Varchar2, Size:15 NOT NULL
Mgr Number, Size : 5
Hiredate date NOT NULL
Sal Number, Size: 7,2 NOT NULL
Comm Number, Size:7,2
FOREIGN KEY
referencing
DeptNum Number, Size:3 Department table

Page 1 of 3
4. Write an SQL insert statements to insert the following data into the Employees table

EmpNum Ename Job Mgr Hiredate Sal Comm DeptNum


7369 SMITH CLERK 7902 17th 800 NULL 20
December
1980
7566 JONES MANAGER 7839 2nd April 1987 1975 NULL 20
7499 ALLEN SALESMAN 7698 20th February 1600 300 30
1981
7839 KING PRESIDENT NULL 17th 5000 NULL 10
November,
1981

5. Run the script InstEmp.sql to populate the remaining tuples in the Employees table.

6. Create a new table, Vendor with the following specifications

Attribute Data type Constraint


NOT NULL, PRIMARY
VendorId Varchar2; size: 5 KEY
VendorName Varchar2;size:30 NOT NULL

7. Run the script InstVendor.sql to populate the Vendor table

8. Insert a row of data into the Vendor table with Vendor Id ‘DL’ and name ‘Dangers Ltd’.

9. Insert the following row of data into the Vendor table as it appears in the list

(‘Complete Computer Supplies’,’CCS’)

10. Change the name of vendor ‘DL’ to ‘MGB Enterprises’.

11. Create the Product table using the following specifications

Attribute Data type Constraint


NOT NULL,
ProductId Varchar2, Size:5 PRIMARY KEY
ProductName Varchar2, Size:30 NOT NULL
NOT NULL,
VendorId Varchar2,Size:5 FOREIGN KEY
NOT NULL; Must
be greater than or
UnitPrice Number.Size:8,2 equal to zero

Page 2 of 3
NOT NULL; Must
be greater than or
UnitsInStock Number,Size:3 equal to zero
ReorderQuantity Number,Size:3
ReorderFlag Char,Size:1 Default: N

12. Add a new column to the Product table,


Name: ReorderLevel
Data type: Number, Size:3
Default: 10

13. Create a sequence called testSequence, which starts with 1 and increments by 1.

14. Create a new table, SequenceTest using the following specifications

Attribute Data type Constraint


NOT NULL,
NumId Number, Size:5 PRIMARY KEY

15. Use the ‘testSequence’ sequence to insert the numbers 1 to 10 in the SequenceTest table.

Page 3 of 3

You might also like