MySQL添加字段和删除字段
MySQL添加字段应该如何实现呢?这是很多刚刚接触MySQL数据库的新人都提到过的问题,下面就为您介绍MySQL添加字段和删除字段的方法,希望对您能有所启迪。
1. alter table `user_movement_log` Add column GatewayId int not null default 0 AFTER `Regionid` //(在哪个字段后面添加)
1. alter table `user_movement_log` drop column Gatewayid //删除字段
1. ALTER TABLE `user_movement_log` CHANGE `GatewayId` `GatewayId` int not null default 0 AFTER RegionID //调整字段顺序
1. alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id); //添加主键
1. alter table t1 change a b integer; //重命名列
1. alter table t1 change b b bigint not null; //改变列的类型 2. alter table infos change list list tinyint not null default '0';
1. alter table t1 rename t2; //重命名表
1. mysql> alter table tablename add index emp_name (name); //加索引
1. mysql> alter table tablename add primary key(id); //加主关键字索引
1. mysql> alter table tablename add unique emp_name2(cardnumber); //加唯一限制条件索引
1. mysql>alter table tablename drop index emp_name; //删除某个索引
- 下一篇: 如何理解tcp是面向连接,udp是无连接
- 上一篇: 良好的源代码控制管理十戒
相关推荐
- PHP函数十进制、二进制、八进制和十六进制转换
- Posted on 02月12日
- select与epoll
- Posted on 02月07日
- PHP对象的在函数间传递
- Posted on 02月26日
- 开机跳过Win8界面直接进入桌面的方法
- Posted on 02月19日