Creating a partition table

From: John Scalia <jayknowsunix(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Creating a partition table
Date: 2020-10-30 16:52:49
Message-ID: BFBB87D2-4AFB-4B2A-A140-E19860849936@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi all,

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);

As what I want to do is create a copy of the current table, create the partitions on the new temp table, and when everything works, drop the original table and do an alter table rename on the new one.

The error is:
ERROR: syntax error at or near “PARTITION”
Line 3: PARTITION BY LIST(attribute_name);

I’ve tried using the word RANGE as opposed to LIST, but the error remains. Does PostgreSQL not support a construct like this one or am I doing something wrong?

Jay

Sent from my iPad

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2020-10-30 17:01:35 Re: Creating a partition table
Previous Message soumik.bhattacharjee 2020-10-30 08:50:37 RE: TCP/IP connections refused