I thought this would work:
ALTER SEQUENCE users_id_seq RESTART WITH (SELECT MAX(id) FROM users);
but it doesn’t! :O It throws “ERROR: syntax error at or near “select” “!
If you have this problem, try the other approach:
SELECT SETVAL(‘users_id_seq’,(SELECT MAX(id) FROM users));
Tested on version 8.4.0, on FreeBSD 8.0…
Advertisement
Tags: PostgreSQL