Timeline for In case of inserted a fixed value into autoincrement how to automatically skip into the next sequence value without causing insert to have an error?
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 22, 2019 at 13:42 | history | edited | Dimitrios Desyllas | CC BY-SA 4.0 |
added 5 characters in body
|
Jul 22, 2019 at 13:08 | vote | accept | Dimitrios Desyllas | ||
Jul 22, 2019 at 12:55 | comment | added | user1822 | Unrelated, but: Postgres 9.2 is no longer supported you should plan an upgrade to the current version as soon as possible. | |
Jul 22, 2019 at 12:54 | answer | added | user1822 | timeline score: 2 | |
Jul 22, 2019 at 10:34 | comment | added | Akina | No way in a query form. Dup error will fail the whole query. | |
Jul 22, 2019 at 10:20 | comment | added | Dimitrios Desyllas | @Akina Is there a way to automatically re-init the counter in case of conflict for example via a pre-insert hook? | |
Jul 22, 2019 at 10:06 | comment | added | user1822 |
The "autoincrement" is only triggered when you do not specify a value. If you do specify an explicit value, Postgres assumes you know what you are doing and will not increment the sequence that's behind the serial column.
|
|
Jul 22, 2019 at 9:45 | comment | added | Akina | Simply do NOT insert the values specified directly. If you need to do it manually than re-init autoincrement with the value above current maximal one. | |
Jul 22, 2019 at 9:35 | history | asked | Dimitrios Desyllas | CC BY-SA 4.0 |