Setting a serial column with serial object that has a name that is built dynamically

From: Robert Lakes <robertl(at)propaas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Setting a serial column with serial object that has a name that is built dynamically
Date: 2017-11-27 23:48:07
Message-ID: CAHnqRj2S+r-rgzRk0DUvWhXwXMcv8-6SQ8zh9Hm30+DTGhGSoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How do I set a serial column with the next value when the serial object has
a name that is built dynamically?

EXECUTE 'CREATE SEQUENCE '|| *t_name *|| *'id_seq'* || ' OWNED BY '||
t_name || '_cdc'||'.table_id';

EXECUTE 'ALTER TABLE ' || quote_ident(t_name || '_cdc') || ' ALTER
COLUMN table_id SET DEFAULT nextval('*'tab_id_seq'*');';

Browse pgsql-general by date

  From Date Subject
Next Message stevenchang1213 2017-11-28 01:29:16 Re: Table and Index bloating
Previous Message Thomas Munro 2017-11-27 22:48:54 Re: ERROR: too many dynamic shared memory segments