DOMAIN usability

From: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: DOMAIN usability
Date: 2003-11-14 17:24:22
Message-ID: 3FB50FC6.5000009@trade-india.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi ,

I think one of the usage patterns of DOMAINS is
to have size specifications and validity constraints
at one place for easy administration of Database.

Eg, instead of declaring email to be varchar(30) in
10s of tables and putting a CHECK constraint for
presence of '@' we could declare

CREATE DOMAIN email_type varchar (30) CHECK ( value ~* '@') ;

And users could use "email_type" in our CREATE TABLEs .

There are two main issues (problems)

*1.* Suppose varchar(30) turns out to be too small oneday
and we want to increase it to varchar(100) , what do i do ?
a) Create a new domain ,
b) Apply all the constraints on new domain
c) Create new column in each of the tables and copy the old column
d) drop the old domain cascaded.

any other more elegent method ?

*2.* Its difficult to see all the constraint defs on a domain .
information_schema.domain_constriants does not have the
definations just the names are present.

Regards
Mallah.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron St-Pierre 2003-11-14 17:54:39 Re: Determine if a string is digit
Previous Message Guillaume Houssay 2003-11-14 17:24:16 about serial