MySQL 查询字段类型注释等信息

table_schema :库名
table_name :表名
表名及表注释

1
SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema='table_schema';

所有:

1
2
3
select *
from information_schema.columns
where table_schema ='databaseName' and table_name = 'tableName';

主要信息:

1
2
3
4
5
6
7
8
select COLUMN_NAME,COLUMN_TYPE,
CASE WHEN IS_NULLABLE = 'NO'
THEN ('是')
ELSE ('否')
END,
COLUMN_DEFAULT,COLUMN_COMMENT
from information_schema.columns
where table_schema ='databaseName' and table_name = 'tableName';
ˆ Back To Top