首先要知道information_schema是什么,在MySQL中,把 information_schema 看作是一个数据库,确切说是信息数据库。其中保存着关于MySQL服务器所维护的所有其他数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权 限等。
列出test数据库中所有的表名,类型(普通表还是view)和使用的引擎
select table_name, table_type, engine
FROM information_schema.tables
WHERE table_schema = 'test'
ORDER BY table_name DESC;
解释: 对表的meta data的查询需要使用information_schema.tables, table_schema是数据库的名称,table_name是具体的表名,table_type指的是表的类型