Re: how to create a new composite type using already existing composite types

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Iain Barnett <iainspeed(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to create a new composite type using already existing composite types
Date: 2010-02-14 00:24:30
Message-ID: 1266107070.29919.5924.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2010-02-10 at 03:46 +0000, Iain Barnett wrote:

> CREATE TYPE inventory_item2 AS (
> name text,
> supplier_id integer,
> price numeric,
> size integer
> );
>
>
> but it would be handy if I could reuse inventory_item instead of
> having to retype the whole lot. I can't work out or find the right
> syntax, can anyone show me how? Any help would be much appreciated.

What about:

CREATE TYPE inventory_item2 AS (
ii inventory_item,
size integer
);

or:

CREATE TABLE inventory_item2 (
LIKE inventory_item,
size integer
);

and that will automatically create the type.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Prasanna Sukumar 2010-02-14 03:03:03 Kerberos library update
Previous Message Diego Schulz 2010-02-13 23:40:02 Re: Problemas con la copia de seguridad PostgresSQL