16.4 CREATE and DROP TABLE
CREATE TABLE statement is used for creating relations.
Each column is described with three parts:
- column name,
- data type,
- optional constraints.
- Constraints can be defined within the CREATE TABLE statement, or they can be added to the table after it is created using the ALTER table statement.
- PRIMARY KEY
- UNIQUE
- NULL / NOT NULL
- DEFAULT
- CHECK
- FOREIGN KEY
16.4.1 DROP TABLE
Remove the table definition and all table data and triggers as well.
DROP TABLE IF EXISTS ARTIST ;
If the table has FK,
SET FOREIGN_KEY_CHECKS = 0;
drop table if exists trans;
SET FOREIGN_KEY_CHECKS = 1;
16.4.2 TRUNCATE Table
Remove the data only.
set foreign_key_checks=0;
truncate table customer;
set foreign_key_checks=1;