经常需要手动增加、删除、修改mysql表的字段类型,可以参考下面的例子:
增加多个字段:
ALTER TABLE `test11` ADD COLUMN ( `ucid` bigint(20) NOT NULL DEFAULT 0 COMMENT \'线索ucid\', `clue_type` int(11) NOT NULL DEFAULT \'1\' COMMENT \'线索类型1招生 2招商\', `work_type` int(11) NOT NULL DEFAULT 0 COMMENT \'线索工种\', `allottime` TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP COMMENT \'分单时间\', `allot_admin_id` int(11) NOT NULL DEFAULT 0 COMMENT \'分单人id\', `allot_store_id` int(11) NOT NULL DEFAULT 0 COMMENT \'分单门店\' )
删除多个字段:
ALTER TABLE `test11` DROP `clue_type`,DROP `work_type`,DROP `ucid`;
修改字段:
ALTER TABLE `test11` modify COLUMN `ucid` bigint(20) NOT NULL DEFAULT 0 COMMENT \'线索ucid\'; ALTER TABLE `test11` modify COLUMN `clue_type` int(1) NOT NULL DEFAULT \'1\' COMMENT \'线索类型1招生 2招商\'; ALTER TABLE `test11` modify COLUMN `work_type` int(3) NOT NULL DEFAULT 0 COMMENT \'线索工种\';