mysql添加表註釋、字段註釋、查看與修改註釋

1 創建表的時候寫註釋
create table test1
(
field_name int comment '字段的註釋'
)comment='表的註釋';

2 修改表的註釋
alter table test1 comment '修改後的表的註釋';

3 修改字段的註釋
alter table test1 modify column field_name int comment '修改後的字段註釋';
--注意:字段名和字段類型照寫就行

4 查看錶註釋的方法
--在生成的SQL語句中看
show create table test1;
--在元數據的表裏面看
use information_schema;
select * from TABLES where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G

5 查看字段註釋的方法
--show
show full columns from test1;
--在元數據的表裏面看
select * from COLUMNS where TABLE_SCHEMA='my_db' and TABLE_NAME='test1' \G
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章