Received: from candle.pha.pa.us (216-55-132-35.dsl.san-diego.abac.net [216.55.132.35]) by postgresql.org (Postfix) with ESMTP id C6DEE474E4E for ; Fri, 26 Apr 2002 19:34:05 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g3QNXvu28948; Fri, 26 Apr 2002 19:33:57 -0400 (EDT) From: Bruce Momjian Message-Id: <200204262333.g3QNXvu28948@candle.pha.pa.us> Subject: Re: smart copy? In-Reply-To: <12691.1019861442@sss.pgh.pa.us> To: Tom Lane Date: Fri, 26 Apr 2002 19:33:57 -0400 (EDT) Cc: Joel Burton , Lucas Rockwell , pgsql-admin@postgresql.org X-Mailer: ELM [version 2.4ME+ PL97 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200204/271 X-Sequence-Number: 4159 Tom Lane wrote: > "Joel Burton" writes: > > $ pg_dump --attribute-inserts --data-only --table=TheTable A > > > > It's slower than running COPY, since you're executing > > dozens/hundreds/kajillions of INSERT commands rather than one COPY command. > > Yup, lots slower. A better idea (which also doesn't require redoing > the export) is: > > 1. Create a temp table that matches the columns present in your data > file. > > 2. COPY from data file into temp table. > > 3. INSERT INTO target_table (column list) SELECT * FROM temp_table; > > You can do pretty much any transformation you need to in the > INSERT/SELECT, so this generalizes to a lot of related cases > where your data file doesn't quite match the data layout you want. It would be easier if we supported COPY out of views. You could create the view you want and COPY out that. Unfortunately, we don't support COPY of views. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026