Re: Creating a partition table

Поиск
Список
Период
Сортировка
От John Scalia
Тема Re: Creating a partition table
Дата
Msg-id D8D76052-3A69-4E31-8E5C-EB965FE6D53A@gmail.com
обсуждение исходный текст
Ответ на Re: Creating a partition table  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Creating a partition table  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
Ok I tried what Laurent had suggested and now the error is:

Insufficient columns in PRIMARY KEY constraint definition.

Now, the attribute the devs want is not a key value in the original table, but if it were that wouldn’t make a great
dealof sense for a partition. So, now why did it gripe? 

Sent from my iPad

> On Oct 30, 2020, at 1:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> John Scalia <jayknowsunix@gmail.com> writes:
>> I have a PostgreSQL server version 11.3 that my devs are asking for some partitioned tables. I can’t seem to get the
syntaxcorrect though. My SQL code is: 
>
>> CREATE TABLE schema.temp_table
>> AS (SELECT * FROM schema.original_table)
>> PARTITION BY LIST(attribute_name);
>
> You can't create and populate a partitioned table in one command; you have
> to create some partitions before you can load data into it.
>
> I believe you could use CREATE TABLE temp_table (LIKE original_table)
> PARTITION BY LIST(attribute_name) to avoid manually repeating the
> column list.  Check the docs to see which other LIKE options you want
> to use.
>
>            regards, tom lane



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

Предыдущее
От: John Scalia
Дата:
Сообщение: Re: Creating a partition table
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Creating a partition table