I have a postgres table that contains data where the id has been set by the code that injected the data. So lets say the id is 0..49.
How can I instruct postgres to start with 50 on the id column for the next insert?
postgresql
I have a postgres table that contains data where the id has been set by the code that injected the data. So lets say the id is 0..49.
How can I instruct postgres to start with 50 on the id column for the next insert?
Best Answer
If you want to happen it automatically (I mean, without the application doing that), you have to create a sequence:
Then change the column to use this as a default:
And that's it. Remember that the default will be used only if you don't pass a value to the given column in your
INSERT
statements.