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 via email to