Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAiv9-0000Hd-RP for pgsql-general@arkaria.postgresql.org; Fri, 03 Nov 2017 20:50:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eAiv8-0003HF-TL for pgsql-general@arkaria.postgresql.org; Fri, 03 Nov 2017 20:50:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eAisj-0007LN-NJ for pgsql-general@postgresql.org; Fri, 03 Nov 2017 20:48:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eAisc-0008Ax-B5 for pgsql-general@postgresql.org; Fri, 03 Nov 2017 20:48:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vA3Klq0F005078; Fri, 3 Nov 2017 16:47:52 -0400 From: Tom Lane To: Robert Lakes cc: pgsql-general@postgresql.org Subject: Re: Adding 'serial' to existing column In-reply-to: References: Comments: In-reply-to Robert Lakes message dated "Fri, 03 Nov 2017 14:38:04 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5076.1509742072.1@sss.pgh.pa.us> Date: Fri, 03 Nov 2017 16:47:52 -0400 Message-ID: <5077.1509742072@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Robert Lakes writes: > 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'); That looks correct, but this not so much: > 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... You want quote_literal, not quote_ident, because you're trying to produce a single-quoted literal. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general