X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E010352812 for ; Wed, 29 Jun 2005 22:15:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37214-03 for ; Thu, 30 Jun 2005 01:15:44 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 343145286D for ; Wed, 29 Jun 2005 22:15:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j5U1Fknp001392; Wed, 29 Jun 2005 21:15:46 -0400 (EDT) To: "Vsevolod (Simon) Ilyushchenko" Cc: pgsql-sql@postgresql.org Subject: Re: Foreign key pg_dump issue and serial column type In-reply-to: <42C33C13.5010308@cshl.edu> References: <42C33C13.5010308@cshl.edu> Comments: In-reply-to "Vsevolod (Simon) Ilyushchenko" message dated "Wed, 29 Jun 2005 20:25:55 -0400" Date: Wed, 29 Jun 2005 21:15:46 -0400 Message-ID: <1391.1120094146@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/365 X-Sequence-Number: 21966 "Vsevolod (Simon) Ilyushchenko" writes: > However, when I pg_dump the database and import it on another server, > the tables are exported alphabetically, so when the 'people_roles' table > is created with its foreign keys, the table 'roles' does not exist yet. > Thus, the foreign key creation fails. Is there a way around it? Are you sure you are using 8.0 pg_dump? That's a longstanding deficiency in older versions, but 8.0 is not supposed to have a problem with it. If you're sure it's an up-to-date pg_dump, could you provide a complete test case (ie, a script to create a database that pg_dump has trouble with)? > 2. I've just discovered the 'serial' column type and tried to do this: > alter table people_roles alter column people_roles_code type serial; > To my surprise, it fails: > ERROR: type "serial" does not exist Serial isn't quite a true type, and so it doesn't work in every context that you might think. It'd probably make sense for "alter column type" to accept it, but for now what you gotta do is create a sequence and set the column default manually. regards, tom lane