PostgreSQL reset autoincrement field

ALTER SEQUENCE mytable_id_seq RESTART WITH 1

If at the same time resetting a autoincrement field in postgresql we also want to empty the table, you can run this command:

TRUNCATE TABLE mytable RESTART IDENTITY;

Leave a Comment

Your email address will not be published. Required fields are marked *