[GENERAL] Reset Sequence number - Mailing list pgsql-general

From Brahmam Eswar
Subject [GENERAL] Reset Sequence number
Date
Msg-id CA+wLFo3kRQh+qbY5stqipzGC1EPryd8aTRH3pY0=NxcXw_xo-A@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] Reset Sequence number  (amul sul <sulamul@gmail.com>)
Re: [GENERAL] Reset Sequence number  (Raymond O'Donnell <rod@iol.ie>)
Re: Reset Sequence number  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general

we are in process of migrating to postgres and need to reset the sequence number with highest value of table key . I want to make it procedural to do that as mentioned below,But it's throwing an error .



DO $$
 DECLARE
 SEQ BIGINT;
 BEGIN 
 
  SEQ:=(SELECT MAX(ID) FROM TABLE_1);
  ALTER SEQUENCE TABLE_1_SEQ  RESTART WITH SEQ;
   
 END$$; 
 
Error : syntax error at or near "SEQ"

--
Thanks & Regards,
Brahmeswara Rao J.

pgsql-general by date:

Previous
From: Niels Kristian Schjødt
Date:
Subject: Re: migrations (was Re: To all who wish to unsubscribe)
Next
From: amul sul
Date:
Subject: Re: [GENERAL] Reset Sequence number