PostgreSQL - Create a new primary key auto-increment column
-- Assuming you have an existing table called "your_table"
-- Add an auto-increment column named "id" using SERIAL
ALTER TABLE your_table
ADD COLUMN id SERIAL PRIMARY KEY;-- Assuming you have an existing table called "your_table"
-- Add an auto-increment column named "id" using GENERATED ALWAYS AS IDENTITY
ALTER TABLE your_table
ADD COLUMN id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY;Last updated