Re: CREATE TABLE & composite type

From: gmb <gmbouwer(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: CREATE TABLE & composite type
Date: 2017-06-28 13:51:58
Message-ID: 1498657918877-5969045.post@n3.nabble.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Klaver-4 wrote
>
> CREATE TABLE inventory_item_table AS ( SELECT some_func( ) limit 0);

Thanks Adrian
My concern is that this will have to execute all code in the function only
to return a empty dataset - his may be ineffective.
A possible workaround will be to have a dedicated param which will determine
whether or not to exit at the start of the function.

I also just realised that a possible workaround will be to create tables
instead of composite types ("Whenever you create a table, a composite type
is also automatically created").

I.e. instead of doing:
CREATE TYPE inventory_item AS ( name text, supplier_id integer, price
numeric );

create an actual table (which will never be used):
CREATE TABLE inventory_item AS ( name text, supplier_id integer, price
numeric );

However, having unused tables in the schema kind of goes against the
grain...

Regards

--
View this message in context: http://www.postgresql-archive.org/CREATE-TABLE-composite-type-tp5969032p5969045.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2017-06-28 13:52:30 Re: CREATE TABLE & composite type
Previous Message Adrian Klaver 2017-06-28 13:37:24 Re: CREATE TABLE & composite type