PostgreSQL SERIAL vs IDENTITY
PostgreSQL SERIAL vs IDENTITY is a SQL data type in the PostgreSQL Specific category. SERIAL is legacy PostgreSQL. IDENTITY (SQL standard) provides better control and security. The syntax is id INT GENERATED ALWAYS AS IDENTITY / id SERIAL. It returns identity column created. A close relative is SERIAL, which postgreSQL auto-increment type. Creates an INTEGER column with a sequence. Equivalent to AUTO_INCREMENT in MySQL. A close relative is RETURNING, which postgreSQL extension that returns values from INSERT/UPDATE/DELETE statements (like OUTPUT in SQL Server). A close relative is ARRAY, which postgreSQL supports array columns and array operations. Can be multi-dimensional. More about this category: PostgreSQL-specific features — SERIAL, RETURNING, ARRAY, JSONB, UPSERT. Related PostgreSQL Specific entries: SERIAL, RETURNING, ARRAY, JSONB, UPSERT (INSERT ON CONFLICT), ILIKE, BIGSERIAL / SMALLSERIAL, GENERATED AS IDENTITY. This page is part of the free SQL Reference documentation covering 762+ statements, functions, and clauses, each with syntax, parameters, return values, and examples for MySQL, PostgreSQL, SQL Server, and SQLite.