2013-10-18 18 views
5

Ich verstehe nur nicht eine Sache. Wenn ich tippe:Holen Sie sich alle Tabellen von information_schema, MySQL

SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';

ich:

+----------------------------------------------+ 
| table_name         | 
+----------------------------------------------+ 
| columns_priv         | 
| db           | 
| event          | 
| func           | 
| general_log         | 
| help_category        | 
| help_keyword         | 
| help_relation        | 
| help_topic         | 
| host           | 
| ndb_binlog_index        | 
| plugin          | 
| proc           | 
| procs_priv         | 
| proxies_priv         | 
| servers          | 
| slow_log          | 
| tables_priv         | 
| time_zone         | 
| time_zone_leap_second      | 
| time_zone_name        | 
| time_zone_transition       | 
| time_zone_transition_type     | 
| user           | 
| cond_instances        | 
| events_waits_current       | 
| events_waits_history       | 
| events_waits_history_long     | 
| events_waits_summary_by_instance    | 
| events_waits_summary_by_thread_by_event_name | 
| events_waits_summary_global_by_event_name | 
| file_instances        | 
| file_summary_by_event_name     | 
| file_summary_by_instance      | 
| mutex_instances        | 
| performance_timers       | 
| rwlock_instances        | 
| setup_consumers        | 
| setup_instruments       | 
| setup_timers         | 
| threads          | 
+----------------------------------------------+ 
41 rows in set (0.23 sec) 

aber die Auswahl scheint gar nicht zu arbeiten:

mysql> select * from db; 
ERROR 1109 (42S02): Unknown table 'db' in information_schema 
mysql> 

Wie ist das möglich? Ich meine, zeigte SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';, dass es eine Tabelle ‚db‘ ...

Zweitens, wenn ich tippe benannt: SELECT table_name FROM INFORMATION_SCHEMA.TABLES; es gibt mir:

+----------------------------------------------+ 
| table_name         | 
+----------------------------------------------+ 
| CHARACTER_SETS        | 
| COLLATIONS         | 
| COLLATION_CHARACTER_SET_APPLICABILITY  | 
| COLUMNS          | 
| COLUMN_PRIVILEGES       | 
| ENGINES          | 
| EVENTS          | 
| FILES          | 
| GLOBAL_STATUS        | 
| GLOBAL_VARIABLES        | 
| KEY_COLUMN_USAGE        | 
| PARAMETERS         | 
| PARTITIONS         | 
| PLUGINS          | 
| PROCESSLIST         | 
| PROFILING         | 
| REFERENTIAL_CONSTRAINTS      | 
| ROUTINES          | 
| SCHEMATA          | 
| SCHEMA_PRIVILEGES       | 
| SESSION_STATUS        | 
| SESSION_VARIABLES       | 
| STATISTICS         | 
| TABLES          | 
| TABLESPACES         | 
| TABLE_CONSTRAINTS       | 
| TABLE_PRIVILEGES        | 
| TRIGGERS          | 
| USER_PRIVILEGES        | 
| VIEWS          | 
| INNODB_BUFFER_PAGE       | 
| INNODB_TRX         | 
| INNODB_BUFFER_POOL_STATS      | 
| INNODB_LOCK_WAITS       | 
| INNODB_CMPMEM        | 
| INNODB_CMP         | 
| INNODB_LOCKS         | 
| INNODB_CMPMEM_RESET       | 
| INNODB_CMP_RESET        | 
| INNODB_BUFFER_PAGE_LRU      | 
| columns_priv         | 
| db           | 
| event          | 
| func           | 
| general_log         | 
| help_category        | 
| help_keyword         | 
| help_relation        | 
| help_topic         | 
| host           | 
| ndb_binlog_index        | 
| plugin          | 
| proc           | 
| procs_priv         | 
| proxies_priv         | 
| servers          | 
| slow_log          | 
| tables_priv         | 
| time_zone         | 
| time_zone_leap_second      | 
| time_zone_name        | 
| time_zone_transition       | 
| time_zone_transition_type     | 
| user           | 
| cond_instances        | 
| events_waits_current       | 
| events_waits_history       | 
| events_waits_history_long     | 
| events_waits_summary_by_instance    | 
| events_waits_summary_by_thread_by_event_name | 
| events_waits_summary_global_by_event_name | 
| file_instances        | 
| file_summary_by_event_name     | 
| file_summary_by_instance      | 
| mutex_instances        | 
| performance_timers       | 
| rwlock_instances        | 
| setup_consumers        | 
| setup_instruments       | 
| setup_timers         | 
| threads          | 
+----------------------------------------------+ 
81 rows in set (0.00 sec) 

