1. 概述

information_schema 数据库跟 performance_schema 一样,都是 MySQL 自带的信息数据库。其中 performance_schema 用于性能分析,而 information_schema 用于存储数据库元数据(关于数据的数据),例如数据库名、表名、列的数据类型、访问权限等。

information_schema 中的表实际上是视图,而不是基本表,因此,文件系统上没有与之相关的文件。

mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema |
+---------------------------------------+
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
| COLUMN_PRIVILEGES |
| ENGINES |
| EVENTS |
| FILES |
| GLOBAL_STATUS |
| GLOBAL_VARIABLES |
| KEY_COLUMN_USAGE |
| OPTIMIZER_TRACE |
| 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_LOCKS |
| INNODB_TRX |
| INNODB_SYS_DATAFILES |
| INNODB_FT_CONFIG |
| INNODB_SYS_VIRTUAL |
| INNODB_CMP |
| INNODB_FT_BEING_DELETED |
| INNODB_CMP_RESET |
| INNODB_CMP_PER_INDEX |
| INNODB_CMPMEM_RESET |
| INNODB_FT_DELETED |
| INNODB_BUFFER_PAGE_LRU |
| INNODB_LOCK_WAITS |
| INNODB_TEMP_TABLE_INFO |
| INNODB_SYS_INDEXES |
| INNODB_SYS_TABLES |
| INNODB_SYS_FIELDS |
| INNODB_CMP_PER_INDEX_RESET |
| INNODB_BUFFER_PAGE |
| INNODB_FT_DEFAULT_STOPWORD |
| INNODB_FT_INDEX_TABLE |
| INNODB_FT_INDEX_CACHE |
| INNODB_SYS_TABLESPACES |
| INNODB_METRICS |
| INNODB_SYS_FOREIGN_COLS |
| INNODB_CMPMEM |
| INNODB_BUFFER_POOL_STATS |
| INNODB_SYS_COLUMNS |
| INNODB_SYS_FOREIGN |
| INNODB_SYS_TABLESTATS |
+---------------------------------------+
61 rows in set (0.00 sec)

2. information_schema 库中常用的表

CHARACTER_SETS 表

提供了 mysql 可用字符集的信息。SHOW CHARACTER SET; 命令从这个表获取结果。

mysql> SHOW CHARACTER SET;
+----------+---------------------------------+---------------------+--------+
| Charset | Description | Default collation | Maxlen |
+----------+---------------------------------+---------------------+--------+
| big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 |
| dec8 | DEC West European | dec8_swedish_ci | 1 |
| cp850 | DOS West European | cp850_general_ci | 1 |
...
| eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 |
| gb18030 | China National Standard GB18030 | gb18030_chinese_ci | 4 |
+----------+---------------------------------+---------------------+--------+
41 rows in set (0.07 sec) mysql> SELECT * FROM CHARACTER_SETS;
+--------------------+----------------------+---------------------------------+--------+
| CHARACTER_SET_NAME | DEFAULT_COLLATE_NAME | DESCRIPTION | MAXLEN |
+--------------------+----------------------+---------------------------------+--------+
| big5 | big5_chinese_ci | Big5 Traditional Chinese | 2 |
| dec8 | dec8_swedish_ci | DEC West European | 1 |
| cp850 | cp850_general_ci | DOS West European | 1 |
...
| eucjpms | eucjpms_japanese_ci | UJIS for Windows Japanese | 3 |
| gb18030 | gb18030_chinese_ci | China National Standard GB18030 | 4 |
+--------------------+----------------------+---------------------------------+--------+
41 rows in set (0.00 sec)

SCHEMATA 表

当前 mysql 实例中所有数据库的信息。SHOW DATABASES; 命令从这个表获取数据。

