MySQL中alter用法
-- 删除列
alter table 【表名】 drop 【列名】
-- 增加列
alter table 【表名】 add 【列名】 int not null comment '注释说明'
-- 修改列的类型信息
alter table 【表名】modify 【列名】 char(10)
-- 重命名列
alter table 【表名】【列名称】【新列名】
-- 重命名表
alter table 【表名】 rename 【新表名】
-- 删除表中主键
alter table 【表名】 drop primary key
-- 添加主键
alter table 【表名】 add CONSTRAINT PK_SJ_RESOURCE_CHARGES PRIMARY KEY (resid,resfromid)
-- 添加索引
alter table 【表名】 add index INDEX_NAME (name);
-- 添加唯一限制条件索引
alter table 【表名】 add unique emp_name2(cardnumber);
-- 删除索引
alter table 【表名】 drop index emp_name;
-- 加主关键字的索引
alter table 【表名】 add primary key(id);
-- 增加字段
alter table 【表名】 add field_name field_type;
-- 修改原字段名称及类型:
alter table 【表名】 table old_field_name new_field_name field_type;
-- 删除字段:
alter table 【表名】 drop field_name;
MySQL中after用法
在该表的指定列名后面加该列名
-- 增加列
alter table 【表名】 add 【列名】 int not null comment '注释说明' AFTER 【指定列名】
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Boy_Martin/article/details/126603466