Interview Q&A / PostgreSQL

INTERVIEW Q&A · 69 QUESTIONS

PostgreSQL interview questions

Indexes, EXPLAIN, transactions and isolation, JSONB and the Postgres specifics backend interviews probe.

  1. 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
  2. How do you generate and store UUIDs in PostgreSQL?

    Use the uuid type, which stores 16 bytes, and generate values with the built-in gen_random_uuid() (available without an extension since PostgreSQL 13). Store them as uuid, not as 36-character text.

    BeginnerQuick answer1 min read