und Im der Lage zu tun: mysql> select * from events; und Im immer einige Ergebnisse. Warum das? Warum kann ich nur für Großbuchstaben auswählen? Und weiter, wie kann ich aus information_schema Tabellen auswählen, die nur in Großbuchstaben angegeben sind? Prost

Wenn es darauf ankommt: Im root angemeldet als meine db.

Antwort

2

'information_schema' hat nur Service-Informationen. Es hat Informationen über die Tabelle 'db' existiert, aber die Tabelle befindet sich NICHT in 'information_schema' DATABASE - irgendwo, aber nicht in 'information_schema'.

Info-Datenbank, die benötigte Tabelle in TABLE_SCHEMA Feld

+0

das ist die Erklärung, die ich verstehe gerettet hat! – yak

3

Sie nur table_name wählen, aber was table_schema:

MariaDB [(none)]> SELECT table_name, table_schema FROM INFORMATION_SCHEMA.TABLES WHERE 

    TABLE_TYPE = 'BASE TABLE'; 
    +----------------------------------------------+--------------------+ 
    | table_name         | table_schema  | 
    +----------------------------------------------+--------------------+ 
    | columns_priv         | mysql    | 
    | db           | mysql    | 
    | event          | mysql    | 
    | func           | mysql    | 
    | general_log         | mysql    | 
    | help_category        | mysql    | 
    | help_keyword         | mysql    | 
    | help_relation        | mysql    | 
    | help_topic         | mysql    | 
    | host           | mysql    | 
    | ndb_binlog_index        | mysql    | 
    | plugin          | mysql    | 
    | proc           | mysql    | 
    | procs_priv         | mysql    | 
    | proxies_priv         | mysql    | 
    | servers          | mysql    | 
    | slow_log          | mysql    | 
    | tables_priv         | mysql    | 
    | time_zone         | mysql    | 
    | time_zone_leap_second      | mysql    | 
    | time_zone_name        | mysql    | 
    | time_zone_transition       | mysql    | 
    | time_zone_transition_type     | mysql    | 
    | user           | mysql    | 
    | cond_instances        | performance_schema | 
    | events_waits_current       | performance_schema | 
    | events_waits_history       | performance_schema | 
    | events_waits_history_long     | performance_schema | 
    | events_waits_summary_by_instance    | performance_schema | 
    | events_waits_summary_by_thread_by_event_name | performance_schema | 
    | events_waits_summary_global_by_event_name | performance_schema | 
    | file_instances        | performance_schema | 
    | file_summary_by_event_name     | performance_schema | 
    | file_summary_by_instance      | performance_schema | 
    | mutex_instances        | performance_schema | 
    | performance_timers       | performance_schema | 
    | rwlock_instances        | performance_schema | 
    | setup_consumers        | performance_schema | 
    | setup_instruments       | performance_schema | 
    | setup_timers         | performance_schema | 
    | threads          | performance_schema | 
    +----------------------------------------------+--------------------+ 

Und Sie erhalten:

MariaDB [(none)]> select * from mysql.db; 
Empty set (0.00 sec) 
Verwandte Themen