pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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:40:21 -0400
Message-ID: <72BCF3AA-1931-4BD9-A00D-497B3C2553E2@gmail.com> (raw)

Well, originally my code had a WITH NO DATA before the PARTITION BY clause, but that was error in as well, but thinking that I would just get structure of the table that way, the error didn’t make any sense.

I’ll try Laurenz’s code example and see what happens.

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





view thread (6+ messages)  latest in thread

Message-ID: <72BCF3AA-1931-4BD9-A00D-497B3C2553E2@gmail.com>
Permalink:  ../72BCF3AA-1931-4BD9-A00D-497B3C2553E2@gmail.com/
Also on:    postgresql.org/message-id/72BCF3AA-1931-4BD9-A00D-497B3C2553E2@gmail.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: jayknowsunix@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Creating a partition table
  In-Reply-To: <72BCF3AA-1931-4BD9-A00D-497B3C2553E2@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