Re: User-Defined Datatypes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philip Reimer <phre(at)wi(dot)uni-muenster(dot)de>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: User-Defined Datatypes
Date: 2002-04-15 19:04:17
Message-ID: 25556.1018897457@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Philip Reimer <phre(at)wi(dot)uni-muenster(dot)de> writes:
> Is it possible to create new structured datatypes in PostgreSQL like in this
> IBM UDB2 statement:

> create type person_t as (
> name varchar(30),
> car car_t)

> create type car_t as (
> model varchar(30),
> plate carchar(20))

> create table car of car_t
> create table person of person_t

We don't support that syntax, but you can achieve approximately the same
effect using inheritance:

create table person_t ( ... );

create table person () inherits(person_t);

Very often, the parent table of an inheritance relationship isn't
intended to ever actually contain any rows itself. In that case the
parent is effectively serving as a datatype, or at least you could
think of it that way.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Timothy Wood 2002-04-15 19:08:42 using CAST and LIKE
Previous Message Gunther Schadow 2002-04-15 18:58:19 Re: User-Defined Datatypes