24.3 INFORMATION_SCHEMA General Tables

The following sections describe what may be denoted as the 'general' set of 'INFORMATION_SCHEMA' tables. These are the tables not associated with particular storage engines, components, or plugins.

 File: manual.info.tmp, Node: information-schema-general-table-reference, Next: information-schema-character-sets-table, Prev: general-information-schema-tables, Up: general-information-schema-tables

24.3.1 INFORMATION_SCHEMA General Table Reference

The following table summarizes 'INFORMATION_SCHEMA' general tables. For greater detail, see the individual table descriptions.

INFORMATION_SCHEMA General Tables

Table Name Description

*note 'CHARACTER_SETS': information-schema-character-sets-table.Available character sets

*note 'COLLATION_CHARACTER_SET_APPLICABILITY': information-schema-collation-character-set-applicability-table.Character set applicable to each collation

*note 'COLLATIONS': information-schema-collations-table.Collations for each character set

*note 'COLUMN_PRIVILEGES': information-schema-column-privileges-table.Privileges defined on columns

*note 'COLUMNS': information-schema-columns-table.Columns in each table

*note 'ENGINES': information-schema-engines-table.Storage engine properties

*note 'EVENTS': information-schema-events-table.Event Manager events

*note 'FILES': information-schema-files-table.Files that store tablespace data

*note 'GLOBAL_STATUS': information-schema-status-table.Global status variables

*note 'GLOBAL_VARIABLES': information-schema-variables-table.Global system variables

*note 'KEY_COLUMN_USAGE': information-schema-key-column-usage-table.Which key columns have constraints

*note 'ndb_transid_mysql_connection_map': information-schema-ndb-transid-mysql-connection-map-table.NDB transaction information

*note 'OPTIMIZER_TRACE': information-schema-optimizer-trace-table.Information produced by optimizer trace activity

*note 'PARAMETERS': information-schema-parameters-table.Stored routine parameters and stored function return values

*note 'PARTITIONS': information-schema-partitions-table.Table partition information

*note 'PLUGINS': information-schema-plugins-table.Plugin information

*note 'PROCESSLIST': information-schema-processlist-table.Information about currently executing threads

*note 'PROFILING': information-schema-profiling-table.Statement profiling information

*note 'REFERENTIAL_CONSTRAINTS': information-schema-referential-constraints-table.Foreign key information

*note 'ROUTINES': information-schema-routines-table.Stored routine information

*note 'SCHEMA_PRIVILEGES': information-schema-schema-privileges-table.Privileges defined on schemas

*note 'SCHEMATA': information-schema-schemata-table.Schema information

*note 'SESSION_STATUS': information-schema-status-table.Status variables for current session

*note 'SESSION_VARIABLES': information-schema-variables-table.System variables for current session

*note 'STATISTICS': information-schema-statistics-table.Table index statistics

*note 'TABLE_CONSTRAINTS': information-schema-table-constraints-table.Which tables have constraints

*note 'TABLE_PRIVILEGES': information-schema-table-privileges-table.Privileges defined on tables

*note 'TABLES': information-schema-tables-table.Table information

*note 'TABLESPACES': information-schema-tablespaces-table.Tablespace information

*note 'TRIGGERS': information-schema-triggers-table.Trigger information

*note 'USER_PRIVILEGES': information-schema-user-privileges-table.Privileges defined globally per user

*note 'VIEWS': information-schema-views-table.View information

 File: manual.info.tmp, Node: information-schema-character-sets-table, Next: information-schema-collations-table, Prev: information-schema-general-table-reference, Up: general-information-schema-tables

24.3.2 The INFORMATION_SCHEMA CHARACTER_SETS Table

The *note 'CHARACTER_SETS': information-schema-character-sets-table. table provides information about available character sets.

The *note 'CHARACTER_SETS': information-schema-character-sets-table. table has these columns:

Notes

Character set information is also available from the note 'SHOW CHARACTER SET': show-character-set. statement. See note show-character-set::. The following statements are equivalent:

 SELECT * FROM INFORMATION_SCHEMA.CHARACTER_SETS
   [WHERE CHARACTER_SET_NAME LIKE 'WILD']

 SHOW CHARACTER SET
   [LIKE 'WILD']

 File: manual.info.tmp, Node: information-schema-collations-table, Next: information-schema-collation-character-set-applicability-table, Prev: information-schema-character-sets-table, Up: general-information-schema-tables

