From: John Scalia <jayknowsunix@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Creating a partition table
Date: Fri, 30 Oct 2020 13:48:53 -0400
Message-ID: <D8D76052-3A69-4E31-8E5C-EB965FE6D53A@gmail.com> (raw)
In-Reply-To: <98825.1604077633@sss.pgh.pa.us>
References: <98825.1604077633@sss.pgh.pa.us>
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 deal of 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 syntax correct 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jayknowsunix@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: Creating a partition table
In-Reply-To: <D8D76052-3A69-4E31-8E5C-EB965FE6D53A@gmail.com>
References: <98825.1604077633@sss.pgh.pa.us> <D8D76052-3A69-4E31-8E5C-EB965FE6D53A@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox