CREATE
The CREATE command in SQL is a DDL (Data Definition Language) command. Other DDL commands include: ALTER and DROP.
Example: Create a table named orders
CREATE TABLE orders (
order_id int(10) not null auto_increment,
payment_id int(10) not null,
product_id int(10) not null,
quantity int(10) not null,
primary key (order_id) );
Example: Change a table structure using the ALTER TABLE command
The following SQL statement will add a field to the Orders table.
ALTER TABLE orders
ADD order_date date not null;
Example: Change a table structure using the ALTER TABLE command
The following SQL statement will drop (delete) a field to the Orders table.
ALTER TABLE orders
DROP COLUMN order_date;
Example: Change a table structure using the ALTER TABLE command
The following SQL statement will change (modify) a field in the orders table. In this case, the quantity field is being increased from an int of size 10 to an int of size 12.
ALTER TABLE orders
MODIFY COLUMN quantity int(12) not null,;