[GENERAL] Adding 'serial' to existing column

Поиск
Список
Период
Сортировка
От Robert Lakes
Тема [GENERAL] Adding 'serial' to existing column
Дата
Msg-id CAHnqRj2zkrAw2X_JcAFZ0G_qV-=mHA0S6fNQ4NgqFvaKZQTDcQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: [GENERAL] Adding 'serial' to existing column
Список pgsql-general
I am new to Postgres and I am trying to build this SQL statement in my SQL script:
ALTER TABLE listings_cdc ALTER COLUMN table_id SET DEFAULT nextval('tab_id_seq');

I am trying to build the above-stated command as a dynamic SQL statement:
 EXECUTE 'ALTER TABLE listings_cdc ALTER COLUMN table_id SET DEFAULT nextval('||quote_ident(tab_id_seq)||')';

I've received an error when running the script this above-stated command:
 ERROR:  column "tab_id_seq" does not exist
LINE 1: ...OLUMN table_id SET DEFAULT nextval('||quote_ident(tab_id_seq...

Need help on how to write the above-stated command as a dynamic SQL statement.

In addition, do you know of a tutorial or a book that I can purchase that teaches how to build dynamic SQL statements

В списке pgsql-general по дате отправления:

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: [GENERAL] [HACKERS] SSL and Encryption
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Adding 'serial' to existing column