Description and remarks of fields in the read table in MySQL

Source: Internet
Author: User

Run the following table creation statement in MySQL. How can I retrieve the field information of this table from the data dictionary?
 
Drop table if exists test_table;
 
Create table test_table (
Test_ID int not null AUTO_INCREMENT primary key comment 'Primary KEY (auto-increment )',
Test_Key varchar (10) not null comment 'category ',
Test_Value varchar (20) not null comment 'date ',
Test_Type int not null comment 'internal type ',
Test_BelongTo int COMMENT 'subordination ',
Test_Grade int DEFAULT 1 COMMENT 'level ',
Test_Remark varchar (50) COMMENT 'note ',
Test_Visible bit DEFAULT 1 COMMENT 'visible'
)
COMMENT = 'test table ';
 
 
 
The answer is:
 
SELECT
 
Column_name AS 'column name ',
 
Data_type AS 'data type ',
 
Character_maximum_length AS 'character length ',
 
Numeric_precision AS 'numeric length ',
 
Numeric_scale AS 'decimal ',
 
Is_nullable AS 'whether to allow non-null ',
 
Case when extra = 'Auto _ secret'
 
THEN 1 ELSE 0 end as 'Auto increment ',
 
Column_default AS 'default ',
 
Column_comment AS 'note'
 
FROM
 
Information_schema.columns
 
WHERE
 
Table_Name = 'test _ table ';
 

Related Article

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.