Mysql 添加字段 修改字段 删除字段

1、添加字段(alter、add)

mysql> alter table users add name varchar(30) not null after id;

2、修改字段(alter、modify/change)

mysql> alter table users modify telno int unsigned default '0';

alter table users change telno phone int unsigned default '0';

modify与change的区别:change可以修改字段名称,modify不行

3、删除字段(alter、drop)

mysql> alter table users drop name;

4、表重命名(rename as)

mysql> alter table users_new rename as users;

5、删除表(drop)

mysql> drop table if exists users;

猜你喜欢

转载自www.cnblogs.com/niemx1030/p/11943691.html