时间:2021-07-01 10:21:17 帮助过:2人阅读
修改字段:
alter table表名
change 字段名 新字段名 字段类型 默认值
例子:
- <span style="color: #0000ff">alter</span> <span style="color: #0000ff">table</span> appstore_souapp_app_androidmarket change hasPrice hasPrice <span style="color: #0000ff">varchar</span>(<span style="color: #800000; font-weight: bold">10</span>) <span style="color: #0000ff">null</span>;
- <span style="color: #0000ff">ALTER</span> <span style="color: #0000ff">TABLE</span> xshop_update_fail CHANGE bill_no bill_no <span style="color: #0000ff">BIGINT</span>(<span style="color: #800000; font-weight: bold">20</span>) UNSIGNED <span style="color: #0000ff">NULL</span> COMMENT <span style="color: #ff0000">‘</span><span style="color: #ff0000">系统订单号</span><span style="color: #ff0000">‘</span>
删除字段:
alter table 表名 drop column 字段名
例子:
- <span style="color: #0000ff">alter</span> <span style="color: #0000ff">table</span> appstore_souapp_app_androidmarket<span style="color: #808080"><</span>BR<span style="color: #808080">></span><span style="color: #0000ff">drop</span> <span style="color: #0000ff">column</span> getPriceCurrency
调整字段顺序:
alter table 表名
change 字段名 新字段名 字段类型 默认值 after 字段名(跳到哪个字段之后)
例子:
- <span style="color: #0000ff">alter</span> <span style="color: #0000ff">table</span> appstore_souapp_app_androidmarket<span style="color: #808080"><</span>BR<span style="color: #808080">></span><span style="color: #000000">change getPriceCurrency
- getPriceCurrency </span><span style="color: #0000ff">varchar</span>(<span style="color: #800000; font-weight: bold">50</span>)<span style="color: #808080">&</span>nbsp;<span style="color: #808080">&</span>nbsp; <span style="color: #0000ff">default</span> <span style="color: #0000ff">null</span> AFTER getPrice
原文:http://blog.csdn.net/changemyself/article/details/5976207
MySQL 字段常用操作 添加,修改,删除,调整字段顺序
标签: