Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

postgresql reset auto_increment index

-- Change the starting value of the sequence

ALTER SEQUENCE project_id_seq RESTART 3000;

-- Same but dynamic :

SELECT SETVAL('project_id_seq', (SELECT MAX(id) + 1 FROM project));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #postgresql #reset #index
ADD COMMENT
Topic
Name
6+4 =