See also: tables with their primary keys.
Primary Key Columns
Snowflake doesn't allow us to simple list all PKs columns by one query. To see specific table primary key columns you can use following command
describe table <table_name>;
Primary Keys Constraints
Query below lists all primary keys constraints (PK) in the database.
select table_schema, constraint_name, table_name, constraint_type from information_schema.table_constraints where constraint_type = 'PRIMARY KEY' order by table_schema, table_name;
- table_schema - schema name constraint belongs to
- constraint_name - name of the PK's constraint
- table_name - name of the table
- constraint_type - type of constraint (redundant as it should be exactly PRIMARY KEY)
- One row represents one primary key (table) in a database
- Scope of rows: all PK constraints in a database
- Ordered by table schema, table name