mysql新增、修改、刪除字段

  平時我們創建表、新增、修改字段等造作一般習慣於用navicat等可視化插件,但是生產環境我們沒有權限的,一般都是寫好SQL提交DBA執行,這時候我們就不能可視化使用插件了,就需要寫SQL腳本了。幾個開發者常用的語句記錄下:

1、新增字段並指定添加位置

alter table mc_wechat_user add merchant_id int(10) DEFAULT 0  COMMENT '商戶id' not Null after wx_uid;

2、修改字段名字

alter table mc_wechat_user change column `status` active int(11) DEFAULT 1 COMMENT '1正常 2刪除' not Null;

3、刪除指定的字段

alter table mc_wechat_user drop`status`;

4、修改表名

alter table mc_wechat_user rename as mc_wechat_user_info;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章