mysql> SELECT * FROM SCHEMATA;
+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| def | information_schema | utf8 | utf8_general_ci | NULL |
| def | mysql | latin1 | latin1_swedish_ci | NULL |
| def | performance_schema | utf8 | utf8_general_ci | NULL |
| def | sys | utf8 | utf8_general_ci | NULL |
| def | test | utf8 | utf8_unicode_ci | NULL |
+--------------+--------------------+----------------------------+------------------------+----------+
10 rows in set (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
10 rows in set (0.00 sec)

TABLES 表

存储数据库中的表信息(包括视图),包括表属于哪个数据库,表的类型、存储引擎、创建时间等信息。SHOW TABLES FROM XX; 命令从这个表获取结果。

mysql> SELECT * FROM TABLES;
+---------------+--------------------+------------------------------------------------------+-------------+--------------------+---------+------------+------------+----------------+-------------+--------------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+--------------------+--------------------------------------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME | UPDATE_TIME | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------------+------------------------------------------------------+-------------+--------------------+---------+------------+------------+----------------+-------------+--------------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+--------------------+--------------------------------------------+
| def | information_schema | CHARACTER_SETS | SYSTEM VIEW | MEMORY | 10 | Fixed | NULL | 384 | 0 | 16434816 | 0 | 0 | NULL | 2018-04-23 11:51:32 | NULL | NULL | utf8_general_ci | NULL | max_rows=43690 | |
| def | information_schema | COLLATIONS | SYSTEM VIEW | MEMORY | 10 | Fixed | NULL | 231 | 0 | 16704765 | 0 | 0 | NULL | 2018-04-23 11:51:32 | NULL | NULL | utf8_general_ci | NULL | max_rows=72628 | |
...
| def | zentao | zt_usertpl | BASE TABLE | MyISAM | 10 | Dynamic | 0 | 0 | 0 | 281474976710655 | 1024 | 0 | 1 | 2017-08-16 16:36:45 | 2017-08-16 16:36:45 | NULL | utf8_general_ci | NULL | | |
+---------------+--------------------+------------------------------------------------------+-------------+--------------------+---------+------------+------------+----------------+-------------+--------------------+--------------+-----------+----------------+---------------------+---------------------+---------------------+-------------------+----------+--------------------+--------------------------------------------+
525 rows in set (3.03 sec) mysql> SHOW TABLES FROM zentao;
+-------------------+
| Tables_in_zentao |
+-------------------+
| zt_action |
| zt_block |
| zt_branch |
...
| zt_usertpl |
+-------------------+
48 rows in set (0.00 sec)

COLUMNS 表

存储表中的列信息,包括表有多少列、每个列的类型等。SHOW COLUMNS FROM schemaname.tablename 命令从这个表获取结果。

mysql> SELECT * FROM COLUMNS LIMIT 2,5;
+---------------+--------------------+----------------+--------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+-------------+------------+-------+------------+----------------+-----------------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | NUMERIC_PRECISION | NUMERIC_SCALE | DATETIME_PRECISION | CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | COLUMN_KEY | EXTRA | PRIVILEGES | COLUMN_COMMENT | GENERATION_EXPRESSION |
+---------------+--------------------+----------------+--------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+-------------+------------+-------+------------+----------------+-----------------------+
| def | information_schema | CHARACTER_SETS | DESCRIPTION | 3 | | NO | varchar | 60 | 180 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(60) | | | select | | |
| def | information_schema | CHARACTER_SETS | MAXLEN | 4 | 0 | NO | bigint | NULL | NULL | 19 | 0 | NULL | NULL | NULL | bigint(3) | | | select | | |
| def | information_schema | COLLATIONS | COLLATION_NAME | 1 | | NO | varchar | 32 | 96 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(32) | | | select | | |
| def | information_schema | COLLATIONS | CHARACTER_SET_NAME | 2 | | NO | varchar | 32 | 96 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(32) | | | select | | |
| def | information_schema | COLLATIONS | ID | 3 | 0 | NO | bigint | NULL | NULL | 19 | 0 | NULL | NULL | NULL | bigint(11) | | | select | | |
+---------------+--------------------+----------------+--------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+-------------+------------+-------+------------+----------------+-----------------------+
5 rows in set (0.08 sec)

STATISTICS 表

表索引的信息。SHOW INDEX FROM schemaname.tablename; 命令从这个表获取结果。

mysql> SHOW INDEX FROM szhuizhong.users;
+-------+------------+---------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+---------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| users | 0 | PRIMARY | 1 | UserID | A | 1460 | NULL | NULL | | BTREE | | |
| users | 0 | Account_index | 1 | Account | A | 1460 | NULL | NULL | | BTREE | | |
| users | 1 | CorpID | 1 | FromID | A | 2 | NULL | NULL | YES | BTREE | | |
+-------+------------+---------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)

