[GENERAL] Reset Sequence number

From: Brahmam Eswar <brahmam1234(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: [GENERAL] Reset Sequence number
Date: 2017-11-22 09:36:11
Message-ID: CA+wLFo3kRQh+qbY5stqipzGC1EPryd8aTRH3pY0=NxcXw_xo-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message amul sul 2017-11-22 10:26:07 Re: [GENERAL] Reset Sequence number
Previous Message Niels Kristian Schjødt 2017-11-22 08:05:49 Re: migrations (was Re: To all who wish to unsubscribe)