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

MySQL 字段常用操作 添加,修改,删除,调整字段顺序

时间:2015-09-27 18:49:43      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:

整理备忘:

添加字段
alter table 表名
Add column 字段名 字段类型  默认值 AFTER 字段名 (在哪个字段后面添加)

例子:

alter table appstore_souapp_app_androidmarket
Add column getPriceCurrency varchar(50)   default null AFTER getPrice

修改字段
alter table表名
change 字段名 新字段名 字段类型 默认值

例子:

alter table appstore_souapp_app_androidmarket change hasPrice hasPrice varchar(10)  null;
ALTER TABLE xshop_update_fail CHANGE bill_no bill_no BIGINT(20) UNSIGNED NULL COMMENT 系统订单号

删除字段
alter table 表名 drop column 字段名

例子:

alter table appstore_souapp_app_androidmarket<BR>drop column getPriceCurrency

调整字段顺序
alter table 表名
change 字段名 新字段名 字段类型 默认值 after 字段名(跳到哪个字段之后)

例子:

alter table appstore_souapp_app_androidmarket<BR>change getPriceCurrency 
getPriceCurrency varchar(50)&nbsp;&nbsp; default null AFTER getPrice

 

原文:http://blog.csdn.net/changemyself/article/details/5976207

MySQL 字段常用操作 添加,修改,删除,调整字段顺序

标签:

原文地址:http://www.cnblogs.com/buyucoder/p/4842489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!