USER_PRIVILEGES 表

用户权限表。内容源自 mysql.user 授权表。是非标准表。

mysql> SELECT * FROM USER_PRIVILEGES;
+-------------------------+---------------+-------------------------+--------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+-------------------------+---------------+-------------------------+--------------+
| 'mysql.sys'@'localhost' | def | USAGE | NO |
| 'root'@'%' | def | SELECT | YES |
| 'root'@'%' | def | INSERT | YES |
| 'root'@'%' | def | UPDATE | YES |
| 'root'@'%' | def | DELETE | YES |
| 'root'@'%' | def | CREATE | YES |
| 'root'@'%' | def | DROP | YES |
| 'root'@'%' | def | RELOAD | YES |
| 'root'@'%' | def | SHUTDOWN | YES |
| 'root'@'%' | def | PROCESS | YES |
| 'root'@'%' | def | FILE | YES |
| 'root'@'%' | def | REFERENCES | YES |
| 'root'@'%' | def | INDEX | YES |
| 'root'@'%' | def | ALTER | YES |
| 'root'@'%' | def | SHOW DATABASES | YES |
| 'root'@'%' | def | SUPER | YES |
| 'root'@'%' | def | CREATE TEMPORARY TABLES | YES |
| 'root'@'%' | def | LOCK TABLES | YES |
| 'root'@'%' | def | EXECUTE | YES |
| 'root'@'%' | def | REPLICATION SLAVE | YES |
| 'root'@'%' | def | REPLICATION CLIENT | YES |
| 'root'@'%' | def | CREATE VIEW | YES |
| 'root'@'%' | def | SHOW VIEW | YES |
| 'root'@'%' | def | CREATE ROUTINE | YES |
| 'root'@'%' | def | ALTER ROUTINE | YES |
| 'root'@'%' | def | CREATE USER | YES |
| 'root'@'%' | def | EVENT | YES |
| 'root'@'%' | def | TRIGGER | YES |
| 'root'@'%' | def | CREATE TABLESPACE | YES |
+-------------------------+---------------+-------------------------+--------------+
29 rows in set (0.00 sec)

SCHEMA_PRIVILEGES 表

方案权限表。给出了关于方案(数据库)权限的信息。内容来自 mysql.db 授权表。是非标准表。

