标签:default change primary null
表的管理之列的增删改
1.增
alter table 表名 add 列声明;
默认这个新增的列在表的最后一列。
如果不想要新增的列在表的最后一列,那么可以:
alter table 表名 add 列声明 after 列名;
alter table 表名 add 列声明 first;
2.删
alter table 表名 drop 列名;
3.改
alter table 表名 change 被改变的列名 列声明;
----------------------
1.默认在表的最后一行增加一列身高sg:
alter table boy add sg tinyint not null default 111;
2.在列flower后增加一列age:
alter table boy add age tinyint not null default 20 after flower;
3.在表的第一列前面新增一列id:
alter table boy add id int primary key auto_increment first;
4.把身高列sg列名改成height ,属性改成无符号的tinyint unsigned:
alter table boy change sg height tinyint unsigned;
5.把新增的列都删掉
alter table boy drop height;
alter table boy drop age;
alter table boy drop id;
标签:default change primary null
原文地址:http://1154179272.blog.51cto.com/10217799/1653260