DB Lab 7
DB Lab 7
Learning objectives:
Learn to use NOT NULL constraint.
Learn to use DEFAULT constraint.
Learn to use UNIQUE constraint.
Learn to use CHECK constraint.
7.0 Preliminaries
Create a table “Customer” with attributes of customer id, name, address, and date of birth and make
sure that customer id cannot be left blank.
DESCRIBE Customer;
DESCRIBE Customer;
Create a table “Product” with attributes of product id, name, and price. Set the product price to $100 if
no value is provided when a new product record is inserted.
DESCRIBE Product;
Add DEFAULT constraint to name attribute of the ‘Customer’ table with default value of ‘John Doe’.
DESCRIBE Customer;
Create a table “Shipment” with attributes of shipment id, customer id, product id, quantity, and ship
date. Make sure that shipment id cannot be repeated.
To add UNIQUE constraint to an already existing table use alter table DDL.
Add UNIQUE constraint to id attribute of the ‘Customer’ table.
Create a table “DummyCheck” with attributes of item and color. Make sure that color are only ‘blue’,
‘red’ or ‘green’.