码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2016-10-08 19:44:58      阅读:181      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!