ID | info
---------
1 | xxx
2 | xxx
4 | xxx
I have a setup similar to this in PostgreSQL. (I'm using a mac running Mojave if that makes a difference).
I have a few more columns but the issue is the ID
column. This was set to be sequential, so using Express I insert into the DB.
Problem is, it increments the ID
on every insert even failing inserts. info
is defined unique
, so trying to insert an existing info
returns an error. But ID
is still incremented.
For example, if I insert 2 rows, I have id 1
& id 2
. Then another one that fails with a unique violation. The the next successful insert gets id = 4
, skipping id = 3
.
Can I set up Postgres so it doesn't increment on failed inserts?