ALTER [IGNORE] TABLE table_name action_list

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.

Table B.1. Actions Performed by ALTER TABLE
Syntax for Action in action_listAction 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_nameDrop a column and all data contained within it.
DROP PRIMARY KEYDrop a table's primary key.
DROP INDEX index_nameDrop named index from a table.
DISABLE KEYSStops MySQL updating non-unique indexes on MyISAM tables (MySQL 4.0 onward).
ENABLE KEYSCreate missing non-unique indexes on MyISAM tables (MySQL 4.0 onward).
RENAME [TO] new_table_nameRename a table.
ORDER BY column_nameSort rows of data on column_name. This can improve performance, but rows will not remain sorted after subsequent write operations.
table_optionsChange table options. See CREATE TABLE for details.

Description in: Day 6

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.151.32