首页 > 数据库技术 > 详细

基本sql语句--列的增删改

时间:2016-10-08 19:42:34      阅读:169      评论:0      收藏:0      [点我收藏+]
列的增删改
 
列声明包括:列名称,列属性,【列类型】,【默认值】。
 
增加列:add
alter table 表名 add 列声明。
 
     如:alter table boy add height tinyint unsigned not null default 0;
增加的列,默认在表的最后一列。
可以用after声明新增列在那一列后面:alter table 表名 add 列声明 after 已存在列名。
     如:alter table boy add age tinyint unsigned not null default 0 after name;
 
若新增列想放在第一列,需要用first关键字:alter table 表名 add 列声明 first。
     如:alter table boy add id int primary key auto_increment first;
 
修改列:change
alter table 表名 change 被改变的列 列声明。
     如:alter table boy change height height smallint not null default 180;
 
删除列:drop
alter table 表名 drop 列名。
     如:alter table boy drop id;
技术分享

 

 
技术分享

基本sql语句--列的增删改

原文:http://www.cnblogs.com/skyline1011/p/5939548.html

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