How to read the description and remarks of the fields in the table under MySQL
In this issue, the editor will bring you instructions and remarks on how to read the fields in the table under MySQL. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
After running the following table statement under MySQL. How to retrieve the information about the fields 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 (self-growing)'
Test_Key varchar (10) NOT NULL COMMENT 'species'
Test_Value varchar (20) NOT NULL COMMENT 'Numeric'
Test_Type int NOT NULL COMMENT 'Internal Type'
Test_BelongTo int COMMENT 'dependency'
Test_Grade int DEFAULT 1 COMMENT 'Rank'
Test_Remark varchar (50) COMMENT 'remarks'
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 `digit length `
Numeric_scale AS `number of decimal places
Whether is_nullable AS `allows non-null nulls
CASE WHEN extra = 'auto_increment'
THEN 1 ELSE 0 END AS `whether self-increment or not
Column_default AS `default value `
Column_comment AS `remarks'
FROM
Information_schema.columns
WHERE
Table_Name='test_table'
The above is the description and remarks on how to read the fields in the table under MySQL shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.