pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Scalia <jayknowsunix@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: Creating a partition table
Date: Fri, 30 Oct 2020 13:07:13 -0400
Message-ID: <98825.1604077633@sss.pgh.pa.us> (raw)
In-Reply-To: <BFBB87D2-4AFB-4B2A-A140-E19860849936@gmail.com>
References: <BFBB87D2-4AFB-4B2A-A140-E19860849936@gmail.com>

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: <98825.1604077633@sss.pgh.pa.us>
Permalink:  ../98825.1604077633@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/98825.1604077633@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, jayknowsunix@gmail.com
  Subject: Re: Creating a partition table
  In-Reply-To: <98825.1604077633@sss.pgh.pa.us>

* 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