日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Mysql 常见ALTER TABLE操作

發布時間:2023/12/9 数据库 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mysql 常见ALTER TABLE操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

刪除列

alter table table_name drop col_name;

增加列(單列)

alter table table_name add col_name col_type comment 'xxx';

增加列(多列)

alter table table_name add col_name col_type comment 'xxx', add col_name col_type(col_length) comment 'xxx';

增加表字段并指明字段放置為第一列

alter table table_name add col_name col_type COMMENT 'sss' FIRST;

增加表字段并指明字段放置為特定列后面

alter table table_name add col_name col_type after col_name_1;

使用MODIFY修改字段類型

alter table table_name modify column col_name col_type;

使用CHANGE修改字段類型

alter table table_name change col_name col_name col_type;

使用CHANGE修改字段名稱

alter table table_name change old_col_name new_col_name col_type;

修改列類型、長度

alter table table_name change old_col_name new_col_name new_col_type;

?

查看表中列屬性

show columns from table_name;

修改表名

rename table old_table_name to new-table-name;

為字段設置NOT NULL和NULL

alter table table_name modify col_name col_type not null commit '字段注釋';

alter table table_name modify col_name col_type default null commit?'字段注釋';

修改字段的默認值

alter table table_name alter col_name set default 10000;

字段刪除默認值?

alter table table_name alter col_name drop default;

?

新增到指定位置語法
alter table app add `name` varchar(64) default '' commit '應用名稱' after `app_id`;
修改順序語法:alter table 表名 change 老字段名 新字段名 字段各種約束 after 字段;
alter table `app` change `title` `title` VARCHAR(64) default '' commit '名稱' after `name`;

總結

以上是生活随笔為你收集整理的Mysql 常见ALTER TABLE操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。