在Mysql 里边 Alter TABLE 子选项中 alter column , change column , modify column 有什么区别?
Alter TABLE
alter column , change column , modify column
如果有一张大表,执行不同的选项会有什么差异? 求解答
认证高级PHP讲师
ALTER COLUMN: Set or remove the default value of a column (very fast operation) Example:
alter table film alter column rental_duration set default 5; alter table film alter column rental_duration drop default;
CHANGE COLUMN: Column renaming, column type change and column position movement Example:
ALTER TABLE MyTable CHANGE COLUMN foo bar VARCHAR(32) NOT NULL FIRST; ALTER TABLE MyTable CHANGE COLUMN foo bar VARCHAR(32) NOT NULL AFTER baz;
MODIFY COLUMN: Except that the column cannot be renamed, it does the same job as CHANGE COLUMN Example:
ALTER TABLE MyTable MODIFY COLUMN foo VARCHAR(32) NOT NULL AFTER baz;
Quoted from: http://blog.csdn.net/dba_waterbin/article/details/17884549
ALTER COLUMN: Set or remove the default value of a column (very fast operation)
Example:
CHANGE COLUMN: Column renaming, column type change and column position movement
Example:
MODIFY COLUMN: Except that the column cannot be renamed, it does the same job as CHANGE COLUMN
Example:
Quoted from: http://blog.csdn.net/dba_waterbin/article/details/17884549