information_schema.schemata-Mysql查询

查数据库:
        
  1. mysql > select schema_name from information_schema . schemata ;
  2. +--------------------+
  3. | schema_name |
  4. +--------------------+
  5. | information_schema |
  6. | mysql |
  7. | newdb |
  8. | performance_schema |
  9. | test |
  10. +--------------------+
  11. 5 rows in set ( 0.02 sec )
查当前数据库的表:
        
  1. mysql > select table_name from information_schema . tables where table_schema = datab
  2. ase ();
  3. Empty set ( 0.00 sec )
查当前数据库表的列:
        
  1. mysql> select column_name from information_schema.columns where table_schema ='newdb' and table_name ='users'; +-------------+ | column_name | +-------------+ | id | | username | | password | +-------------+ 3 rows in set (0.05 sec)