mysql> SELECT * FROM SCHEMA_PRIVILEGES;
+-------------------------+---------------+--------------+-------------------------+--------------+
| GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE |
+-------------------------+---------------+--------------+-------------------------+--------------+
| 'mysql.sys'@'localhost' | def | sys | TRIGGER | NO |
| 'root'@'%' | def | mysql | SELECT | YES |
| 'root'@'%' | def | mysql | INSERT | YES |
| 'root'@'%' | def | mysql | UPDATE | YES |
| 'root'@'%' | def | mysql | DELETE | YES |
| 'root'@'%' | def | mysql | CREATE | YES |
| 'root'@'%' | def | mysql | DROP | YES |
| 'root'@'%' | def | mysql | REFERENCES | YES |
| 'root'@'%' | def | mysql | INDEX | YES |
| 'root'@'%' | def | mysql | ALTER | YES |
| 'root'@'%' | def | mysql | CREATE TEMPORARY TABLES | YES |
| 'root'@'%' | def | mysql | LOCK TABLES | YES |
| 'root'@'%' | def | mysql | EXECUTE | YES |
| 'root'@'%' | def | mysql | CREATE VIEW | YES |
| 'root'@'%' | def | mysql | SHOW VIEW | YES |
| 'root'@'%' | def | mysql | CREATE ROUTINE | YES |
| 'root'@'%' | def | mysql | ALTER ROUTINE | YES |
| 'root'@'%' | def | mysql | EVENT | YES |
| 'root'@'%' | def | mysql | TRIGGER | YES |
+-------------------------+---------------+--------------+-------------------------+--------------+
19 rows in set (0.00 sec)

TABLE_PRIVILEGES 表

表权限表。给出了关于表权限的信息。内容源自 mysql.tables_priv 授权表。是非标准表。

mysql> SELECT * FROM TABLE_PRIVILEGES;
+-------------------------+---------------+--------------+------------+----------------+--------------+
| GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | PRIVILEGE_TYPE | IS_GRANTABLE |
+-------------------------+---------------+--------------+------------+----------------+--------------+
| 'mysql.sys'@'localhost' | def | sys | sys_config | SELECT | NO |
+-------------------------+---------------+--------------+------------+----------------+--------------+
1 row in set (0.00 sec)

COLUMN_PRIVILEGES 表

列权限表。给出了关于列权限的信息。内容源自 mysql.columns_priv 授权表。是非标准表。

mysql> SELECT * FROM COLUMN_PRIVILEGES;
Empty set (0.00 sec)

COLLATIONS 表

提供了关于各字符集的对照信息。SHOW COLLATION; 命令从这个表获取结果。

mysql> SELECT * FROM COLLATIONS;
+--------------------------+--------------------+-----+------------+-------------+---------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN |
+--------------------------+--------------------+-----+------------+-------------+---------+
| big5_chinese_ci | big5 | 1 | Yes | Yes | 1 |
| big5_bin | big5 | 84 | | Yes | 1 |
| dec8_swedish_ci | dec8 | 3 | Yes | Yes | 1 |
| dec8_bin | dec8 | 69 | | Yes | 1 |
...
| gb18030_bin | gb18030 | 249 | | Yes | 1 |
| gb18030_unicode_520_ci | gb18030 | 250 | | Yes | 8 |
+--------------------------+--------------------+-----+------------+-------------+---------+
222 rows in set (0.03 sec)

COLLATION_CHARACTER_SET_APPLICABILITY 表

指明了可用于校对的字符集。相当于 SHOW COLLATION 命令结果的前两个字段。

mysql> SELECT * FROM COLLATION_CHARACTER_SET_APPLICABILITY;
+--------------------------+--------------------+
| COLLATION_NAME | CHARACTER_SET_NAME |
+--------------------------+--------------------+
| big5_chinese_ci | big5 |
| big5_bin | big5 |
| dec8_swedish_ci | dec8 |
...
| gb18030_bin | gb18030 |
| gb18030_unicode_520_ci | gb18030 |
+--------------------------+--------------------+
222 rows in set (0.00 sec)

TABLE_CONSTRAINTS 表

描述了存在约束的表。以及表的约束类型。

