MSSQL has the lovely added functionality of Auto Increment. Meaning that when you add a new record to a table, it automatically gets added to the next ID. To clear this up, an example is. Customer A has an ID of 1, we add a new record to this table, and it’s automatically given the ID of 2, so the table is logical in the way it flows. If auto increment was not in place each time we add a new record we would need to get the last ID entered, add one, then manually insert the record with that ID, which is too much hassle for a consistently used database.

The problem arises here; PostgreSQL doesn’t have an auto increment feature!

This doesn’t mean we cant have the functionality of auto increment, it just means we have to work around it.

PostgreSQL has something we call Sequences, which when added to our table can perform the same role as an auto increment field. I’m still currently looking into this, but it doesn’t seem too hard.

Be Sociable, Share!
  • Greg

    If you set ‘serial’ (or ‘bigserial’) as the type of a field when creating the table, it creates the sequence for you, pretty much like specifying auto increment in MySQL.

  • thanks Greg, good tip