Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYXv5-0000jl-0U for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 17:10:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kYXv3-0001A2-Vg for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 17:10:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYXrx-0004vk-1N for pgsql-admin@lists.postgresql.org; Fri, 30 Oct 2020 17:07:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYXru-0003jN-Ku for pgsql-admin@postgresql.org; Fri, 30 Oct 2020 17:07:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09UH7DFn098826; Fri, 30 Oct 2020 13:07:13 -0400 From: Tom Lane To: John Scalia cc: pgsql-admin Subject: Re: Creating a partition table In-reply-to: References: Comments: In-reply-to John Scalia message dated "Fri, 30 Oct 2020 12:52:49 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <98824.1604077633.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 30 Oct 2020 13:07:13 -0400 Message-ID: <98825.1604077633@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk John Scalia writes: > I have a PostgreSQL server version 11.3 that my devs are asking for some= partitioned tables. I can=E2=80=99t 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