INFORMATION_SCHEMA.TABLES
INFORMATION_SCHEMA.TABLES
是MySQL自带的(被视作)一个信息数据库,保存着MySQL服务器所维护的其他数据库的信息。INFORMATION_SCHEMA.TABLES
其中有数个只读表,实际上是视图,不是基本表,因此无法看到任何相关的文件。INFORMATION_SCHEMA.TABLES中各种字段名见此
-
查询(基础)表 方法一
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "数据库名" AND TABLE_TYPE = "BASE TABLE";
返回举例:
mysql> SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "test" AND TABLE_TYPE = "BASE TABLE"; +------------+ | TABLE_NAME | +------------+ | t | +------------+ 1 row in set (0.00 sec)
查询(基础)表 方法二
USE TABLE xxx SHOW TABLES;
返回举例:
mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | t | +----------------+ 1 row in set (0.00 sec)
-
查询视图
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = "数据库名" AND TABLE_TYPE = "VIEW";
-
查询所有触发器
SELECT * FROM information_schema.`triggers`;
测试证明,information_schema也遵循 “Linux平台MySQL不区分大小写”
mysql.proc
-
查询所有函数
SELECT name FROM mysql.proc WHERE db="数据库名" and type="funtion";
-
查询所有存储过程
SELECT name FROM mysql.proc WHERE db="数据库名" and type="procedure";
检测
mysql> SELECT name FROM mysql.proc WHERE db="test" and type="procedure"; +-------------------+ | name | +-------------------+ | add_sum | | add_sum_procedure | | findByNums | +-------------------+ 3 rows in set (0.00 sec)