Skip to content

Instantly share code, notes, and snippets.

@kouzouigh
Forked from popravich/PostgreSQL_index_naming.rst
Created September 19, 2019 13:40
Show Gist options
  • Save kouzouigh/8a6fc826617a9f353306b813f3bec124 to your computer and use it in GitHub Desktop.
Save kouzouigh/8a6fc826617a9f353306b813f3bec124 to your computer and use it in GitHub Desktop.
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
  • fkey for a Foreign key;
  • check for a Check constraint;

Standard suffix for sequences is

seq for all sequences

Found here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment