What's the benefit (or usage scenario) of a "typed table"?
I recently stumbled over "typed tables" in Postgres
(there were several questions containing this on stackoverflow recently)
create type some_type as (id integer, data text);
create table some_table of some_type;
I wonder what the benefit of a typed table is and when this would be useful?
Regards
Thomas
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
On Saturday, December 31, 2016, Thomas Kellerer <spam_eater@gmx.net> wrote:
I recently stumbled over "typed tables" in Postgres
(there were several questions containing this on stackoverflow recently)create type some_type as (id integer, data text);
create table some_table of some_type;I wonder what the benefit of a typed table is and when this would be
useful?
Given that I'd frown upon having two types with identical structure I'd say
this is could be harmfull if swallowed. Thoguh it might find use in
refactoring and maintaining backward compatibility. It does setup an
object dependency which is the only visible difference from just copy the
type definition into the CREATE TABLE. But I'd say if you want a table
with said structure you should plan on droppign the original type after
you've altered all references to it to point to the new implicit type
created with the table.
David J.
David G. Johnston schrieb am 31.12.2016 um 16:51:
I wonder what the benefit of a typed table is and when this would be useful?
But I'd say if you want a table with said structure you should plan on
droppign the original type after you've altered all references to it to
point to the new implicit type created with the table.
I am not planning to use it.
I am just wondering _if_ there is an advantage to this setup
Apparently at some point someone thought it would be useful, otherwise
it wouldn't have been implemented I guess.
Thomas
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Thomas Kellerer <spam_eater@gmx.net> writes:
I recently stumbled over "typed tables" in Postgres
(there were several questions containing this on stackoverflow recently)
create type some_type as (id integer, data text);
create table some_table of some_type;
I wonder what the benefit of a typed table is and when this would be useful?
AFAIK we implemented that only because it's in the SQL standard.
Otherwise you might as well use, for instance, CREATE TABLE ... LIKE.
regards, tom lane
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
On 12/31/2016 08:25 AM, Thomas Kellerer wrote:
David G. Johnston schrieb am 31.12.2016 um 16:51:
I wonder what the benefit of a typed table is and when this would be
useful?But I'd say if you want a table with said structure you should plan on
droppign the original type after you've altered all references to it to
point to the new implicit type created with the table.I am not planning to use it.
I am just wondering _if_ there is an advantage to this setup
Apparently at some point someone thought it would be useful, otherwise
it wouldn't have been implemented I guess.
I see it as completing the loop. A table creates a composite type, a
composite type creates a table. Not sure where that falls on the useful
scale.
Thomas
--
Adrian Klaver
adrian.klaver@aklaver.com
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
On 12/31/16 10:34 AM, Thomas Kellerer wrote:
I recently stumbled over "typed tables" in Postgres
(there were several questions containing this on stackoverflow recently)create type some_type as (id integer, data text);
create table some_table of some_type;I wonder what the benefit of a typed table is and when this would be useful?
One use is with PL/Proxy. You create the type on the proxy, thus
allowing you to define functions using the type. Then create the table
on the backend from the type, thus ensuring they are the same.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general