1、查询一个表中有多少个字段:
SELECT COUNT(*) FROM information_schema. COLUMNS
WHERE table_schema = '数据库名'
AND table_name = '表名';
2、查询一个数据库中有多少张表:
SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES WHERE table_schema = '数据库名' GROUP BY table_schema;
3、查询一个数据库中一共有多少个字段:
SELECT COUNT(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '数据库名';
4、查询一个数据库中的所有表和所有字段、字段类型及注释等信息:
SELECT TABLE_NAME, column_name, DATA_TYPE, column_comment FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = '数据库名' ;