24.3.3 The INFORMATION_SCHEMA COLLATIONS Table

The *note 'COLLATIONS': information-schema-collations-table. table provides information about collations for each character set.

The *note 'COLLATIONS': information-schema-collations-table. table has these columns:

Notes

Collation information is also available from the note 'SHOW COLLATION': show-collation. statement. See note show-collation::. The following statements are equivalent:

 SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS
   [WHERE COLLATION_NAME LIKE 'WILD']

 SHOW COLLATION
   [LIKE 'WILD']

 File: manual.info.tmp, Node: information-schema-collation-character-set-applicability-table, Next: information-schema-columns-table, Prev: information-schema-collations-table, Up: general-information-schema-tables

24.3.4 The INFORMATION_SCHEMA COLLATION_CHARACTER_SET_APPLICABILITY Table

The *note 'COLLATION_CHARACTER_SET_APPLICABILITY': information-schema-collation-character-set-applicability-table. table indicates what character set is applicable for what collation.

The *note 'COLLATION_CHARACTER_SET_APPLICABILITY': information-schema-collation-character-set-applicability-table. table has these columns:

Notes

The note 'COLLATION_CHARACTER_SET_APPLICABILITY': information-schema-collation-character-set-applicability-table. columns are equivalent to the first two columns displayed by the note 'SHOW COLLATION': show-collation. statement.

 File: manual.info.tmp, Node: information-schema-columns-table, Next: information-schema-column-privileges-table, Prev: information-schema-collation-character-set-applicability-table, Up: general-information-schema-tables

24.3.5 The INFORMATION_SCHEMA COLUMNS Table

The *note 'COLUMNS': information-schema-columns-table. table provides information about columns in tables.

The *note 'COLUMNS': information-schema-columns-table. table has these columns:

Notes

Column information is also available from the note 'SHOW COLUMNS': show-columns. statement. See note show-columns::. The following statements are nearly equivalent:

 SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
   FROM INFORMATION_SCHEMA.COLUMNS
   WHERE table_name = 'TBL_NAME'
   [AND table_schema = 'DB_NAME']
   [AND column_name LIKE 'WILD']

 SHOW COLUMNS
   FROM TBL_NAME
   [FROM DB_NAME]
   [LIKE 'WILD']

 File: manual.info.tmp, Node: information-schema-column-privileges-table, Next: information-schema-engines-table, Prev: information-schema-columns-table, Up: general-information-schema-tables

24.3.6 The INFORMATION_SCHEMA COLUMN_PRIVILEGES Table

The *note 'COLUMN_PRIVILEGES': information-schema-column-privileges-table. table provides information about column privileges. It takes its values from the 'mysql.columns_priv' system table.

The *note 'COLUMN_PRIVILEGES': information-schema-column-privileges-table. table has these columns:

Notes

The following statements are not equivalent:

 SELECT ... FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES

 SHOW GRANTS ...

 File: manual.info.tmp, Node: information-schema-engines-table, Next: information-schema-events-table, Prev: information-schema-column-privileges-table, Up: general-information-schema-tables

24.3.7 The INFORMATION_SCHEMA ENGINES Table

The *note 'ENGINES': information-schema-engines-table. table provides information about storage engines. This is particularly useful for checking whether a storage engine is supported, or to see what the default engine is.

The *note 'ENGINES': information-schema-engines-table. table has these columns:

Notes

Storage engine information is also available from the note 'SHOW ENGINES': show-engines. statement. See note show-engines::. The following statements are equivalent:

 SELECT * FROM INFORMATION_SCHEMA.ENGINES

 SHOW ENGINES

 File: manual.info.tmp, Node: information-schema-events-table, Next: information-schema-files-table, Prev: information-schema-engines-table, Up: general-information-schema-tables

24.3.8 The INFORMATION_SCHEMA EVENTS Table

The note 'EVENTS': information-schema-events-table. table provides information about Event Manager events, which are discussed in note event-scheduler::.

The *note 'EVENTS': information-schema-events-table. table has these columns:

Notes

Example

