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 1gYzZ5-00038j-Os for pgsql-general@arkaria.postgresql.org; Mon, 17 Dec 2018 20:32:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYzZ3-0000Fe-IQ for pgsql-general@arkaria.postgresql.org; Mon, 17 Dec 2018 20:32:33 +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 1gYzZ3-0000FW-8P for pgsql-general@lists.postgresql.org; Mon, 17 Dec 2018 20:32:33 +0000 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYzYy-000759-UP for pgsql-general@lists.postgresql.org; Mon, 17 Dec 2018 20:32:32 +0000 Received: by mail-oi1-x232.google.com with SMTP id i6so104411oia.6 for ; Mon, 17 Dec 2018 12:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=wSmNn1uJ6ZbzpePMsOHWo8DPbWtoxPKQA8UYgOzCJZc=; b=smqdZhpZJ7Pw6vy1XTnyJrnse91IUUtAS1pOpJJ7ZqF3MnFti4pjETysSCy3sODMnd AF7vMRo7Me2lptZcjfP4SZlIq9X6p7r8Wh5CEBs0oHFLTZ6w4RU7bU35poLONuw3WZf7 VQabz5UGHxIrWwgGx4fxkB1TDAdcMRF28celc3Vw4/1mUvh/Rzq2NetZuCKmyheOJpDD JzNJbwnmCsnTwekplfgx5drms6WLQwrg+PJdE5Ih7vi14fBp2U9KS2uXQMCtMNe8pqgE 7xjvmza/1QblcFF8x50DSDjZYFsGxjDQ+GYRp+bvdsXw4nOUbSb8PApfwpthSpXKOxQL 0dUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=wSmNn1uJ6ZbzpePMsOHWo8DPbWtoxPKQA8UYgOzCJZc=; b=hdmIrKdjNA2cFsYmSgXpPL7Q35M8AniHO6OgkwsGYXeLlWhz2HfKuLJxr3ckkUM4+f A59lU0EI6N0UjfJd0Ghol/Mz/DO4sbCgR/xOjsYRBIvpC7IkvNhHzw1gsdv9vl1nReaL YrzDY1J+5rX3SECx6HnESvEGtWUGZOBIkpgFWxB53+xaIV3Hk4r3RdklO6ksVMtH6w1e jI/GCUV0g17+qqFiylnnYr/XZj0v3FLtvxlz6WO9ou6/yDreY1r3gddMitVqfv2A6kOx 6iSx6/0mwaeWh5E9HA0JWN20ySyGRG9m4FExx1Kd6bT3KaXKrCxaWVggTY5wnexcXEfu W2xQ== X-Gm-Message-State: AA+aEWZqCC8yTZqhCgAfyWHf7iJLv+3iG8rn+GfqYZfBVtWhq31lcgzJ FcB1ncp8khbTpLQsah7edH809P5c X-Google-Smtp-Source: AFSGD/UnA080HrCDvkb9/WVDLqjR8zvsePfCosl/H+eIcRPY5CYl1AazGxEFY/jOKM5E6Tcqagtpdw== X-Received: by 2002:aca:2c05:: with SMTP id s5mr6604063ois.190.1545078747022; Mon, 17 Dec 2018 12:32:27 -0800 (PST) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id w5sm6156056oif.48.2018.12.17.12.32.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 12:32:26 -0800 (PST) Subject: Re: Alter table column constraint To: pgsql-general@lists.postgresql.org References: <0d4474ae-9cd8-ee3b-0f95-e5f37f4daaa2@commandprompt.com> From: Ron Message-ID: Date: Mon, 17 Dec 2018 14:32:25 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/17/2018 02: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. Melvin is saying to: 1. create a table named valid_industry, 2. populate it with the valid industries, 3. create an FK constraint on your main table's industry column to valid_industry.industry, and then 4. drop the constraint invalid_industry. -- Angular momentum makes the world go 'round.