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 ';