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 1kYYWL-000257-Pv for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 17:49:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kYYWJ-0001nG-Lc for pgsql-admin@arkaria.postgresql.org; Fri, 30 Oct 2020 17:48:59 +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 1kYYWJ-0001n8-Bm for pgsql-admin@lists.postgresql.org; Fri, 30 Oct 2020 17:48:59 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kYYWG-00042w-7k for pgsql-admin@postgresql.org; Fri, 30 Oct 2020 17:48:58 +0000 Received: by mail-qk1-x730.google.com with SMTP id a64so2239132qkc.5 for ; Fri, 30 Oct 2020 10:48:56 -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:date:message-id :references:cc:in-reply-to:to; bh=Odwv109vMsC6/3ARY+rVetIeVEz/VZCK7R+hzQfSbjc=; b=DoU5W+04Lmp9v5EwS+sUNrTEVZtVb/Dag697scY0JUtKqV9oCN3S8jh4J+YUjbeRed kP+Z1TAVEIEw/aIzm7zReJW0zFdtJi3/eK4g14AO5FB6qWrXAhCFmCyueJCmJlrgOJuE UT5wlsl6BrzamzknyH5yeMgP4kP0HIMSZdcP/7QYXK84mXavaDprZ3t9jkHvW2CJqhYo j5SrIN8qO3uuPqhCRZH/CTr7tIfAyrPBebYwSbr8KPSfdDajNCyRklymhBAFjbRh64/X DcRKpBgaEaWYMqeSLgvAh2qng/PacxuW28YZXWtx3LgL3cVqr77O38oci6kWQxzj1hRP 6aKw== 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:date:message-id:references:cc:in-reply-to:to; bh=Odwv109vMsC6/3ARY+rVetIeVEz/VZCK7R+hzQfSbjc=; b=fHXdrgTvb/bcWULU2bjRWbR0GEhqnG6Gv/mJ92dkYQb+HDEurpZ2GL20HVO/w6fbz8 peEgpCSXslVqI8r5yTDUviWZ4pewrl2TVKeYhcRs0XlTKe7CGCy7MBCtY4EIZyKhllPr kddvjGoIVhC3NoP+iJA/feinn5bwBtsPubX+pNB+YwOxEmxQ57xR6pyZgxtJ9KZnazpQ X54afAPWiT41W8j5VudfYU8r7WPw3RzEjh3fo/RCL+SLGSxg7vesfWww5uDFn6cvF4e0 cuyDErKfBqThb+XXVpsmcPlDNL2xjo6D1S6bufJPsIeKSsNAtVAccfE5lPUCok0wUjKE tTEA== X-Gm-Message-State: AOAM531G5yHsF+SAQnU8/e5FAmDvDZD19svO/w0Q4Kf4WQFOGDpqTMqU Z7J5xSlgxPoAS1dDvIMIHXc= X-Google-Smtp-Source: ABdhPJxWmdE99BT+d28qyKtOhKxz/ox7q/Vk34aFw+2HtoQVB751XEKweojBnOxlWrwF+AWFxsImtw== X-Received: by 2002:a05:620a:13ab:: with SMTP id m11mr3204637qki.56.1604080135170; Fri, 30 Oct 2020 10:48:55 -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 o2sm2954854qkk.121.2020.10.30.10.48.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Oct 2020 10:48:54 -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 Date: Fri, 30 Oct 2020 13:48:53 -0400 Message-Id: References: <98825.1604077633@sss.pgh.pa.us> Cc: pgsql-admin In-Reply-To: <98825.1604077633@sss.pgh.pa.us> To: Tom Lane X-Mailer: iPad Mail (18A8395) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ok I tried what Laurent had suggested and now the error is: Insufficient columns in PRIMARY KEY constraint definition. Now, the attribute the devs want is not a key value in the original table, b= ut if it were that wouldn=E2=80=99t make a great deal of sense for a partiti= on. So, now why did it gripe? 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