Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:mysql:alter_table [2007/03/24 22:40] – billh | docs:mysql:alter_table [2008/08/03 00:25] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== ALTER TABLE ====== | ====== ALTER TABLE ====== | ||
* http:// | * http:// | ||
+ | |||
+ | ===== Standard Syntax ===== | ||
+ | <code sql> | ||
+ | ALTER TABLE tablename | ||
+ | ( | ||
+ | ADD|DROP | ||
+ | ADD|DROP | ||
+ | ... | ||
+ | ); | ||
+ | </ | ||
===== Adding a Primary Key ===== | ===== Adding a Primary Key ===== | ||
Line 13: | Line 23: | ||
* alter table mytable CONVERT TO CHARACTER SET latin1 [COLLATE collation_name]; | * alter table mytable CONVERT TO CHARACTER SET latin1 [COLLATE collation_name]; | ||
+ | ===== Converting to a different engine ===== | ||
+ | * alter table mytable type = INNODB; | ||
+ | * alter table mytable type = MYISAM; | ||
+ | |||
+ | ===== Renaming a Column ===== | ||
+ | * alter table weeks change status_id status_type_id int(2) not null; | ||
+ | * table name: weeks | ||
+ | * old column name: status_id | ||
+ | * new column name: status_type_id |