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 1kYYO4-0001mT-0L for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 17:40:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kYYO2-00056v-VK for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 17:40:26 +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 1kYYO2-00054h-MT for pgsql-admin@lists.postgresql.org; Fri, 30 Oct 2020 17:40:26 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kYYO0-0003yF-LN for pgsql-admin@postgresql.org; Fri, 30 Oct 2020 17:40:25 +0000 Received: by mail-qt1-x82c.google.com with SMTP id m14so4655277qtc.12 for ; Fri, 30 Oct 2020 10:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:message-id:date :cc:to; bh=2amhDNqcmxeTbg0+3oUF4yGVglORrK0TCBYv8w/+Yrw=; b=FC5TStUWEwzAsaZSefAH/lca+n6UhYbF0wpM/wvqRAClBJbZD805BrSVVkxzU/+i7c 5NTH9b7Q5NoDHcwZdYtvopGiN3+KR14NmtIm7/NU7h3ePlolWFFvWYXaSDtM0jZAdZlN 0pQWqKktgtNABy60T3016GqIGpxl63x1gKkNmWJARpHFvYwmiUHnc570d4YyQxE/RZdD M1MSeVyAlzF6D+xRVF64G/auXi/jgA9SmFU8K7ufta3HA781z1j6y4bMvWw0vXczMAHk tJkjcFLG69I5HH37y7w30t/5WvR58HrZNGKObz/xheuyzZ1feotkFvgQIc8T+JfRXDw0 GU/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:message-id:date:cc:to; bh=2amhDNqcmxeTbg0+3oUF4yGVglORrK0TCBYv8w/+Yrw=; b=SkNdYqsaTvXbdANrf/huY9H0Ea00fpvI4iMTV9GuCck+kjNOQ8bxzW0Z7WcUx9FvgP wDM0+T3EZs0EkQWXl17PcfVm+dOEPLvdImdiVXb+C6/TrP6TBj4Fo0jgOUwn9rCylSkp JZEXpfFyJ2o3/6ga70twPZcBk3WLt1MDUTCS3OC+WFsrmrLDVE37ibgm9DwHSbPfOqe1 pd1ZIPIWni7goOuZfcIpR2FcAX8hkASBa7MeiuMVYMNX3Ldor37irPS3wROkiv5Kt0XQ LYz7GFj95+96gq114LiVeezFacKiTL83FwTlxV1v3TYNEctHRScSFzFSUCijZIIArYMS +KOA== X-Gm-Message-State: AOAM533ikOXHkqa0lXgGoMLodjdPbTjAvZprsTl61oNAYWgZmTN4yMMb SAdSKJHogZQvhcFFh2s9MTg= X-Google-Smtp-Source: ABdhPJzuk5sFbABmSvE6P0h3/yqBZ/whXwHmDFV2jA7a0h88IMVRJs9qI2AN5lQBhmV4qNMaRMtGEw== X-Received: by 2002:aed:23f1:: with SMTP id k46mr3364784qtc.377.1604079623601; Fri, 30 Oct 2020 10:40:23 -0700 (PDT) Received: from [192.168.1.35] (cpe-71-72-37-104.neo.res.rr.com. [71.72.37.104]) by smtp.gmail.com with ESMTPSA id a21sm2953257qkk.98.2020.10.30.10.40.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Oct 2020 10:40:22 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: John Scalia Mime-Version: 1.0 (1.0) Subject: Re: Creating a partition table Message-Id: <72BCF3AA-1931-4BD9-A00D-497B3C2553E2@gmail.com> Date: Fri, 30 Oct 2020 13:40:21 -0400 Cc: pgsql-admin To: Tom Lane X-Mailer: iPad Mail (18A8395) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =EF=BB=BFWell, 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 s= tructure of the table that way, the error didn=E2=80=99t make any sense. I=E2=80=99ll try Laurenz=E2=80=99s code example and see what happens. Sent from my iPad > On Oct 30, 2020, at 1:07 PM, Tom Lane wrote: >=20 > =EF=BB=BFJohn Scalia writes: >> I have a PostgreSQL server version 11.3 that my devs are asking for some p= artitioned tables. I can=E2=80=99t seem to get the syntax correct though. My= SQL code is: >=20 >> CREATE TABLE schema.temp_table >> AS (SELECT * FROM schema.original_table) >> PARTITION BY LIST(attribute_name); >=20 > 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. >=20 > 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. >=20 > regards, tom lane