属性:
SELECT
TABLE_SCHEMA AS 库名,
TABLE_NAME AS 表名,
COLUMN_NAME AS 字段名,
ORDINAL_POSITION AS 字段顺序,
COLUMN_DEFAULT AS 默认值,
IS_NULLABLE AS 是否为空,
DATA_TYPE AS 字段类型,
CHARACTER_MAXIMUM_LENGTH AS 长度,
NUMERIC_PRECISION AS '数值精度(最大数)',
NUMERIC_SCALE AS 小数精度,
column_comment AS 字段注释,
EXTRA AS 额外说明,
column_key AS 约束
FROM
information_schema.COLUMNS
WHERE
table_schema = '数据库名'
AND table_name = '表名';
样例:
SELECT
TABLE_SCHEMA AS 库名,
TABLE_NAME AS 表名,
COLUMN_NAME AS 字段名,
ORDINAL_POSITION AS 字段顺序,
COLUMN_DEFAULT AS 默认值,
IS_NULLABLE AS 是否为空,
DATA_TYPE AS 字段类型,
CHARACTER_MAXIMUM_LENGTH AS 长度,
NUMERIC_PRECISION AS '数值精度(最大数)',
NUMERIC_SCALE AS 小数精度,
column_comment AS 字段注释,
EXTRA AS 额外说明,
column_key AS 约束
FROM
information_schema.COLUMNS
WHERE
table_schema = 'industry_model_hkht'
AND table_name = 'visit_count';