mysql> SELECT * FROM TABLE_CONSTRAINTS;
+--------------------+-------------------+--------------------+--------------+---------------------------+-----------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | TABLE_SCHEMA | TABLE_NAME | CONSTRAINT_TYPE |
+--------------------+-------------------+--------------------+--------------+---------------------------+-----------------+
| def | mysql | PRIMARY | mysql | columns_priv | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | db | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | engine_cost | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | event | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | func | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | gtid_executed | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | help_category | PRIMARY KEY |
| def | mysql | name | mysql | help_category | UNIQUE |
| def | mysql | PRIMARY | mysql | help_keyword | PRIMARY KEY |
| def | mysql | name | mysql | help_keyword | UNIQUE |
| def | mysql | PRIMARY | mysql | help_relation | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | help_topic | PRIMARY KEY |
| def | mysql | name | mysql | help_topic | UNIQUE |
| def | mysql | PRIMARY | mysql | innodb_index_stats | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | innodb_table_stats | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | ndb_binlog_index | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | plugin | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | proc | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | procs_priv | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | proxies_priv | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | server_cost | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | servers | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | slave_master_info | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | slave_relay_log_info | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | slave_worker_info | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | tables_priv | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | time_zone | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | time_zone_leap_second | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | time_zone_name | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | time_zone_transition | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | time_zone_transition_type | PRIMARY KEY |
| def | mysql | PRIMARY | mysql | user | PRIMARY KEY |
| def | sys | PRIMARY | sys | sys_config | PRIMARY KEY |
| def | zentao | PRIMARY | zentao | zt_action | PRIMARY KEY |
...
| def | zentao | account | zentao | zt_usergroup | UNIQUE |
| def | zentao | PRIMARY | zentao | zt_userquery | PRIMARY KEY |
| def | zentao | PRIMARY | zentao | zt_usertpl | PRIMARY KEY |
+--------------------+-------------------+--------------------+--------------+---------------------------+-----------------+
213 rows in set (0.37 sec)

KEY_COLUMN_USAGE 表

描述了具有约束的键列。

mysql> SELECT * FROM KEY_COLUMN_USAGE;
+--------------------+-------------------+--------------------+---------------+--------------+---------------------------+--------------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | POSITION_IN_UNIQUE_CONSTRAINT | REFERENCED_TABLE_SCHEMA | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+--------------------+-------------------+--------------------+---------------+--------------+---------------------------+--------------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+
| def | mysql | PRIMARY | def | mysql | columns_priv | Host | 1 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | columns_priv | Db | 2 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | columns_priv | User | 3 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | columns_priv | Table_name | 4 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | columns_priv | Column_name | 5 | NULL | NULL | NULL | NULL |
...
| def | mysql | PRIMARY | def | mysql | time_zone_leap_second | Transition_time | 1 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | time_zone_name | Name | 1 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | time_zone_transition | Time_zone_id | 1 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | time_zone_transition | Transition_time | 2 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | time_zone_transition_type | Time_zone_id | 1 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | time_zone_transition_type | Transition_type_id | 2 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | user | Host | 1 | NULL | NULL | NULL | NULL |
| def | mysql | PRIMARY | def | mysql | user | User | 2 | NULL | NULL | NULL | NULL |
| def | sys | PRIMARY | def | sys | sys_config | variable | 1 | NULL | NULL | NULL | NULL |
+--------------------+-------------------+--------------------+---------------+--------------+---------------------------+--------------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+
278 rows in set (0.03 sec)

ROUTINES 表

提供了关于存储子程序(存储程序和函数)的信息。此时,ROUTINES 表不包含自定义函数(UDF)。名为“mysql.proc name”的列指明了对应于 INFORMATION_SCHEMA.ROUTINES 表的 mysql.proc 列。

VIEWS 表

给出了关于数据库中的视图的信息。需要有 show views 权限,否则无法查看视图信息。

