Re: Domains (Was [PERFORM] Views With Unions) - Mailing list pgsql-general

From Jochem van Dieten
Subject Re: Domains (Was [PERFORM] Views With Unions)
Date
Msg-id 3F2BE6DF.2060706@oli.tudelft.nl
Whole thread Raw
In response to Domains (Was [PERFORM] Views With Unions)  (Francisco J Reyes <fran@natserv.net>)
Responses Re: Domains (Was [PERFORM] Views With Unions)  (Ron Johnson <ron.l.johnson@cox.net>)
Re: Domains (Was [PERFORM] Views With Unions)  (Francisco J Reyes <fran@natserv.net>)
List pgsql-general
Francisco J Reyes wrote:
> Are domains user defined types? That they seem to be based on what I see
> on the docs.

They are similar a bit to user defined types, but there are some
important differences.

First of all, domains are based on other datatypes, so you would
have to have an existing datatype that is a sufficiently close match.
Secondly, domains can be mixed directly with the datatype they
are based on and other domains that are based on that datatype.
User defined types require you to first cast them (which in turn
implies a casting function needs to be defined) to the other/a
common type before you can mix them.

Overall, I tend to see them more as macro's then as real
datatypes. Typically I use them to verify that data is properly
formatted (like the phone number example).

Please note that the SQL:1999 concept of user defined types is
quite different from the one in PostgreSQL (in his book "Advanced
SQL:1999" Jim Melton even warns that domains may be deprecated in
future SQL standards in favour of SQL-style user defined types).

Jochem




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: plPHP -- sort of an announcement.. but not commercial
Next
From: Joe Conway
Date:
Subject: Re: pl/R questions