Changing or modifying a structure of an existing table is done by using ALTER TABLE statement. The "structure" that may be changed with ALTER TABLE includes following options:

  • adding columns;
  • dropping columns;
  • changing data type of a column;
  • adding keys;
  • renaming table;
  • etc...

Syntax

ALTER TABLE table_name

   (

   action1[,action2,?];

   )

Adding a column in a table is written like this:

ALTER TABLE table_name ADD column_name datatype;

Following two examples are showing how to delete a column, and change data type respectively:

ALTER TABLE table_name DROP COLUMN column_name;

ALTER TABLE table_name MODIFY column_name datatype;

With the ALTER TABLE statement we can also rename a table:

ALTER TABLE date RENAME TO date_and_time;