SQL Server → PostgreSQL

IDENTITY vs SERIAL: Auto-Increment Keys in PostgreSQL Migration

SQL Server IDENTITY columns become GENERATED ALWAYS AS IDENTITY or SERIAL in PostgreSQL. Understand sequences and gaps.

IDENTITY(seed, increment) generates automatic values in SQL Server. In PostgreSQL the modern standard is GENERATED ALWAYS AS IDENTITY; SERIAL is legacy but still common in older scripts.

Equivalent DDL

PostgreSQL (recommended)

CREATE TABLE orders (
  id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  customer_id INT NOT NULL,
  total NUMERIC(18,2)
);

Analisador de Impacto

DDL with IDENTITY needs sequence review after data load. Analyze the full schema before cutover.

Abrir Análise de Projeto →