mysql> SELECT * FROM VIEWS LIMIT 1\G
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: sys
TABLE_NAME: host_summary
VIEW_DEFINITION: select if(isnull(`performance_schema`.`accounts`.`HOST`),'background',`performance_schema`.`accounts`.`HOST`) AS `host`,sum(`stmt`.`total`) AS `statements`,`sys`.`format_time`(sum(`stmt`.`total_latency`)) AS `statement_latency`,`sys`.`format_time`(ifnull((sum(`stmt`.`total_latency`) / nullif(sum(`stmt`.`total`),0)),0)) AS `statement_avg_latency`,sum(`stmt`.`full_scans`) AS `table_scans`,sum(`io`.`ios`) AS `file_ios`,`sys`.`format_time`(sum(`io`.`io_latency`)) AS `file_io_latency`,sum(`performance_schema`.`accounts`.`CURRENT_CONNECTIONS`) AS `current_connections`,sum(`performance_schema`.`accounts`.`TOTAL_CONNECTIONS`) AS `total_connections`,count(distinct `performance_schema`.`accounts`.`USER`) AS `unique_users`,`sys`.`format_bytes`(sum(`mem`.`current_allocated`)) AS `current_memory`,`sys`.`format_bytes`(sum(`mem`.`total_allocated`)) AS `total_memory_allocated` from (((`performance_schema`.`accounts` join `sys`.`x$host_summary_by_statement_latency` `stmt` on((`performance_schema`.`accounts`.`HOST` = `stmt`.`host`))) join `sys`.`x$host_summary_by_file_io` `io` on((`performance_schema`.`accounts`.`HOST` = `io`.`host`))) join `sys`.`x$memory_by_host_by_current_bytes` `mem` on((`performance_schema`.`accounts`.`HOST` = `mem`.`host`))) group by if(isnull(`performance_schema`.`accounts`.`HOST`),'background',`performance_schema`.`accounts`.`HOST`)
CHECK_OPTION: NONE
IS_UPDATABLE: NO
DEFINER: mysql.sys@localhost
SECURITY_TYPE: INVOKER
CHARACTER_SET_CLIENT: utf8
COLLATION_CONNECTION: utf8_general_ci
1 row in set (0.03 sec)

TRIGGERS 表

提供了关于触发程序的信息。必须有 super 权限才能查看该表。

mysql> SELECT * FROM TRIGGERS LIMIT 1\G
*************************** 1. row ***************************
TRIGGER_CATALOG: def
TRIGGER_SCHEMA: sys
TRIGGER_NAME: sys_config_insert_set_user
EVENT_MANIPULATION: INSERT
EVENT_OBJECT_CATALOG: def
EVENT_OBJECT_SCHEMA: sys
EVENT_OBJECT_TABLE: sys_config
ACTION_ORDER: 1
ACTION_CONDITION: NULL
ACTION_STATEMENT: BEGIN IF @sys.ignore_sys_config_triggers != true AND NEW.set_by IS NULL THEN SET NEW.set_by = USER(); END IF; END
ACTION_ORIENTATION: ROW
ACTION_TIMING: BEFORE
ACTION_REFERENCE_OLD_TABLE: NULL
ACTION_REFERENCE_NEW_TABLE: NULL
ACTION_REFERENCE_OLD_ROW: OLD
ACTION_REFERENCE_NEW_ROW: NEW
CREATED: 2017-05-27 11:18:43.60
SQL_MODE:
DEFINER: mysql.sys@localhost
CHARACTER_SET_CLIENT: utf8
COLLATION_CONNECTION: utf8_general_ci
DATABASE_COLLATION: utf8_general_ci
1 row in set (0.00 sec)

