From this article, I understand that the sequence can go out of sync in the following situations: -
- importing many rows with an INSERT script or restoring an extensive database;
- manually setting the wrong value of a sequence with the setval() function;
- inserting a new record into a table by manually specifying the id field in the INSERT query.
I understand how 2 and 3 can cause a sequence to go out of sync, but I don't understand how 1 can cause the sequence being out of sync issue. I tried finding it online, but the articles usually describe the out of sync issue, when it happens and how it can be fixed.
Can someone please help me understand this? Thank you.