X-Original-To: pgsql-admin@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 543F0475C9E for ; Thu, 20 Feb 2003 17:28:27 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 38979-02 for ; Thu, 20 Feb 2003 17:28:16 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 308464761DB for ; Thu, 20 Feb 2003 16:41:12 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.5/8.12.5) with ESMTP id h1KM8J6P008231; Thu, 20 Feb 2003 17:08:19 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id h1KLf6p16481; Thu, 20 Feb 2003 16:41:06 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id CWVL16H9; Thu, 20 Feb 2003 16:40:51 -0500 Subject: Re: pg_restore fails when restoring a database view From: Robert Treat To: Pius Chan Cc: pgsql-admin@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 20 Feb 2003 16:41:06 -0500 Message-Id: <1045777266.14518.59.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/342 X-Sequence-Number: 7540 Your problem is that the dump file doesn't specify the column name for the view. When you go to restore it, having no names to reference, it gives both columns the name ?column?, which errors out. This is fixed in 7.3 if you use the tar format (though oddly you'll get a different error with plain text dumps). If you can't upgrade, you can rewrite the view to use alias's in the select: CREATE VIEW "V_EDUCATION_LEVEL" AS SELECT 1 AS id, 'College or above' AS description UNION SELECT 2 AS id, 'Secondary' AS description; Robert Treat On Fri, 2003-02-14 at 16:16, Pius Chan wrote: > Hi, > > I have created a database view by : > > CREATE VIEW V_EDUCATION_LEVEL ( id, description ) AS > SELECT 1, 'College or above' > UNION ALL > SELECT 2, 'Secondary'; > > Then I pg_dump(ed) the database by specifying a tar format and tried to > pg_restore to a destination database. However, I encountered the following > error: > > pg_restore: creating VIEW v_education_level > pg_restore: [archiver (db)] could not execute query: ERROR: CREATE TABLE: > attribute "?column?" duplicated > pg_restore: *** aborted because of error > > I am running Postgres 7.2.2. > > Thanks, > > Pius