MySQL 中的 information_schema 数据库的更多相关文章

  1. MySQL中的information_schema数据库表说明

    MySQL 中的 information_schema 数据库   版权声明:https://blog.csdn.net/kikajack/article/details/80065753 1. 概述 ...

  2. MySQL中的information_schema数据库详解

    information_schema数据库是MySQL自带的,它提供了访问数据库元数据的方式.什么是元数据呢?元数据是关于数据的数据,如数据库名或表名,列的数据类型,或访问权限等.有些时候用于表述该信 ...

  3. MySQL 中的默认数据库介绍

    MySQL 中的默认数据库介绍:https://dataedo.com/kb/databases/mysql/default-databases-schemas 默认数据库 官方文档 informat ...

  4. MySQL自带information_schema数据库使用

    MySQL的information_schema数据库是什么,有什么作用? 大家在安装或使用MYSQL时,会发现除了自己安装的数据库以外,还有一个 information_schema数据库.info ...

  5. MySQL中的information_schema

    information_schema 数据库是MySQL自带的,可看作是一个数据库,确切说是信息数据库.其中保存着关于MySQL服务器所维护的所有其他数据库的信息.如数据库名,数据库的表,表栏的数据类 ...

  6. EF Core使用CodeFirst在MySql中创建新数据库以及已有的Mysql数据库如何使用DB First生成域模型

    官方教程:https://docs.microsoft.com/en-us/aspnet/core/data/?view=aspnetcore-2.1 使用EF CodeFirst在MySql中创建新 ...

  7. Mysql 中如何创建数据库和数据表

    这里的数据库为:user  数据表为 aaa mysql –uroot –p                 进入mysql create database user;            创建数据 ...

  8. MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句

    查询所有数据库占用磁盘空间大小的SQL语句: ,),' MB') as data_size, concat(,),'MB') as index_size from information_schema ...

  9. MySQL中关于主从数据库同步延迟的问题解决

    MySQL的主从同步是一个很成熟的架构,优点为:①在从服务器可以执行查询工作(即我们常说的读功能),降低主服务器压力;②在从主服务器进行备份,避免备份期间影响主服务器服务;③当主服务器出现问题时,可以 ...

随机推荐

  1. 关于mysql的使用命令(持续更新中...)

    特别提示  本说明中的mysql 是基于windwos平台下的5.5 版本 安装完成后 请到mysql中设置配置文件   链接分享:链接:https://pan.baidu.com/s/1tv4ulZ ...

  2. SpringBoot(六) -- SpringBoot错误处理机制

    一.SpringBoot中的默认的错误处理机制 1.在SpringBootWeb开发中,当我们访问请求出现错误时,会返回一个默认的错误页面: 2.在使用其他客户端访问的时候,则返回一个json数据: ...

  3. winCE/Windows 应用程序消息提示框自动消失功能

    近期在做winCE系统的扫描枪应用程序,遇到了一些问题,其中包括消失提示框在手持终端显示过小, 用户要求提示框提示几秒后自动关闭,Windows平台可以通过调用系统API以定时器的方式进行自动销毁. ...

  4. npm基本介绍及使用

    1.什么是npm npm全称node package manager,是node包管理和分发工具.可以理解为前端的maven.通过npm可以很方便的下载js库,管理前端工程.node已经集成npm工具 ...

  5. Runnable和Thread区别和比较

    在很多博客中用这样一个例子来说明 Runnable更容易实现资源共享,能多个线程同时处理一个资源. 看代码: public static void main(String[] args) { new ...

  6. python 学习第四十七天shelve模块

    shelve模块是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式. 1,序列化 import shelve f=shelve.open('she ...

  7. java反射, 不看你可别后悔

    开发中, 难免遇到些私有的属性和方法, 就好比下面的实体一样, 我们该怎么获得她, 并玩弄于手掌呢? 我们先来个实体瞧瞧, 给你个对象你也new不了, hahaha- 单身wang public cl ...

  8. 17、前端知识点--Vue中ref的使用

    methods里面的方法,需要手动触发才会执行. 如果想让页面一上来就执行的话,就需要写在mounted这个钩子函数中. <body> <div id="app" ...

  9. 20191126PHP连接数据(1)

    引进数据 mysql> create database stu1 character set utf8; mysql> use stu1 mysql> set names utf8; ...

  10. Winfrom中数据的双向绑定(使用INotifyPropertyChanged)

    在WPF中新建项目是自动实现了INotifyPropertyChanged接口,用于数据绑定时非常的方便在winfrom中也可以实现INotifyPropertyChanged接口 将需要绑定的字段写 ...