Answer the question
In order to leave comments, you need to log in
How to autoincrement to check for the existence of a record?
I am migrating data from MySQL to Postgresql - I have not worked with it before, but the need forces me because of the presence of multipolygons in it. I ran into a problem that when inserting a record, auto-increment simply increments the counter and tries to insert the record. Since data with their old IDs have already been migrated to the database, an error pops up when setting new values, that such an ID already exists. I see a decision to increase the initial value of the counter by a deliberately larger one than the imported data. But it looks more like a crutch than a solution. Is it possible to somehow force postgresql to work with auto-increment like MySQL - there is a check, if there is already such an ID in the table, then it looks for the next free one.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question