SELECT
LOWER(t.column_name) NAME,
IF(t.is_nullable = 'yes' , '1' , '0') nullable,
(t.ordinal_position * 10) sort ,
t.column_comment COMMENT ,
t.data_type dataType ,
t.character_maximum_length maxLength,
t.column_type columnType,
t.column_key columnKey,
t.extra extra
FROM
information_schema.`columns` t
WHERE table_name = UPPER('表名') AND t.table_schema = '库名'
# 也可以直接查当前选择数据库 AND t.table_schema = (SELECT DATABASE())
ORDER BY t.ordinal_position asc