> ## 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 CONSTRAINTS

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 CONSTRAINTS` <InternalLink path="sql-statements">statement</InternalLink> lists all named <InternalLink path="constraints">constraints</InternalLink> as well as any unnamed <InternalLink path="check">`CHECK`</InternalLink> constraints on a table.

## Required privileges

The user must have any <InternalLink path="security-reference/authorization#managing-privileges">privilege</InternalLink> on the target table.

## Aliases

`SHOW CONSTRAINT` is an alias for `SHOW CONSTRAINTS`.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/URZZsrJ2y-tKyo7i/images/sql-diagrams/v24.3/show_constraints.svg?fit=max&auto=format&n=URZZsrJ2y-tKyo7i&q=85&s=443c14b83d9f1aebddd343623ff9a0af" alt="show_constraints syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="631" height="81" data-path="images/sql-diagrams/v24.3/show_constraints.svg" />

## Parameters

| Parameter     | Description                                          |
| ------------- | ---------------------------------------------------- |
| `table\_name` | The name of the table for which to show constraints. |

## Response

The following fields are returned for each constraint.

| Field              | Description                                                                    |
| ------------------ | ------------------------------------------------------------------------------ |
| `table\_name`      | The name of the table.                                                         |
| `constraint\_name` | The name of the constraint.                                                    |
| `constraint\_type` | The type of constraint.                                                        |
| `details`          | The definition of the constraint, including the column(s) to which it applies. |
| `validated`        | Whether values in the column(s) match the constraint.                          |

## Example

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> CREATE TABLE orders (
    id INT PRIMARY KEY,
    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)
);
```

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

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
+------------+------------------------+-----------------+--------------------------------------------------------------------------+-----------+
| table_name |    constraint_name     | constraint_type |                                 details                                  | validated |
+------------+------------------------+-----------------+--------------------------------------------------------------------------+-----------+
| orders     | check_priority         | CHECK           | CHECK (priority BETWEEN 1 AND 5)                                         |   true    |
| orders     | check_status           | CHECK           | CHECK (status IN ('open':::STRING, 'in progress':::STRING,               |   true    |
|            |                        |                 | 'done':::STRING, 'cancelled':::STRING))                                  |           |
| orders     | orders_customer_id_key | UNIQUE          | UNIQUE (customer_id ASC)                                                 |   true    |
| orders     | primary                | PRIMARY KEY     | PRIMARY KEY (id ASC)                                                     |   true    |
+------------+------------------------+-----------------+--------------------------------------------------------------------------+-----------+
(4 rows)
```

## See also

* <InternalLink path="constraints">Constraints</InternalLink>
* <InternalLink path="alter-table#add-constraint">`ADD CONSTRAINT`</InternalLink>
* <InternalLink path="alter-table#rename-constraint">`RENAME CONSTRAINT`</InternalLink>
* <InternalLink path="alter-table#drop-constraint">`DROP CONSTRAINT`</InternalLink>
* <InternalLink path="alter-table#validate-constraint">`VALIDATE CONSTRAINT`</InternalLink>
* <InternalLink path="create-table">`CREATE TABLE`</InternalLink>
* <InternalLink path="information-schema">Information Schema</InternalLink>
* <InternalLink path="sql-statements">SQL Statements</InternalLink>
