google-site-verification=ECX1M6_Vb39ty4VtQDXQce6wOjmPTxSettd3hTIZb9Q

How to make auto increment column in Postgres?

random

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: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.