MySQL 工具sql
查询所有字段,根据库名获取所有的字段信息
SELECT TABLE_SCHEMA AS '库名', TABLE_NAME AS '表名', COLUMN_NAME AS '列名', ORDINAL_POSITION AS '列的排列顺序', COLUMN_DEFAULT AS '默认值', IS_NULLABLE AS '是否为空', DATA_TYPE AS '数据类型', CHARACTER_MAXIMUM_LENGTH AS '字符最大长度', NUMERIC_PRECISION AS '数值精度(最大位数)', NUMERIC_SCALE AS '小数精度', COLUMN_TYPE AS 列类型, COLUMN_KEY 'KEY', EXTRA AS '额外说明', COLUMN_COMMENT AS '注释' FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = 'fssuat' ORDER BY table_name, ordinal_position;
-- 查看数据库中所有表的记录数
use information_schema; SELECT table_name, table_rows FROM TABLES WHERE TABLE_SCHEMA='fssuat' ORDER BY table_rows DESC;
SELECT t.TABLE_NAME AS '表名', t.TABLE_COMMENT AS '表注释', c.COLUMN_NAME AS '列名', c.COLUMN_COMMENT AS '列注释', c.DATA_TYPE AS '数据类型', c.CHARACTER_MAXIMUM_LENGTH AS '字符最大长度' FROM information_schema.`TABLES` t JOIN information_schema.`COLUMNS` c ON t.TABLE_NAME = c.TABLE_NAME WHERE t.TABLE_SCHEMA = 'test'
参考: