Home  >  Article  >  Database  >  How to query all tables and comments in mysql

How to query all tables and comments in mysql

WBOY
WBOYOriginal
2022-05-19 10:42:0711064browse

In mysql, you can use the "select TABLE_NAME,TABLE_COMMENT from INFORMATION_SCHEMA.Tables where table_schema = 'database name'" statement to query all tables and comments.

How to query all tables and comments in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to query all tables and comments in mysql

View the table names and table comments of all tables under the Mysql database. The syntax is as follows:

SELECT 
TABLE_NAME 表名,TABLE_COMMENT 表注释
FROM information_schema.tables
WHERE TABLE_SCHEMA = '数据库名' 
ORDER BY TABLE_NAME;

Expand knowledge :

1. View the table names, table comments and data volume of all tables under the Mysql database "ori_data"

SELECT 
TABLE_NAME 表名,TABLE_COMMENT 表注释,TABLE_ROWS 数据量
FROM information_schema.tables
WHERE TABLE_SCHEMA = 'ori_data' 
ORDER BY TABLE_NAME;

2. Query the database 'ori_data ' All field comments in the following table 'accumulation'

SELECT 
COLUMN_NAME 字段名,column_comment 字段注释 
FROM INFORMATION_SCHEMA.Columns 
WHERE table_name='accumulation' AND table_schema='ori_data'

3. Query the table names, table comments and corresponding table field comments of all tables under the database "ori_data"

SELECT 
a.TABLE_NAME 表名,a.TABLE_COMMENT 表注释,b.COLUMN_NAME 表字段,b.COLUMN_TYPE 字段类型,b.COLUMN_COMMENT 字段注释
FROM information_schema.TABLES a,INFORMATION_SCHEMA.Columns b 
WHERE b.TABLE_NAME=a.TABLE_NAME AND a.TABLE_SCHEMA='ori_data'

Recommended learning: mysql video tutorial

The above is the detailed content of How to query all tables and comments in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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