Home > Database > Mysql Tutorial > 开发日志:mySQL创建表时添加表和列的注释,以及查看表和列的注_MySQL

开发日志:mySQL创建表时添加表和列的注释,以及查看表和列的注_MySQL

PHP中文网
Release: 2016-05-27 14:12:20
Original
1489 people have browsed it

开发日志:mySQL创建表时添加表和列的注释,以及查看表和列的注_MySQL

1创建表时候添加默认注释

CREATE TABLE groups(   gid INT PRIMARY KEY AUTO_INCREMENT COMMENT '设置主键自增',  
gname VARCHAR(200) COMMENT '列注释',) COMMENT='表注释'
Copy after login

2修改已创建了的表注释

ALTER TABLE groups COMMENT '修改表注释'ALTER TABLE groups MODIFY COLUMN gname VARCHAR(100) COMMENT '修改列注释'
Copy after login

3查看表注释 ( 我喜欢用第二个 )

SHOW  CREATE TABLE communication_group
Copy after login

SELECT table_name,table_comment FROM information_schema.tables  
WHERE table_schema = '所在的db' AND table_name ='表名groups'
Copy after login

4查看列注释 ( 我喜欢用第一个 )

SHOW FULL COLUMNS FROM groups-- 这个可以按条件的去搜索某名字或某数据类型的列的信息:
例如SHOW FULL COLUMNS FROM tableName WHERE FIELD = 'add_time' OR TYPE LIKE '%date%' --
 查看tableName表中列名是add_time的或类型是date的列
Copy after login

SELECT  column_name, column_comment FROM information_schema.columns WHERE table_schema ='db'  
AND table_name = 'groups'
Copy after login

以上就是开发日志:mySQL创建表时添加表和列的注释,以及查看表和列的注_MySQL的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template