ALTER [ONLINE | OFFLINE] [IGNORE] TABLEtbl_name
alter_specification
[,alter_specification
] ...alter_specification
:
table_options
| ADD [COLUMN]col_name
column_definition
[FIRST | AFTERcol_name
]
| ADD [COLUMN] (col_name
column_definition
,...)
| ADD {INDEX|KEY} [index_name
]
[index_type
] (index_col_name
,...) [index_option
] ...
| ADD [CONSTRAINT [symbol
]] PRIMARY KEY
[index_type
] (index_col_name
,...) [index_option
] ...
| ADD [CONSTRAINT [symbol
]]
UNIQUE [INDEX|KEY] [index_name
]
[index_type
] (index_col_name
,...) [index_option
] ...
| ADD FULLTEXT [INDEX|KEY] [index_name
]
(index_col_name
,...) [index_option
] ...
| ADD SPATIAL [INDEX|KEY] [index_name
]
(index_col_name
,...) [index_option
] ...
| ADD [CONSTRAINT [symbol
]]
FOREIGN KEY [index_name
] (index_col_name
,...)
reference_definition
| ALTER [COLUMN]col_name
{SET DEFAULTliteral
| DROP DEFAULT}
| CHANGE [COLUMN]old_col_name
new_col_name
column_definition
[FIRST|AFTERcol_name
]
| MODIFY [COLUMN]col_name
column_definition
[FIRST | AFTERcol_name
]
| DROP [COLUMN]col_name
| DROP PRIMARY KEY
| DROP {INDEX|KEY}index_name
| DROP FOREIGN KEYfk_symbol
| DISABLE KEYS
| ENABLE KEYS
| RENAME [TO]new_tbl_name
| ORDER BYcol_name
[,col_name
] ...
| CONVERT TO CHARACTER SETcharset_name
[COLLATEcollation_name
]
| [DEFAULT] CHARACTER SET [=]charset_name
[COLLATE [=]collation_name
]
| DISCARD TABLESPACE
| IMPORT TABLESPACE
|partition_options
| ADD PARTITION (partition_definition
)
| DROP PARTITIONpartition_names
| COALESCE PARTITIONnumber
| REORGANIZE PARTITION [partition_names
INTO (partition_definitions
)]
| ANALYZE PARTITION {partition_names
| ALL }
| CHECK PARTITION {partition_names
| ALL }
| OPTIMIZE PARTITION {partition_names
| ALL }
| REBUILD PARTITION {partition_names
| ALL }
| REPAIR PARTITION {partition_names
| ALL }
| PARTITION BYpartitioning_expression
| REMOVE PARTITIONINGindex_col_name
:
col_name
[(length
)] [ASC | DESC]index_type
:
USING {BTREE | HASH | RTREE}index_option
:
KEY_BLOCK_SIZE [=]value
|index_type
| WITH PARSERparser_name
table_options
:
table_option
[[,]table_option
] ... (seeCREATE TABLE
options)
ตัวอย่างการเพิ่ม column
ALTER TABLE TB1 ADD COLUMN_1 VARCHAR(5) AFTER COLUMN_2;
Refer
No comments:
Post a Comment