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

How to query all tables and comments in mysql

WBOY
Release: 2022-05-19 10:42:07
Original
11155 people have browsed it

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;
Copy after login

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;
Copy after login

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'
Copy after login

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'
Copy after login

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template