From: Josh Berkus <josh@berkus.org>
To: Dinesh Chandra 12108 <Dinesh.Chandra@cyient.com>
To: pgsql-performance-owner@postgresql.org <pgsql-performance-owner@postgresql.org>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Auto generate number in Postgres-9.1.
Date: Mon, 20 Mar 2017 09:43:11 -0400
Message-ID: <97da050c-395c-7205-c5e9-95e7fdf13fde@berkus.org> (raw)
In-Reply-To: <ab77f3e1c16540a09002740e283529c5@cyient.com>
References: <ab77f3e1c16540a09002740e283529c5@cyient.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Dinesh,
> I have to add one column “ID” in postgres table which will generate
> Auto Increment
> <http://www.davidghedini.com/pg/entry/postgresql_auto_increment>ed number .
>
>
>
> Example:
>
> Suppose I have five records and if I insert 1 new record It should auto
> generate 6.
https://www.postgresql.org/docs/9.6/static/sql-createsequence.html
also SERIAL on this page:
https://www.postgresql.org/docs/9.6/static/datatype-numeric.html>
> If I truncate the same table and then again insert rows should start
> with 1 in “ID” column.
That's not how it works, normally. I'd suggest adding an ON TRUNCATE
trigger to the table.
--
Josh Berkus
Containers & Databases Oh My!
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: josh@berkus.org, Dinesh.Chandra@cyient.com, pgsql-performance-owner@postgresql.org
Subject: Re: Auto generate number in Postgres-9.1.
In-Reply-To: <97da050c-395c-7205-c5e9-95e7fdf13fde@berkus.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox