查看所有数据库中所有表的数据库名和表名
SELECT `TABLES`.`TABLE_SCHEMA`, `TABLES`.`TABLE_NAME` FROM `information_schema`.`TABLES`
查看所有数据库中所有基本表的数据库名和表名
SELECT `TABLES`.`TABLE_SCHEMA`, `TABLES`.`TABLE_NAME` FROM `information_schema`.`TABLES` WHERE `TABLES`.`TABLE_TYPE` = ‘base table‘;
查看test1数据库中t1表中的所有列信息
其中order by `ORDINAL_POSITION`指按照表中原有列的顺序
SELECT * FROM `information_schema`.`COLUMNS` where `TABLE_SCHEMA`=‘test1‘ and `TABLE_NAME`=‘t1‘ order by `ORDINAL_POSITION`;
查看test1数据库所有表中的表名称和列名
SELECT DISTINCT TABLE_NAME,COLUMN_NAME FROM `information_schema`.`COLUMNS` where `TABLE_SCHEMA`=‘test1‘;
时间: 2024-12-30 00:03:23