SHOW COLUMNS

The SHOW COLUMNS statement shows details about columns in a table, including each column's name, type, default value, and whether or not it's nullable.

Required privileges

The user must have any privilege on the target table.

Synopsis

SHOWCOLUMNSFROMtable_name

Parameters

ParameterDescription
table_nameThe name of the table for which to show columns.

Response

The following fields are returned for each column.

FieldDescription
column_nameThe name of the column.
data_typeThe data type of the column.
is_nullableWhether or not the column accepts NULL. Possible values: true or false.
column_defaultThe default value for the column, or an expression that evaluates to a default value.
generation_expressionThe expression used for a computed column.
indicesThe list of indexes that the column is involved in, as an array.
is_hiddenWhether or not the column is hidden. Possible values: true or false.

Examples

  1. > CREATE TABLE orders (
  2. id INT PRIMARY KEY DEFAULT unique_rowid(),
  3. date TIMESTAMP NOT NULL,
  4. priority INT DEFAULT 1,
  5. customer_id INT UNIQUE,
  6. status STRING DEFAULT 'open',
  7. CHECK (priority BETWEEN 1 AND 5),
  8. CHECK (status in ('open', 'in progress', 'done', 'cancelled')),
  9. FAMILY (id, date, priority, customer_id, status)
  10. );
  1. > SHOW COLUMNS FROM orders;
  1. column_name | data_type | is_nullable | column_default | generation_expression | indices | is_hidden
  2. +-------------+-----------+-------------+-----------------+-----------------------+--------------------------------------+-----------+
  3. id | INT | false | unique_rowid() | | {"primary","orders_customer_id_key"} | false
  4. date | TIMESTAMP | false | NULL | | {} | false
  5. priority | INT | true | 1:::INT | | {} | false
  6. customer_id | INT | true | NULL | | {"orders_customer_id_key"} | false
  7. status | STRING | true | 'open':::STRING | | {} | false
  8. (5 rows)
  1. > CREATE TABLE foo (x INT);
  1. > SHOW COLUMNS FROM foo;
  1. column_name | data_type | is_nullable | column_default | generation_expression | indices | is_hidden
  2. +-------------+-----------+-------------+----------------+-----------------------+-------------+-----------+
  3. x | INT | true | NULL | | {} | false
  4. rowid | INT | false | unique_rowid() | | {"primary"} | true
  5. (2 rows)

See also

Was this page helpful?
YesNo