[GENERAL] CREATE TABLE & composite type

Поиск
Список
Период
Сортировка
От gmb
Тема [GENERAL] CREATE TABLE & composite type
Дата
Msg-id 1498656447255-5969032.post@n3.nabble.com
обсуждение исходный текст
Ответы Re: [GENERAL] CREATE TABLE & composite type
Список pgsql-general
Hi Referencing https://www.postgresql.org/docs/9.6/static/rowtypes.html Taking a chance here.... Is there a short-hand way in which I can create a table with the same structure as a user defined composite type ? E.g. CREATE TYPE inventory_item AS ( name text, supplier_id integer, price numeric ); CREATE TABLE inventory_item_table ( like type inventory_item ); We're using composite types rather extensively as the return structure of functions: CREATE FUNCTION some_func() RETURNS SETOF inventory_item ....; Of course I can: CREATE TABLE inventory_item_table AS ( SELECT some_func( ) ); But , in some cases , where the function returns a large number of records I want to create the table beforehand in order to add indexes: CREATE TABLE inventory_item_table ( like type inventory_item ); CREATE INDEX idx ON inventory_item_table ( id ); INSERT INTO inventory_item_table SELECT some_func(); Will appreciate any input. Regards gmbouwer

View this message in context: CREATE TABLE & composite type
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] iso-8859-1 lvalue 'PIDFILE' in section 'Service'
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] Accessing DB2 tables from postgresql