Get the App
SLTechnology News&Howtos  ›  Database  › 

How to view comments in the mysql table

Shulou Source: shulou.com Published: 2022-06-01 02:00:13 10月04日 Update

Editor to share with you how to check the notes in the mysql table, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The way to view the comments in the mysql table: 1, to view the comments of all tables through the "information_schema.TABLES" statement; 2, to view the comments of all tables through "information_schema.TABLES a LEFT JOIN..." Statement to query comments for all tables and fields, and so on.

Mysql view table comments or field comments

View comments for all tables

SELECTtable_name table name, table_comment table description FROMinformation_schema.TABLESWHEREtable_schema = 'database name' ORDER BYtable_name

Query comments for all tables and fields

SELECTa.table_name table name, a.table_comment table description, b.COLUMN_NAME field name, b.column_comment field description, b.column_type field type, b.column_key constraint FROMinformation_schema. TABLES aLEFT JOIN information_schema. COLUMNS b ON a.table_name = b.TABLE_NAMEWHEREa.table_schema = 'database name' ORDER BYa.table_name

Query comments for all fields of a table

Select COLUMN_NAME field name, column_comment field description, column_type field type, column_key constraint from information_schema.columns where table_schema = 'database name' and table_name = 'table name'

Or

Show full columns from table name

View the DDL generated by the table

Note that table names are not enclosed in single quotation marks

Show create table table name

Create new tables and add comments for tables and fields

Create table t_user (ID INT (19) primary key auto_increment comment 'primary key', NAME VARCHAR (300) comment 'name', CREATE_TIME date comment 'creation time') comment = 'user information table'

Modify the comments of the table / field

Modify table comments

Alter table t_user comment = 'modified table annotation information (user information table)'

Modify field comment

Alter table t_user modify column id int comment 'primary key ID'; above is all the contents of how to view the comments in the mysql table. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Fields comments comments information data database query content user article type statement not much most name quotation mark method time more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Linux Apple Huawei Shulou Tech Info