CH-13 Table Creation and Data Manipulation
CH-13 Table Creation and Data Manipulation
USE myDb;
SHOW DATABASES;
Unique Constraint
Default Constraint
Check Constraint
Unique Constraint
This specify no two rows have the same
value in the specified columns
Unique Constraint
This declares a column as the primary key
of the table. This constraint is similar to
unique constraint except that only one
column can be applied in this constraint .
Primary Key Constraint
The primary key cannot allow NULL values
Unique Constraint
1).
Unique Constraint
Descp char(20) CHECK
(descp
IN(‘NUT’,’BOLT’,’SCREW’,’WRENCH’,’NAIL’))
2)
Primary Key Constraint Price decimal CHECK(price BETWEEN 253.00
and 770.00)
3)Ordate char(10) NOT NULL CHECK(ordate
LIKE ‘- -/- -/- - - -’)
Default Constraint
4) CHECK (
( discount=0.15 AND city=‘HISSAR’)OR
( discount=0.13 AND city=‘JAIPUR’)OR
Check Constraint ( discount=0.17 AND city=‘MOHALI’))
DESC[RIBE] <Tablename>;
SHOW TABLES;
CREATING TABLE FROM EXISTING TABLE
Show columns from<tablename>;
CHANGING DATA WITH DML COMMANDS
INSERT INTO COMMAND
Order of column With MODIFY clause can reorder column within table. Use FIRST or
AFTER clause to specify the position of the column.
MODIFYING COLUMN DEFINATIONS
Order of column