I want to update the sequences for a table in RDS Postgres 11. Tried the following commands but I don't see the changes committed to the db. I even used commit
.
What am I missing?
1. SELECT setval(pg_get_serial_sequence('table1', 'id'), coalesce(max(id),0) + 1, false) FROM table1;
2. SELECT setval('table1_id_seq', (SELECT COALESCE(max(id), 0) + 1 FROM table1));
ALTER TABLE table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq');
CREATE TABLE public.table1 (
id serial4 NOT NULL, --default nextval('table1_id_seq'::regclass)
account_id int4 NOT NULL,
CONSTRAINT table1_pkey PRIMARY KEY (id) );
select currval('table1_id_seq')
returns 6
.