MySQL:添加和查看表注释、字段注释

版权声明:本文为博主原创文章,欢迎转载,请注明出处 https://blog.csdn.net/mouday/article/details/89319738

添加注释

创建表的时候写注释

create table student
(
	name varchar(20) comment '字段的注释',
	age int comment '字段的注释'
)comment='表的注释';

修改注释

修改表的注释

alter table student comment '修改后的表的注释';

修改字段的注释

alter table student 
modify column name varchar(20) comment '修改后的字段注释';
--注意:字段名和字段类型照写就行

查看注释

查看表注释的方法

--在生成的SQL语句中看
show create table student;

--在元数据的表里面看
use information_schema;
select * from TABLES where TABLE_SCHEMA='demo' and TABLE_NAME='student' \G

查看字段注释的方法

--show
show full columns from student;

--在元数据的表里面看
select * from COLUMNS where TABLE_SCHEMA='demo' and TABLE_NAME='student' \G

参考
mysql添加表注释、字段注释、查看与修改注释

猜你喜欢

转载自blog.csdn.net/mouday/article/details/89319738