Re: Composite type

From: Chris Travers <chris(dot)travers(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: antono124 <g(dot)antonopoulos000(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Composite type
Date: 2014-01-29 02:39:48
Message-ID: CAKt_ZfvEscqNoqu1xQPiy8zK2=5f8bO6BHQoMAVsfWsc7f+Wxw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2014-01-29 04:08:16 Re: PostgreSQL specific datatypes very confusing for beginners who use wrappers around JDBC
Previous Message Raghavendra 2014-01-29 02:19:02 Re: PostgreSQL 9.2.4 using large amount of memory