Online Toy Store Management System
CREATE TABLE TOY_STORE_PRASANTH
(TOY_STORE_ID NUMBER(3) PRIMARY KEY,
TOY_STORE_NAME VARCHAR2(30) NOT NULL,
CITY VARCHAR2(30) DEFAULT 'Delhi',
PHONENUMBER NUMBER(10) NOT NULL UNIQUE,
STORE_OPENING_TIME TIMESTAMP CHECK(STORE_OPENING_TIME < '8:00:00') ,
STORE_CLOSING_TIME TIMESTAMP CHECK(STORE_CLOSING_TIME > '10:00:00'))
Table Created.
Constraints used:
PRIMARY KEY:
The PRIMARY KEY constraint uniquely identifies each record in a
database table. Primary keys must contain UNIQUE values. A primary
key column cannot contain NULL values. Most tables should have a primary
key, and each table can have only ONE primary key. A table can have only
one primary key, which may consist of single or multiple fields. When multiple
fields are used as a primary key, they are called a composite key.
NOT NULL:
We select only the records with no NULL
values. Always use IS NULL to look for NULL values.
DEFAULT Constraint:
The DEFAULT constraint is used
to insert a default value into a column.The default value will be added to all new records, if no other
value is specified.
UNIQUE:
The
UNIQUE constraint uniquely identifies each record in a database table.The
UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for
a column or set of columns. A PRIMARY KEY constraint automatically has a
UNIQUE constraint defined on it.
Note that you can have
many UNIQUE constraints per table, but only one PRIMARY KEY constraint per
table.
TIMESTAMP:
TIMESTAMP - format: YYYY-MM-DD
HH:MI:SS
No comments:
Post a Comment