Suppose that the user ''jon'@'ghidora'' creates an event named 'e_daily', and then modifies it a few minutes later using an *note 'ALTER EVENT': alter-event. statement, as shown here:

 DELIMITER |

 CREATE EVENT e_daily
     ON SCHEDULE
       EVERY 1 DAY
     COMMENT 'Saves total number of sessions then clears the table each day'
     DO
       BEGIN
         INSERT INTO site_activity.totals (time, total)
           SELECT CURRENT_TIMESTAMP, COUNT(*)
             FROM site_activity.sessions;
         DELETE FROM site_activity.sessions;
       END |

 DELIMITER ;

 ALTER EVENT e_daily
     ENABLE;

(Note that comments can span multiple lines.)

This user can then run the following *note 'SELECT': select. statement, and obtain the output shown:

 mysql> SELECT * FROM INFORMATION_SCHEMA.EVENTS
        WHERE EVENT_NAME = 'e_daily'
        AND EVENT_SCHEMA = 'myschema'\G
 *************************** 1. row ***************************
        EVENT_CATALOG: def
         EVENT_SCHEMA: myschema
           EVENT_NAME: e_daily
              DEFINER: jon@ghidora
            TIME_ZONE: SYSTEM
           EVENT_BODY: SQL
     EVENT_DEFINITION: BEGIN
         INSERT INTO site_activity.totals (time, total)
           SELECT CURRENT_TIMESTAMP, COUNT(*)
             FROM site_activity.sessions;
         DELETE FROM site_activity.sessions;
       END
           EVENT_TYPE: RECURRING
           EXECUTE_AT: NULL
       INTERVAL_VALUE: 1
       INTERVAL_FIELD: DAY
             SQL_MODE: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,
                       NO_ZERO_IN_DATE,NO_ZERO_DATE,
                       ERROR_FOR_DIVISION_BY_ZERO,
                       NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
               STARTS: 2018-08-08 11:06:34
                 ENDS: NULL
               STATUS: ENABLED
        ON_COMPLETION: NOT PRESERVE
              CREATED: 2018-08-08 11:06:34
         LAST_ALTERED: 2018-08-08 11:06:34
        LAST_EXECUTED: 2018-08-08 16:06:34
        EVENT_COMMENT: Saves total number of sessions then clears the
                       table each day
           ORIGINATOR: 1
 CHARACTER_SET_CLIENT: utf8
 COLLATION_CONNECTION: utf8_general_ci
   DATABASE_COLLATION: latin1_swedish_ci

Event information is also available from the note 'SHOW EVENTS': show-events. statement. See note show-events::. The following statements are equivalent:

 SELECT
     EVENT_SCHEMA, EVENT_NAME, DEFINER, TIME_ZONE, EVENT_TYPE, EXECUTE_AT,
     INTERVAL_VALUE, INTERVAL_FIELD, STARTS, ENDS, STATUS, ORIGINATOR,
     CHARACTER_SET_CLIENT, COLLATION_CONNECTION, DATABASE_COLLATION
   FROM INFORMATION_SCHEMA.EVENTS
   WHERE table_schema = 'DB_NAME'
   [AND column_name LIKE 'WILD']

 SHOW EVENTS
   [FROM DB_NAME]
   [LIKE 'WILD']

 File: manual.info.tmp, Node: information-schema-files-table, Next: information-schema-status-table, Prev: information-schema-events-table, Up: general-information-schema-tables

24.3.9 The INFORMATION_SCHEMA FILES Table

The *note 'FILES': information-schema-files-table. table provides information about the files in which MySQL tablespace data is stored.

The note 'FILES': information-schema-files-table. table provides information about 'InnoDB' data files. In NDB Cluster, this table also provides information about the files in which NDB Cluster Disk Data tables are stored. For additional information specific to 'InnoDB', see note files-table-innodb-notes::, later in this section; for additional information specific to NDB Cluster, see *note files-table-ndb-notes::.

The *note 'FILES': information-schema-files-table. table has these columns:

Notes

InnoDB Notes

The following notes apply to 'InnoDB' data files.

NDB Notes

 File: manual.info.tmp, Node: information-schema-status-table, Next: information-schema-variables-table, Prev: information-schema-files-table, Up: general-information-schema-tables

24.3.10 The INFORMATION_SCHEMA GLOBAL_STATUS and SESSION_STATUS Tables

Note:

The value of the 'show_compatibility_56' system variable affects the information available from the tables described here. For details, see the description of that variable in *note server-system-variables::.

Note:

Information available from the tables described here is also available from the Performance Schema. The 'INFORMATION_SCHEMA' tables are deprecated in preference to the Performance Schema tables and are removed in MySQL 8.0. For advice on migrating away from the 'INFORMATION_SCHEMA' tables to the Performance Schema tables, see *note performance-schema-variable-table-migration::.

The note 'GLOBAL_STATUS': information-schema-status-table. and note 'SESSION_STATUS': information-schema-status-table. tables provide information about server status variables. Their contents correspond to the information produced by the note 'SHOW GLOBAL STATUS': show-status. and note 'SHOW SESSION STATUS': show-status. statements (see *note show-status::).

Notes

 File: manual.info.tmp, Node: information-schema-variables-table, Next: information-schema-key-column-usage-table, Prev: information-schema-status-table, Up: general-information-schema-tables

24.3.11 The INFORMATION_SCHEMA GLOBAL_VARIABLES and SESSION_VARIABLES Tables

Note:

The value of the 'show_compatibility_56' system variable affects the information available from the tables described here. For details, see the description of that variable in *note server-system-variables::.

Note:

Information available from the tables described here is also available from the Performance Schema. The 'INFORMATION_SCHEMA' tables are deprecated in preference to the Performance Schema tables and are removed in MySQL 8.0. For advice on migrating away from the 'INFORMATION_SCHEMA' tables to the Performance Schema tables, see *note performance-schema-variable-table-migration::.

The note 'GLOBAL_VARIABLES': information-schema-variables-table. and note 'SESSION_VARIABLES': information-schema-variables-table. tables provide information about server status variables. Their contents correspond to the information produced by the note 'SHOW GLOBAL VARIABLES': show-variables. and note 'SHOW SESSION VARIABLES': show-variables. statements (see *note show-variables::).

Notes

 File: manual.info.tmp, Node: information-schema-key-column-usage-table, Next: information-schema-ndb-transid-mysql-connection-map-table, Prev: information-schema-variables-table, Up: general-information-schema-tables

24.3.12 The INFORMATION_SCHEMA KEY_COLUMN_USAGE Table

The *note 'KEY_COLUMN_USAGE': information-schema-key-column-usage-table. table describes which key columns have constraints.

The *note 'KEY_COLUMN_USAGE': information-schema-key-column-usage-table. table has these columns:

Suppose that there are two tables name 't1' and 't3' that have the following definitions:

 CREATE TABLE t1
 (
     s1 INT,
     s2 INT,
     s3 INT,
     PRIMARY KEY(s3)
 ) ENGINE=InnoDB;

 CREATE TABLE t3
 (
     s1 INT,
     s2 INT,
     s3 INT,
     KEY(s1),
     CONSTRAINT CO FOREIGN KEY (s2) REFERENCES t1(s3)
 ) ENGINE=InnoDB;

For those two tables, the *note 'KEY_COLUMN_USAGE': information-schema-key-column-usage-table. table has two rows:

 File: manual.info.tmp, Node: information-schema-ndb-transid-mysql-connection-map-table, Next: information-schema-optimizer-trace-table, Prev: information-schema-key-column-usage-table, Up: general-information-schema-tables

24.3.13 The INFORMATION_SCHEMA ndb_transid_mysql_connection_map Table

The 'ndb_transid_mysql_connection_map' table provides a mapping between 'NDB' transactions, 'NDB' transaction coordinators, and MySQL Servers attached to an NDB Cluster as API nodes. This information is used when populating the note 'server_operations': mysql-cluster-ndbinfo-server-operations. and note 'server_transactions': mysql-cluster-ndbinfo-server-transactions. tables of the *note 'ndbinfo': mysql-cluster-ndbinfo. NDB Cluster information database.

The *note 'ndb_transid_mysql_connection_map': information-schema-ndb-transid-mysql-connection-map-table. table has these columns:

Notes

The 'mysql_connection_id' value is the same as the connection or session ID shown in the output of *note 'SHOW PROCESSLIST': show-processlist.

There are no 'SHOW' statements associated with this table.

