How to make auto increment column in Postgres?
Auto Increment - Set auto increment primary key in Postgresql
Here, I will explain about to make a column auto-increment or identity type in PostgreSQL database.
Step-1: Create a SEQUENCE first using the below syntax:
CREATE SEQUENCE AUTOID;
Step-2: After this alter column from your existing table using the below syntax:
ALTER TABLE "USERACCESSPROFILE" ALTER COLUMN "ID" SET DEFAULT NEXTVAL('AUTOID');
Note: We use double quotes for table or column name and single quotes for values.
How to make auto increment column in Postgres?
Reviewed by Ravi Kumar
on
9:28 PM
Rating:
No comments: