I have a postgres table defined as below:
CREATE TABLE public.Table_1
(
id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1
START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 )
)
Due to data migration, the id column is messed up and the value for id that is being generated on INSERT is not unique. Hence, I need to reset the id column as below
SELECT MAX(id) + 1 From Table_1;
ALTER TABLE Table_1 ALTER COLUMN id RESTART WITH 935074;
Right now I run the first query to get the Max(id) + 1 value and then I need to substitute it in the ALTER query. Is there a way to store the result of SELECT and just use the variable inside ALTER statement?