SHOW COLUMNS

On this page Carat arrow pointing down
Warning:
As of November 10, 2018, CockroachDB v1.0 is no longer supported. For more details, refer to the Release Support Policy.

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

SHOW COLUMNS FROM table_name

Parameters

Parameter Description
table_name The name of the table for which to show columns.

Response

The following fields are returned for each column.

Field Description
Field The name of the column.
Type The data type of the column.
Null Whether or not the column accepts NULL. Possible values: true or false.
Default The default value for the column, or an expression that evaluates to a default value.
Indices The list of indexes that the column is involved in, as an array.

Example

> CREATE TABLE orders (
    id INT PRIMARY KEY DEFAULT unique_rowid(),
    date TIMESTAMP NOT NULL,
    priority INT DEFAULT 1,
    customer_id INT UNIQUE,
    status STRING DEFAULT 'open',
    CHECK (priority BETWEEN 1 AND 5),
    CHECK (status in ('open', 'in progress', 'done', 'cancelled')),
    FAMILY (id, date, priority, customer_id, status)
);

> SHOW COLUMNS FROM orders;
+-------------+-----------+-------+----------------+----------------------------------+
|    Field    |   Type    | Null  |    Default     |             Indices              |
+-------------+-----------+-------+----------------+----------------------------------+
| id          | INT       | false | unique_rowid() | {primary,orders_customer_id_key} |
| date        | TIMESTAMP | false | NULL           | {}                               |
| priority    | INT       | true  |              1 | {}                               |
| customer_id | INT       | true  | NULL           | {orders_customer_id_key}         |
| status      | STRING    | true  | 'open'         | {}                               |
+-------------+-----------+-------+----------------+----------------------------------+
(5 rows)

See Also


Yes No
On this page

Yes No