Re: [PERFORM] Auto generate number in Postgres-9.1.

2017-03-20 Thread Andreas Karlsson
On 03/20/2017 03:08 PM, Dinesh Chandra 12108 wrote: But on deletion it's not automatically re-adjusting the id's. Do I need to create trigger for this?? It is possible to do but I advice against adjusting the IDs on DELETE due to to do so safely would require locking the entire table in the

Re: [PERFORM] Auto generate number in Postgres-9.1.

2017-03-20 Thread Dinesh Chandra 12108
--Original Message- From: pgsql-performance-ow...@postgresql.org [mailto:pgsql-performance-ow...@postgresql.org] On Behalf Of John Gorman Sent: 20 March, 2017 7:20 PM To: pgsql-performance@postgresql.org; pgsql-performance-ow...@postgresql.org Subject: Re: [PERFORM] Auto generate number in Po

Re: [PERFORM] Auto generate number in Postgres-9.1.

2017-03-20 Thread John Gorman
erformance-ow...@postgresql.org [mailto:pgsql-performance-ow...@postgresql.org] On Behalf Of Josh Berkus Sent: Monday, March 20, 2017 6:43 AM To: Dinesh Chandra 12108; pgsql-performance-ow...@postgresql.org Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Auto generate number in Postgres-

Re: [PERFORM] Auto generate number in Postgres-9.1.

2017-03-20 Thread Josh Berkus
Dinesh, > I have to add one column “ID” in postgres table which will generate > Auto Increment > ed number . > > > > Example: > > Suppose I have five records and if I insert 1 new record It should auto > generate 6. https://www

Re: [PERFORM] Auto generate number in Postgres-9.1.

2017-03-20 Thread Andreas Karlsson
On 03/20/2017 02:43 PM, Josh Berkus wrote: 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. Actually that may not be necessary as long as you make sure to use

[PERFORM] Auto generate number in Postgres-9.1.

2017-03-20 Thread Dinesh Chandra 12108
Dear expert, I have to add one column "ID" in postgres table which will generate Auto Incremented number . Example: Suppose I have five records and if I insert 1 new record It should auto generate 6. If I truncate the same table