This is a nonstandard table, specific to NDB Cluster. It is implemented as an 'INFORMATION_SCHEMA' plugin; you can verify that it is supported by checking the output of *note 'SHOW PLUGINS': show-plugins. If 'ndb_transid_mysql_connection_map' support is enabled, the output from this statement includes a plugin having this name, of type 'INFORMATION SCHEMA', and having status 'ACTIVE', as shown here (using emphasized text):

 mysql> SHOW PLUGINS;
 +----------------------------------+--------+--------------------+---------+---------+
 | Name                             | Status | Type               | Library | License |
 +----------------------------------+--------+--------------------+---------+---------+
 | binlog                           | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | mysql_native_password            | ACTIVE | AUTHENTICATION     | NULL    | GPL     |
 | CSV                              | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | MEMORY                           | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | MRG_MYISAM                       | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | MyISAM                           | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | PERFORMANCE_SCHEMA               | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | BLACKHOLE                        | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | ARCHIVE                          | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | ndbcluster                       | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | ndbinfo                          | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 _| ndb_transid_mysql_connection_map | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |_
 | InnoDB                           | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 | INNODB_TRX                       | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | INNODB_LOCKS                     | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | INNODB_LOCK_WAITS                | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | INNODB_CMP                       | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | INNODB_CMP_RESET                 | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | INNODB_CMPMEM                    | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | INNODB_CMPMEM_RESET              | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
 | partition                        | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
 +----------------------------------+--------+--------------------+---------+---------+
 22 rows in set (0.00 sec)

The plugin is enabled by default. You can disable it (or force the server not to run unless the plugin starts) by starting the server with the '--ndb-transid-mysql-connection-map' option. If the plugin is disabled, the status is shown by *note 'SHOW PLUGINS': show-plugins. as 'DISABLED'. The plugin cannot be enabled or disabled at runtime.

Although the names of this table and its columns are displayed using lowercase, you can use uppercase or lowercase when referring to them in SQL statements.

For this table to be created, the MySQL Server must be a binary supplied with the NDB Cluster distribution, or one built from the NDB Cluster sources with *note 'NDB': mysql-cluster. storage engine support enabled. It is not available in the standard MySQL 5.7 Server.

 File: manual.info.tmp, Node: information-schema-optimizer-trace-table, Next: information-schema-parameters-table, Prev: information-schema-ndb-transid-mysql-connection-map-table, Up: general-information-schema-tables

24.3.14 The INFORMATION_SCHEMA OPTIMIZER_TRACE Table

The note 'OPTIMIZER_TRACE': information-schema-optimizer-trace-table. table provides information produced by the optimizer tracing capability for traced statements. To enable tracking, use the 'optimizer_trace' system variable. For details, see note optimizer-tracing::.

The *note 'OPTIMIZER_TRACE': information-schema-optimizer-trace-table. table has these columns:

 File: manual.info.tmp, Node: information-schema-parameters-table, Next: information-schema-partitions-table, Prev: information-schema-optimizer-trace-table, Up: general-information-schema-tables

24.3.15 The INFORMATION_SCHEMA PARAMETERS Table

The note 'PARAMETERS': information-schema-parameters-table. table provides information about parameters for stored routines (stored procedures and stored functions), and about return values for stored functions. The note 'PARAMETERS': information-schema-parameters-table. table does not include built-in (native) functions or loadable functions. Parameter information is similar to the contents of the 'param_list' column in the 'mysql.proc' table.

The *note 'PARAMETERS': information-schema-parameters-table. table has these columns:

 File: manual.info.tmp, Node: information-schema-partitions-table, Next: information-schema-plugins-table, Prev: information-schema-parameters-table, Up: general-information-schema-tables

24.3.16 The INFORMATION_SCHEMA PARTITIONS Table

The note 'PARTITIONS': information-schema-partitions-table. table provides information about table partitions. Each row in this table corresponds to an individual partition or subpartition of a partitioned table. For more information about partitioning tables, see note partitioning::.

The *note 'PARTITIONS': information-schema-partitions-table. table has these columns:

Notes

 File: manual.info.tmp, Node: information-schema-plugins-table, Next: information-schema-processlist-table, Prev: information-schema-partitions-table, Up: general-information-schema-tables

24.3.17 The INFORMATION_SCHEMA PLUGINS Table

The *note 'PLUGINS': information-schema-plugins-table. table provides information about server plugins.

The *note 'PLUGINS': information-schema-plugins-table. table has these columns:

Notes

