Re: User-Defined Datatypes - Mailing list pgsql-general

From Tom Lane
Subject Re: User-Defined Datatypes
Date
Msg-id 25556.1018897457@sss.pgh.pa.us
Whole thread Raw
In response to User-Defined Datatypes  (Philip Reimer <phre@wi.uni-muenster.de>)
Responses Re: User-Defined Datatypes
List pgsql-general
Philip Reimer <phre@wi.uni-muenster.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

pgsql-general by date:

Previous
From: Gunther Schadow
Date:
Subject: Re: User-Defined Datatypes
Next
From: Timothy Wood
Date:
Subject: using CAST and LIKE