Change the starting value of a serial – Postgresql

You can alter a sequence using RESTART WITH to change the current sequence number;

ALTER SEQUENCE test_seq RESTART WITH 300;

To get the sequence name if you created it using the serial keyword, use

SELECT adsrc FROM pg_attrdef WHERE adrelid = (SELECT oid FROM pg_class WHERE relname="table name goes here"); 

An SQLfiddle to test with.

Leave a Comment