Plugin information is also available from the note 'SHOW PLUGINS': show-plugins. statement. See note show-plugins::. These statements are equivalent:

 SELECT
   PLUGIN_NAME, PLUGIN_STATUS, PLUGIN_TYPE,
   PLUGIN_LIBRARY, PLUGIN_LICENSE
 FROM INFORMATION_SCHEMA.PLUGINS;

 SHOW PLUGINS;

 File: manual.info.tmp, Node: information-schema-processlist-table, Next: information-schema-profiling-table, Prev: information-schema-plugins-table, Up: general-information-schema-tables

24.3.18 The INFORMATION_SCHEMA PROCESSLIST Table

The MySQL process list indicates the operations currently being performed by the set of threads executing within the server. The note 'PROCESSLIST': information-schema-processlist-table. table is one source of process information. For a comparison of this table with other sources, see note processlist-sources::.

The *note 'PROCESSLIST': information-schema-processlist-table. table has these columns:

Notes

The following statements are equivalent:

 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST

 SHOW FULL PROCESSLIST

 File: manual.info.tmp, Node: information-schema-profiling-table, Next: information-schema-referential-constraints-table, Prev: information-schema-processlist-table, Up: general-information-schema-tables

24.3.19 The INFORMATION_SCHEMA PROFILING Table

The note 'PROFILING': information-schema-profiling-table. table provides statement profiling information. Its contents correspond to the information produced by the note 'SHOW PROFILE': show-profile. and note 'SHOW PROFILES': show-profiles. statements (see note show-profile::). The table is empty unless the 'profiling' session variable is set to 1.

Note:

This table is deprecated; expect it to be removed in a future release of MySQL. Use the note Performance Schema: performance-schema. instead; see note performance-schema-query-profiling::.

The *note 'PROFILING': information-schema-profiling-table. table has these columns:

Notes

Profiling information is also available from the note 'SHOW PROFILE': show-profile. and note 'SHOW PROFILES': show-profiles. statements. See *note show-profile::. For example, the following queries are equivalent:

 SHOW PROFILE FOR QUERY 2;

 SELECT STATE, FORMAT(DURATION, 6) AS DURATION
 FROM INFORMATION_SCHEMA.PROFILING
 WHERE QUERY_ID = 2 ORDER BY SEQ;

 File: manual.info.tmp, Node: information-schema-referential-constraints-table, Next: information-schema-routines-table, Prev: information-schema-profiling-table, Up: general-information-schema-tables

24.3.20 The INFORMATION_SCHEMA REFERENTIAL_CONSTRAINTS Table

The *note 'REFERENTIAL_CONSTRAINTS': information-schema-referential-constraints-table. table provides information about foreign keys.

The *note 'REFERENTIAL_CONSTRAINTS': information-schema-referential-constraints-table. table has these columns:

 File: manual.info.tmp, Node: information-schema-routines-table, Next: information-schema-schemata-table, Prev: information-schema-referential-constraints-table, Up: general-information-schema-tables

24.3.21 The INFORMATION_SCHEMA ROUTINES Table

The note 'ROUTINES': information-schema-routines-table. table provides information about stored routines (stored procedures and stored functions). The note 'ROUTINES': information-schema-routines-table. table does not include built-in (native) functions or loadable functions.

The column named ''mysql.proc' Name' indicates the 'mysql.proc' table column that corresponds to the 'INFORMATION_SCHEMA' *note 'ROUTINES': information-schema-routines-table. table column, if any.

The *note 'ROUTINES': information-schema-routines-table. table has these columns:

Notes

 File: manual.info.tmp, Node: information-schema-schemata-table, Next: information-schema-schema-privileges-table, Prev: information-schema-routines-table, Up: general-information-schema-tables

24.3.22 The INFORMATION_SCHEMA SCHEMATA Table

A schema is a database, so the *note 'SCHEMATA': information-schema-schemata-table. table provides information about databases.

The *note 'SCHEMATA': information-schema-schemata-table. table has these columns:

Schema names are also available from the note 'SHOW DATABASES': show-databases. statement. See note show-databases::. The following statements are equivalent:

 SELECT SCHEMA_NAME AS `Database`
   FROM INFORMATION_SCHEMA.SCHEMATA
   [WHERE SCHEMA_NAME LIKE 'WILD']

 SHOW DATABASES
   [LIKE 'WILD']

You see only those databases for which you have some kind of privilege, unless you have the global *note 'SHOW DATABASES': show-databases. privilege.

Caution:

