The COLUMNS view contains information about columns in tables.
| Column | Description |
|---|---|
TABLE_CATALOG |
The catalog where the table containing the column resides. This value is always def. |
TABLE_SCHEMA |
The schema (database) where the table containing the column resides. |
TABLE_NAME |
The name of the table containing the column. |
COLUMN_NAME |
The name of the column. |
ORDINAL_POSITION |
The position of the column within the table. Used for ordering, as SELECT from COLUMNS doesn’t automatically order rows. |
COLUMN_DEFAULT |
The default value for the column, or NULL if no default is set. |
IS_NULLABLE |
Indicates whether NULL values are allowed in the column: YES if they are, NO if not. |
DATA_TYPE |
The column’s data type name without any additional details. |
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 columns, the numeric precision. |
NUMERIC_SCALE |
For numeric columns, the numeric scale. |
DATETIME_PRECISION |
For temporal columns, the fractional seconds precision. |
CHARACTER_SET_NAME |
For character columns, the character set name. |
COLLATION_NAME |
For character columns, the collation name. |
COLUMN_TYPE |
The column’s data type, including any additional attributes such as length or precision. |
COLUMN_KEY |
Indicates whether the column is indexed. Possible values:
|
EXTRA |
Additional information about the column. |
PRIVILEGES |
The privileges granted on the column. |
COLUMN_COMMENT |
The comment included in the column definition. |
GENERATION_EXPRESSION |
For generated columns, the expression used to compute values. Empty for non-generated columns. |
SRS_ID |
For spatial columns, the column’s SRID (spatial reference system identifier). NULL for nonspatial columns or spatial columns without an SRID attribute. |
Column information is also available from the SHOW COLUMNS statement.
Information about generated invisible primary key (GIPK) columns is included in the INFORMATION_SCHEMA.COLUMNS view by default. You can hide these columns by setting the show_gipk_in_create_table_and_information_schema system variable to OFF.
For more information, see the MySQL documentation: The INFORMATION_SCHEMA COLUMNS Table.