时间:2021-07-01 10:21:17 帮助过:6人阅读
SCHEMATA表:提供了当前MySQL实例中所有数据库的信息。show databases;的结果取值于此。
mysql> select * from schemata; +--------------+--------------------+----------------------------+------------------------+----------+ | CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH | +--------------+--------------------+----------------------------+------------------------+----------+ | def | information_schema | utf8 | utf8_general_ci | NULL | | def | civil | utf8 | utf8_general_ci | NULL | | def | class_7 | utf8 | utf8_general_ci | NULL | | def | db1 | utf8 | utf8_general_ci | NULL | | def | express | utf8 | utf8_general_ci | NULL | | def | mysql | utf8 | utf8_general_ci | NULL | | def | performance_schema | utf8 | utf8_general_ci | NULL | | def | test | utf8 | utf8_general_ci | NULL | +--------------+--------------------+----------------------------+------------------------+----------+ 8 rows in set (0.00 sec)SCHEMATA表的内容
mysql> desc schemata; +----------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------------+--------------+------+-----+---------+-------+ | CATALOG_NAME | varchar(512) | NO | | | | | SCHEMA_NAME | varchar(64) | NO | | | | | DEFAULT_CHARACTER_SET_NAME | varchar(32) | NO | | | | | DEFAULT_COLLATION_NAME | varchar(32) | NO | | | | | SQL_PATH | varchar(512) | YES | | NULL | | +----------------------------+--------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)SCHEMATA的结构
从表中可以看出,SCHEMATA中包含每个库的名字、字符集等信息。
COLUMNS表:提供了表中的列信息。详细表述了某张表的所有列以及每个列的信息。show columns from schemaname.tablename的结果取值于此。
mysql> desc columns; +--------------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------+---------------------+------+-----+---------+-------+ | TABLE_CATALOG | varchar(512) | NO | | | | | TABLE_SCHEMA | varchar(64) | NO | | | | | TABLE_NAME | varchar(64) | NO | | | | | COLUMN_NAME | varchar(64) | NO | | | | | ORDINAL_POSITION | bigint(21) unsigned | NO | | 0 | | | COLUMN_DEFAULT | longtext | YES | | NULL | | | IS_NULLABLE | varchar(3) | NO | | | | | DATA_TYPE | varchar(64) | NO | | | | | CHARACTER_MAXIMUM_LENGTH | bigint(21) unsigned | YES | | NULL | | | CHARACTER_OCTET_LENGTH | bigint(21) unsigned | YES | | NULL | | | NUMERIC_PRECISION | bigint(21) unsigned | YES | | NULL | | | NUMERIC_SCALE | bigint(21) unsigned | YES | | NULL | | | CHARACTER_SET_NAME | varchar(32) | YES | | NULL | | | COLLATION_NAME | varchar(32) | YES | | NULL | | | COLUMN_TYPE | longtext | NO | | NULL | | | COLUMN_KEY | varchar(3) | NO | | | | | EXTRA | varchar(27) | NO | | | | | PRIVILEGES | varchar(80) | NO | | | | | COLUMN_COMMENT | varchar(1024) | NO | | | | +--------------------------+---------------------+------+-----+---------+-------+ 19 rows in set (0.00 sec)COLUMNS的结构属性
TABLES表:提供了关于数据库中的表的信息(包括视图)。详细表述了某个表属于哪个schema(概述)、表类型、表引擎、创建时间等信息。show tables from schemaname的结果取值于此。
mysql> desc tables; +-----------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------------+------+-----+---------+-------+ | TABLE_CATALOG | varchar(512) | NO | | | | | TABLE_SCHEMA | varchar(64) | NO | | | | | TABLE_NAME | varchar(64) | NO | | | | | TABLE_TYPE | varchar(64) | NO | | | | | ENGINE | varchar(64) | YES | | NULL | | | VERSION | bigint(21) unsigned | YES | | NULL | | | ROW_FORMAT | varchar(10) | YES | | NULL | | | TABLE_ROWS | bigint(21) unsigned | YES | | NULL | | | AVG_ROW_LENGTH | bigint(21) unsigned | YES | | NULL | | | DATA_LENGTH | bigint(21) unsigned | YES | | NULL | | | MAX_DATA_LENGTH | bigint(21) unsigned | YES | | NULL | | | INDEX_LENGTH | bigint(21) unsigned | YES | | NULL | | | DATA_FREE | bigint(21) unsigned | YES | | NULL | | | AUTO_INCREMENT | bigint(21) unsigned | YES | | NULL | | | CREATE_TIME | datetime | YES | | NULL | | | UPDATE_TIME | datetime | YES | | NULL | | | CHECK_TIME | datetime | YES | | NULL | | | TABLE_COLLATION | varchar(32) | YES | | NULL | | | CHECKSUM | bigint(21) unsigned | YES | | NULL | | | CREATE_OPTIONS | varchar(255) | YES | | NULL | | | TABLE_COMMENT | varchar(2048) | NO | | | | +-----------------+---------------------+------+-----+---------+-------+ 21 rows in set (0.00 sec)TABLES表的结构属性
STATISTICS表:提供了关于表索引的信息。show index from schemaname.tablename的取值于此。
+---------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------+------+-----+---------+-------+ | TABLE_CATALOG | varchar(512) | NO | | | | | TABLE_SCHEMA | varchar(64) | NO | | | | | TABLE_NAME | varchar(64) | NO | | | | | NON_UNIQUE | bigint(1) | NO | | 0 | | | INDEX_SCHEMA | varchar(64) | NO | | | | | INDEX_NAME | varchar(64) | NO | | | | | SEQ_IN_INDEX | bigint(2) | NO | | 0 | | | COLUMN_NAME | varchar(64) | NO | | | | | COLLATION | varchar(1) | YES | | NULL | | | CARDINALITY | bigint(21) | YES | | NULL | | | SUB_PART | bigint(3) | YES | | NULL | | | PACKED | varchar(10) | YES | | NULL | | | NULLABLE | varchar(3) | NO | | | | | INDEX_TYPE | varchar(16) | NO | | | | | COMMENT | varchar(16) | YES | | NULL | | | INDEX_COMMENT | varchar(1024) | NO | | | | +---------------+---------------+------+-----+---------+-------+STATISTICS表的数据结构属性
USER_PRIVILEGES(用户权限)表:给出了关于方案(数据库)权限的信息。该信息源来自mysql.user授权表,是非标准表。
+--------------------------------+---------------+-------------------------+--------------+ | GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE | +--------------------------------+---------------+-------------------------+--------------+ | ‘root‘@‘localhost‘ | def | SELECT | YES | | ‘root‘@‘localhost‘ | def | INSERT | YES | | ‘root‘@‘localhost‘ | def | UPDATE | YES | | ‘root‘@‘localhost‘ | def | DELETE | YES | | ‘root‘@‘localhost‘ | def | CREATE | YES | | ‘root‘@‘localhost‘ | def | DROP | YES | | ‘root‘@‘localhost‘ | def | RELOAD | YES | | ‘root‘@‘localhost‘ | def | SHUTDOWN | YES | | ‘root‘@‘localhost‘ | def | PROCESS | YES | | ‘root‘@‘localhost‘ | def | FILE | YES | | ‘root‘@‘localhost‘ | def | REFERENCES | YES | | ‘root‘@‘localhost‘ | def | INDEX | YES | | ‘root‘@‘localhost‘ | def | ALTER | YES | | ‘root‘@‘localhost‘ | def | SHOW DATABASES | YES | | ‘root‘@‘localhost‘ | def | SUPER | YES | | ‘root‘@‘localhost‘ | def | CREATE TEMPORARY TABLES | YES | | ‘root‘@‘localhost‘ | def | LOCK TABLES | YES | | ‘root‘@‘localhost‘ | def | EXECUTE | YES | | ‘root‘@‘localhost‘ | def | REPLICATION SLAVE | YES | | ‘root‘@‘localhost‘ | def | REPLICATION CLIENT | YES | | ‘root‘@‘localhost‘ | def | CREATE VIEW | YES | | ‘root‘@‘localhost‘ | def | SHOW VIEW | YES | | ‘root‘@‘localhost‘ | def | CREATE ROUTINE | YES | | ‘root‘@‘localhost‘ | def | ALTER ROUTINE | YES | | ‘root‘@‘localhost‘ | def | CREATE USER | YES | | ‘root‘@‘localhost‘ | def | EVENT | YES | | ‘root‘@‘localhost‘ | def | TRIGGER | YES | | ‘root‘@‘localhost‘ | def | CREATE TABLESPACE | YES | | ‘root‘@‘localhost.localdomain‘ | def | SELECT | YES | | ‘root‘@‘localhost.localdomain‘ | def | INSERT | YES | | ‘root‘@‘localhost.localdomain‘ | def | UPDATE | YES | | ‘root‘@‘localhost.localdomain‘ | def | DELETE | YES | | ‘root‘@‘localhost.localdomain‘ | def | CREATE | YES | | ‘root‘@‘localhost.localdomain‘ | def | DROP | YES | | ‘root‘@‘localhost.localdomain‘ | def | RELOAD | YES | | ‘root‘@‘localhost.localdomain‘ | def | SHUTDOWN | YES | | ‘root‘@‘localhost.localdomain‘ | def | PROCESS | YES | | ‘root‘@‘localhost.localdomain‘ | def | FILE | YES | | ‘root‘@‘localhost.localdomain‘ | def | REFERENCES | YES | | ‘