MySQL 建表时给表和字段加上注释

1.创建带注释的表

CREATE TABLE test.game(

nId INT PRIMARY KEY AUTO_INCREMENT COMMENT ‘设置主键自增’,

szName VARCHAR(128) COMMENT ‘游戏名字’,

szPath VARCHAR(256) COMMENT ‘下载路径’) COMMENT=‘表注释’;

2.查看整个表的结构

show create table test.game

3.修改现有表的注释

ALTER TABLE test.game COMMENT=‘最近游戏列表’;

4.查看表的注释

SELECT table_name,table_comment FROM information_schema.tables

WHERE table_schema = ‘test’ AND table_name =‘game’;

5.修改现有列,加上注释

alter table test.game modify column szPath varchar(255) comment ‘游戏路径’;

6.查看所有列的注释

SHOW FULL COLUMNS FROM test.game;

7.查看指定列的注释

SELECT column_name, column_comment FROM information_schema.columns

WHERE table_schema =‘test’ AND table_name = ‘game’;

你可能感兴趣的:(记录)