Because a global privilege is considered a privilege for all databases, any global privilege enables a user to see all database names with note 'SHOW DATABASES': show-databases. or by examining the 'INFORMATION_SCHEMA' note 'SCHEMATA': information-schema-schemata-table. table.

 File: manual.info.tmp, Node: information-schema-schema-privileges-table, Next: information-schema-statistics-table, Prev: information-schema-schemata-table, Up: general-information-schema-tables

24.3.23 The INFORMATION_SCHEMA SCHEMA_PRIVILEGES Table

The *note 'SCHEMA_PRIVILEGES': information-schema-schema-privileges-table. table provides information about schema (database) privileges. It takes its values from the 'mysql.db' system table.

The *note 'SCHEMA_PRIVILEGES': information-schema-schema-privileges-table. table has these columns:

Notes

The following statements are not equivalent:

 SELECT ... FROM INFORMATION_SCHEMA.SCHEMA_PRIVILEGES

 SHOW GRANTS ...

 File: manual.info.tmp, Node: information-schema-statistics-table, Next: information-schema-tables-table, Prev: information-schema-schema-privileges-table, Up: general-information-schema-tables

24.3.24 The INFORMATION_SCHEMA STATISTICS Table

The *note 'STATISTICS': information-schema-statistics-table. table provides information about table indexes.

The *note 'STATISTICS': information-schema-statistics-table. table has these columns:

Notes

Information about table indexes is also available from the note 'SHOW INDEX': show-index. statement. See note show-index::. The following statements are equivalent:

 SELECT * FROM INFORMATION_SCHEMA.STATISTICS
   WHERE table_name = 'TBL_NAME'
   AND table_schema = 'DB_NAME'

 SHOW INDEX
   FROM TBL_NAME
   FROM DB_NAME

 File: manual.info.tmp, Node: information-schema-tables-table, Next: information-schema-tablespaces-table, Prev: information-schema-statistics-table, Up: general-information-schema-tables

24.3.25 The INFORMATION_SCHEMA TABLES Table

The *note 'TABLES': information-schema-tables-table. table provides information about tables in databases.

The *note 'TABLES': information-schema-tables-table. table has these columns:

Notes

Table information is also available from the note 'SHOW TABLE STATUS': show-table-status. and note 'SHOW TABLES': show-tables. statements. See note show-table-status::, and note show-tables::. The following statements are equivalent:

 SELECT
     TABLE_NAME, 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
   FROM INFORMATION_SCHEMA.TABLES
   WHERE table_schema = 'DB_NAME'
   [AND table_name LIKE 'WILD']

 SHOW TABLE STATUS
   FROM DB_NAME
   [LIKE 'WILD']

The following statements are equivalent:

 SELECT
   TABLE_NAME, TABLE_TYPE
   FROM INFORMATION_SCHEMA.TABLES
   WHERE table_schema = 'DB_NAME'
   [AND table_name LIKE 'WILD']

 SHOW FULL TABLES
   FROM DB_NAME
   [LIKE 'WILD']

 File: manual.info.tmp, Node: information-schema-tablespaces-table, Next: information-schema-table-constraints-table, Prev: information-schema-tables-table, Up: general-information-schema-tables

24.3.26 The INFORMATION_SCHEMA TABLESPACES Table

This table is unused. Other 'INFORMATION_SCHEMA' tables may provide related information:

 File: manual.info.tmp, Node: information-schema-table-constraints-table, Next: information-schema-table-privileges-table, Prev: information-schema-tablespaces-table, Up: general-information-schema-tables

24.3.27 The INFORMATION_SCHEMA TABLE_CONSTRAINTS Table

The *note 'TABLE_CONSTRAINTS': information-schema-table-constraints-table. table describes which tables have constraints.

The *note 'TABLE_CONSTRAINTS': information-schema-table-constraints-table. table has these columns:

 File: manual.info.tmp, Node: information-schema-table-privileges-table, Next: information-schema-triggers-table, Prev: information-schema-table-constraints-table, Up: general-information-schema-tables

24.3.28 The INFORMATION_SCHEMA TABLE_PRIVILEGES Table

The *note 'TABLE_PRIVILEGES': information-schema-table-privileges-table. table provides information about table privileges. It takes its values from the 'mysql.tables_priv' system table.

The *note 'TABLE_PRIVILEGES': information-schema-table-privileges-table. table has these columns:

Notes

