A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/sql/show-primary-keys below:

Website Navigation


SHOW PRIMARY KEYS | Snowflake Documentation

SHOW PRIMARY KEYS

Lists primary keys for one or more tables. You can specify the following options:

Syntax
SHOW [ TERSE ] PRIMARY KEYS
    [ IN { ACCOUNT | DATABASE [ <database_name> ] | SCHEMA [ <schema_name> ] | TABLE | [ TABLE ] <table_name> } ]

Copy

Parameters
TERSE

This clause is accepted in the syntax but has no effect on the output.

IN { ACCOUNT | DATABASE [ <database_name> ] | SCHEMA [ <schema_name> ] | TABLE | [ TABLE ] <table_name> }

Specifies the scope of the command, which determines whether the command lists records only for the current or specified database, schema, table, or account.

If you specify the keyword ACCOUNT, then the command retrieves records for all schemas in all databases of the current account.

If you specify the keyword DATABASE, then:

If you specify the keyword SCHEMA, then:

If you specify the keyword TABLE without a table_name, then:

If you specify a <table_name> (with or without the keyword TABLE), then:

Default: Depends on whether the session currently has a database in use:

Usage notes

Important

For standard tables, Snowflake does not enforce PRIMARY KEY constraints; however, they are enforced on hybrid tables.

Output

The command output provides primary key properties and metadata in the following columns:

Column

Description

created_on

Date and time when the table was created.

database_name

Database in which the table is stored.

schema_name

Schema in which the table is stored.

table_name

Name of the table.

column_name

Name of the column in the primary key.

key_sequence

If the primary key is composed of multiple columns, the number in the key_sequence column indicates the order of those columns in the primary key. For example, if the primary key is defined as CONSTRAINT pkey1 PRIMARY KEY (column_x, column_y), the key_sequence number for column_x is 1 and the key_sequence number for column_y is 2.

comment

The comment (if any) specified for the constraint when the constraint was created.

constraint_name

The name of the constraint.

Examples
SHOW PRIMARY KEYS;

SHOW PRIMARY KEYS IN ACCOUNT;

SHOW PRIMARY KEYS IN DATABASE;

SHOW PRIMARY KEYS IN DATABASE my_database;

SHOW PRIMARY KEYS IN SCHEMA;

SHOW PRIMARY KEYS IN SCHEMA my_schema;

SHOW PRIMARY KEYS IN SCHEMA my_database.my_schema;

SHOW PRIMARY KEYS IN my_table;

SHOW PRIMARY KEYS IN my_database.my_schema.my_table;

Copy


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4