Содержание
- 19.1. The
INFORMATION_SCHEMA CHARACTER_SETSTable - 19.2. The
INFORMATION_SCHEMA COLLATIONSTable - 19.3. The
INFORMATION_SCHEMA COLLATION_CHARACTER_SET_APPLICABILITYTable - 19.4. The
INFORMATION_SCHEMA COLUMNSTable - 19.5. The
INFORMATION_SCHEMA COLUMN_PRIVILEGESTable - 19.6. The
INFORMATION_SCHEMA ENGINESTable - 19.7. The
INFORMATION_SCHEMA EVENTSTable - 19.8. The
INFORMATION_SCHEMA FILESTable - 19.9. The
INFORMATION_SCHEMA GLOBAL_STATUSandSESSION_STATUSTables - 19.10. The
INFORMATION_SCHEMA GLOBAL_VARIABLESandSESSION_VARIABLESTables - 19.11. The
INFORMATION_SCHEMA KEY_COLUMN_USAGETable - 19.12. The
INFORMATION_SCHEMA PARAMETERSTable - 19.13. The
INFORMATION_SCHEMA PARTITIONSTable - 19.14. The
INFORMATION_SCHEMA PLUGINSTable - 19.15. The
INFORMATION_SCHEMA PROCESSLISTTable - 19.16. The
INFORMATION_SCHEMA PROFILINGTable - 19.17. The
INFORMATION_SCHEMA REFERENTIAL_CONSTRAINTSTable - 19.18. The
INFORMATION_SCHEMA ROUTINESTable - 19.19. The
INFORMATION_SCHEMA SCHEMATATable - 19.20. The
INFORMATION_SCHEMA SCHEMA_PRIVILEGESTable - 19.21. The
INFORMATION_SCHEMA STATISTICSTable - 19.22. The
INFORMATION_SCHEMA TABLESTable - 19.23. The
INFORMATION_SCHEMA TABLESPACESTable - 19.24. The
INFORMATION_SCHEMA TABLE_CONSTRAINTSTable - 19.25. The
INFORMATION_SCHEMA TABLE_PRIVILEGESTable - 19.26. The
INFORMATION_SCHEMA TRIGGERSTable - 19.27. The
INFORMATION_SCHEMA USER_PRIVILEGESTable - 19.28. The
INFORMATION_SCHEMA VIEWSTable - 19.29.
INFORMATION_SCHEMATables forInnoDB - 19.30. Thread Pool
INFORMATION_SCHEMATables - 19.31. Other
INFORMATION_SCHEMATables - 19.32. Extensions to
SHOWStatements
INFORMATION_SCHEMA provides access to database
metadata, information about the MySQL server
such as the name of a database or table, the data type of a column,
or access privileges. Other terms that are sometimes used for this
information are data dictionary and
system catalog.
Usage Notes for the INFORMATION_SCHEMA Database
INFORMATION_SCHEMA is a database within each
MySQL instance, the place that stores information about all the
other databases that the MySQL server maintains. The
INFORMATION_SCHEMA database contains several
read-only tables. They are actually views, not base tables, so there
are no files associated with them, and you cannot set triggers on
them. Also, there is no database directory with that name.
Although you can select INFORMATION_SCHEMA as the
default database with a USE
statement, you can only read the contents of tables, not perform
INSERT,
UPDATE, or
DELETE operations on them.
Пример
Here is an example of a statement that retrieves information from
INFORMATION_SCHEMA:
mysql>SELECT table_name, table_type, engine->FROM information_schema.tables->WHERE table_schema = 'db5'->ORDER BY table_name;+------------+------------+--------+ | table_name | table_type | engine | +------------+------------+--------+ | fk | BASE TABLE | InnoDB | | fk2 | BASE TABLE | InnoDB | | goto | BASE TABLE | MyISAM | | into | BASE TABLE | MyISAM | | k | BASE TABLE | MyISAM | | kurs | BASE TABLE | MyISAM | | loop | BASE TABLE | MyISAM | | pk | BASE TABLE | InnoDB | | t | BASE TABLE | MyISAM | | t2 | BASE TABLE | MyISAM | | t3 | BASE TABLE | MyISAM | | t7 | BASE TABLE | MyISAM | | tables | BASE TABLE | MyISAM | | v | VIEW | NULL | | v2 | VIEW | NULL | | v3 | VIEW | NULL | | v56 | VIEW | NULL | +------------+------------+--------+ 17 rows in set (0.01 sec)
Explanation: The statement requests a list of all the tables in
database db5, showing just three pieces of
information: the name of the table, its type, and its storage
engine.
The definition for character columns (for example,
TABLES.TABLE_NAME) is generally
VARCHAR( where N) CHARACTER SET
utf8N is at least 64.
MySQL uses the default collation for this character set
(utf8_general_ci) for all searches, sorts,
comparisons, and other string operations on such columns. However,
searches in INFORMATION_SCHEMA string columns are
also affected by file system case sensitivity. For more information,
see Section 9.1.7.9, “Collation and INFORMATION_SCHEMA Searches”.
Each MySQL user has the right to access these tables, but can see
only the rows in the tables that correspond to objects for which the
user has the proper access privileges. In some cases (for example,
the ROUTINE_DEFINITION column in the
INFORMATION_SCHEMA.ROUTINES table),
users who have insufficient privileges will see
NULL.
Character Set Considerations
The definition for character columns (for example,
TABLES.TABLE_NAME) is generally
VARCHAR( where N) CHARACTER SET
utf8N is at least 64.
MySQL uses the default collation for this character set
(utf8_general_ci) for all searches, sorts,
comparisons, and other string operations on such columns.
Because some MySQL objects are represented as files, searches in
INFORMATION_SCHEMA string columns can be affected
by file system case sensitivity. For more information, see
Section 9.1.7.9, “Collation and INFORMATION_SCHEMA Searches”.
INFORMATION_SCHEMA as Alternative to SHOW Statements
The SELECT ... FROM INFORMATION_SCHEMA statement
is intended as a more consistent way to provide access to the
information provided by the various
SHOW statements that MySQL supports
(SHOW DATABASES,
SHOW TABLES, and so forth). Using
SELECT has these advantages, compared
to SHOW:
It conforms to Codd's rules, because all access is done on tables.
You can use the familiar syntax of the
SELECTstatement, and only need to learn some table and column names.The implementor need not worry about adding keywords.
You can filter, sort, concatenate, and transform the results from
INFORMATION_SCHEMAqueries into whatever format your application needs, such as a data structure or a text representation to parse.This technique is more interoperable with other database systems. For example, Oracle Database users are familiar with querying tables in the Oracle data dictionary.
Because SHOW is familiar and widely
used, the SHOW statements remain as
an alternative. In fact, along with the implementation of
INFORMATION_SCHEMA, there are enhancements to
SHOW as described in
Section 19.32, “Extensions to SHOW Statements”.
Privileges
Each MySQL user has the right to access these tables, but can see
only the rows in the tables that correspond to objects for which the
user has the proper access privileges. In some cases (for example,
the ROUTINE_DEFINITION column in the
INFORMATION_SCHEMA.ROUTINES table),
users who have insufficient privileges see NULL.
These restrictions do not apply for
InnoDB tables; you can see them with
only the PROCESS privilege.
The same privileges apply to selecting information from
INFORMATION_SCHEMA and viewing the same
information through SHOW statements.
In either case, you must have some privilege on an object to see
information about it.
Performance Considerations
INFORMATION_SCHEMA queries that search for
information from more than one database might take a long time and
impact performance. To check the efficiency of a query, you can use
EXPLAIN. For information about using
EXPLAIN output to tune
INFORMATION_SCHEMA queries, see
Section 7.2.4, “Optimizing INFORMATION_SCHEMA Queries”.
Standards Considerations
The implementation for the INFORMATION_SCHEMA
table structures in MySQL follows the ANSI/ISO SQL:2003 standard
Часть 11 Schemata. Our intent is approximate
compliance with SQL:2003 core feature F021 Basic
information schema.
Users of SQL Server 2000 (which also follows the standard) may
notice a strong similarity. However, MySQL has omitted many columns
that are not relevant for our implementation, and added columns that
are MySQL-specific. One such column is the ENGINE
column in the INFORMATION_SCHEMA.TABLES
table.
Although other DBMSs use a variety of names, like
syscat or system, the standard
name is INFORMATION_SCHEMA.
To avoid using any name that is reserved in the standard or in DB2,
SQL Server, or Oracle, we changed the names of some columns marked
“MySQL extension”. (For example, we changed
COLLATION to TABLE_COLLATION
in the TABLES table.) See the list of
reserved words near the end of this article:
http://web.archive.org/web/20070409075643rn_1/www.dbazine.com/db2/db2-disarticles/gulutzan5.
Conventions in the INFORMATION_SCHEMA Reference Sections
The following sections describe each of the tables and columns in
INFORMATION_SCHEMA. For each column, there are
three pieces of information:
“
INFORMATION_SCHEMAName” indicates the name for the column in theINFORMATION_SCHEMAtable. This corresponds to the standard SQL name unless the “Remarks” field says “MySQL extension.”“
SHOWName” indicates the equivalent field name in the closestSHOWstatement, if there is one.“Remarks” provides additional information where applicable. If this field is
NULL, it means that the value of the column is alwaysNULL. If this field says “MySQL extension,” the column is a MySQL extension to standard SQL.
Many sections indicate what SHOW
statement is equivalent to a SELECT
that retrieves information from
INFORMATION_SCHEMA. For
SHOW statements that display
information for the default database if you omit a FROM
clause, you can often
select information for the default database by adding an
db_nameAND TABLE_SCHEMA = SCHEMA() condition to the
WHERE clause of a query that retrieves
information from an INFORMATION_SCHEMA table.
For answers to questions that are often asked concerning the
INFORMATION_SCHEMA database, see
Section B.7, “MySQL 5.5 FAQ: INFORMATION_SCHEMA”.
The CHARACTER_SETS table provides
information about available character sets.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
CHARACTER_SET_NAME | Charset | |
DEFAULT_COLLATE_NAME | Default collation | |
DESCRIPTION | Описание | MySQL extension |
MAXLEN | Maxlen | MySQL extension |
The following statements are equivalent:
SELECT * FROM INFORMATION_SCHEMA.CHARACTER_SETS [WHERE CHARACTER_SET_NAME LIKE 'wild'] SHOW CHARACTER SET [LIKE 'wild']
The COLLATIONS table provides
information about collations for each character set.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
COLLATION_NAME | Collation | |
CHARACTER_SET_NAME | Charset | MySQL extension |
ID | Id | MySQL extension |
IS_DEFAULT | Default | MySQL extension |
IS_COMPILED | Compiled | MySQL extension |
SORTLEN | Sortlen | MySQL extension |
COLLATION_NAMEis the collation name.CHARACTER_SET_NAMEis the name of the character set with which the collation is associated.IDis the collation ID.IS_DEFAULTindicates whether the collation is the default for its character set.IS_COMPILEDindicates whether the character set is compiled into the server.SORTLENis related to the amount of memory required to sort strings expressed in the character set.
Collation information is also available from the
SHOW COLLATION statement. The
following statements are equivalent:
SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLLATIONS [WHERE COLLATION_NAME LIKE 'wild'] SHOW COLLATION [LIKE 'wild']
The
COLLATION_CHARACTER_SET_APPLICABILITY
table indicates what character set is applicable for what
collation. The columns are equivalent to the first two display
fields that we get from SHOW
COLLATION.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
COLLATION_NAME | Collation | |
CHARACTER_SET_NAME | Charset |
The COLUMNS table provides
information about columns in tables.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TABLE_CATALOG | def | |
TABLE_SCHEMA | ||
TABLE_NAME | ||
COLUMN_NAME | Field | |
ORDINAL_POSITION | see notes | |
COLUMN_DEFAULT | Default | |
IS_NULLABLE | Null | |
DATA_TYPE | Type | |
CHARACTER_MAXIMUM_LENGTH | Type | |
CHARACTER_OCTET_LENGTH | ||
NUMERIC_PRECISION | Type | |
NUMERIC_SCALE | Type | |
CHARACTER_SET_NAME | ||
COLLATION_NAME | Collation | |
COLUMN_TYPE | Type | MySQL extension |
COLUMN_KEY | Key | MySQL extension |
EXTRA | Extra | MySQL extension |
PRIVILEGES | Privileges | MySQL extension |
COLUMN_COMMENT | Comment | MySQL extension |
Notes:
In
SHOW, theTypedisplay includes values from several differentCOLUMNScolumns.ORDINAL_POSITIONis necessary because you might want to sayORDER BY ORDINAL_POSITION. UnlikeSHOW,SELECTdoes not have automatic ordering.CHARACTER_OCTET_LENGTHshould be the same asCHARACTER_MAXIMUM_LENGTH, except for multi-byte character sets.CHARACTER_SET_NAMEcan be derived fromCollation. For example, if you saySHOW FULL COLUMNS FROM t, and you see in theCollationcolumn a value oflatin1_swedish_ci, the character set is what is before the first underscore:latin1.
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 FROMtbl_name[FROMdb_name] [LIKE 'wild']
The COLUMN_PRIVILEGES table provides
information about column privileges. This information comes from
the mysql.columns_priv grant table.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
GRANTEE | '
value | |
TABLE_CATALOG | def | |
TABLE_SCHEMA | ||
TABLE_NAME | ||
COLUMN_NAME | ||
PRIVILEGE_TYPE | ||
IS_GRANTABLE |
Notes:
In the output from
SHOW FULL COLUMNS, the privileges are all in one field and in lowercase, for example,select,insert,update,references. InCOLUMN_PRIVILEGES, there is one privilege per row, in uppercase.PRIVILEGE_TYPEcan contain one (and only one) of these values:SELECT,INSERT,UPDATE,REFERENCES.If the user has
GRANT OPTIONprivilege,IS_GRANTABLEshould beYES. Otherwise,IS_GRANTABLEshould beNO. The output does not listGRANT OPTIONas a separate privilege.
The following statements are not equivalent:
SELECT ... FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES SHOW GRANTS ...
The PLUGINS table provides
information about storage engines.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
ENGINE | Engine | MySQL extension |
SUPPORT | Support | MySQL extension |
COMMENT | Comment | MySQL extension |
TRANSACTIONS | Transactions | MySQL extension |
XA | XA | MySQL extension |
SAVEPOINTS | Savepoints | MySQL extension |
Notes:
The
ENGINEStable is a nonstandard table.
The EVENTS table provides information
about scheduled events, which are discussed in
Section 18.4, “Using the Event Scheduler”. The SHOW Name values
correspond to column names of the SHOW
EVENTS statement.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
EVENT_CATALOG | def, MySQL extension | |
EVENT_SCHEMA | Db | MySQL extension |
EVENT_NAME | Name | MySQL extension |
DEFINER | Definer | MySQL extension |
TIME_ZONE | Time zone | MySQL extension |
EVENT_BODY | MySQL extension | |
EVENT_DEFINITION | MySQL extension | |
EVENT_TYPE | Type | MySQL extension |
EXECUTE_AT | Execute at | MySQL extension |
INTERVAL_VALUE | Interval value | MySQL extension |
INTERVAL_FIELD | Interval field | MySQL extension |
SQL_MODE | MySQL extension | |
STARTS | Starts | MySQL extension |
ENDS | Ends | MySQL extension |
STATUS | Status | MySQL extension |
ON_COMPLETION | MySQL extension | |
CREATED | MySQL extension | |
LAST_ALTERED | MySQL extension | |
LAST_EXECUTED | MySQL extension | |
EVENT_COMMENT | MySQL extension | |
ORIGINATOR | Originator | MySQL extension |
CHARACTER_SET_CLIENT | character_set_client | MySQL extension |
COLLATION_CONNECTION | collation_connection | MySQL extension |
DATABASE_COLLATION | Database Collation | MySQL extension |
Notes:
The
EVENTStable is a nonstandard table.EVENT_CATALOG: The value of this column is alwaysdef.EVENT_SCHEMA: The name of the schema (database) to which this event belongs.EVENT_NAME: The name of the event.DEFINER: The account of the user who created the event, in'format.user_name'@'host_name'TIME_ZONE: The event time zone, which is the time zone used for scheduling the event and that is in effect within the event as it executes. The default value isSYSTEM.EVENT_BODY: The language used for the statements in the event'sDOclause; in MySQL 5.5, this is alwaysSQL.This column is not to be confused with the column of the same name (now named
EVENT_DEFINITION) that existed in earlier MySQL versions.EVENT_DEFINITION: The text of the SQL statement making up the event'sDOclause; in other words, the statement executed by this event.EVENT_TYPE: The event repetition type, eitherONE TIME(transient) orRECURRING(repeating).EXECUTE_AT: For a one-time event, this is theDATETIMEvalue specified in theATclause of theCREATE EVENTstatement used to create the event, or of the lastALTER EVENTstatement that modified the event. The value shown in this column reflects the addition or subtraction of anyINTERVALvalue included in the event'sATclause. For example, if an event is created usingON SCHEDULE AT CURRENT_TIMESTAMP + '1:6' DAY_HOUR, and the event was created at 2006-02-09 14:05:30, the value shown in this column would be'2006-02-10 20:05:30'.If the event's timing is determined by an
EVERYclause instead of anATclause (that is, if the event is recurring), the value of this column isNULL.INTERVAL_VALUE: For recurring events, this column contains the numeric portion of the event'sEVERYclause.For a one-time event (that is, an event whose timing is determined by an
ATclause), this column isNULL.INTERVAL_FIELD: For recurring events, this column contains the units portion of theEVERYclause governing the timing of the event. Thus, this column contains a value such as 'YEAR', 'QUARTER', 'DAY', and so on.For a one-time event (that is, an event whose timing is determined by an
ATclause), this column isNULL.SQL_MODE: The SQL mode in effect at the time the event was created or altered.STARTS: For a recurring event whose definition includes aSTARTSclause, this column contains the correspondingDATETIMEvalue. As with theEXECUTE_ATcolumn, this value resolves any expressions used.If there is no
STARTSclause affecting the timing of the event, this column isNULLENDS: For a recurring event whose definition includes aENDSclause, this column contains the correspondingDATETIMEvalue. As with theEXECUTE_ATcolumn, this value resolves any expressions used.If there is no
ENDSclause affecting the timing of the event, this column isNULL.STATUS: One of the three valuesENABLED,DISABLED, orSLAVESIDE_DISABLED.SLAVESIDE_DISABLEDindicates that the creation of the event occurred on another MySQL server acting as a replication master and was replicated to the current MySQL server which is acting as a slave, but the event is not presently being executed on the slave. See Section 15.4.1.8, “Replication of Invoked Features”, for more information.ON_COMPLETION: One of the two valuesPRESERVEorNOT PRESERVE.CREATED: The date and time when the event was created. This is aDATETIMEvalue.LAST_ALTERED: The date and time when the event was last modified. This is aDATETIMEvalue. If the event has not been modified since its creation, this column holds the same value as theCREATEDcolumn.LAST_EXECUTED: The date and time when the event last executed. ADATETIMEvalue. If the event has never executed, this column isNULL.LAST_EXECUTEDindicates when the event started. As a result, theENDScolumn is never less thanLAST_EXECUTED.EVENT_COMMENT: The text of a comment, if the event has one. If not, the value of this column is an empty string.ORIGINATOR: The server ID of the MySQL server on which the event was created; used in replication. The default value is 0.CHARACTER_SET_CLIENTis the session value of thecharacter_set_clientsystem variable when the event was created.COLLATION_CONNECTIONis the session value of thecollation_connectionsystem variable when the event was created.DATABASE_COLLATIONis the collation of the database with which the event is associated.
Пример: Suppose that the user
jon@ghidora creates an event named
e_daily, and then modifies it a few minutes
later using an 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
ENABLED;(Note that comments can span multiple lines.)
This user can then run the following
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: test EVENT_NAME: e_daily DEFINER: paul@localhost 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: STARTS: 2008-09-03 12:13:39 ENDS: NULL STATUS: ENABLED ON_COMPLETION: NOT PRESERVE CREATED: 2008-09-03 12:13:39 LAST_ALTERED: 2008-09-03 12:13:39 LAST_EXECUTED: NULL EVENT_COMMENT: Saves total number of sessions then clears the table each day ORIGINATOR: 1 CHARACTER_SET_CLIENT: latin1 COLLATION_CONNECTION: latin1_swedish_ci DATABASE_COLLATION: latin1_swedish_ci
Times in the EVENTS table are
displayed using the event time zone or the current session time
zone, as described in Section 18.4.4, “Event Metadata”.
The FILES table provides information
about the files in which MySQL NDB
Disk Data tables are stored.
This table provides information about Disk Data
files only; you cannot use it for
determining disk space allocation or availability for individual
NDB tables. However, it is possible to see
how much space is allocated for each
NDB table having data stored on
disk—as well as how much remains available for storage of
of data on disk for that table—using
ndb_desc. For more information, see
Section 16.4.9, “ndb_desc — Describe NDB Tables”.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
FILE_ID | MySQL extension | |
FILE_NAME | MySQL extension | |
FILE_TYPE | MySQL extension | |
TABLESPACE_NAME | MySQL extension | |
TABLE_CATALOG | MySQL extension | |
TABLE_SCHEMA | MySQL extension | |
TABLE_NAME | MySQL extension | |
LOGFILE_GROUP_NAME | MySQL extension | |
LOGFILE_GROUP_NUMBER | MySQL extension | |
ENGINE | MySQL extension | |
FULLTEXT_KEYS | MySQL extension | |
DELETED_ROWS | MySQL extension | |
UPDATE_COUNT | MySQL extension | |
FREE_EXTENTS | MySQL extension | |
TOTAL_EXTENTS | MySQL extension | |
EXTENT_SIZE | MySQL extension | |
INITIAL_SIZE | MySQL extension | |
MAXIMUM_SIZE | MySQL extension | |
AUTOEXTEND_SIZE | MySQL extension | |
CREATION_TIME | MySQL extension | |
LAST_UPDATE_TIME | MySQL extension | |
LAST_ACCESS_TIME | MySQL extension | |
RECOVER_TIME | MySQL extension | |
TRANSACTION_COUNTER | MySQL extension | |
VERSION | MySQL extension | |
ROW_FORMAT | MySQL extension | |
TABLE_ROWS | MySQL extension | |
AVG_ROW_LENGTH | MySQL extension | |
DATA_LENGTH | MySQL extension | |
MAX_DATA_LENGTH | MySQL extension | |
INDEX_LENGTH | MySQL extension | |
DATA_FREE | MySQL extension | |
CREATE_TIME | MySQL extension | |
UPDATE_TIME | MySQL extension | |
CHECK_TIME | MySQL extension | |
CHECKSUM | MySQL extension | |
STATUS | MySQL extension | |
EXTRA | MySQL extension |
Notes:
FILE_IDcolumn values are auto-generated.FILE_NAMEis the name of anUNDOlog file created byCREATE LOGFILE GROUPorALTER LOGFILE GROUP, or of a data file created byCREATE TABLESPACEorALTER TABLESPACE.FILE_TYPEis one of the valuesUNDOFILE,DATAFILE, orTABLESPACE.TABLESPACE_NAMEis the name of the tablespace with which the file is associated.Currently, the value of the
TABLESPACE_CATALOGcolumn is alwaysNULL.TABLE_NAMEis the name of the Disk Data table with which the file is associated, if any.The
LOGFILE_GROUP_NAMEcolumn gives the name of the log file group to which the log file or data file belongs.For an
UNDOlog file, theLOGFILE_GROUP_NUMBERcontains the auto-generated ID number of the log file group to which the log file belongs.For a MySQL Cluster Disk Data log file or data file, the value of the
ENGINEcolumn is alwaysNDBorNDBCLUSTER.For a MySQL Cluster Disk Data log file or data file, the value of the
FULLTEXT_KEYScolumn is always empty.The
FREE EXTENTScolumn displays the number of extents which have not yet been used by the file. TheTOTAL EXTENTScolumn show the total number of extents allocated to the file.The difference between these two columns is the number of extents currently in use by the file:
SELECT TOTAL_EXTENTS - FREE_EXTENTS AS extents_used FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME = 'myfile.dat';You can approximate the amount of disk space in use by the file by multiplying this difference by the value of the
EXTENT_SIZEcolumn, which gives the size of an extent for the file in bytes:SELECT (TOTAL_EXTENTS - FREE_EXTENTS) * EXTENT_SIZE AS bytes_used FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME = 'myfile.dat';Similarly, you can estimate the amount of space that remains available in a given file by multiplying
FREE_EXTENTSbyEXTENT_SIZE:SELECT FREE_EXTENTS * EXTENT_SIZE AS bytes_free FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME = 'myfile.dat';ImportantThe byte values produced by the preceding queries are approximations only, and their precision is inversely proportional to the value of
EXTENT_SIZE. That is, the largerEXTENT_SIZEbecomes, the less accurate the approximations are.It is also important to remember that once an extent is used, it cannot be freed again without dropping the data file of which it is a part. This means that deletes from a Disk Data table do not release disk space.
The extent size can be set in a
CREATE TABLESPACEstatement. See Section 12.1.18, “CREATE TABLESPACEСинтаксис”, for more information.The
INITIAL_SIZEcolumn shows the size in bytes of the file. This is the same value that was used in theINITIAL_SIZEclause of theCREATE LOGFILE GROUP,ALTER LOGFILE GROUP,CREATE TABLESPACE, orALTER TABLESPACEstatement used to create the file.For MySQL Cluster Disk Data files, the value of the
MAXIMUM_SIZEcolumn is always the same asINITIAL_SIZE, and theAUTOEXTEND_SIZEcolumn is always empty.The
CREATION_TIMEcolumn shows the date and time when the file was created. TheLAST_UPDATE_TIMEcolumn displays the date and time when the file was last modified. TheLAST_ACCESSEDcolumn provides the date and time when the file was last accessed by the server.Currently, the values of these columns are as reported by the operating system, and are not supplied by the
NDBstorage engine. Where no value is provided by the operating system, these columns display0000-00-00 00:00:00.For MySQL Cluster Disk Data files, the value of the
RECOVER_TIMEandTRANSACTION_COUNTERcolumns is always0.For MySQL Cluster Disk Data files, the following columns are always
NULL:VERSIONROW_FORMATTABLE_ROWSAVG_ROW_LENGTHDATA_LENGTHMAX_DATA_LENGTHINDEX_LENGTHDATA_FREECREATE_TIMEUPDATE_TIMECHECK_TIMECHECKSUM
For MySQL Cluster Disk Data files, the value of the
STATUScolumn is alwaysNORMAL.For MySQL Cluster Disk Data files, the
EXTRAcolumn shows which data node the file belongs to, as each data node has its own copy of the file. Suppose that you use this statement on a MySQL Cluster with four data nodes:CREATE LOGFILE GROUP mygroup ADD UNDOFILE 'new_undo.dat' INITIAL_SIZE 2G ENGINE NDB;After running the
CREATE LOGFILE GROUPstatement successfully, you should see a result similar to the one shown here for this query against theFILEStable:mysql>
SELECT LOGFILE_GROUP_NAME, FILE_TYPE, EXTRA->FROM INFORMATION_SCHEMA.FILES->WHERE FILE_NAME = 'new_undo.dat';+--------------------+-------------+----------------+ | LOGFILE_GROUP_NAME | FILE_TYPE | EXTRA | +--------------------+-------------+----------------+ | mygroup | UNDO FILE | CLUSTER_NODE=3 | | mygroup | UNDO FILE | CLUSTER_NODE=4 | | mygroup | UNDO FILE | CLUSTER_NODE=5 | | mygroup | UNDO FILE | CLUSTER_NODE=6 | +--------------------+-------------+----------------+ 4 rows in set (0.01 sec)The
FILEStable is a nonstandard table.An additional row is present in the
FILEStable following the creation of a logfile group. This row hasNULLfor the value of theFILE_NAMEcolumn. For this row, the value of theFILE_IDcolumn is always0, that of theFILE_TYPEcolumn is alwaysUNDO FILE, and that of theSTATUScolumn is alwaysNORMAL. Currently, the value of theENGINEcolumn is alwaysNDBCLUSTER.The
FREE_EXTENTScolumn in this row shows the total number of free extents available to all undo files belonging to a given log file group whose name and number are shown in theLOGFILE_GROUP_NAMEandLOGFILE_GROUP_NUMBERcolumns, respectively.Suppose there are no existing log file groups on your MySQL Cluster, and you create one using the following statement:
mysql>
CREATE LOGFILE GROUP lg1->ADD UNDOFILE 'undofile.dat'->INITIAL_SIZE = 16M->UNDO_BUFFER_SIZE = 1M->ENGINE = NDB;Query OK, 0 rows affected (3.81 sec)You can now see this
NULLrow when you query theFILEStable:mysql>
SELECT DISTINCT->FILE_NAME AS File,->FREE_EXTENTS AS Free,->TOTAL_EXTENTS AS Total,->EXTENT_SIZE AS Size,->INITIAL_SIZE AS Initial->FROM INFORMATION_SCHEMA.FILES;+--------------+---------+---------+------+----------+ | File | Free | Total | Size | Initial | +--------------+---------+---------+------+----------+ | undofile.dat | NULL | 4194304 | 4 | 16777216 | | NULL | 4184068 | NULL | 4 | NULL | +--------------+---------+---------+------+----------+ 2 rows in set (0.01 sec)The total number of free extents available for undo logging is always somewhat less than the sum of the
TOTAL_EXTENTScolumn values for all undo files in the log file group due to overhead required for maintaining the undo files. This can be seen by adding a second undo file to the log file group, then repeating the previous query against theFILEStable:mysql>
ALTER LOGFILE GROUP lg1->ADD UNDOFILE 'undofile02.dat'->INITIAL_SIZE = 4M->ENGINE = NDB;Query OK, 0 rows affected (1.02 sec) mysql>SELECT DISTINCT->FILE_NAME AS File,->FREE_EXTENTS AS Free,->TOTAL_EXTENTS AS Total,->EXTENT_SIZE AS Size,->INITIAL_SIZE AS Initial->FROM INFORMATION_SCHEMA.FILES;+----------------+---------+---------+------+----------+ | File | Free | Total | Size | Initial | +----------------+---------+---------+------+----------+ | undofile.dat | NULL | 4194304 | 4 | 16777216 | | undofile02.dat | NULL | 1048576 | 4 | 4194304 | | NULL | 5223944 | NULL | 4 | NULL | +----------------+---------+---------+------+----------+ 3 rows in set (0.01 sec)The amount of free space in bytes which is available for undo logging by Disk Data tables using this log file group can be approximated by multiplying the number of free extents by the initial size:
mysql>
SELECT->FREE_EXTENTS AS 'Free Extents',->FREE_EXTENTS * EXTENT_SIZE AS 'Free Bytes'->FROM INFORMATION_SCHEMA.FILES->WHERE LOGFILE_GROUP_NAME = 'lg1'->AND FILE_NAME IS NULL;+--------------+------------+ | Free Extents | Free Bytes | +--------------+------------+ | 5223944 | 20895776 | +--------------+------------+ 1 row in set (0.02 sec)If you create a MySQL Cluster Disk Data table and then insert some rows into it, you can see approximately how much space remains for undo logging afterward, for example:
mysql>
CREATE TABLESPACE ts1->ADD DATAFILE 'data1.dat'->USE LOGFILE GROUP lg1->INITIAL_SIZE 512M->ENGINE = NDB;Query OK, 0 rows affected (8.71 sec) mysql>CREATE TABLE dd (->c1 INT NOT NULL PRIMARY KEY,->c2 INT,->c3 DATE->)->TABLESPACE ts1 STORAGE DISK->ENGINE = NDB;Query OK, 0 rows affected (2.11 sec) mysql>INSERT INTO dd VALUES->(NULL, 1234567890, '2007-02-02'),->(NULL, 1126789005, '2007-02-03'),->(NULL, 1357924680, '2007-02-04'),->(NULL, 1642097531, '2007-02-05');Query OK, 4 rows affected (0.01 sec) mysql>SELECT->FREE_EXTENTS AS 'Free Extents',->FREE_EXTENTS * EXTENT_SIZE AS 'Free Bytes'->FROM INFORMATION_SCHEMA.FILES->WHERE LOGFILE_GROUP_NAME = 'lg1'->AND FILE_NAME IS NULL;+--------------+------------+ | Free Extents | Free Bytes | +--------------+------------+ | 5207565 | 20830260 | +--------------+------------+ 1 row in set (0.01 sec)An additional row is present in the
FILEStable for any MySQL Cluster tablespace, whether or not any data files are associated with the tablespace. This row hasNULLfor the value of theFILE_NAMEcolumn. For this row, the value of theFILE_IDcolumn is always0, that of theFILE_TYPEcolumn is alwaysTABLESPACE, and that of theSTATUScolumn is alwaysNORMAL. Currently, the value of theENGINEcolumn is alwaysNDBCLUSTER.There are no
SHOWstatements associated with theFILEStable.For additional information, and examples of creating and dropping MySQL Cluster Disk Data objects, see Section 16.5.11, “MySQL Cluster Disk Data Tables”.
The GLOBAL_STATUS
and SESSION_STATUS
tables provide information about server status variables. Their
contents correspond to the information produced by the
SHOW GLOBAL
STATUS and
SHOW SESSION
STATUS statements (see Section 12.7.5.36, “SHOW STATUS Синтаксис”).
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
| VARIABLE_NAME | Variable_name | |
| VARIABLE_VALUE | Value |
Notes:
The
VARIABLE_VALUEcolumn for each of these tables is defined asVARCHAR(20480).
The
GLOBAL_VARIABLES
and
SESSION_VARIABLES
tables provide information about server status variables. Their
contents correspond to the information produced by the
SHOW GLOBAL
VARIABLES and
SHOW SESSION
VARIABLES statements (see
Section 12.7.5.40, “SHOW VARIABLES Синтаксис”).
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
| VARIABLE_NAME | Variable_name | |
| VARIABLE_VALUE | Value |
Notes:
The
VARIABLE_VALUEcolumn for each of these tables is defined asVARCHAR(20480).
The KEY_COLUMN_USAGE table describes
which key columns have constraints.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
CONSTRAINT_CATALOG | def | |
CONSTRAINT_SCHEMA | ||
CONSTRAINT_NAME | ||
TABLE_CATALOG | def | |
TABLE_SCHEMA | ||
TABLE_NAME | ||
COLUMN_NAME | ||
ORDINAL_POSITION | ||
POSITION_IN_UNIQUE_CONSTRAINT | ||
REFERENCED_TABLE_SCHEMA | ||
REFERENCED_TABLE_NAME | ||
REFERENCED_COLUMN_NAME |
Notes:
If the constraint is a foreign key, then this is the column of the foreign key, not the column that the foreign key references.
The value of
ORDINAL_POSITIONis the column's position within the constraint, not the column's position within the table. Column positions are numbered beginning with 1.The value of
POSITION_IN_UNIQUE_CONSTRAINTisNULLfor unique and primary-key constraints. For foreign-key constraints, it is the ordinal position in key of the table that is being referenced.Suppose that there are two tables name
t1andt3that 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
KEY_COLUMN_USAGEtable has two rows:One row with
CONSTRAINT_NAME='PRIMARY',TABLE_NAME='t1',COLUMN_NAME='s3',ORDINAL_POSITION=1,POSITION_IN_UNIQUE_CONSTRAINT=NULL.One row with
CONSTRAINT_NAME='CO',TABLE_NAME='t3',COLUMN_NAME='s2',ORDINAL_POSITION=1,POSITION_IN_UNIQUE_CONSTRAINT=1.
The PARAMETERS table provides
information about stored procedure and function parameters, and
about return values for stored functions. Parameter information is
similar to the contents of the param_list
column in the mysql.proc table.
INFORMATION_SCHEMA Name | mysql.proc Name | Remarks |
|---|---|---|
SPECIFIC_CATALOG | def | |
SPECIFIC_SCHEMA | db | routine database |
SPECIFIC_NAME | name | routine name |
ORDINAL_POSITION | 1, 2, 3, ... for parameters, 0 for function RETURNS
clause | |
PARAMETER_MODE | IN, OUT, INOUT
(NULL for RETURNS) | |
PARAMETER_NAME | parameter name (NULL for RETURNS) | |
DATA_TYPE | same as for COLUMNS table | |
CHARACTER_MAXIMUM_LENGTH | same as for COLUMNS table | |
CHARACTER_OCTET_LENGTH | same as for COLUMNS table | |
NUMERIC_PRECISION | same as for COLUMNS table | |
NUMERIC_SCALE | same as for COLUMNS table | |
CHARACTER_SET_NAME | same as for COLUMNS table | |
COLLATION_NAME | same as for COLUMNS table | |
DTD_IDENTIFIER | same as for COLUMNS table | |
ROUTINE_TYPE | type | same as for ROUTINES table |
Notes:
The
PARAMETERStable was added in MySQL 5.5.3.For successive parameters of a stored procedure or function, the
ORDINAL_POSITIONvalues are 1, 2, 3, and so forth. For a stored function, there is also a row that describes the data type for theRETURNSclause. The return value is not a true parameter, so the row that describes it has these unique characteristics:The
ORDINAL_POSITIONvalue is 0.The
PARAMETER_NAMEandPARAMETER_MODEvalues areNULLbecause the return value has no name and the mode does not apply.
The PARTITIONS table provides
information about table partitions. See
Глава 17, Partitioning, for more information about
partitioning tables.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TABLE_CATALOG | MySQL extension | |
TABLE_SCHEMA | MySQL extension | |
TABLE_NAME | MySQL extension | |
PARTITION_NAME | MySQL extension | |
SUBPARTITION_NAME | MySQL extension | |
PARTITION_ORDINAL_POSITION | MySQL extension | |
SUBPARTITION_ORDINAL_POSITION | MySQL extension | |
PARTITION_METHOD | MySQL extension | |
SUBPARTITION_METHOD | MySQL extension | |
PARTITION_EXPRESSION | MySQL extension | |
SUBPARTITION_EXPRESSION | MySQL extension | |
PARTITION_DESCRIPTION | MySQL extension | |
TABLE_ROWS | MySQL extension | |
AVG_ROW_LENGTH | MySQL extension | |
DATA_LENGTH | MySQL extension | |
MAX_DATA_LENGTH | MySQL extension | |
INDEX_LENGTH | MySQL extension | |
DATA_FREE | MySQL extension | |
CREATE_TIME | MySQL extension | |
UPDATE_TIME | MySQL extension | |
CHECK_TIME | MySQL extension | |
CHECKSUM | MySQL extension | |
PARTITION_COMMENT | MySQL extension | |
NODEGROUP | MySQL extension | |
TABLESPACE_NAME | MySQL extension |
Notes:
The
PARTITIONStable is a nonstandard table.Each record in this table corresponds to an individual partition or subpartition of a partitioned table.
TABLE_CATALOG: This column is alwaysdef.TABLE_SCHEMA: This column contains the name of the database to which the table belongs.TABLE_NAME: This column contains the name of the table containing the partition.PARTITION_NAME: The name of the partition.SUBPARTITION_NAME: If thePARTITIONStable record represents a subpartition, then this column contains the name of subpartition; otherwise it isNULL.PARTITION_ORDINAL_POSITION: All partitions are indexed in the same order as they are defined, with1being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.SUBPARTITION_ORDINAL_POSITION: Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.PARTITION_METHOD: One of the valuesRANGE,LIST,HASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available partitioning types as discussed in Section 17.2, “Partitioning Types”.SUBPARTITION_METHOD: One of the valuesHASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available subpartitioning types as discussed in Section 17.2.6, “Subpartitioning”.PARTITION_EXPRESSION: This is the expression for the partitioning function used in theCREATE TABLEorALTER TABLEstatement that created the table's current partitioning scheme.For example, consider a partitioned table created in the
testdatabase using this statement:CREATE TABLE tp ( c1 INT, c2 INT, c3 VARCHAR(25) ) PARTITION BY HASH(c1 + c2) PARTITIONS 4;The
PARTITION_EXPRESSIONcolumn in a PARTITIONS table record for a partition from this table displaysc1 + c2, as shown here:mysql>
SELECT DISTINCT PARTITION_EXPRESSION>FROM INFORMATION_SCHEMA.PARTITIONS>WHERE TABLE_NAME='tp' AND TABLE_SCHEMA='test';+----------------------+ | PARTITION_EXPRESSION | +----------------------+ | c1 + c2 | +----------------------+ 1 row in set (0.09 sec)SUBPARTITION_EXPRESSION: This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table asPARTITION_EXPRESSIONdoes for the partitioning expression used to define a table's partitioning.If the table has no subpartitions, then this column is
NULL.PARTITION_DESCRIPTION: This column is used for RANGE and LIST partitions. For aRANGEpartition, it contains the value set in the partition'sVALUES LESS THANclause, which can be either an integer orMAXVALUE. For aLISTpartition, this column contains the values defined in the partition'sVALUES INclause, which is a comma-separated list of integer values.For partitions whose
PARTITION_METHODis other thanRANGEorLIST, this column is alwaysNULL.TABLE_ROWS: The number of table rows in the partition.For partitioned
InnoDBtables, the row count given in theTABLE_ROWScolumn is only an estimated value used in SQL optimization, and may not always be exact.For
NDBtables, you can also obtain this information using the ndb_desc utility.AVG_ROW_LENGTH: The average length of the rows stored in this partition or subpartition, in bytes.This is the same as
DATA_LENGTHdivided byTABLE_ROWS.You can also obtain equivalent information using the ndb_desc utility.
DATA_LENGTH: The total length of all rows stored in this partition or subpartition, in bytes—that is, the total number of bytes stored in the partition or subpartition.For
NDBtables, you can also obtain this information using the ndb_desc utility.MAX_DATA_LENGTH: The maximum number of bytes that can be stored in this partition or subpartition.For
NDBtables, you can also obtain this information using the ndb_desc utility.INDEX_LENGTH: The length of the index file for this partition or subpartition, in bytes.For partitions of
NDBtables, whether the tables use implicit or explicit partitioning, theINDEX_LENGTHcolumn value is always 0. However, you can obtain equivalent information using the ndb_desc utility.DATA_FREE: The number of bytes allocated to the partition or subpartition but not used.For
NDBtables, you can also obtain this information using the ndb_desc utility.CREATE_TIME: The time of the partition's or subpartition's creation.UPDATE_TIME: The time that the partition or subpartition was last modified.CHECK_TIME: The last time that the table to which this partition or subpartition belongs was checked.ЗамечаниеSome storage engines do not update this time; for tables using these storage engines, this value is always
NULL.CHECKSUM: The checksum value, if any; otherwise, this column isNULL.PARTITION_COMMENT: This column contains the text of any comment made for the partition.The default value for this column is an empty string.
NODEGROUP: This is the nodegroup to which the partition belongs. This is relevant only to MySQL Cluster tables; otherwise the value of this column is always0.TABLESPACE_NAME: This column contains the name of the tablespace to which the partition belongs. Currently, the value of this column is alwaysDEFAULT.A nonpartitioned table has one record in
INFORMATION_SCHEMA.PARTITIONS; however, the values of thePARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION, andPARTITION_DESCRIPTIONcolumns are allNULL. (ThePARTITION_COMMENTcolumn in this case is blank.)In MySQL 5.5, there is also only one record in the
PARTITIONStable for a table using theNDBCLUSTERstorage engine. The same columns are alsoNULL(or empty) as for a nonpartitioned table.
The PLUGINS table provides
information about server plugins.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
PLUGIN_NAME | Name | MySQL extension |
PLUGIN_VERSION | MySQL extension | |
PLUGIN_STATUS | Status | MySQL extension |
PLUGIN_TYPE | Type | MySQL extension |
PLUGIN_TYPE_VERSION | MySQL extension | |
PLUGIN_LIBRARY | Library | MySQL extension |
PLUGIN_LIBRARY_VERSION | MySQL extension | |
PLUGIN_AUTHOR | MySQL extension | |
PLUGIN_DESCRIPTION | MySQL extension | |
PLUGIN_LICENSE | MySQL extension | |
LOAD_OPTION | MySQL extension |
Notes:
The
PLUGINStable is a nonstandard table.PLUGIN_NAMEis the name used to refer to the plugin in statements such asINSTALL PLUGINandUNINSTALL PLUGIN.PLUGIN_VERSIONis the version from the plugin's general type descriptor.PLUGIN_STATUSindicates the plugin status, one ofACTIVE,INACTIVE,DISABLED, orDELETED.PLUGIN_TYPEindicates the type of plugin, such asSTORAGE ENGINE,INFORMATION_SCHEMA, orAUTHENTICATION.PLUGIN_TYPE_VERSIONis the version from the plugin's type-specific descriptor.PLUGIN_LIBRARYis the name of the plugin shared object file. This is the name used to refer to the plugin file in statements such asINSTALL PLUGINandUNINSTALL PLUGIN. This file is located in the directory named by theplugin_dirsystem variable. If the library name isNULL, the plugin is compiled in and cannot be uninstalled withUNINSTALL PLUGIN.PLUGIN_LIBRARY_VERSIONindicates the plugin API interface version.PLUGIN_AUTHORnames the plugin author.PLUGIN_DESCRIPTIONprovides a short description of the plugin.PLUGIN_LICENSEindicates how the plugin is licensed; for example,GPL.LOAD_OPTIONindicates how the plugin was loaded. The value isOFF,ON,FORCE, orFORCE_PLUS_PERMANENT. See Section 5.1.7.1, “Installing and Uninstalling Plugins”. This column was added in MySQL 5.5.7.
For plugins installed with INSTALL
PLUGIN, the PLUGIN_NAME and
PLUGIN_LIBRARY values are also registered in
the mysql.plugin table.
These statements are equivalent:
SELECT PLUGIN_NAME, PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_LIBRARY, PLUGIN_LICENSE FROM INFORMATION_SCHEMA.PLUGINS; SHOW PLUGINS;
For information about plugin data structures that form the basis
of the information in the PLUGINS
table, see Section 22.2, “The MySQL Plugin API”.
Plugin information is also available using the
SHOW PLUGINS statement. See
Section 12.7.5.26, “SHOW PLUGINS Синтаксис”.
The PROCESSLIST table provides
information about which threads are running.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
ID | Id | MySQL extension |
USER | User | MySQL extension |
HOST | Host | MySQL extension |
DB | db | MySQL extension |
COMMAND | Command | MySQL extension |
TIME | Time | MySQL extension |
STATE | State | MySQL extension |
INFO | Info | MySQL extension |
For an extensive description of the table columns, see
Section 12.7.5.30, “SHOW PROCESSLIST Синтаксис”.
Notes:
The
PROCESSLISTtable is a nonstandard table.Like the output from the corresponding
SHOWstatement, thePROCESSLISTtable will only show information about your own threads, unless you have thePROCESSprivilege, in which case you will see information about other threads, too. As an anonymous user, you cannot see any rows at all.If an SQL statement refers to
INFORMATION_SCHEMA.PROCESSLIST, then MySQL will populate the entire table once, when statement execution begins, so there is read consistency during the statement. There is no read consistency for a multi-statement transaction, though.
The following statements are equivalent:
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST SHOW FULL PROCESSLIST
The PROFILING table provides
statement profiling information. Its contents correspond to the
information produced by the SHOW
PROFILES and SHOW PROFILE
statements (see Section 12.7.5.32, “SHOW PROFILES Синтаксис”). The table is
empty unless the profiling
session variable is set to 1.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
QUERY_ID | Query_ID | |
SEQ | | |
STATE | Status | |
DURATION | Duration | |
CPU_USER | CPU_user | |
CPU_SYSTEM | CPU_system | |
CONTEXT_VOLUNTARY | Context_voluntary | |
CONTEXT_INVOLUNTARY | Context_involuntary | |
BLOCK_OPS_IN | Block_ops_in | |
BLOCK_OPS_OUT | Block_ops_out | |
MESSAGES_SENT | Messages_sent | |
MESSAGES_RECEIVED | Messages_received | |
PAGE_FAULTS_MAJOR | Page_faults_major | |
PAGE_FAULTS_MINOR | Page_faults_minor | |
SWAPS | Swaps | |
SOURCE_FUNCTION | Source_function | |
SOURCE_FILE | Source_file | |
SOURCE_LINE | Source_line |
Notes:
QUERY_IDis a numeric statement identifier.SEQis a sequence number indicating the display order for rows with the sameQUERY_IDvalue.STATEis the profiling state to which the row measurements apply.DURATIONindicates how long statement execution remained in the given state, in seconds.CPU_USERandCPU_SYSTEMindicate user and system CPU use, in seconds.CONTEXT_VOLUNTARYandCONTEXT_INVOLUNTARYindicate how many voluntary and involuntary context switches occurred.BLOCK_OPS_INandBLOCK_OPS_OUTindicate the number of block input and output operations.MESSAGES_SENTandMESSAGES_RECEIVEDindicate the number of communication messages sent and received.PAGE_FAULTS_MAJORandPAGE_FAULTS_MINORindicate the number of major and minor page faults.SWAPSindicates how many swaps occurred.SOURCE_FUNCTION,SOURCE_FILE, andSOURCE_LINEprovide information indicating where in the source code the profiled state executes.
The REFERENTIAL_CONSTRAINTS table
provides information about foreign keys.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
| CONSTRAINT_CATALOG | def | |
| CONSTRAINT_SCHEMA | ||
| CONSTRAINT_NAME | ||
| UNIQUE_CONSTRAINT_CATALOG | def | |
| UNIQUE_CONSTRAINT_SCHEMA | ||
| UNIQUE_CONSTRAINT_NAME | ||
| MATCH_OPTION | ||
| UPDATE_RULE | ||
| DELETE_RULE | ||
| TABLE_NAME | ||
| REFERENCED_TABLE_NAME |
Notes:
TABLE_NAMEhas the same value asTABLE_NAMEinINFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_SCHEMAandCONSTRAINT_NAMEidentify the foreign key.UNIQUE_CONSTRAINT_SCHEMA,UNIQUE_CONSTRAINT_NAME, andREFERENCED_TABLE_NAMEidentify the referenced key.The only valid value at this time for
MATCH_OPTIONisNONE.The possible values for
UPDATE_RULEorDELETE_RULEareCASCADE,SET NULL,SET DEFAULT,RESTRICT,NO ACTION.
The ROUTINES table provides
information about stored routines (both procedures and functions).
The ROUTINES table does not include
user-defined functions (UDFs).
The column named “mysql.proc name”
indicates the mysql.proc table column that
corresponds to the
INFORMATION_SCHEMA.ROUTINES table
column, if any.
INFORMATION_SCHEMA Name | mysql.proc Name | Remarks |
|---|---|---|
SPECIFIC_NAME | specific_name | |
ROUTINE_CATALOG | def | |
ROUTINE_SCHEMA | db | |
ROUTINE_NAME | name | |
ROUTINE_TYPE | type | {PROCEDURE|FUNCTION} |
DATA_TYPE | same as for COLUMNS table | |
CHARACTER_MAXIMUM_LENGTH | same as for COLUMNS table | |
CHARACTER_OCTET_LENGTH | same as for COLUMNS table | |
NUMERIC_PRECISION | same as for COLUMNS table | |
NUMERIC_SCALE | same as for COLUMNS table | |
CHARACTER_SET_NAME | same as for COLUMNS table | |
COLLATION_NAME | same as for COLUMNS table | |
DTD_IDENTIFIER | data type descriptor | |
ROUTINE_BODY | SQL | |
ROUTINE_DEFINITION | body | |
EXTERNAL_NAME | NULL | |
EXTERNAL_LANGUAGE | language | NULL |
PARAMETER_STYLE | SQL | |
IS_DETERMINISTIC | is_deterministic | |
SQL_DATA_ACCESS | sql_data_access | |
SQL_PATH | NULL | |
SECURITY_TYPE | security_type | |
CREATED | created | |
LAST_ALTERED | modified | |
SQL_MODE | sql_mode | MySQL extension |
ROUTINE_COMMENT | comment | MySQL extension |
DEFINER | definer | MySQL extension |
CHARACTER_SET_CLIENT | MySQL extension | |
COLLATION_CONNECTION | MySQL extension | |
DATABASE_COLLATION | MySQL extension |
Notes:
MySQL calculates
EXTERNAL_LANGUAGEthus:If
mysql.proc.language='SQL',EXTERNAL_LANGUAGEisNULLOtherwise,
EXTERNAL_LANGUAGEis what is inmysql.proc.language. However, we do not have external languages yet, so it is alwaysNULL.
CHARACTER_SET_CLIENTis the session value of thecharacter_set_clientsystem variable when the routine was created.COLLATION_CONNECTIONis the session value of thecollation_connectionsystem variable when the routine was created.DATABASE_COLLATIONis the collation of the database with which the routine is associated.The
DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,CHARACTER_OCTET_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE,CHARACTER_SET_NAME, andCOLLATION_NAMEcolumns provide information about the data type for theRETURNSclause of stored functions. If a stored routine is a stored procedure, these columns all areNULL. These columns were added in MySQL 5.5.3.Information about stored function
RETURNSdata types is also available in thePARAMETERStable. The return value data type row for a function can be identified as the row that has anORDINAL_POSITIONvalue of 0.
A schema is a database, so the
SCHEMATA table provides information
about databases.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
CATALOG_NAME | def | |
SCHEMA_NAME | Database | |
DEFAULT_CHARACTER_SET_NAME | ||
DEFAULT_COLLATION_NAME | ||
SQL_PATH | NULL |
The following statements are equivalent:
SELECT SCHEMA_NAME AS `Database` FROM INFORMATION_SCHEMA.SCHEMATA [WHERE SCHEMA_NAME LIKE 'wild'] SHOW DATABASES [LIKE 'wild']
The SCHEMA_PRIVILEGES table provides
information about schema (database) privileges. This information
comes from the mysql.db grant table.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
GRANTEE | '
value, MySQL extension | |
TABLE_CATALOG | def, MySQL extension | |
TABLE_SCHEMA | MySQL extension | |
PRIVILEGE_TYPE | MySQL extension | |
IS_GRANTABLE | MySQL extension |
Notes:
This is a nonstandard table. It takes its values from the
mysql.dbtable.
The STATISTICS table provides
information about table indexes.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TABLE_CATALOG | def | |
TABLE_SCHEMA | = Database | |
TABLE_NAME | Table | |
NON_UNIQUE | Non_unique | |
INDEX_SCHEMA | = Database | |
INDEX_NAME | Key_name | |
SEQ_IN_INDEX | Seq_in_index | |
COLUMN_NAME | Column_name | |
COLLATION | Collation | |
CARDINALITY | Cardinality | |
SUB_PART | Sub_part | MySQL extension |
PACKED | Packed | MySQL extension |
NULLABLE | Null | MySQL extension |
INDEX_TYPE | Index_type | MySQL extension |
COMMENT | Comment | MySQL extension |
Notes:
There is no standard table for indexes. The preceding list is similar to what SQL Server 2000 returns for
sp_statistics, except that we replaced the nameQUALIFIERwithCATALOGand we replaced the nameOWNERwithSCHEMA.Clearly, the preceding table and the output from
SHOW INDEXare derived from the same parent. So the correlation is already close.
The following statements are equivalent:
SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name = 'tbl_name' AND table_schema = 'db_name' SHOW INDEX FROMtbl_nameFROMdb_name
The TABLES table provides information
about tables in databases.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TABLE_CATALOG | def | |
TABLE_SCHEMA | Table_... | |
TABLE_NAME | Table_... | |
TABLE_TYPE | ||
ENGINE | Engine | MySQL extension |
VERSION | Version | The version number of the table's .frm file, MySQL
extension |
ROW_FORMAT | Row_format | MySQL extension |
TABLE_ROWS | Rows | MySQL extension |
AVG_ROW_LENGTH | Avg_row_length | MySQL extension |
DATA_LENGTH | Data_length | MySQL extension |
MAX_DATA_LENGTH | Max_data_length | MySQL extension |
INDEX_LENGTH | Index_length | MySQL extension |
DATA_FREE | Data_free | MySQL extension |
AUTO_INCREMENT | Auto_increment | MySQL extension |
CREATE_TIME | Create_time | MySQL extension |
UPDATE_TIME | Update_time | MySQL extension |
CHECK_TIME | Check_time | MySQL extension |
TABLE_COLLATION | Collation | MySQL extension |
CHECKSUM | Checksum | MySQL extension |
CREATE_OPTIONS | Create_options | MySQL extension |
TABLE_COMMENT | Comment | MySQL extension |
Notes:
TABLE_SCHEMAandTABLE_NAMEare a single field in aSHOWdisplay, for exampleTable_in_db1.TABLE_TYPEshould beBASE TABLEorVIEW. Currently, theTABLEStable does not listTEMPORARYtables.For partitioned tables, the
ENGINEcolumn shows the name of the storage engine used by all partitions. (Previously, this column showedPARTITIONfor such tables.)The
TABLE_ROWScolumn isNULLif the table is in theINFORMATION_SCHEMAdatabase.For
InnoDBtables, the row count is only a rough estimate used in SQL optimization. (This is also true if theInnoDBtable is partitioned.)For
NDBtables,DATA_LENGTHincludes data stored in main memory only; theMAX_DATA_LENGTHandDATA_FREEcolumns apply to Disk Data.For MySQL Cluster Disk Data tables,
MAX_DATA_LENGTHshows the space allocated for the disk part of a Disk Data table or fragment. (In-memory data resource usage is reported by theDATA_LENGTHcolumn.)The
DATA_FREEcolumn shows the free space in bytes forInnoDBtables.For MySQL Cluster,
DATA_FREEshows the space allocated on disk for, but not used by, a Disk Data table or fragment on disk. (In-memory data resource usage is reported by theDATA_LENGTHcolumn.)We have nothing for the table's default character set.
TABLE_COLLATIONis close, because collation names begin with a character set name.The
CREATE_OPTIONScolumn showspartitionedif the table is partitioned.
The following statements are equivalent:
SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name' [AND table_name LIKE 'wild'] SHOW TABLES FROMdb_name[LIKE 'wild']
The TABLESPACES table provides
information about active tablespaces. The table was added in MySQL
5.5.3.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TABLESPACE_NAME | MySQL extension | |
ENGINE | MySQL extension | |
TABLESPACE_TYPE | MySQL extension | |
LOGFILE_GROUP_NAME | MySQL extension | |
EXTENT_SIZE | MySQL extension | |
AUTOEXTEND_SIZE | MySQL extension | |
MAXIMUM_SIZE | MySQL extension | |
NODEGROUP_ID | MySQL extension | |
TABLESPACE_COMMENT | MySQL extension |
The TABLE_CONSTRAINTS table describes
which tables have constraints.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
CONSTRAINT_CATALOG | def | |
CONSTRAINT_SCHEMA | ||
CONSTRAINT_NAME | ||
TABLE_SCHEMA | ||
TABLE_NAME | ||
CONSTRAINT_TYPE |
Notes:
The
CONSTRAINT_TYPEvalue can beUNIQUE,PRIMARY KEY, orFOREIGN KEY.The
UNIQUEandPRIMARY KEYinformation is about the same as what you get from theKey_namefield in the output fromSHOW INDEXwhen theNon_uniquefield is0.The
CONSTRAINT_TYPEcolumn can contain one of these values:UNIQUE,PRIMARY KEY,FOREIGN KEY,CHECK. This is aCHAR(notENUM) column. TheCHECKvalue is not available until we supportCHECK.
The TABLE_PRIVILEGES table provides
information about table privileges. This information comes from
the mysql.tables_priv grant table.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
GRANTEE | '
value | |
TABLE_CATALOG | def | |
TABLE_SCHEMA | ||
TABLE_NAME | ||
PRIVILEGE_TYPE | ||
IS_GRANTABLE |
Notes:
PRIVILEGE_TYPEcan contain one (and only one) of these values:SELECT,INSERT,UPDATE,REFERENCES,ALTER,INDEX,DROP,CREATE VIEW.
The following statements are not equivalent:
SELECT ... FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES SHOW GRANTS ...
The TRIGGERS table provides
information about triggers. You can see results only for databases
and tables for which you have the
TRIGGER privilege.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TRIGGER_CATALOG | def | |
TRIGGER_SCHEMA | ||
TRIGGER_NAME | Trigger | |
EVENT_MANIPULATION | Event | |
EVENT_OBJECT_CATALOG | def | |
EVENT_OBJECT_SCHEMA | ||
EVENT_OBJECT_TABLE | Table | |
ACTION_ORDER | 0 | |
ACTION_CONDITION | NULL | |
ACTION_STATEMENT | Statement | |
ACTION_ORIENTATION | ROW | |
ACTION_TIMING | Timing | |
ACTION_REFERENCE_OLD_TABLE | NULL | |
ACTION_REFERENCE_NEW_TABLE | NULL | |
ACTION_REFERENCE_OLD_ROW | OLD | |
ACTION_REFERENCE_NEW_ROW | NEW | |
CREATED | NULL (0) | |
SQL_MODE | MySQL extension | |
DEFINER | MySQL extension | |
CHARACTER_SET_CLIENT | MySQL extension | |
COLLATION_CONNECTION | MySQL extension | |
DATABASE_COLLATION | MySQL extension |
Notes:
The
TRIGGER_SCHEMAandTRIGGER_NAMEcolumns contain the name of the database in which the trigger occurs and the trigger name, respectively.The
EVENT_MANIPULATIONcolumn contains one of the values'INSERT','DELETE', or'UPDATE'.As noted in Section 18.3, “Using Triggers”, every trigger is associated with exactly one table. The
EVENT_OBJECT_SCHEMAandEVENT_OBJECT_TABLEcolumns contain the database in which this table occurs, and the table's name.The
ACTION_ORDERcolumn contains the ordinal position of the trigger's action within the list of all similar triggers on the same table. Currently, this value is always0, because it is not possible to have more than one trigger with the sameEVENT_MANIPULATIONandACTION_TIMINGon the same table.The
ACTION_STATEMENTcolumn contains the statement to be executed when the trigger is invoked. This is the same as the text displayed in theStatementcolumn of the output fromSHOW TRIGGERS. Note that this text uses UTF-8 encoding.The
ACTION_ORIENTATIONcolumn always contains the value'ROW'.The
ACTION_TIMINGcolumn contains one of the two values'BEFORE'or'AFTER'.The columns
ACTION_REFERENCE_OLD_ROWandACTION_REFERENCE_NEW_ROWcontain the old and new column identifiers, respectively. This means thatACTION_REFERENCE_OLD_ROWalways contains the value'OLD'andACTION_REFERENCE_NEW_ROWalways contains the value'NEW'.The
SQL_MODEcolumn shows the server SQL mode that was in effect at the time when the trigger was created (and thus which remains in effect for this trigger whenever it is invoked, regardless of the current server SQL mode). The possible range of values for this column is the same as that of thesql_modesystem variable. See Section 5.1.6, “Server SQL Modes”.The
DEFINERcolumn indicates who defined the trigger.CHARACTER_SET_CLIENTis the session value of thecharacter_set_clientsystem variable when the trigger was created.COLLATION_CONNECTIONis the session value of thecollation_connectionsystem variable when the trigger was created.DATABASE_COLLATIONis the collation of the database with which the trigger is associated.The following columns currently always contain
NULL:ACTION_CONDITION,ACTION_REFERENCE_OLD_TABLE,ACTION_REFERENCE_NEW_TABLE, andCREATED.
Пример, using the ins_sum trigger defined in
Section 18.3, “Using Triggers”:
mysql> SELECT * FROM INFORMATION_SCHEMA.TRIGGERS\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: 0
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: NULL
SQL_MODE:
DEFINER: me@localhost
The USER_PRIVILEGES table provides
information about global privileges. This information comes from
the mysql.user grant table.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
GRANTEE | '
value, MySQL extension | |
TABLE_CATALOG | def, MySQL extension | |
PRIVILEGE_TYPE | MySQL extension | |
IS_GRANTABLE | MySQL extension |
Notes:
This is a nonstandard table. It takes its values from the
mysql.usertable.
The VIEWS table provides information
about views in databases. You must have the
SHOW VIEW privilege to access this
table.
INFORMATION_SCHEMA Name | SHOW Name | Remarks |
|---|---|---|
TABLE_CATALOG | def | |
TABLE_SCHEMA | ||
TABLE_NAME | ||
VIEW_DEFINITION | ||
CHECK_OPTION | ||
IS_UPDATABLE | ||
DEFINER | ||
SECURITY_TYPE | ||
CHARACTER_SET_CLIENT | MySQL extension | |
COLLATION_CONNECTION | MySQL extension |
Notes:
The
VIEW_DEFINITIONcolumn has most of what you see in theCreate Tablefield thatSHOW CREATE VIEWproduces. Skip the words beforeSELECTand skip the wordsWITH CHECK OPTION. Suppose that the original statement was:CREATE VIEW v AS SELECT s2,s1 FROM t WHERE s1 > 5 ORDER BY s1 WITH CHECK OPTION;
Then the view definition looks like this:
SELECT s2,s1 FROM t WHERE s1 > 5 ORDER BY s1
The
CHECK_OPTIONcolumn has a value ofNONE,CASCADE, orLOCAL.MySQL sets a flag, called the view updatability flag, at
CREATE VIEWtime. The flag is set toYES(true) ifUPDATEandDELETE(and similar operations) are legal for the view. Otherwise, the flag is set toNO(false). TheIS_UPDATABLEcolumn in theVIEWStable displays the status of this flag. It means that the server always knows whether a view is updatable. If the view is not updatable, statements suchUPDATE,DELETE, andINSERTare illegal and will be rejected. (Note that even if a view is updatable, it might not be possible to insert into it; for details, refer to Section 12.1.20, “CREATE VIEWСинтаксис”.)The
DEFINERcolumn indicates who defined the view.SECURITY_TYPEhas a value ofDEFINERorINVOKER.CHARACTER_SET_CLIENTis the session value of thecharacter_set_clientsystem variable when the view was created.COLLATION_CONNECTIONis the session value of thecollation_connectionsystem variable when the view was created.
MySQL lets you use 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 will not affect the
results from the view. However an additional consequence is that
comments prior to SELECT are
stripped from the definition by the server.
The InnoDB tables related to the
InnoDB storage engine help you to monitor ongoing
InnoDB activity, to detect inefficiencies before
they turn into issues, or to troubleshoot performance and capacity
issues that do occur. As your database becomes bigger and busier,
running up against the limits of your hardware capacity, you monitor
and tune these aspects to keep the database running smoothly. The
monitoring information deals with:
InnoDBtable compression, a feature whose use depends on a balance between I/O reduction, CPU usage, buffer pool management, and how much compression is possible for your data.Transactions and locks, features that balance high performance for a single operation, against the ability to run multiple operations concurrently. (Transactions are the high-level, user-visible aspect of concurrency. Locks are the low-level mechanism that transactions use to avoid reading or writing unreliable data.)
The INNODB_CMP and
INNODB_CMP_RESET tables contain status
information on operations related to compressed
InnoDB tables.
Table 19.1. Columns of INNODB_CMP and
INNODB_CMP_RESET
| Column name | Описание |
|---|---|
PAGE_SIZE | Compressed page size in bytes. |
COMPRESS_OPS | Number of times a B-tree page of the size PAGE_SIZE
has been compressed. Pages are compressed whenever an empty
page is created or the space for the uncompressed modification
log runs out. |
COMPRESS_OPS_OK | Number of times a B-tree page of the size PAGE_SIZE
has been successfully compressed. This count should never
exceed COMPRESS_OPS. |
COMPRESS_TIME | Total time in seconds spent in attempts to compress B-tree pages of the
size PAGE_SIZE. |
UNCOMPRESS_OPS | Number of times a B-tree page of the size PAGE_SIZE
has been uncompressed. B-tree pages are uncompressed whenever
compression fails or at first access when the uncompressed
page does not exist in the buffer pool. |
UNCOMPRESS_TIME | Total time in seconds spent in uncompressing B-tree pages of the size
PAGE_SIZE. |
Notes:
Use these tables to measure the effectiveness of
InnoDBtable compression in your database. For usage information, see Section 13.4.6.1.3, “Using the Compression Information Schema Tables”.
The INNODB_CMPMEM and
INNODB_CMPMEM_RESET tables contain status
information on compressed pages within the
InnoDB buffer pool.
Table 19.2. Columns of INNODB_CMPMEM and INNODB_CMPMEM_RESET
| Column name | Описание |
|---|---|
PAGE_SIZE | Block size in bytes. Each record of this table describes blocks of this size. |
PAGES_USED | Number of blocks of the size PAGE_SIZE that are
currently in use. |
PAGES_FREE | Number of blocks of the size PAGE_SIZE that are
currently available for allocation. This column shows the
external fragmentation in the memory pool. Ideally, these
numbers should be at most 1. |
RELOCATION_OPS | Number of times a block of the size PAGE_SIZE has
been relocated. The buddy system can relocate the allocated
“buddy neighbor” of a freed block when it tries
to form a bigger freed block. Reading from the table
INNODB_CMPMEM_RESET resets this count. |
RELOCATION_TIME | Total time in microseconds spent in relocating blocks of the size
PAGE_SIZE. Reading from the table
INNODB_CMPMEM_RESET resets this count. |
Notes:
Use these tables to measure the effectiveness of
InnoDBtable compression in your database. For usage information, see Section 13.4.6.1.3, “Using the Compression Information Schema Tables”.
The INNODB_TRX table contains
information about every transaction currently executing inside
InnoDB, including whether the transaction is
waiting for a lock, when the transaction started, and the SQL
statement the transaction is executing.
Table 19.3. INNODB_TRX Columns
| Column name | Описание |
|---|---|
TRX_ID | Unique transaction ID number, internal to InnoDB. |
TRX_WEIGHT | The weight of a transaction, reflecting (but not necessarily the exact
count of) the number of rows altered and the number of rows
locked by the transaction. To resolve a deadlock,
InnoDB selects the transaction with the
smallest weight as the “victim” to rollback.
Transactions that have changed non-transactional tables are
considered heavier than others, regardless of the number of
altered and locked rows. |
TRX_STATE | Transaction execution state. One of RUNNING,
LOCK WAIT, ROLLING BACK
or COMMITTING. |
TRX_STARTED | Transaction start time. |
TRX_REQUESTED_LOCK_ID | ID of the lock the transaction is currently waiting for (if
TRX_STATE is LOCK WAIT,
otherwise NULL). Details about the lock can
be found by joining with INNODB_LOCKS on
LOCK_ID. |
TRX_WAIT_STARTED | Time when the transaction started waiting on the lock (if
TRX_STATE is LOCK WAIT,
otherwise NULL). |
TRX_MYSQL_THREAD_ID | MySQL thread ID. Can be used for joining with
PROCESSLIST on ID. See
Section 13.4.6.3.3, “Possible Inconsistency with PROCESSLIST”. |
TRX_QUERY | The SQL query that is being executed by the transaction. |
TRX_OPERATION_STATE | The transaction's current operation, or NULL. |
TRX_TABLES_IN_USE | The number of InnoDB tables used while processing the current SQL statement of this transaction. |
TRX_TABLES_LOCKED | Number of InnoDB tables that currently have any locks. (Because these are row locks, not table locks, the tables can usually still be read from and written to by multiple transactions, despite some rows being locked.) |
TRX_LOCK_STRUCTS | The number of locks reserved by the transaction. |
TRX_LOCK_MEMORY_BYTES | Total size taken up by the lock structures of this transaction in memory. |
TRX_ROWS_LOCKED | Approximate number or rows locked by this transaction. The value might include delete-marked rows that are physically present but not visible to the transaction. |
TRX_ROWS_MODIFIED | The number of modified and inserted rows in this transaction. |
TRX_CONCURRENCY_TICKETS | A value indicating how much work the current transaction can do before
being swapped out, as specified by the
innodb_concurrency_tickets option. |
TRX_ISOLATION_LEVEL | The isolation level of the current transaction. |
TRX_UNIQUE_CHECKS | Whether unique checks are turned on or off for the current transaction. (They might be turned off during a bulk data load, for example.) |
TRX_FOREIGN_KEY_CHECKS | Whether foreign key checks are turned on or off for the current transaction. (They might be turned off during a bulk data load, for example.) |
TRX_LAST_FOREIGN_KEY_ERROR | Detailed error message for last FK error, or NULL. |
TRX_ADAPTIVE_HASH_LATCHED | Whether or not the adaptive hash index is locked by the current transaction. (Only a single transaction at a time can modify the adaptive hash index.) |
TRX_ADAPTIVE_HASH_TIMEOUT | Whether to relinquish the search latch immediately for the adaptive hash index, or reserve it across calls from MySQL. When there is no AHI contention, this value remains zero and statements reserve the latch until they finish. During times of contention, it counts down to zero, and statements release the latch immediately after each row lookup. |
TRX_IS_READ_ONLY | A value of 1 indicates the transaction is read-only. (5.6.4 and up.) |
TRX_AUTOCOMMIT_NON_LOCKING |
A value of 1 indicates the transaction is a
|
Notes:
Use this table to help diagnose performance problems that occur during times of heavy concurrent load. For usage information, see Section 13.4.6.2.4, “Using the Transaction Information Schema Tables”.
The INNODB_LOCKS table contains
information about each lock that an InnoDB
transaction has requested but not yet acquired, and each lock that
a transaction holds that is blocking another transaction.
Table 19.4. INNODB_LOCKS Columns
| Column name | Описание |
|---|---|
LOCK_ID | Unique lock ID number, internal to InnoDB. Should be
treated as an opaque string. Although
LOCK_ID currently contains
TRX_ID, the format of the data in
LOCK_ID is not guaranteed to remain the
same in future releases. You should not write programs that
parse the LOCK_ID value. |
LOCK_TRX_ID | ID of the transaction holding this lock. Details about the transaction
can be found by joining with INNODB_TRX on
TRX_ID. |
LOCK_MODE | Mode of the lock. One of S, X,
IS, IX,
S_GAP, X_GAP,
IS_GAP, IX_GAP, or
AUTO_INC for shared, exclusive, intention
shared, intention exclusive row locks, shared and exclusive
gap locks, intention shared and intention exclusive gap locks,
and auto-increment table level lock, respectively. Refer to
the sections Section 13.3.9.1, “InnoDB Lock Modes” and
Section 13.3.9, “The InnoDB Transaction Model and Locking” for information on
InnoDB locking. |
LOCK_TYPE | Type of the lock. One of RECORD or
TABLE for record (row) level or table level
locks, respectively. |
LOCK_TABLE | Name of the table that has been locked or contains locked records. |
LOCK_INDEX | Name of the index if LOCK_TYPE='RECORD', otherwise
NULL. |
LOCK_SPACE | Tablespace ID of the locked record if
LOCK_TYPE='RECORD', otherwise
NULL. |
LOCK_PAGE | Page number of the locked record if
LOCK_TYPE='RECORD', otherwise
NULL. |
LOCK_REC | Heap number of the locked record within the page if
LOCK_TYPE='RECORD', otherwise
NULL. |
LOCK_DATA | Primary key of the locked record if
LOCK_TYPE='RECORD', otherwise
NULL. This column contains the value(s) of
the primary key column(s) in the locked row, formatted as a
valid SQL string (ready to be copied to SQL commands). If
there is no primary key then the InnoDB
internal unique row ID number is used. When the page
containing the locked record is not in the buffer pool (in the
case that it was paged out to disk while the lock was held),
InnoDB does not fetch the page from disk,
to avoid unnecessary disk operations. Instead,
LOCK_DATA is set to
NULL. |
Notes:
Use this table to help diagnose performance problems that occur during times of heavy concurrent load. For usage information, see Section 13.4.6.2.4, “Using the Transaction Information Schema Tables”.
The INNODB_LOCK_WAITS table contains
one or more rows for each blocked InnoDB
transaction, indicating the lock it has requested and any locks
that are blocking that request.
Table 19.5. INNODB_LOCK_WAITS Columns
| Column name | Описание |
|---|---|
REQUESTING_TRX_ID | ID of the requesting transaction. |
REQUESTED_LOCK_ID | ID of the lock for which a transaction is waiting. Details about the
lock can be found by joining with
INNODB_LOCKS on LOCK_ID. |
BLOCKING_TRX_ID | ID of the blocking transaction. |
BLOCKING_LOCK_ID | ID of a lock held by a transaction blocking another transaction from
proceeding. Details about the lock can be found by joining
with INNODB_LOCKS on
LOCK_ID. |
Notes:
Use this table to help diagnose performance problems that occur during times of heavy concurrent load. For usage information, see Section 13.4.6.2.4, “Using the Transaction Information Schema Tables”.
The following sections describe the
INFORMATION_SCHEMA tables associated with the
thread pool plugin. They provide information about thread pool
operation:
TP_THREAD_STATE: Information about thread pool thread statesTP_THREAD_GROUP_STATE: Information about thread pool thread group statesTP_THREAD_GROUP_STATS: Thread group statistics
Rows in these tables represent snapshots in time. In the case of
TP_THREAD_STATE, all rows for a thread
group comprise a snapshot in time. Thus, the MySQL server holds the
mutex of the thread group while producing the snapshot. But it does
not hold mutexes on all thread groups at the same time, to prevent a
statement against TP_THREAD_STATE from
blocking the entire MySQL server.
The thread pool INFORMATION_SCHEMA tables are
implemented by individual plugins and the decision whether to load
one can be made independently of the others (see
Section 7.11.6.1, “Thread Pool Components and Installation”). However, the content of
all the tables depends on the thread pool plugin being enabled. If a
table plugin is enabled but the thread pool plugin is not, the table
becomes visible and can be accessed but will be empty.
This table has one row per thread created by the thread pool to handle connections. The table has these columns:
TP_GROUP_IDThe thread group ID.
TP_THREAD_NUMBERThe ID of the thread within its thread group.
TP_GROUP_IDandTP_THREAD_NUMBERtogether provide a unique key within the table.PROCESS_COUNTThe 10ms interval in which the statement that uses this thread is currently executing. 0 means no statement is executing, 1 means it is in the first 10ms, and so forth.
WAIT_TYPEThe type of wait for the thread.
NULLmeans the thread is not blocked. Otherwise, the thread is blocked by a call tothd_wait_begin()and the value specifies the type of wait. Thecolumns of thexxx_WAITTP_THREAD_GROUP_STATStable accumulate counts for each wait type.The
WAIT_TYPEvalue is a string that describes the type of wait, as shown in the following table.Table 19.6.
WAIT_TYPEValuesWait Type Meaning THD_WAIT_SLEEPWaiting for sleep THD_WAIT_DISKIOWaiting for Disk IO THD_WAIT_ROW_LOCKWaiting for row lock THD_WAIT_GLOBAL_LOCKWaiting for global lock THD_WAIT_META_DATA_LOCKWaiting for metadata lock THD_WAIT_TABLE_LOCKWaiting for table lock THD_WAIT_USER_LOCKWaiting for user lock THD_WAIT_BINLOGWaiting for binlog THD_WAIT_GROUP_COMMITWaiting for group commit THD_WAIT_SYNCWaiting for fsync
This table has one row per thread group in the thread pool. Each row provides information about the current state of a group. The table has these columns:
TP_GROUP_IDThe thread group ID. This is a unique key within the table.
CONSUMER THREADSThe number of consumer threads. There is at most one thread ready to start executing if the active threads become stalled or blocked.
RESERVE_THREADSThe number of threads in the reserved state. This means that they will not be started until there is a need to wake a new thread and there is no consumer thread. This is where most threads end up when the thread group has created more threads than needed for normal operation. Often a thread group needs additional threads for a short while and then does not need them again for a while. In this case, they go into the reserved state and remain until needed again. They take up some extra memory resources, but no extra computing resources.
CONNECTION_COUNTThe number of connections using this thread group.
QUEUED_QUERIESThe number of statements waiting in the high-priority queue.
QUEUED_TRANSACTIONSThe number of statements waiting in the low-priority queue. These are the initial statements for transactions that have not started, so they also represent queued transactions.
STALL_LIMITThe value of the
thread_pool_stall_limitvariable on the thread group. This is the same value for all thread groups.PRIO_KICKUP_TIMERThe value of the
thread_pool_prio_kickup_timeron the thread group. This is the same value for all thread groups.ALGORITHMThe value of the
thread_pool_algorithmon the thread group. This is the same value for all thread groups.THREAD_COUNTThe number of threads started in the thread pool as part of this thread group.
ACTIVE_THREAD_COUNTThe number of threads active executing statements.
MAX_THREAD_IDS_IN_GROUPThe maximum thread ID of the threads in the group. This is the same as
MAX(TP_THREAD_NUMBER)for the threads when selected from theTP_THREAD_GROUP_STATEtable. That is, these two queries are equivalent:SELECT TP_GROUP_ID, MAX_THREAD_IDS_IN_GROUP FROM TP_THREAD_GROUP_STATE; SELECT TP_GROUP_ID, MAX(TP_THREAD_NUMBER) FROM TP_THREAD_STATE GROUP BY TP_GROUP_ID;
STALLED_THREAD_COUNTThe number of stalled statements in the thread group. A stalled statement could be executing, but from a thread pool perspective it is stalled and making no progress. A long-running statement quickly ends up in this category.
WAITING_THREAD_NUMBERIf there is a thread handling the polling of statements in the thread group, this specifies the thread number within this thread group. It is possible that this thread could be executing a statement.
OLDEST_QUEUEDHow long in milliseconds the oldest queued statement has been waiting for execution.
This table reports statistics per thread group. There is one row per group. The table has these columns:
TP_GROUP_IDThe thread group ID. This is a unique key within the table.
CONNECTIONS_STARTEDThe number of connections started.
CONNECTIONS_CLOSEDThe number of connections closed.
QUERIES_EXECUTEDThe number of statements executed. This number is incremented when a statement starts executing, not when it finishes.
QUERIES_QUEUEDThe number of statements received that were queued for execution. This does not count statements that the thread group was able to begin executing immediately without queuing, which can happen under the conditions described in Section 7.11.6.2, “Thread Pool Operation”.
THREADS_STARTEDThe number of threads started.
PRIO_KICKUPSThe number of statements that have been moved from low-priority queue to high-priority queue based on the value of the
thread_pool_prio_kickup_timersystem variable. If this number increases quickly, consider increasing the value of that variable. A quickly increasing counter means that the priority system is not keeping transactions from starting too early. ForInnoDB, this most likely means deteriorating performance due to too many concurrent transactions..STALLED_QUERIES_EXECUTEDThe number of statements that have become defined as stalled due to executing for a time longer than the value of the
thread_pool_stall_limitsystem variable.BECOME_CONSUMER_THREADThe number of times thread have been assigned the consumer thread role.
BECOME_RESERVE_THREADThe number of times threads have been assigned the reserve thread role.
BECOME_WAITING_THREADThe number of times threads have been assigned the waiter thread role. When statements are queued, this happens very often, even in normal operation, so rapid increases in this value are normal in the case of a highly loaded system where statements are queued up.
WAKE_THREAD_STALL_CHECKERThe number of times the stall check thread decided to wake or create a thread to possibly handle some statements or take care of the waiter thread role.
SLEEP_WAITSThe number of
THD_WAIT_SLEEPwaits. These occur when threads go to sleep; for example, by calling theSLEEP()function.DISK_IO_WAITSThe number of
THD_WAIT_DISKIOwaits. These occur when threads perform disk I/O that is likely to not hit the file system cache. Such waits occur when the buffer pool reads and writes data to disk, not for normal reads from and writes to files.ROW_LOCK_WAITSThe number of
THD_WAIT_ROW_LOCKwaits for release of a row lock by another transaction.GLOBAL_LOCK_WAITSThe number of
THD_WAIT_GLOBAL_LOCKwaits for a global lock to be released.META_DATA_LOCK_WAITSThe number of
THD_WAIT_META_DATA_LOCKwaits for a metadata lock to be released.TABLE_LOCK_WAITSThe number of
THD_WAIT_TABLE_LOCKwaits for a table to be unlocked that the statement needs to access.USER_LOCK_WAITSThe number of
THD_WAIT_USER_LOCKwaits for a special lock constructed by the user thread.BINLOG_WAITSThe number of
THD_WAIT_BINLOG_WAITSwaits for the binary log to become free.GROUP_COMMIT_WAITSThe number of
THD_WAIT_GROUP_COMMITwaits. These occur when a group commit must wait for the other parties to complete their part of a transaction.FSYNC_WAITSThe number of
THD_WAIT_SYNCwaits for a file sync operation.
Some extensions to SHOW statements
accompany the implementation of
INFORMATION_SCHEMA:
INFORMATION_SCHEMA is an information database,
so its name is included in the output from
SHOW DATABASES. Similarly,
SHOW TABLES can be used with
INFORMATION_SCHEMA to obtain a list of its
tables:
mysql> SHOW TABLES FROM INFORMATION_SCHEMA;
+---------------------------------------+
| Tables_in_INFORMATION_SCHEMA |
+---------------------------------------+
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
| COLUMN_PRIVILEGES |
| ENGINES |
| EVENTS |
| FILES |
| GLOBAL_STATUS |
| GLOBAL_VARIABLES |
| KEY_COLUMN_USAGE |
| PARTITIONS |
| PLUGINS |
| PROCESSLIST |
| REFERENTIAL_CONSTRAINTS |
| ROUTINES |
| SCHEMATA |
| SCHEMA_PRIVILEGES |
| SESSION_STATUS |
| SESSION_VARIABLES |
| STATISTICS |
| TABLES |
| TABLE_CONSTRAINTS |
| TABLE_PRIVILEGES |
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
+---------------------------------------+
27 rows in set (0.00 sec)
SHOW COLUMNS and
DESCRIBE can display information
about the columns in individual
INFORMATION_SCHEMA tables.
SHOW statements that accept a
LIKE clause to limit the rows
displayed also permit a WHERE clause that
specifies more general conditions that selected rows must satisfy:
SHOW CHARACTER SET SHOW COLLATION SHOW COLUMNS SHOW DATABASES SHOW FUNCTION STATUS SHOW INDEX SHOW OPEN TABLES SHOW PROCEDURE STATUS SHOW STATUS SHOW TABLE STATUS SHOW TABLES SHOW TRIGGERS SHOW VARIABLES
The WHERE clause, if present, is evaluated
against the column names displayed by the
SHOW statement. For example, the
SHOW CHARACTER SET statement
produces these output columns:
mysql> SHOW CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset | Описание | 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 |
| hp8 | HP West European | hp8_english_ci | 1 |
| koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 |
| latin1 | cp1252 West European | latin1_swedish_ci | 1 |
| latin2 | ISO 8859-2 Central European | latin2_general_ci | 1 |
...
To use a WHERE clause with
SHOW CHARACTER SET, you would refer
to those column names. As an example, the following statement
displays information about character sets for which the default
collation contains the string 'japanese':
mysql> SHOW CHARACTER SET WHERE `Default collation` LIKE '%japanese%';
+---------+---------------------------+---------------------+--------+
| Charset | Описание | Default collation | Maxlen |
+---------+---------------------------+---------------------+--------+
| ujis | EUC-JP Japanese | ujis_japanese_ci | 3 |
| sjis | Shift-JIS Japanese | sjis_japanese_ci | 2 |
| cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 |
| eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 |
+---------+---------------------------+---------------------+--------+
This statement displays the multi-byte character sets:
mysql> SHOW CHARACTER SET WHERE Maxlen > 1;
+---------+---------------------------+---------------------+--------+
| Charset | Описание | Default collation | Maxlen |
+---------+---------------------------+---------------------+--------+
| big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 |
| ujis | EUC-JP Japanese | ujis_japanese_ci | 3 |
| sjis | Shift-JIS Japanese | sjis_japanese_ci | 2 |
| euckr | EUC-KR Korean | euckr_korean_ci | 2 |
| gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | 2 |
| gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 |
| utf8 | UTF-8 Unicode | utf8_general_ci | 3 |
| ucs2 | UCS-2 Unicode | ucs2_general_ci | 2 |
| cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 |
| eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 |
+---------+---------------------------+---------------------+--------+