数据库
首页 > 数据库> > 获取数据库表字段的各项属性

获取数据库表字段的各项属性

作者:互联网

SELECT
	COLUMN_NAME "字段名称",
	COLUMN_TYPE "字段类型",
	CHARACTER_MAXIMUM_LENGTH "字段最大长度",
	IF( EXTRA = "auto_increment", CONCAT( COLUMN_KEY, "(", IF ( EXTRA = "auto_increment", "自增长", EXTRA ), ")" ), COLUMN_KEY ) "主外键",
	IS_NULLABLE "空标识",
	COLUMN_COMMENT "字段说明"
FROM
	information_schema.COLUMNS
WHERE TABLE_SCHEMA = '库名' AND TABLE_NAME = '表名';

image

标签:NAME,EXTRA,COLUMN,auto,数据库,表字,increment,TABLE,属性
来源: https://www.cnblogs.com/DJOSIMON/p/15841690.html