Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Is there a way to create a new composite type using already existing composite type?

For example,

CREATE TABLE inventory_item (
    name            text,
    supplier_id     integer REFERENCES suppliers,
    price           numeric CHECK (price > 0)
);

produces the following type automatically
CREATE TYPE inventory_item AS (
    name            text,
    supplier_id     integer,
    price           numeric
);

but I'd also like to have a type with an extra column for certain functions

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.

Regards
Iain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux