Re: User-Defined Types

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: "David F(dot) Johnson" <dfjohnson(at)cabaret(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: User-Defined Types
Date: 2007-07-09 19:58:44
Message-ID: 22C28D3C-52D8-40CF-8A46-D48FAE69940C@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jul 5, 2007, at 15:53 , David F. Johnson wrote:

> During the development of a database often there is a need to change a
> field's declaration from, say, VARCHAR(32) to, say, VARCHAR(64).

> Is there a simple way to make a user-defined type that is a specific
> declaration of a built-in type (like VARCHAR(##)) without having to
> implement the type's support functions?

In PostgreSQL there's no performance advantage to limiting a varchar.
I'd recommend making all of your references to any varchar columns
not include a limit (i.e., just text or varchar), and perhaps setting
the referenced column as text with a length check constraint if one
is needed to satisfy some business rule. Then you can easily alter
the allowed length by altering the check constraint. (Similarly you
could use varchar(n) on the referenced column as well, and then just
ALTER TABLE ALTER TYPE instead of altering the check constraint. I
don't know if one has a performance advantage in checking the length
of the value.)

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gauthier, Dave 2007-07-09 20:06:38 returns setof rec... simple exampe doesn't work
Previous Message Tim Olsen 2007-07-09 19:50:33 Re: dropdb ; createdb equivalent without createdb permission?