Development Log: add notes for tables and columns when creating a mySQL table, and view the notes for tables and columns _ MySQL

Source: Internet
Author: User
Development Log: Add comments for tables and columns when creating a table in mySQL, and view comments for tables and columns. Development Log: add notes for tables and columns when creating a mySQL table, and view the notes for tables and columns _ MySQL

1. add a default comment when creating a table

Create table groups (gid int primary key AUTO_INCREMENT COMMENT 'Set primary key auto-incrementing', gname VARCHAR (200) COMMENT 'column COMMENT ',) COMMENT = 'Table COMMENT'

2. modify the created table comment

Alter table groups COMMENT 'alter TABLE groups modify column gname VARCHAR (100) comment' modify column comment'

3. View table comments (I like to use the second one)

SHOW  CREATE TABLE communication_group

Or

SELECT table_name, table_comment FROM information_schema.tables WHERE table_schema = 'DB 'AND table_name = 'Table name group'

4. View column comments (I like to use the first one)

Show full columns from groups -- you can search for the information of a name or column of a data type by condition: for example, show full columns from tableName where field = 'add _ time' or type like '% date %' -- View COLUMNS whose column name is add_time OR whose TYPE is date in the tableName table

Or

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

The above is the development log: mySQL adds notes for tables and columns when creating tables, as well as views the content of note_mysql for tables and columns. For more information, see PHP Chinese network (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.