Difference between revisions of "Altering MySQL Tables"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (New page: =See= * http://dev.mysql.com/doc/refman/5.0/en/alter-table.html <pre> ALTER [IGNORE] TABLE tbl_name alter_specification [, alter_specification] ... alter_specification: table_op...) |
PeterHarding (talk | contribs) |
||
| Line 44: | Line 44: | ||
ALTER TABLE enables you to change the structure of an existing table. For example, yo | ALTER TABLE enables you to change the structure of an existing table. For example, yo | ||
</pre> | |||
=Examples= | |||
<pre> | |||
ALTER TABLE employees MODIFY fname NEWDEFINITION | |||
</pre> | </pre> | ||
Latest revision as of 10:36, 10 March 2008
See
ALTER [IGNORE] TABLE tbl_name
alter_specification [, alter_specification] ...
alter_specification:
table_option ...
| ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name ]
| ADD [COLUMN] (col_name column_definition,...)
| ADD {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
PRIMARY KEY [index_type] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...)
| ADD [FULLTEXT|SPATIAL] [INDEX|KEY] [index_name] (index_col_name,...)
| ADD [CONSTRAINT [symbol]]
FOREIGN KEY [index_name] (index_col_name,...)
reference_definition
| ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
| CHANGE [COLUMN] old_col_name new_col_name column_definition
[FIRST|AFTER col_name]
| MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]
| DROP [COLUMN] col_name
| DROP PRIMARY KEY
| DROP {INDEX|KEY} index_name
| DROP FOREIGN KEY fk_symbol
| DISABLE KEYS
| ENABLE KEYS
| RENAME [TO] new_tbl_name
| ORDER BY col_name [, col_name] ...
| CONVERT TO CHARACTER SET charset_name [COLLATE collation_name]
| [DEFAULT] CHARACTER SET charset_name [COLLATE collation_name]
| DISCARD TABLESPACE
| IMPORT TABLESPACE
index_col_name:
col_name [(length)] [ASC | DESC]
index_type:
USING {BTREE | HASH | RTREE}
ALTER TABLE enables you to change the structure of an existing table. For example, yo
Examples
ALTER TABLE employees MODIFY fname NEWDEFINITION