Lists: | pgsql-novice |
---|
From: | Matt Clark <mclark(at)rushe(dot)aero(dot)org> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Alias for data types? |
Date: | 2003-03-31 16:16:07 |
Message-ID: | 200303311616.h2VGG7S20265@rushe.aero.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-novice |
Is there a way to define an alias or synonym for a data type?
I have an existing schema (from a Sybase DB), which defines a datatype via the
SQLServer method:
EXEC sp_addtype XID, 'numeric(16,0)' , 'NULL';
Then throughout the rest of the TABLE definitions, uses XID as a type, as in
CREATE TABLE foo ( fooid XID not null,......
CREATE TABLE bar ( barid XID not null,......
etcetera
Of course, I could edit all of the SQL to replace occurrences of XID with the
desired type; but that would require a lot of editing, say if I needed to change
the type again.
I've not found any hints in the documentation which describe this capability.
And I'm trying to maintain the existing SQL as much as possible. I'm currently
using Postgresqkl-7.3
Any suggestions are appreciated.....
Thanks,
Matt
From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Matt Clark <mclark(at)rushe(dot)aero(dot)org> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Alias for data types? |
Date: | 2003-03-31 16:23:06 |
Message-ID: | 3E886B6A.4040106@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-novice |
Matt Clark wrote:
> Is there a way to define an alias or synonym for a data type?
>
> I have an existing schema (from a Sybase DB), which defines a datatype via the
> SQLServer method:
>
> EXEC sp_addtype XID, 'numeric(16,0)' , 'NULL';
>
Take a look at DOMAINs:
http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/sql-createdomain.html
HTH,
Joe
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Matt Clark <mclark(at)rushe(dot)aero(dot)org> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Alias for data types? |
Date: | 2003-03-31 18:13:31 |
Message-ID: | 24124.1049134411@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-novice |
Matt Clark <mclark(at)rushe(dot)aero(dot)org> writes:
> Is there a way to define an alias or synonym for a data type?
CREATE DOMAIN is a pretty serviceable way of making an alias for a type.
regards, tom lane