
有的,用如下方法:
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
在MySQL数据库中,\x0d\x0a字段或列的注释是用属性comment来添加。\x0d\x0a\x0d\x0a创建新表的脚本中,\x0d\x0a可在字段定义脚本中添加comment属性来添加注释。\x0d\x0a\x0d\x0a示例代码如下:\x0d\x0acreate table test(\x0d\x0aid int not null default 0 comment '用户id'\x0d\x0a)\x0d\x0a\x0d\x0a如果是已经建好的表,\x0d\x0a也可以用修改字段的命令,然后加上comment属性定义,就可以添加上注释了。\x0d\x0a\x0d\x0a示例代码如下:\x0d\x0aalter table test\x0d\x0achange column id id int not null default 0 comment '测试表id\x0d\x0a\x0d\x0a给表的字段或列添加注释已经知道了,\x0d\x0a那么如何来查看已有表的所有字段的注释呢?\x0d\x0a可以用命令:show full columns from table 来查看,\x0d\x0a示例如下:\x0d\x0ashow full columns from testALTER TABLE table_name COMMENT='这是表的注释'1.给表加注释:
ALTER TABLE table_name COMMENT='这是表的注释'2.给列加注释:
ALTER table table_name MODIFY `column_name` datetime DEFAULT NULL COMMENT '这是字段的注释'欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)