Interview Q&A / PostgreSQL
PostgreSQL interview questions
Indexes, EXPLAIN, transactions and isolation, JSONB and the Postgres specifics backend interviews probe.
Prefer rapid revision? Practise PostgreSQL short interview answers →
- What is the difference between SERIAL and IDENTITY columns, and when would you use a UUID primary key?
SERIAL is an older PostgreSQL shorthand that creates a sequence and sets it as the column default. IDENTITY (GENERATED ALWAYS or BY DEFAULT AS IDENTITY) is the SQL-standard replacement and is preferred for new tables. Use a UUID when IDs must be generated outside the database, merged across systems, or must not be guessable.
BeginnerIn-depth3 min read - When should a primary key be bigint instead of integer in PostgreSQL?
integer tops out at about 2.1 billion. If a table could ever reach that many rows over its life, including rows deleted along the way, use bigint from the start, because changing the type later rewrites the table and every foreign key.
BeginnerQuick answer1 min read