



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




































<schema_name>.<table_name>( col1_name
col1_type, col2_name
col2_type, ...colM_name
colM_type, constraint1,...,constraintN
example with no constraints: CREATE
dept_locations
dnumber
integer(4), dlocation
varchar(15)
if schema name isomitted, table createdin the default DBstatement ends withsemi-colon
other options:
Dnumber
CHECK(Dnumber
AND^ Dnumber
CREATE^
TABLE^ product
(category
INT^ NOT
NULL,^
id^ INT^
NOT^ NULL,
price^ DECIMAL,PRIMARY
KEY(category,
id))^ ENGINE=INNODB;
CREATE^
TABLE^ customer
(id^ INT
NOT^ NULL,PRIMARY^ KEY^ (id))
ENGINE=INNODB;
CREATE^
TABLE^ product_order
(no INT
NOT^ NULL
AUTO_INCREMENT, product_category
INT^ NOT
NULL,
product_id
INT^ NOT
NULL, customer_id
INT^ NOT
NULL,
PRIMARY
KEY(no), INDEX^ (product_category,
product_id),
FOREIGN
KEY^ (product_category,
product_id)
REFERENCES
product(category,
id)
ON^ UPDATE
CASCADE
ON^ DELETE
RESTRICT,
INDEX^ (customer_id),FOREIGN
KEY^ (customer_id)REFERENCES^ customer(id))
ENGINE=INNODB;
defines “storage engine”
not the same as
the SELECT operation of the relational
multi-set
(sometimes called
a^ bag ) of tuples; it is
not^ a set of tuples