From 83553cc579fa24e6dbc200f1a59977f518757864 Mon Sep 17 00:00:00 2001 From: Ran Date: Fri, 12 Jun 2020 13:35:42 +0800 Subject: [PATCH 1/4] system-tables: add a description for columns --- .../system-table-information-schema.md | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/system-tables/system-table-information-schema.md b/system-tables/system-table-information-schema.md index c5304e076dd0e..d7bc4a76a20d7 100644 --- a/system-tables/system-table-information-schema.md +++ b/system-tables/system-table-information-schema.md @@ -192,6 +192,34 @@ CHARACTER_MAXIMUM_LENGTH: NULL 1 row in set (0.01 sec) ``` +The description of columns in the `COLUMNS` table is as follows: + +* `TABLE_CATALOG`: The name of the catalog to which the table with the column belongs. The value is always `def`. +* `TABLE_SCHEMA`: The name of the database in which the table with the column is located. +* `TABLE_NAME`: The name of the table with the column. +* `COLUMN_NAME`: The name of the column. +* `ORDINAL_POSITION`: The position of the column in the table. +* `COLUMN_DEFAULT`: The default value of the column. If the explicit default value is `NULL`, or if the column definition does not include the `default` clause, this value is `NULL`. +* `IS_NULLABLE`: Whether the column is nullable. If the column can store empty value, this value is `YES`; otherwise, it is `NO`. +* `DATA_TYPE`: The type of data in the column. +* `CHARACTER_MAXIMUM_LENGTH`: The maximum length of a string column, in characters. +* `CHARACTER_OCTET_LENGTH`: The maximum length of a string column, in bytes. +* `NUMERIC_PRECISION`: The numeric precision of a number column. +* `NUMERIC_SCALE`: The numeric scale of a number column. +* `DATETIME_PRECISION`: The fractional second precision of a time column. +* `CHARACTER_SET_NAME`: The name of the character set of a string column. +* `COLLATION_NAME`: The name of the collation rule of a string column. +* `COLUMN_TYPE`: The column type. +* `COLUMN_KEY`: Whether this column is indexed. It has the following values: + * Null: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index. + * `PRI`: This column is the primary key or one of multiple primary keys. + * `UNI`: This column is the first column of the unique index. + * `MUL`: The column is the first column of a non-unique index, in which a given value is allowed to occur for multiple times. +* `EXTRA`: Any additional information about the given column. +* `PRIVILEGES`: The privilege that the current user has on this column. Currently, this value is fixed in TiDB, and is always `select,insert,update,references`. +* `COLUMN_COMMENT`: Comments contained in the column definition. +* `GENERATION_EXPRESSION`: For generated columns, this value displays the expression used to calculate the column value. For non-generated columns, the value is empty. + The corresponding `SHOW` statement is as follows: {{< copyable "sql" >}} @@ -211,7 +239,7 @@ SHOW COLUMNS FROM t1 FROM test; ### ENGINES table -The `ENGINES` table provides information about storage engines. For compatibility, TiDB will always describe InnoDB as the only supported engine: +The `ENGINES` table provides information about storage engines. For compatibility, TiDB will always describe InnoDB as the only supported engine. In addition, other column values in the `ENGINES` table are also fixed values. {{< copyable "sql" >}} @@ -230,6 +258,15 @@ TRANSACTIONS: YES 1 row in set (0.00 sec) ``` +The description of columns in the `ENGINES` table is as follows: + +* `ENGINES`: The name of the storage engine. +* `SUPPORT`: The level of support that the server has on the storage engine. In TiDB, the value is always `DEFAULT`. +* `COMMENT`: The brief description of the storage engine. +* `TRANSACTIONS`:Whether the storage engine supports transactions. +* `XA`: Whether the storage engine supports XA transactions. +* `SAVEPOINTS`: Whether the storage engine supports `savepoints`. + ### KEY_COLUMN_USAGE table The `KEY_COLUMN_USAGE` table describes the key constraints of the columns, such as the primary key constraint: @@ -270,6 +307,21 @@ POSITION_IN_UNIQUE_CONSTRAINT: NULL 2 rows in set (0.00 sec) ``` +The description of columns in the `KEY_COLUMN_USAGE` table is as follows: + +* `CONSTRAINT_CATALOG`: The name of the catalog to which the constraint belongs. The value is always `def`. +* `CONSTRAINT_SCHEMA`: The name of the database to which the constraint belongs. +* `CONSTRAINT_NAME`: The name of the constraint. +* `TABLE_CATALOG`: The name of the catalog to which the table belongs. The value is always `def`. +* `TABLE_SCHEMA`: The name of the database to which the table belongs. +* `TABLE_NAME`: The name of the table with constraints. +* `COLUMN_NAME`: The name of the column with constraints. +* `ORDINAL_POSITION`: The position of the column in the constraint, rather than in the table. The position number starts from `1`. +* `POSITION_IN_UNIQUE_CONSTRAINT`: The unique constraint and the primary key constraint are empty. For foreign key constraint, this column is the position of the referenced table's key. +* `REFERENCED_TABLE_SCHEMA`: The name of the database referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. +* `REFERENCED_TABLE_NAME`: The name of the table referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. +* `REFERENCED_COLUMN_NAME`: The name of the column referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. + ### PROCESSLIST table `PROCESSLIST`, just like `show processlist`, is used to view the requests that are being handled. From 12c97782e1c8801eecec626a2f70d140e084ae3f Mon Sep 17 00:00:00 2001 From: Ran Date: Wed, 17 Jun 2020 10:31:10 +0800 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- .../system-table-information-schema.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/system-tables/system-table-information-schema.md b/system-tables/system-table-information-schema.md index d7bc4a76a20d7..6e1c344c3a2cc 100644 --- a/system-tables/system-table-information-schema.md +++ b/system-tables/system-table-information-schema.md @@ -195,7 +195,7 @@ CHARACTER_MAXIMUM_LENGTH: NULL The description of columns in the `COLUMNS` table is as follows: * `TABLE_CATALOG`: The name of the catalog to which the table with the column belongs. The value is always `def`. -* `TABLE_SCHEMA`: The name of the database in which the table with the column is located. +* `TABLE_SCHEMA`: The name of the schema in which the table with the column is located. * `TABLE_NAME`: The name of the table with the column. * `COLUMN_NAME`: The name of the column. * `ORDINAL_POSITION`: The position of the column in the table. @@ -204,18 +204,18 @@ The description of columns in the `COLUMNS` table is as follows: * `DATA_TYPE`: The type of data in the column. * `CHARACTER_MAXIMUM_LENGTH`: The maximum length of a string column, in characters. * `CHARACTER_OCTET_LENGTH`: The maximum length of a string column, in bytes. -* `NUMERIC_PRECISION`: The numeric precision of a number column. +* `NUMERIC_PRECISION`: The numeric precision of a number-type column. * `NUMERIC_SCALE`: The numeric scale of a number column. * `DATETIME_PRECISION`: The fractional second precision of a time column. * `CHARACTER_SET_NAME`: The name of the character set of a string column. -* `COLLATION_NAME`: The name of the collation rule of a string column. +* `COLLATION_NAME`: The name of the collation of a string column. * `COLUMN_TYPE`: The column type. -* `COLUMN_KEY`: Whether this column is indexed. It has the following values: - * Null: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index. +* `COLUMN_KEY`: Whether this column is indexed. This field might have the following values: + * Empty: This column is not indexed, or this column is indexed and is the second column in a multi-column non-unique index. * `PRI`: This column is the primary key or one of multiple primary keys. * `UNI`: This column is the first column of the unique index. * `MUL`: The column is the first column of a non-unique index, in which a given value is allowed to occur for multiple times. -* `EXTRA`: Any additional information about the given column. +* `EXTRA`: Any additional information of the given column. * `PRIVILEGES`: The privilege that the current user has on this column. Currently, this value is fixed in TiDB, and is always `select,insert,update,references`. * `COLUMN_COMMENT`: Comments contained in the column definition. * `GENERATION_EXPRESSION`: For generated columns, this value displays the expression used to calculate the column value. For non-generated columns, the value is empty. @@ -262,7 +262,7 @@ The description of columns in the `ENGINES` table is as follows: * `ENGINES`: The name of the storage engine. * `SUPPORT`: The level of support that the server has on the storage engine. In TiDB, the value is always `DEFAULT`. -* `COMMENT`: The brief description of the storage engine. +* `COMMENT`: The brief comment on the storage engine. * `TRANSACTIONS`:Whether the storage engine supports transactions. * `XA`: Whether the storage engine supports XA transactions. * `SAVEPOINTS`: Whether the storage engine supports `savepoints`. @@ -310,15 +310,15 @@ POSITION_IN_UNIQUE_CONSTRAINT: NULL The description of columns in the `KEY_COLUMN_USAGE` table is as follows: * `CONSTRAINT_CATALOG`: The name of the catalog to which the constraint belongs. The value is always `def`. -* `CONSTRAINT_SCHEMA`: The name of the database to which the constraint belongs. +* `CONSTRAINT_SCHEMA`: The name of the schema to which the constraint belongs. * `CONSTRAINT_NAME`: The name of the constraint. * `TABLE_CATALOG`: The name of the catalog to which the table belongs. The value is always `def`. -* `TABLE_SCHEMA`: The name of the database to which the table belongs. +* `TABLE_SCHEMA`: The name of the schema to which the table belongs. * `TABLE_NAME`: The name of the table with constraints. * `COLUMN_NAME`: The name of the column with constraints. * `ORDINAL_POSITION`: The position of the column in the constraint, rather than in the table. The position number starts from `1`. -* `POSITION_IN_UNIQUE_CONSTRAINT`: The unique constraint and the primary key constraint are empty. For foreign key constraint, this column is the position of the referenced table's key. -* `REFERENCED_TABLE_SCHEMA`: The name of the database referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. +* `POSITION_IN_UNIQUE_CONSTRAINT`: The unique constraint and the primary key constraint are empty. For foreign key constraints, this column is the position of the referenced table's key. +* `REFERENCED_TABLE_SCHEMA`: The name of the schema referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. * `REFERENCED_TABLE_NAME`: The name of the table referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. * `REFERENCED_COLUMN_NAME`: The name of the column referenced by the constraint. Currently in TiDB, the value of this column in all constraints is `nil`, except for the foreign key constraint. From 936e556dbbb71ba0e4ba4c5e6559748b7775d236 Mon Sep 17 00:00:00 2001 From: Ran Date: Wed, 17 Jun 2020 11:17:44 +0800 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Lynn --- system-tables/system-table-information-schema.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system-tables/system-table-information-schema.md b/system-tables/system-table-information-schema.md index 6e1c344c3a2cc..f312d8fda6847 100644 --- a/system-tables/system-table-information-schema.md +++ b/system-tables/system-table-information-schema.md @@ -200,13 +200,13 @@ The description of columns in the `COLUMNS` table is as follows: * `COLUMN_NAME`: The name of the column. * `ORDINAL_POSITION`: The position of the column in the table. * `COLUMN_DEFAULT`: The default value of the column. If the explicit default value is `NULL`, or if the column definition does not include the `default` clause, this value is `NULL`. -* `IS_NULLABLE`: Whether the column is nullable. If the column can store empty value, this value is `YES`; otherwise, it is `NO`. +* `IS_NULLABLE`: Whether the column is nullable. If the column can store null values, this value is `YES`; otherwise, it is `NO`. * `DATA_TYPE`: The type of data in the column. -* `CHARACTER_MAXIMUM_LENGTH`: The maximum length of a string column, in characters. -* `CHARACTER_OCTET_LENGTH`: The maximum length of a string column, in bytes. +* `CHARACTER_MAXIMUM_LENGTH`: For string columns, the maximum length in characters. +* `CHARACTER_OCTET_LENGTH`: For string columns, the maximum length in bytes. * `NUMERIC_PRECISION`: The numeric precision of a number-type column. * `NUMERIC_SCALE`: The numeric scale of a number column. -* `DATETIME_PRECISION`: The fractional second precision of a time column. +* `DATETIME_PRECISION`: For time-type columns, the fractional seconds precision. * `CHARACTER_SET_NAME`: The name of the character set of a string column. * `COLLATION_NAME`: The name of the collation of a string column. * `COLUMN_TYPE`: The column type. From 96fc153d84939790ad0d2d8ffb2734088cd6cbfa Mon Sep 17 00:00:00 2001 From: Ran Date: Wed, 17 Jun 2020 12:58:25 +0800 Subject: [PATCH 4/4] Update system-tables/system-table-information-schema.md Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- system-tables/system-table-information-schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-tables/system-table-information-schema.md b/system-tables/system-table-information-schema.md index 3c34cade71cdf..2bd7701f91ddb 100644 --- a/system-tables/system-table-information-schema.md +++ b/system-tables/system-table-information-schema.md @@ -205,7 +205,7 @@ The description of columns in the `COLUMNS` table is as follows: * `CHARACTER_MAXIMUM_LENGTH`: For string columns, the maximum length in characters. * `CHARACTER_OCTET_LENGTH`: For string columns, the maximum length in bytes. * `NUMERIC_PRECISION`: The numeric precision of a number-type column. -* `NUMERIC_SCALE`: The numeric scale of a number column. +* `NUMERIC_SCALE`: The numeric scale of a number-type column. * `DATETIME_PRECISION`: For time-type columns, the fractional seconds precision. * `CHARACTER_SET_NAME`: The name of the character set of a string column. * `COLLATION_NAME`: The name of the collation of a string column.