Re: [GENERAL] CREATE TABLE & composite type - Mailing list pgsql-general

From gmb
Subject Re: [GENERAL] CREATE TABLE & composite type
Date
Msg-id 1498657918877-5969045.post@n3.nabble.com
Whole thread Raw
In response to Re: [GENERAL] CREATE TABLE & composite type  (Adrian Klaver <adrian.klaver@aklaver.com>)
List 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.


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] CREATE TABLE & composite type
Next
From: Merlin Moncure
Date:
Subject: Re: [GENERAL] CREATE TABLE & composite type