mysql_注释

MYSQL注释

注释

为啥添加注释

字段有时候一多的话,会很麻烦,特别是我这种英语小白,用英文做字段,看下来全部字段满眼懵逼.所以添加上备注是最方便的

如何给字段添加注释

创建表的时候写注释
create table test1 ( 
    field_name int comment '字段的注释' 
)comment='表的注释'; 
修改已经创建好表的注释
alter table table_name comment '注释内容';//修改的是表注释
alter table table_name modify column field_name int comment'注释内容';//修改表中的字段注释1
alter table table_name modify column field_name varchar(255) comment'注释内容';//修改表中的字段注释2

上面2种不同的修改方法,注意类型要按照类型(长度)的方式,如果长度有的话;

如何查看注释

show full columns from table_name;//查看注释
//sql语句查看
show  create  table  table_name; 

延伸

只查询列名和类型和注释,方便修改注释
select column_name, column_type, column_comment from information_schema.columns where table_schema ='数据库名称' and table_name = '表名' ;

同样,也可以查看column_type等字段
只需要替换2个引号中间的即可,db为数据库名称,tablename为表名称

查看数据库下所有表名
select table_name from information_schema.tables where table_schema='数据库名称' and table_type='base table';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值