Note
This view is available starting with V1.4.
Purpose
Records column information.
Columns
| Column | Type | Nullable | Description |
|---|---|---|---|
| TABLE_CATALOG | varchar(4096) | NO | Fixed value (def) |
| TABLE_SCHEMA | varchar(128) | NO | The database to which the column belongs. |
| TABLE_NAME | varchar(256) | NO | The name of the table to which the column belongs. |
| COLUMN_NAME | varchar(128) | NO | The column name. |
| ORDINAL_POSITION | bigint(20) unsigned | NO | The column number. |
| COLUMN_DEFAULT | varchar(262144) | YES | The default value of the column. |
| IS_NULLABLE | varchar(4) | NO | Indicates whether the column value can be NULL. |
| DATA_TYPE | varchar(64) | NO | The data type of the column. |
| CHARACTER_MAXIMUM_LENGTH | bigint(20) unsigned | YES | The maximum number of characters in the column. |
| CHARACTER_OCTET_LENGTH | bigint(20) unsigned | YES | The maximum number of bytes in the column. |
| NUMERIC_PRECISION | bigint(20) unsigned | YES | The numeric precision. |
| NUMERIC_SCALE | bigint(20) unsigned | YES | The number of decimal places. |
| DATETIME_PRECISION | bigint(20) unsigned | YES | The precision of the datetime type. |
| CHARACTER_SET_NAME | varchar(128) | YES | The name of the character set to which the column belongs. |
| COLLATION_NAME | varchar(128) | YES | The collation method of the character set. |
| COLUMN_TYPE | varchar(64) | NO | The field type. |
| COLUMN_KEY | varchar(3) | NO | The index or primary key column. |
| EXTRA | varchar(4096) | NO | Other information. |
| PRIVILEGES | varchar(200) | NO | The privilege information. |
| COLUMN_COMMENT | varchar(2048) | NO | The comment. |
| GENERATION_EXPRESSION | varchar(262144) | NO | For a generated column, the expression used to calculate the column value. For a non-generated column, this column is empty. |
| SRS_ID | bigint(20) unsigned | YES | The ID of the spatial coordinate system. |
Sample query
Query the information of all columns in the tbl1 table.
obclient [infotest]> SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME='tbl1';
The query result is as follows:
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+----------------+-------------+------------+-------+--------------------------------+----------------+-----------------------+--------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | NUMERIC_PRECISION | NUMERIC_SCALE | DATETIME_PRECISION | CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | COLUMN_KEY | EXTRA | PRIVILEGES | COLUMN_COMMENT | GENERATION_EXPRESSION | SRS_ID |
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+----------------+-------------+------------+-------+--------------------------------+----------------+-----------------------+--------+
| def | infotest | tbl1 | col1 | 1 | NULL | NO | int | NULL | NULL | 11 | 0 | NULL | NULL | NULL | int(11) | | | select,insert,update,reference | | | NULL |
| def | infotest | tbl1 | col2 | 2 | NULL | YES | int | NULL | NULL | 11 | 0 | NULL | NULL | NULL | int(11) | | | select,insert,update,reference | | | NULL |
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+----------------+-------------+------------+-------+--------------------------------+----------------+-----------------------+--------+
2 rows in set