<新增一個欄位>
ALTER TABLE `{table_name}` ADD `{new_column_name}` {new_column_type} CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
EX:
ALTER TABLE `User` ADD `name` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
EX:
ALTER TABLE `User` ADD `name` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '' COMMENT '姓名' ;
<修改已經存在的欄位>
ALTER TABLE `{table_name}` CHANGE `{column_name_original}` `{column_name_modified}` {column_type} CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '{default_value}'
EX:
ALTER TABLE `User` CHANGE `name` `name` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT ' '
沒有留言:
張貼留言