The following statements are not equivalent:

 SELECT ... FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES

 SHOW GRANTS ...

 File: manual.info.tmp, Node: information-schema-triggers-table, Next: information-schema-user-privileges-table, Prev: information-schema-table-privileges-table, Up: general-information-schema-tables

24.3.29 The INFORMATION_SCHEMA TRIGGERS Table

The *note 'TRIGGERS': information-schema-triggers-table. table provides information about triggers. To see information about a table's triggers, you must have the 'TRIGGER' privilege for the table.

The *note 'TRIGGERS': information-schema-triggers-table. table has these columns:

Example

The following example uses the 'ins_sum' trigger defined in *note triggers:::

 mysql> SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
        WHERE TRIGGER_SCHEMA='test' AND TRIGGER_NAME='ins_sum'\G
 *************************** 1. row ***************************
            TRIGGER_CATALOG: def
             TRIGGER_SCHEMA: test
               TRIGGER_NAME: ins_sum
         EVENT_MANIPULATION: INSERT
       EVENT_OBJECT_CATALOG: def
        EVENT_OBJECT_SCHEMA: test
         EVENT_OBJECT_TABLE: account
               ACTION_ORDER: 1
           ACTION_CONDITION: NULL
           ACTION_STATEMENT: SET @sum = @sum + NEW.amount
         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: 2018-08-08 10:10:12.61
                   SQL_MODE: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,
                             NO_ZERO_IN_DATE,NO_ZERO_DATE,
                             ERROR_FOR_DIVISION_BY_ZERO,
                             NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
                    DEFINER: me@localhost
       CHARACTER_SET_CLIENT: utf8
       COLLATION_CONNECTION: utf8_general_ci
         DATABASE_COLLATION: latin1_swedish_ci

Trigger information is also available from the note 'SHOW TRIGGERS': show-triggers. statement. See note show-triggers::.

 File: manual.info.tmp, Node: information-schema-user-privileges-table, Next: information-schema-views-table, Prev: information-schema-triggers-table, Up: general-information-schema-tables

24.3.30 The INFORMATION_SCHEMA USER_PRIVILEGES Table

The *note 'USER_PRIVILEGES': information-schema-user-privileges-table. table provides information about global privileges. It takes its values from the 'mysql.user' system table.

The *note 'USER_PRIVILEGES': information-schema-user-privileges-table. table has these columns:

Notes

The following statements are not equivalent:

 SELECT ... FROM INFORMATION_SCHEMA.USER_PRIVILEGES

 SHOW GRANTS ...

 File: manual.info.tmp, Node: information-schema-views-table, Prev: information-schema-user-privileges-table, Up: general-information-schema-tables

24.3.31 The INFORMATION_SCHEMA VIEWS Table

The *note 'VIEWS': information-schema-views-table. table provides information about views in databases. You must have the 'SHOW VIEW' privilege to access this table.

The *note 'VIEWS': information-schema-views-table. table has these columns:

Notes

MySQL permits different 'sql_mode' settings to tell the server the type of SQL syntax to support. For example, you might use the 'ANSI' SQL mode to ensure MySQL correctly interprets the standard SQL concatenation operator, the double bar ('||'), in your queries. If you then create a view that concatenates items, you might worry that changing the 'sql_mode' setting to a value different from 'ANSI' could cause the view to become invalid. But this is not the case. No matter how you write out a view definition, MySQL always stores it the same way, in a canonical form. Here is an example that shows how the server changes a double bar concatenation operator to a 'CONCAT()' function:

 mysql> SET sql_mode = 'ANSI';
 Query OK, 0 rows affected (0.00 sec)

 mysql> CREATE VIEW test.v AS SELECT 'a' || 'b' as col1;
 Query OK, 0 rows affected (0.00 sec)

 mysql> SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS
        WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v';
 +----------------------------------+
 | VIEW_DEFINITION                  |
 +----------------------------------+
 | select concat('a','b') AS `col1` |
 +----------------------------------+
 1 row in set (0.00 sec)

The advantage of storing a view definition in canonical form is that changes made later to the value of 'sql_mode' do not affect the results from the view. However, an additional consequence is that comments prior to *note 'SELECT': select. are stripped from the definition by the server.

 File: manual.info.tmp, Node: innodb-information-schema-tables, Next: thread-pool-information-schema-tables, Prev: general-information-schema-tables, Up: information-schema