| show tables | Shows all tables within the current database. |
>SHOW TABLES; |
| create table | Creates a new table in the current database. |
>CREATE TABLE TABLENAME ( COLUMN1 DATATYPE, COLUMN2 DATATYPE, COLUMN3 DATATYPE, .... CONSTRAINTS .... ); |
| alter table (add column) | Adds a new column to an existing table. |
>ALTER TABLE TABLENAME ADD COLUMNNAME DATATYPE; |
| alter table (drop column) | Deletes a column from an existing table. |
>ALTER TABLE TABLENAME DROP COLUMN COLUMNNAME; |
| alter table (alter column) | Alters an existing column in an already existing table. |
>ALTER TABLE TABLENAME ALTER COLUMN COLUMNNAME DATATYPE; |
| alter table(add primary key) | Alters or adds primary key to an existing table. |
>ALTER TABLE TABLENAME ADD PRIMARY KEY (COLUMNNAME,...); |
| alter table(drop primary key) | Drops an existing primary key in a table. |
>ALTER TABLE TABLENAME DROP PRIMARY KEY; |
| alter table(add foreign key) | Creates a foreign key on an existing table. |
>ALTER TABLE TABLENAME1 ADD FOREIGN KEY (COLUMN1) REFERENCES TABLENAME2(COLUMN2); |
| alter table(drop foreign key) | Deletes an existing foreign key in an already existing table. |
> ALTER TABLE TABLENAME DROP FOREIGN KEY FOREIGNKEY_NAME; |
| rename table | Changes the name of an existing table. |
>RENAME TABLE OLD_TABLENAME TO NEW_TABLENAME; |
| drop table | Deletes the entire table along with its definition. |
>DROP TABLE TABLE_NAME; |
| truncate table | Remove all records in a MySQL table. |
>TRUNCATE TABLE TABLENAME; |
| describe table | Displays all the columns of an existing table. |
>DESCRIBE TABLE_NAME; |
| describe table column | Displays all the values stored in a particular column. |
>DESCRIBE TABLE_NAME COLUMN_NAME; |