在MySQL中,information_schema 可以理解为信息数据库;在INFORMATION_SCHEMA中,有数个只读表。它们实际上是视图,而不是基本表,因此,你将无法看到与之相关的任何文件。如数据库名,数据库的表,表栏的数据类型与访问权限等等。
select * from information_schema.SCHEMATA;
show databases
select * from information_schema.TABLES;
show tables from "schemaname或者databasename";
select * from information_schema.COLUMNS;
show columns from "schemaname.tablename";
select * from information_schema.STATISTICS;
show index from "schemaname.tablename";
select * from information_schema.USER_PRIVILEGES;
select * from information_schema.SCHEMA_PRIVILEGES;
select * from information_schema.TABLE_PRIVILEGES;
select * from information_schema.COLUMN_PRIVILEGES;
select * from information_schema.CHARACTER_SETS;
SHOW CHARACTER SET;
select * from information_schema.COLLATIONS;
select * from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY;
SHOW COLLATION;
select * from information_schema.TABLE_CONSTRAINTS;
select * from information_schema.KEY_COLUMN_USAGE;
select * from information_schema.ROUTINES;
select * from information_schema.VIEWS;
select * from information_schema.TRIGGERS;
COLUMNS表:提供了关于表中的列的信息。详细表述了某个列属于哪个表。
若要从这些视图中检索信息,请指定完全合格的 INFORMATION_SCHEMA (view_name)名称。
SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=‘数据库名’;