> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SHOW COLUMNS

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `SHOW COLUMNS` <InternalLink path="sql-statements">statement</InternalLink> 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 <InternalLink path="security-reference/authorization#managing-privileges">privilege</InternalLink> on the target table.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/kYb5CU8_1XGPxWhU/images/sql-diagrams/v24.1/show_columns.svg?fit=max&auto=format&n=kYb5CU8_1XGPxWhU&q=85&s=576b2d0e1cd9b8ba796613437b726b9b" alt="show_columns syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="653" height="69" data-path="images/sql-diagrams/v24.1/show_columns.svg" />

## 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                                                                                                  |
| ------------------------ | ------------------------------------------------------------------------------------------------------------ |
| `column\_name`           | The name of the column.                                                                                      |
| `data\_type`             | The <InternalLink path="data-types">data type</InternalLink> of the column.                                  |
| `is\_nullable`           | Whether or not the column accepts `NULL`. Possible values: `true` or `false`.                                |
| `column\_default`        | The default value for the column, or an expression that evaluates to a default value.                        |
| `generation\_expression` | The expression used for a <InternalLink path="computed-columns">computed column</InternalLink>.              |
| `indices`                | The list of <InternalLink path="indexes">indexes</InternalLink> that the column is involved in, as an array. |
| `is\_hidden`             | Whether or not the column is hidden. Possible values: `true` or `false`.                                     |

## Examples

#### Setup

To follow along, run <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink> to start a temporary, in-memory cluster with the <InternalLink path="movr">`movr`</InternalLink> sample dataset preloaded:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach demo
```

### Show columns in a table

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW COLUMNS FROM users;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  column_name | data_type | is_nullable | column_default | generation_expression |         indices          | is_hidden
--------------+-----------+-------------+----------------+-----------------------+--------------------------+------------
  id          | UUID      |    false    | NULL           |                       | {primary,users_name_idx} |   false
  city        | VARCHAR   |    false    | NULL           |                       | {primary,users_name_idx} |   false
  name        | VARCHAR   |    true     | NULL           |                       | {primary,users_name_idx} |   false
  address     | VARCHAR   |    true     | NULL           |                       | {primary}                |   false
  credit_card | VARCHAR   |    true     | NULL           |                       | {primary}                |   false
(5 rows)
```

Alternatively, within the built-in SQL shell, you can use the `\d ` <InternalLink path="cockroach-sql#commands">shell command</InternalLink>:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> \d users
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  column_name | data_type | is_nullable | column_default | generation_expression |  indices  | is_hidden
+-------------+-----------+-------------+----------------+-----------------------+-----------+-----------+
  id          | UUID      |    false    | NULL           |                       | {primary,users_name_idx} |   false
  city        | VARCHAR   |    false    | NULL           |                       | {primary,users_name_idx} |   false
  name        | VARCHAR   |    true     | NULL           |                       | {primary,users_name_idx} |   false
  address     | VARCHAR   |    true     | NULL           |                       | {primary}                |   false
  credit_card | VARCHAR   |    true     | NULL           |                       | {primary}                |   false
(5 rows)
```

### Show columns with comments

You can use <InternalLink path="comment-on">`COMMENT ON`</InternalLink> to add comments on a column.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> COMMENT ON COLUMN users.credit_card IS 'This column contains user payment information.';
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW COLUMNS FROM users WITH COMMENT;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  column_name | data_type | is_nullable | column_default | generation_expression |  indices  | is_hidden |                    comment
+-------------+-----------+-------------+----------------+-----------------------+-----------+-----------+------------------------------------------------+
  id          | UUID      |    false    | NULL           |                       | {primary} |   false   | NULL
  city        | VARCHAR   |    false    | NULL           |                       | {primary} |   false   | NULL
  name        | VARCHAR   |    true     | NULL           |                       | {primary} |   false   | NULL
  address     | VARCHAR   |    true     | NULL           |                       | {primary} |   false   | NULL
  credit_card | VARCHAR   |    true     | NULL           |                       | {primary} |   false   | This column contains user payment information.

(5 rows)
```

## See also

* <InternalLink path="create-table">`CREATE TABLE`</InternalLink>
* <InternalLink path="information-schema">Information Schema</InternalLink>
* <InternalLink path="sql-statements">SQL Statements</InternalLink>
* <InternalLink path="comment-on">`COMMENT ON`</InternalLink>
