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
Hi, Thanks for your immediate response Its working fine when we insert a new row. But on deletion it's not automatically re-adjusting the id's. Do I need to create trigger for this?? Regards, Dinesh Chandra |Database administrator (Oracle/PostgreSQL)| Cyient Ltd. Noida. -Original Mes

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

2017-03-20 Thread John Gorman
Sequences are stored as a separate object in PostgreSQL. Here in this example table and you can see that rec_id is a sequence number and that the object name is: whiteboards_rec_id_seq mydb=> \d whiteboards Table "public.whiteboards" Column |

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