List all primary keys (PKs) and their columns in Vertica database

Query below lists all primary keys constraints (PK) in the database with their columns (one row per column).

See also: list of all primary keys (one row per PK).

Query

select table_schema,
       table_name,
       constraint_name,
       ordinal_position as pos,
       column_name,
       is_enabled
from v_catalog.primary_keys
order by table_schema,
         table_name,
         ordinal_position;

Columns

  • table_schema - PK schema name
  • table_name - PK table name
  • constraint_name - PK constraint name
  • pos - index of column in table (1, 2, ...). 2 or higher means key is composite (contains more than one column)
  • column_name - PK column name
  • is_enabled - indicate if primary key constraint is enabled or not

Rows

  • One row represents one primary key column
  • Scope of rows: columns of all PK constraints in a database
  • Ordered by table schema, table name, column position

Sample results

You could also get this

Get this interactive HTML data dictionary in minutes with Dataedo.

See live HTML data dictionary sample

Try for free

0
There are no comments. Click here to write the first comment.