数据库表的修改

数据库表的修改

1.添加列:
alter table <表名> add <新列名> <数据类型> [first|after 已存在列名];

alter table t_user add tel int;

2.修改列名
alter table <表名> change <旧列名> <新列名> <新数据类型>;

alter table t_user change tel email varchar(30);

3.修改列的数据类型:
alter table <表名> modify <列名> <数据类型>;

alter table t_user modify email char(20);

4.修改列的排列位置:
alter table <表名> modify <列名1> <数据类型> first|after <列名2>;

alter table t_user modify email char(20) after name;

5.删除列
alter table <表名> drop <列名>;

alter table t_userc drop email;

6.修改表名
alter table <旧表名> rename to <新表名>

alter table t_user rename to tab_user;

猜你喜欢

转载自blog.csdn.net/weixin_44121790/article/details/104239739