SHOW DATABASES; Display existing databases
CREATE DATABASE school; Create a new database
USE school; Go inside the database
CREATE TABLE student( sid INT (5), fname VARCHAR (20), lname VARCHAR (20), town VARCHAR (20), PRIMARY KEY (sid)); Create a new table with a primary key
SHOW TABLES; Display existing tables in the database
DESCRIBE student; Display the description of a table
CREATE TABLE course( coid INT (3), cname VARCHAR (20) fee DECIMAL(5)); Create a new table without a primary key ALTER TABLE course ADD PRIMARY KEY (coid); Add primary key after creating a table CREATE TABLE enroll( sid INT (5), coid INT (5), date VARCHAR(10), PRIMARY KEY (sid,coid), FOREIGN KEY (sid) REFERENCES student(sid)); Create a table with a foreign key
ATLER TABLE enroll ADD FOREIGN KEY (coid) REFERENCES course(coid); Add foreign key after creating a table
ALTER TABLE course ADD duration VARCHAR (10); Add a new column to a table ALTER TABLE course DROP duration; Remove a column from a table
ALTER TABLE course DROP PRIMARY KEY; Remove the primary key of a table
ALTER TABLE enroll DROP FOREIGN KEY sid; Remove a foreign key of a table DROP TABLE course; Remove a table DROP DATABASE school; Remove a database