Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:


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

Copy link

meglio commented Oct 8, 2021

Why not make all prefixes same length to ease readability?

That's what I do:


Copy link

OsoianMarcel commented Jun 28, 2022

And also, why not to make them prefix (not suffix) for better readability?

Copy link

popravich commented Jun 28, 2022

It was found here:
Copied it to gist just in case (if I forget where to look for it)

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