I am working on a project with Matlab-2017b and PosgreSQL(via ODBC drivers). In the code there are some files that needed to be renamed with the database table's corresponding id number.
While doing some testing with the scenario where the sequence's current value is 1 test results shows this weird behaviour.
If the pgAdmin-4 Gui is used to open sequence properties and set the current value to 1 after the code executes the sequence returns 2.
But if the query below from MATLAB is run:
ALTER SEQUENCE seq RESTART WITH 1;
then code executed, the newly inserted element id's column is 1.
While the code already handled to work properly, there are still some curiosity about what goes on behind this?