表结构操作

1
2
3
4
5
6
7
8
9
10
删除列:alter table person drop column birthday;
添加列:alter table person add column birthday datetime;
修改列:alter table person modify count bigint not null;
添加主键:alter table person add primary key(id);
删除主键:alter table person drop primary key;
添加唯一索引:alter table person add unique name_unique_index(name);
添加普通索引:alter table person add index birthday_index(birthday);
删除索引:alter table person drop index name_unique_index;(给出索引名)
改变某一列的编码:alter table person change name name varchar(255) character set utf8;
修改表名:alter table person to person_new;