April 2, 2023
SELECT MAX(id) FROM public.table_name;
SELECT nextval('public."table_name_id_seq"');
Use the below query to set primary key id sequence of your table to max id incremented by one.
SELECT setval('public."table_name_id_seq"',
(SELECT MAX(id) FROM public.users)
);
Hope it helps. Thank you.