MySQL从information_schema查询表的所有字段信息,根据information_schema.tables表和information_schema.columns表
SELECT
t.table_schema,
t.table_name,
t.table_type,
c.column_name,
c.column_type,
c.column_default,
c.column_key,
c.is_nullable,
c.extra,
c.column_comment
FROM information_schema.tables t
INNER JOIN information_schema.columns c
ON t.table_name = c.table_name
AND t.table_schema = c.table_schema
WHERE 1=1
and t.table_schema = '库名'
and t.table_name = '表名';
版权声明:本文为u011809238原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。