[ERP system design] [database design] reads Table Comments and table field comments

Source: Internet
Author: User

Previously, due to the requirement of Project customers to see the table comment and field comment in the table, it was a bit confusing at the beginning. I have not done it before, but it is still a step by step.

Test: [A table already exists in the database, which is described here]

1. Create a table

Mysql> create table stu1 (-> id int not null auto_increment primary key comment "a"->)-> comment = "remark 1"; Query OK, 0 rows affected (0.11 sec) mysql> create table stu2 (-> id int not null auto_increment primary key comment "B"->)-> comment = "NOTE 2 "; query OK, 0 rows affected (0.07 sec) mysql> create table stu3 (-> id int not null auto_increment primary key comment "C"->) -> comment = "NOTE 3"; Query OK, 0 rows affected (0.11 sec) mysql> show tables; + ---------------- + | Tables_in_test | + ---------------- + | stu1 | stu2 | stu3 | test_table | + ---------------- + 4 rows in set (0.01 sec)

  

2. View All Table comments in the database

Essentials: select table_comment from information_schema.tables where table_schema = "Database Name ";

 

Mysql> select table_comment from information_schema.tables where table_schema = "test "; + --------------- + | table_comment | + --------------- + | Note 1 | Note 2 | Note 3 | test table | + --------------- + 4 rows in set (0.01 sec)

  

3. View All field comments in the data table

Essentials: select column_comment from Information_schema.columns where table_name = "table name ";

Mysql> select column_comment as "field comment" from Information_schema.columns where table_name = "stu1 "; + ---------- + | field comment | + ---------- + | a | + ---------- + 1 row in set (0.04 sec) mysql>

Summary:

The implementation of these statements is conducive to improving the user experience and achieving the objective of software dummies

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.