We are using a software that needs to request the max primary key column value to add a new row into the table that was requested.
I know that there are some alternatives like:
- Sequences, and
- GUIDs
in PostgreSQL, but is there something similiar like:
- Identity-type in SQL Server or
- any auto-increment columns of any other DB (MySQL)
in PostgreSQL, is there a way to achieve this with a (stored) procedure or a trigger and how?
serial
](www.postgresql.org/docs/current/interactive/datatype-numeric.html) would be the obvious answer, like gbn provided. But it seems you might be trying to avoid gaps in your serial numbers? That's not always a good idea. Also, do you have concurrent write access? Clarify your objective, edit the question. – Erwin Brandstetter Dec 8 '14 at 8:36