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

列的增删改
 
列声明包括:列名称,列属性,【列类型】,【默认值】。
 
增加列: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语句--列的增删改
 
基本sql语句--列的增删改