pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAlias to a type
8+ messages / 6 participants
[nested] [flat]
* Alias to a type
@ 2005-06-22 11:27 Veikko Mäkinen <veikko.makinen@ecom.fi>
0 siblings, 2 replies; 8+ messages in thread
From: Veikko Mäkinen @ 2005-06-22 11:27 UTC (permalink / raw)
To: pgsql-sql
Hey,
Is it possible to create a new type as an alias to a pre-defined type? I
use "USERID varchar(20)" in almost every table I have I'd like to make
an alias for that type eg.
<pseudo-sql>
create type myschema.useridtype as varchar(20);
</pseudo-sql>
I might have to alter the type some day and this way I'd have to just
re-define the alias. Can this be achieved by creating a new type with
CREATE TYPE? What are the input/output functions in the CREATE TYPE
definition?
Thanks.
-veikko
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 11:42 Achilleus Mantzios <achill@matrix.gatewaynet.com>
parent: Veikko Mäkinen <veikko.makinen@ecom.fi>
1 sibling, 1 reply; 8+ messages in thread
From: Achilleus Mantzios @ 2005-06-22 11:42 UTC (permalink / raw)
To: Veikko Mäkinen <veikko.makinen@ecom.fi>; +Cc: pgsql-sql
O Veikko Mäkinen Ýãñáøå óôéò Jun 22, 2005 :
> Hey,
>
> Is it possible to create a new type as an alias to a pre-defined type? I
> use "USERID varchar(20)" in almost every table I have I'd like to make
> an alias for that type eg.
>
> <pseudo-sql>
> create type myschema.useridtype as varchar(20);
> </pseudo-sql>
>
Try something like
CREATE DOMAIN my_integer AS INTEGER;
> I might have to alter the type some day and this way I'd have to just
> re-define the alias. Can this be achieved by creating a new type with
> CREATE TYPE? What are the input/output functions in the CREATE TYPE
> definition?
>
> Thanks.
>
>
> -veikko
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
--
-Achilleus
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 12:04 Sean Davis <sdavis2@mail.nih.gov>
parent: Achilleus Mantzios <achill@matrix.gatewaynet.com>
0 siblings, 2 replies; 8+ messages in thread
From: Sean Davis @ 2005-06-22 12:04 UTC (permalink / raw)
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>; +Cc: Veikko Mäkinen <veikko.makinen@ecom.fi>; pgsql-sql
On Jun 22, 2005, at 7:42 AM, Achilleus Mantzios wrote:
> O Veikko Mδkinen έγραψε στις Jun 22, 2005 :
>
>> Hey,
>>
>> Is it possible to create a new type as an alias to a pre-defined
>> type? I
>> use "USERID varchar(20)" in almost every table I have I'd like to make
>> an alias for that type eg.
>>
>> <pseudo-sql>
>> create type myschema.useridtype as varchar(20);
>> </pseudo-sql>
>>
>
> Try something like
>
> CREATE DOMAIN my_integer AS INTEGER;
Just for my own edification, does creating a "simple" domain like this
then require a whole set of functions for indexing, etc., like other
more complex user-defined types, or will postgres "do the right thing"?
Thanks,
Sean
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 12:07 Richard Huxton <dev@archonet.com>
parent: Veikko Mäkinen <veikko.makinen@ecom.fi>
1 sibling, 1 reply; 8+ messages in thread
From: Richard Huxton @ 2005-06-22 12:07 UTC (permalink / raw)
To: Veikko Mäkinen <veikko.makinen@ecom.fi>; +Cc: pgsql-sql
Veikko Mäkinen wrote:
> Hey,
>
> Is it possible to create a new type as an alias to a pre-defined type? I
> use "USERID varchar(20)" in almost every table I have I'd like to make
> an alias for that type eg.
CREATE DOMAIN username_string AS varchar(20);
Test it with your client applications though, make sure they cope. Some
don't cope well with user-defined types.
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 12:14 Achilleus Mantzios <achill@matrix.gatewaynet.com>
parent: Sean Davis <sdavis2@mail.nih.gov>
1 sibling, 0 replies; 8+ messages in thread
From: Achilleus Mantzios @ 2005-06-22 12:14 UTC (permalink / raw)
To: Sean Davis <sdavis2@mail.nih.gov>; +Cc: Veikko Mäkinen <veikko.makinen@ecom.fi>; pgsql-sql
O Sean Davis Ýãñáøå óôéò Jun 22, 2005 :
>
> On Jun 22, 2005, at 7:42 AM, Achilleus Mantzios wrote:
>
> > O Veikko Mδkinen ÎγÏαÏε ÏÏÎ¹Ï Jun 22, 2005 :
> >
> >> Hey,
> >>
> >> Is it possible to create a new type as an alias to a pre-defined
> >> type? I
> >> use "USERID varchar(20)" in almost every table I have I'd like to make
> >> an alias for that type eg.
> >>
> >> <pseudo-sql>
> >> create type myschema.useridtype as varchar(20);
> >> </pseudo-sql>
> >>
> >
> > Try something like
> >
> > CREATE DOMAIN my_integer AS INTEGER;
>
> Just for my own edification, does creating a "simple" domain like this
> then require a whole set of functions for indexing, etc., like other
> more complex user-defined types, or will postgres "do the right thing"?
In the above example you may safely consider indexing columns
of type my_integer as indexing INTEGERs.
>
> Thanks,
> Sean
>
>
--
-Achilleus
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 12:18 Bruno Wolff III <bruno@wolff.to>
parent: Sean Davis <sdavis2@mail.nih.gov>
1 sibling, 0 replies; 8+ messages in thread
From: Bruno Wolff III @ 2005-06-22 12:18 UTC (permalink / raw)
To: Sean Davis <sdavis2@mail.nih.gov>; +Cc: Achilleus Mantzios <achill@matrix.gatewaynet.com>; Veikko Mäkinen <veikko.makinen@ecom.fi>; pgsql-sql
On Wed, Jun 22, 2005 at 08:04:39 -0400,
Sean Davis <sdavis2@mail.nih.gov> wrote:
>
>
> Just for my own edification, does creating a "simple" domain like this
> then require a whole set of functions for indexing, etc., like other
> more complex user-defined types, or will postgres "do the right thing"?
No, the underlying type's class is still used. You don't need to create
new comparison or type conversion functions.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 13:14 Veikko Mäkinen <veikko.makinen@ecom.fi>
parent: Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 8+ messages in thread
From: Veikko Mäkinen @ 2005-06-22 13:14 UTC (permalink / raw)
To: pgsql-sql
Richard Huxton wrote:
> Veikko Mäkinen wrote:
>
>> Hey,
>>
>> Is it possible to create a new type as an alias to a pre-defined type?
>> I use "USERID varchar(20)" in almost every table I have I'd like to
>> make an alias for that type eg.
>
>
> CREATE DOMAIN username_string AS varchar(20);
>
> Test it with your client applications though, make sure they cope. Some
> don't cope well with user-defined types.
Splendid, thank you all :) I'm quite sure loosely typed PHP can cope
with my user-defined types ;)
But now I need a better modeling tool because Azzurri Clay 1.1 (Eclipse
plug-in) doesn't let me define new types... Any suggestions? SQL DDL
generation is the only demand I really have.
-veikko
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Alias to a type
@ 2005-06-22 14:42 KÖPFERL Robert <robert.koepferl@sonorys.at>
0 siblings, 0 replies; 8+ messages in thread
From: KÖPFERL Robert @ 2005-06-22 14:42 UTC (permalink / raw)
To: pgsql-sql
Keep in mind, though. Using a DOMAIN in some definition 'seals' the domain.
Yo can't change the domain unless you drop all dependent objects
|-----Original Message-----
|From: Veikko Mäkinen [mailto:veikko.makinen@ecom.fi]
|Sent: Mittwoch, 22. Juni 2005 15:14
|To: pgsql-sql@postgresql.org
|Subject: Re: [SQL] Alias to a type
|
|
|Richard Huxton wrote:
|> Veikko Mäkinen wrote:
|>
|>> Hey,
|>>
|>> Is it possible to create a new type as an alias to a
|pre-defined type?
|>> I use "USERID varchar(20)" in almost every table I have I'd like to
|>> make an alias for that type eg.
|>
|>
|> CREATE DOMAIN username_string AS varchar(20);
|>
|> Test it with your client applications though, make sure they
|cope. Some
|> don't cope well with user-defined types.
|
|
|Splendid, thank you all :) I'm quite sure loosely typed PHP can cope
|with my user-defined types ;)
|
|But now I need a better modeling tool because Azzurri Clay 1.1
|(Eclipse
|plug-in) doesn't let me define new types... Any suggestions? SQL DDL
|generation is the only demand I really have.
|
|
|-veikko
|
|
|---------------------------(end of
|broadcast)---------------------------
|TIP 3: if posting/reading through Usenet, please send an appropriate
| subscribe-nomail command to majordomo@postgresql.org so
|that your
| message can get through to the mailing list cleanly
|
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2005-06-22 14:42 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-22 11:27 Alias to a type Veikko Mäkinen <veikko.makinen@ecom.fi>
2005-06-22 11:42 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2005-06-22 12:04 ` Sean Davis <sdavis2@mail.nih.gov>
2005-06-22 12:14 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2005-06-22 12:18 ` Bruno Wolff III <bruno@wolff.to>
2005-06-22 12:07 ` Richard Huxton <dev@archonet.com>
2005-06-22 13:14 ` Veikko Mäkinen <veikko.makinen@ecom.fi>
2005-06-22 14:42 Re: Alias to a type KÖPFERL Robert <robert.koepferl@sonorys.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox