MySQL中alter用法大全
admin 阅读:61 2024-03-02
1:删除列
alter table 【表名】 drop 【列名】2:增加列
alter table 【表名】 add 【列名】 int not null comment '注释说明'3:修改列的类型信息
alter table 【表名】modify 【列名】 char(10) 4:重命名列
alter table 【表名】【列名称】【新列名】5:重命名表
alter table 【表名】 rename 【新表名】6:删除表中主键
alter table 【表名】 drop primary key7:添加主键
alter table 【表名】 add CONSTRAINT PK_SJ_RESOURCE_CHARGES PRIMARY KEY (resid,resfromid)8:添加索引
alter table 【表名】 add index INDEX_NAME (name);9:添加唯一限制条件索引
alter table 【表名】 add unique emp_name2(cardnumber);10:删除索引
alter table 【表名】 drop index emp_name;11:加主关键字的索引
alter table 【表名】 add primary key(id);12:增加字段
alter table 【表名】 add field_name field_type;13:修改原字段名称及类型:
alter table 【表名】 table old_field_name new_field_name field_type;14:删除字段:
alter table 【表名】 drop field_name;声明
1、部分文章来源于网络,仅作为参考。 2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!





