> Can you please tell me, how to do this in postgresql????
Use a SERIAL datatype:
http://postgresql.crimelabs.net/users-lounge/docs/7.1/user/datatype.html#DATATYPE-SERIAL