Re: Composite type - Mailing list pgsql-general

From Chris Travers
Subject Re: Composite type
Date
Msg-id CAKt_ZfvEscqNoqu1xQPiy8zK2=5f8bO6BHQoMAVsfWsc7f+Wxw@mail.gmail.com
Whole thread Raw
In response to Re: Composite type  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-general

As a note, the following also works:

CREATE TYPE foo AS (bar text, baz int);
CREATE TABLE table_of_foo OF foo (primary key(bar));

The one thing that doesn't work is the REF syntax and the operators that go along with that.  However, you could come up with dereferencing functions and operators oneself.

Personally in this case I would probably use inheritance instead for the simple reason that tables can inherit but complex types cannot.  You can use CHECK(false) NOINHERIT to effectively relegate a table to a type if you have a sufficiently recent version of PostgreSQL.

Best Wishes,
Chris Travers

pgsql-general by date:

Previous
From: Raghavendra
Date:
Subject: Re: PostgreSQL 9.2.4 using large amount of memory
Next
From: Craig Ringer
Date:
Subject: Re: PostgreSQL specific datatypes very confusing for beginners who use wrappers around JDBC