MySQL 如何获取视图列表
为了获取MySQL视图列表,我们可以使用SELECT命令和LIKE操作符。让我们先看一下语法。
mysql> SELECT TABLE_SCHEMA, TABLE_NAME
-> FROM information_schema.tables
-> WHERE TABLE_TYPE LIKE 'VIEW';
以下是输出,显示视图的总数。
+--------------+-----------------------------------------------+
| TABLE_SCHEMA | TABLE_NAME |
+--------------+-----------------------------------------------+
| sys | version |
| sys | innodb_buffer_stats_by_schema |
| sys | xinnodb_buffer_stats_by_schema |
| sys | innodb_buffer_stats_by_table |
| sys | xinnodb_buffer_stats_by_table |
| sys | schema_object_overview |
| sys | schema_auto_increment_columns |
| sys | xschema_flattened_keys |
| sys | schema_redundant_indexes |
| sys | ps_check_lost_instrumentation |
| sys | latest_file_io |
| sys | xlatest_file_io |
| sys | io_by_thread_by_latency |
| sys | xio_by_thread_by_latency |
| sys | io_global_by_file_by_bytes |
| sys | xio_global_by_file_by_bytes |
| sys | io_global_by_file_by_latency |
| sys | xio_global_by_file_by_latency |
| sys | io_global_by_wait_by_bytes |
| sys | xio_global_by_wait_by_bytes |
| sys | io_global_by_wait_by_latency |
| sys | xio_global_by_wait_by_latency |
| sys | innodb_lock_waits |
| sys | xinnodb_lock_waits |
| sys | memory_by_user_by_current_bytes |
| sys | xmemory_by_user_by_current_bytes |
| sys | memory_by_host_by_current_bytes |
| sys | xmemory_by_host_by_current_bytes |
| sys | memory_by_thread_by_current_bytes |
| sys | xmemory_by_thread_by_current_bytes |
| sys | memory_global_by_current_bytes |
| sys | xmemory_global_by_current_bytes |
| sys | memory_global_total |
| sys | xmemory_global_total |
| sys | schema_index_statistics |
| sys | xschema_index_statistics |
| sys | xps_schema_table_statistics_io |
| sys | schema_table_statistics |
| sys | xschema_table_statistics |
| sys | schema_table_statistics_with_buffer |
| sys | xschema_table_statistics_with_buffer |
| sys | schema_tables_with_full_table_scans |
| sys | xschema_tables_with_full_table_scans |
| sys | schema_unused_indexes |
| sys | schema_table_lock_waits |
| sys | xschema_table_lock_waits |
| sys | statement_analysis |
| sys | xstatement_analysis |
| sys | statements_with_errors_or_warnings |
| sys | xstatements_with_errors_or_warnings |
| sys | statements_with_full_table_scans |
| sys | xstatements_with_full_table_scans |
| sys | xps_digest_avg_latency_distribution |
| sys | xps_digest_95th_percentile_by_avg_us |
| sys | statements_with_runtimes_in_95th_percentile |
| sys | xstatements_with_runtimes_in_95th_percentile |
| sys | statements_with_sorting |
| sys | xstatements_with_sorting |
| sys | statements_with_temp_tables |
| sys | xstatements_with_temp_tables |
| sys | user_summary_by_file_io_type |
| sys | xuser_summary_by_file_io_type |
| sys | user_summary_by_file_io |
| sys | xuser_summary_by_file_io |
| sys | user_summary_by_statement_type |
| sys | xuser_summary_by_statement_type |
| sys | user_summary_by_statement_latency |
| sys | xuser_summary_by_statement_latency |
| sys | user_summary_by_stages |
| sys | xuser_summary_by_stages |
| sys | user_summary |
| sys | xuser_summary |
| sys | host_summary_by_file_io_type |
| sys | xhost_summary_by_file_io_type |
| sys | host_summary_by_file_io |
| sys | xhost_summary_by_file_io |
| sys | host_summary_by_statement_type |
| sys | xhost_summary_by_statement_type |
| sys | host_summary_by_statement_latency |
| sys | xhost_summary_by_statement_latency |
| sys | host_summary_by_stages |
| sys | xhost_summary_by_stages |
| sys | host_summary |
| sys | xhost_summary |
| sys | wait_classes_global_by_avg_latency |
| sys | xwait_classes_global_by_avg_latency |
| sys | wait_classes_global_by_latency |
| sys | xwait_classes_global_by_latency |
| sys | waits_by_user_by_latency |
| sys | xwaits_by_user_by_latency |
| sys | waits_by_host_by_latency |
| sys | xwaits_by_host_by_latency |
| sys | waits_global_by_latency |
| sys | xwaits_global_by_latency |
| sys | metrics |
| sys | processlist |
| sys | xprocesslist |
| sys | session |
| sys | xsession |
| sys | session_ssl_status |
+--------------+-----------------------------------------------+
100 rows in set (0.01 sec)
阅读更多:MySQL 教程
极客教程