ALTER Table Examples
ADD
Column
ALTER TABLE table_name
ADD column_name datatype;
AFTER
Note, you can add multiple columns at the same time.
ALTER TABLE table_name
ADD column_name datatype
AFTER column_name;
Rename Column
CHANGE
ALTER TABLE table_name
CHANGE old_column new_column DATATYPE;
DROP
Column
ALTER TABLE table_name
DROP column_name1,
DROP column_name2;
Table
DROP TABLE table_name;
RENAME
Table
ALTER TABLE table_name RENAME To new_table_name
Examples
-- Add a new column
ALTER TABLE users ADD lastname varchar(128);
-- Add a new column after another column
ALTER TABLE users ADD email varchar(128) AFTER lastname;
-- Rename a column
ALTER TABLE users CHANGE name firstname varchar(128);