In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following is to introduce how to use the SQL query statement to obtain the table name of the table in the Mysql database, table description, field ID, field name, data type, length, precision, whether it can be null, default value, self-increment, primary key, column description.
Query table information (table name / table description)
SELECT table_name name,TABLE_COMMENT value FROM INFORMATION_SCHEMA.TABLES WHERE table_type='base table' and table_schema = 'database name' order by table_name asc
2. Query field information (field ID/ field name / data type / length / precision / whether it can be null/ default value / self-increment / primary key / column description)
Method 1:
SHOW FULL COLUMNS FROM table name
Method 2:
Select ORDINAL_POSITION as Colorder,Column_Name as ColumnName,data_type as TypeName,COLUMN_COMMENT as DeText, (case when data_type = 'float' or data_type =' double' or data_type = 'decimal' then NUMERIC_PRECISION else CHARACTER_MAXIMUM_LENGTH end) as length,NUMERIC_SCALE as Scale, (case when EXTRA='auto_increment' then 1 else 0 end) as IsIdentity, (case when COLUMN_KEY='PRI' then 1 else 0 end) as IsPK, (case when IS_NULLABLE =' NO' then 0 else 1 end) as CanNull COLUMN_DEFAULT as DefaultValfrom information_schema.columns where table_schema = 'database name' and table_name = 'table name' order by ORDINAL_POSITION asc
These are several ways for Sql to obtain column information such as table names and field names and data types in the MySql database. If it is not what you need, you can also take a look at the related articles below.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.