Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYzdD-0003Wz-Ov for pgsql-general@arkaria.postgresql.org; Mon, 17 Dec 2018 20:36:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYzdC-0007i7-DO for pgsql-general@arkaria.postgresql.org; Mon, 17 Dec 2018 20:36:50 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYzdA-0007ZH-JF for pgsql-general@lists.postgresql.org; Mon, 17 Dec 2018 20:36:50 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYzd6-0007DD-27 for pgsql-general@postgresql.org; Mon, 17 Dec 2018 20:36:48 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8D5B2221AF; Mon, 17 Dec 2018 15:36:41 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 17 Dec 2018 15:36:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=a 9YJgt6l3ky+SDC7zK76W08lulE7yeX3wFYqWF8DOzk=; b=yTZjVePwech5E1j5h XoTA0TOeit80P6U56qpHdYQwfiKHjgH84yCpjq6W+PDtPSZCvYyKQouaL1Zqs9xm jAEJopmrxh1QKrm8xpW5f+gnrPqZYtFS/2wXi3zrATBsTIzgWqi6GRTQyijAFx11 90Znfc2aK6wubTltV/qkswePsIUja29G1m1Bk5OJ6qhtRhNKaWc+mxZmBu481pN6 Len4iYx39Inficg2D7tfU4NbrLyJs6WjmjNClYQ1MsvDyVDQRSkezThIy6LpUhMh SwEpSels3sdYqQTt0jidITx9g6Wzd0zpISk5ZTG5E8SHD+Vua2WGRRHNpGeK+eOs pSjBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=a9YJgt6l3ky+SDC7zK76W08lulE7yeX3wFYqWF8DO zk=; b=XJfM/wr6AqFG61ngYx07XyM/5Ld/bhq1UMfKYP/WE0jhDqWXXaLiLhtSi l32P3GMTRHmC9xMzwT+582tyxBqZ7l28mOHyhPjvl6KxMZbKcixJYq2KSzyvxNLE n0qEpm0B5PRtUCHirfxDmAG/XIpp8ezr2bUpE/EzmcvZzMfZ4PZFlpwW08dKp7zw aT56zFiPE5/PdKeu97mZb3u7L1NnUW0BrUaW6wVJJXYCI+YdzLp9FrYFp7Xe/Myf 3ja2WAI+Axmt2OHFOrG2mbPX4VZVxZVM+/dBoOsD1res4aotM+FwGM1kctev81N8 e5ODGKs+Xbvb/F8YRJp5hY6eQFk3w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudeifedghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkff gfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceo rggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecukfhppeejgedrle egrdejfedrvddvvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id BFFC6E4043; Mon, 17 Dec 2018 15:36:40 -0500 (EST) Subject: Re: Alter table column constraint To: Rich Shepard , pgsql-general@postgresql.org References: <0d4474ae-9cd8-ee3b-0f95-e5f37f4daaa2@commandprompt.com> From: Adrian Klaver Message-ID: <5dc1d1d7-9d60-4a51-d99d-168a0dd479e7@aklaver.com> Date: Mon, 17 Dec 2018 12:36:39 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/17/18 12:20 PM, Rich Shepard wrote: > On Mon, 17 Dec 2018, Melvin Davidson wrote: > >> Yes, you must drop then add the revised constraint. However, from your >> statement above, it sounds to me as if you would be better off using A >> FOREIGN kEY CONSTRAINT. It makes things a lot simpler. > > Melvin, > >   I don't follow. Here's the DDL for that column: > > industry varchar(24) NOT NULL >     CONSTRAINT invalid_industry >     CHECK (industry in ('Agriculture', 'Business, other', 'Chemicals', >     'Energy', 'Law', 'Manufacturing', 'Mining', 'Municipalities', >     'Ports/Marine Services', 'Transportation')), > > and I want to remove Municipalities for the more general Government. What Melvin suggested was to: 1) Move this ('Agriculture', 'Business, other', 'Chemicals', ..) into its own table say something like: CREATE TABLE industry(industry_code varchar PRIMARY KEY, industry_desc varchar) 2) Change the industry field in your existing table to: industry varchar(24) NOT NULL REFERENCES industry(industry_code) ON UPDATE CASCADE. Where this helps is that in the situation you describe in your original post you just change 'Municipalities' to 'Government' in the industry table and the referring table automatically gets the change via the ON UPDATE CASCADE. > > Regards, > > Rich > -- Adrian Klaver adrian.klaver@aklaver.com