Upload
desitoronto
View
148
Download
0
Embed Size (px)
Citation preview
5/14/2018 DBAS 55892 Assignment 2 Winter 2012 - slidepdf.com
http://slidepdf.com/reader/full/dbas-55892-assignment-2-winter-2012 1/3
DBAS 55892 Assignment Sheridan Institute
DBAS 55892 Assignment 2Due Date: the day of the final examination
Part I.
1. You are about to create a table and remember that one of the columns has to include a NOT
NULL constraint. Modify the following SQL command so that the column named colC cannotcontain a NULL value, and then create a table.
CREATE TABLE homework
(colA NUMBER,colB NUMBER(8,0),
colC DATE DEFAULT SYSDATE,
colD VARCHAR2(2));
2. Change the HOMEWORK table so colA and colB together are the primary key for the table.
3. Add a column to the HOMEWORK table with the name colE. This column should only beallowed to contain numeric values between 3 and 8. Name the constraint homework_colE_ck.
4. Change the HOMEWORK table so that the colB can only contain values that are stored in theOrder ID column of the ORDERS table in your database schema. Make certain that after you
make the change, colB is still part of the composite key created in Step 2.
5. Issue a select statement that would allow you to view the conditions for all the CHECK on the
HOMEWORK table.
6. Add another column to the HOMEWORK table. This column should be named colF and be
able to store dates. Although the column is no part of the primary key, it should not be allowedto contain any duplicate or NULL values.
7. Disable the constraint named homework_colE_ck.
8. You have decided that the primary key for the HOMEWORK table should only consist of column cola. Make the changes needed to make cola the only column used for the table’s
primary key.
9. Enable the constraint named homework_colE_ck.
10. Change the constraint on colB that references the ORDERS table so that if an order is deletedfrom the ORDERS table, any entries in the HOMEWORK table related to that order willautomatically be deleted also.
Part II
1. Write the command to create a public synonym named PUBLIC_STUDENT for the
STUDENT table in your database schema.
Page 1 of 2
5/14/2018 DBAS 55892 Assignment 2 Winter 2012 - slidepdf.com
http://slidepdf.com/reader/full/dbas-55892-assignment-2-winter-2012 2/3
DBAS 55892 Assignment Sheridan Institute
2. Create a private synonym PRIVATE_FACULTY for the FACULTY table in your databaseschema.
3. Write the command to select F_ID, F_LAST, and F_FIRST fields from all of the records inyour FACULTY table using your private synonym.
4. Create a sequence that will generate integers starting with the value 9. Each value should bethree less than the previous value generated. The lowest possible value the sequence should beallowed to generate is -1, and it should not be allowed to cycle. Name the sequence
MY_FIRST_SEQUENCE.
Page 2 of 2