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 1gekn1-0002DS-Im for pgsql-general@arkaria.postgresql.org; Wed, 02 Jan 2019 17:58:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gekn0-0006nF-93 for pgsql-general@arkaria.postgresql.org; Wed, 02 Jan 2019 17:58:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gekmz-0006kL-Tf for pgsql-general@lists.postgresql.org; Wed, 02 Jan 2019 17:58:46 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gekmx-00010E-Bx for pgsql-general@postgresql.org; Wed, 02 Jan 2019 17:58:44 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id B13809934A for ; Wed, 2 Jan 2019 09:58:41 -0800 (PST) Date: Wed, 2 Jan 2019 09:58:41 -0800 (PST) From: Rich Shepard To: "pgsql-general@postgresql.org" Subject: Re: Implementing standard SQL's DOMAIN constraint In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2 Jan 2019, David G. Johnston wrote: >> I'm not following you. I have two tables each with a column, >> state_code char(2) NOT NULL. > That is a char(2) column for which ‘??’ is a valid value. The fact that it > is named state_code is immaterial; the domain that you created doesn’t get > used. There is no magic linking just by virtue of using the same name. > > Change char(2) to state_code if you wish to apply the domain on the column. David, I think I'm now on your page. In the schema I change the column data type to state_code, then I add the SQL code creating the domain at the top of the .sql file. Yes? Thanks, Rich