mysql中的comment用法
mysql中的comment用法
在MySQL數據庫中,字段或列的注釋是用屬性comment來添加。
創建新表的腳本中,
可在字段定義腳本中添加comment屬性來添加注釋。
示例代碼如下:
create table test(
id int not null default 0 comment ‘用戶id’
)
如果是已經建好的表,
也可以用修改字段的命令,然后加上comment屬性定義,就可以添加上注釋了。
示例代碼如下:
alter table test
change column id id int not null default 0 comment ‘測試表id’
查看已有表的所有字段的注釋呢?
可以用命令:show full columns from table 來查看,
示例如下:
show full columns from test;
1 創建表的時候寫注釋
create table test1
(
field_name int comment ‘字段的注釋’
)comment=‘表的注釋’;
2 修改表的注釋
alter table test1 comment ‘修改后的表的注釋’;
3 修改字段的注釋
alter table test1 modify column field_name int comment ‘修改后的字段注釋’;
–注意:字段名和字段類型照寫就行
總結
以上是生活随笔為你收集整理的mysql中的comment用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java is a like a_JAV
- 下一篇: Scikit-Learn 机器学习笔记