Description: Changes the structure of an existing table.
Usage: action_list can contain any number of actions separated by commas, with keywords whose syntax is listed in Table B.1.
Syntax for Action in action_list | Action Performed |
---|---|
ADD [COLUMN] column_declaration [FIRST | AFTER column_name] | Add a column to the table. |
ADD INDEX [index_name] (column_name,...) | Add an index on one or more columns, optionally named but otherwise taking its name from column_name, the first indexed column. |
ADD PRIMARY KEY (column_name,...) | Add a primary key. |
ADD UNIQUE [index_name] (column_name,...) | Add a unique key on one or more columns, optionally named but otherwise taking its name from column_name, the first indexed column. |
ADD FULLTEXT [index_name] (column_name,...) | Add a full-text index on one or more columns, optionally named but otherwise taking its name from column_name, the first indexed column. |
ADD [CONSTRAINT symbol] FOREIGN KEY index_name (column_name,...) [reference_definition] | Does nothing; included for compatibility only. |
ALTER [COLUMN] column_name {SET DEFAULT literal | DROP DEFAULT} | Specify new default value for a column or remove old default value. |
CHANGE [COLUMN] column_name column_declaration [FIRST | AFTER other_column_name] | Modify declaration of column column_name to new name and declaration given by column_declaration. Optionally moves column to first position or places it after other_column_name if FIRST or AFTER specified. |
MODIFY [COLUMN] column_declaration [FIRST | AFTER other_column_name] | Modify column declaration without renaming declaration given by column_declaration. Optionally moves column to first position or places it after other_column_name if FIRST or AFTER specified. |
DROP [COLUMN] column_name | Drop a column and all data contained within it. |
DROP PRIMARY KEY | Drop a table's primary key. |
DROP INDEX index_name | Drop named index from a table. |
DISABLE KEYS | Stops MySQL updating non-unique indexes on MyISAM tables (MySQL 4.0 onward). |
ENABLE KEYS | Create missing non-unique indexes on MyISAM tables (MySQL 4.0 onward). |
RENAME [TO] new_table_name | Rename a table. |
ORDER BY column_name | Sort rows of data on column_name. This can improve performance, but rows will not remain sorted after subsequent write operations. |
table_options | Change table options. See CREATE TABLE for details. |
Description in: Day 6
3.15.151.32