Home  >  Article  >  Database  >  [MySQL] The information_schema library contains field information for all tables

[MySQL] The information_schema library contains field information for all tables

little bottle
little bottleforward
2019-04-22 10:36:263152browse

information_schema provides access to database metadata, statistical information, and information about MySQL Server (for example: database name or table name, field data type and access permissions, etc.). The information stored in the information_schema library can also be called the MySQL data dictionary or system catalog. This article mainly describes the field information of all tables contained in the information_schema library. Interested friends can learn more.

After sql injection, the field information of all tables can be obtained through this database

1.
COLLATIONS table
Provides information about the collation rules of each character set. The COLLATIONS table contains the following columns:
COLLATION_NAME collation name.
CHARACTER_SET_NAME The name of the character set associated with the collation.
ID Sorting rule ID.
IS_DEFAULT Whether the collation is the default value of its character set.
IS_COMPILED Whether the character set has been compiled into the server.
SORTLEN This relates to the amount of memory required to sort the strings represented in the character set.

2.
SHOW COLLATION;//You can also query the collation information

3.
COLLATION_CHARACTER_SET_APPLICABILITY table
COLLATION_NAME collation name.
CHARACTER_SET_NAME The name of the character set associated with the collation

4.
COLUMNS Provides information about the fields in the table

TABLE_CATALOG The name of the catalog to which the table containing this column belongs. The value is always def.
TABLE_SCHEMA contains the name of the database where the field is located.
TABLE_NAME contains the name of the table where the field is located.
The name of the COLUMN_NAME field.
ORDINAL_POSITION The position of the field in the table. ORDINAL_POSITION is necessary because you probably want to say ORDER BY ORDINAL_POSITION. Unlike SHOW COLUMNS, SELECT in the COLUMNS table is not automatically sorted. The syntax of show columns is for example: show columns from my_test.user;

The default value of the COLUMN_DEFAULT field. If the field has an explicit default value of NULL, or the field definition does not contain a DEFAULT clause, this value is NULL.
IS_NULLABLE field can be nullable. The value is YES if NULL values ​​can be stored in the column, NO otherwise.
DATA_TYPE field data type. The DATA_TYPE value is just the type name, no other information.
The COLUMN_TYPE value contains the type name and possibly other information such as precision or length.
CHARACTER_MAXIMUM_LENGTH For string columns, the maximum length in characters.
CHARACTER_OCTET_LENGTH For string columns, the maximum length in bytes.
NUMERIC_PRECISION For numeric fields, numeric precision.
NUMERIC_SCALE For numeric fields, numeric scale.
DATETIME_PRECISION For time fields, fractional seconds precision.
CHARACTER_SET_NAME For string fields, character set name.
COLLATION_NAME For string fields, the collation name.
COLUMN_TYPE field data type.
The DATA_TYPE value is just the type name, no other information.
The COLUMN_TYPE value contains the type name and possibly other information such as precision or length.

COLUMN_KEY Whether the name is indexed
EXTRA Any other available information about the given field.
PRIVILEGES Your permissions on this field.
COLUMN_COMMENT Any comments contained in the field definition.
GENERATION_EXPRESSION For generated fields, displays the expression used to calculate column values.

Related tutorials: mysql video tutorial

The above is the detailed content of [MySQL] The information_schema library contains field information for all tables. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete