首页 > 其他 > 详细

19_列的增删改

时间:2015-05-20 18:41:56      阅读:177      评论:0      收藏:0      [点我收藏+]

表的管理之列的增删改


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;


19_列的增删改

原文:http://1154179272.blog.51cto.com/10217799/1653260

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!