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 1oIwpH-0005M3-02 for pgsql-general@arkaria.postgresql.org; Tue, 02 Aug 2022 18:41:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oIwpF-0006QF-Rk for pgsql-general@arkaria.postgresql.org; Tue, 02 Aug 2022 18:41:05 +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 1oIwpF-0006Q6-HD for pgsql-general@lists.postgresql.org; Tue, 02 Aug 2022 18:41:05 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oIwpD-0004Dx-9Y for pgsql-general@lists.postgresql.org; Tue, 02 Aug 2022 18:41:04 +0000 Received: by mail-pg1-x531.google.com with SMTP id r186so13084024pgr.2 for ; Tue, 02 Aug 2022 11:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc; bh=35ojLK3n34POor3xrwohhV09XdEGGgP7Co77M4dYA7E=; b=kXbQbc9zV+Z2LbA7/Z3wtQjml7hXs0q576rKfaXyjcOIpr1bh08EuvUE3fog61FFeX jjCPImEWtDJXl3AWdbZGD36EbSDLj5UO79ExTS2Hs/B+OeTJAsdvJjwk9kLzxElO/moT qBzMwhdHGJJqLyL/TJ6XGm2BU3SI2ipUSlmz99cTbnrSt/GE8VgBMcHuqu3fUGdzHiUr 9BDysNgRbRc4j1LZr3h5ku6slWOFgWrCTQhaNQs+WeqipfunB5uIsWrPI6lgqdLrWFtd lLItaCuHacQQVanx78WHXiPITh1QIQW3xm5m/h/KD+h9J+W/fL+BIVKXSqBsWfygwUia YfnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc; bh=35ojLK3n34POor3xrwohhV09XdEGGgP7Co77M4dYA7E=; b=8MJwMic8pjG96daF/Ysc1RjfbH4O+TUUSlE3Q6eYwnurXsvYJaYNlGoydjESON387G L+RHwNMj0jJ3cACEJnvyNTA/QEtCa8ibktSvLbnlPUkn9vyAoseCOoISHR48WXSHqofv CaFTKr4tvix9uR8VIGr9FHvj/1b/xDk03wzPdRNzttNnWRdFCmJcMeHq2VmfInbzzwSI 9WNsHJS9ShL82m0yMnGcxAVN7bCT6gjpIVOOYfyKUk4LbWs74eVtt7pL10XxCcgIJ4ny YZhS0D+8kFsYIRFhQsUZ6ITzlbO8iuT09kCxKMN0+Z6SBHYnVj4MBTG0WCPWHHyby9BO /SrA== X-Gm-Message-State: AJIora+4H7wSSNIXG/zraEVnkXk42b15dbPFBm8PBChy9uTWJw+JkxnK ANeJh74zBR2HajrzyFWkGKEVa9sCE6g= X-Google-Smtp-Source: AGRyM1sKsihBE0vBGb3ELSBd72aqTpcIRXryXu51bpmSrq0A8G7BUoMFF/ED178xwobbQ3iUSGw7hA== X-Received: by 2002:a05:6a00:168e:b0:52b:b62e:ad73 with SMTP id k14-20020a056a00168e00b0052bb62ead73mr22122982pfc.56.1659465661819; Tue, 02 Aug 2022 11:41:01 -0700 (PDT) Received: from [10.128.56.11] ([155.98.131.3]) by smtp.gmail.com with ESMTPSA id y124-20020a623282000000b0052895642037sm6061131pfy.139.2022.08.02.11.41.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Aug 2022 11:41:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------6yStj4M0icxUWXh6sqh0dnPM" Message-ID: <0f9d8171-7b10-2e3e-50a3-a4fa3fbfc0e2@gmail.com> Date: Tue, 2 Aug 2022 12:41:00 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Copying records from TABLE_A to TABLE_B (in the same database) Content-Language: en-CA To: pgsql-general@lists.postgresql.org References: <5adcc923-889d-bb68-5a04-60125b6f0e96@gmail.com> From: Rob Sargent In-Reply-To: <5adcc923-889d-bb68-5a04-60125b6f0e96@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------6yStj4M0icxUWXh6sqh0dnPM Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/2/22 12:37, Ron wrote: > AWS RDS Postgresql 12.10 > > There are no indices or constraints (except for NOT NULL) on table_a. > > The two ways that I know are: >     INSERT INTO table_a SELECT * FROM table_b; > and >     \COPY table_a TO '/tmp/table_a.tsv' WITH (FORMAT BINARY); >     \COPY table_b FROM '/tmp/table_a.tsv' WITH (FORMAT BINARY); > > Is there a faster/better way? > create view ? --------------6yStj4M0icxUWXh6sqh0dnPM Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 8/2/22 12:37, Ron wrote:
AWS RDS Postgresql 12.10

There are no indices or constraints (except for NOT NULL) on table_a.

The two ways that I know are:
    INSERT INTO table_a SELECT * FROM table_b;
and
    \COPY table_a TO '/tmp/table_a.tsv' WITH (FORMAT BINARY);
    \COPY table_b FROM '/tmp/table_a.tsv' WITH (FORMAT BINARY);

Is there a faster/better way?

create view ?
--------------6yStj4M0icxUWXh6sqh0dnPM--