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 18037528B9 for ; Wed, 29 Jun 2005 21:26:04 -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 24734-09 for ; Thu, 30 Jun 2005 00:25:58 +0000 (GMT) Received: from mercury.cshl.edu (mercury.cshl.edu [143.48.1.21]) by svr1.postgresql.org (Postfix) with ESMTP id 51EF45281E for ; Wed, 29 Jun 2005 21:25:55 -0300 (ADT) Received: from fe01.cshl.edu (fe01.cshl.edu [143.48.42.50]) by mercury.cshl.edu (8.12.11/8.12.11) with ESMTP id j5U0PuCN015984; Wed, 29 Jun 2005 20:25:56 -0400 (EDT) (envelope-from simonf@phage.cshl.edu) Received: from [143.48.3.70] ([143.48.3.70]) by fe01.cshl.edu with Microsoft SMTPSVC(6.0.3790.1830); Wed, 29 Jun 2005 20:25:55 -0400 Message-ID: <42C33C13.5010308@cshl.edu> Date: Wed, 29 Jun 2005 20:25:55 -0400 From: "Vsevolod (Simon) Ilyushchenko" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Foreign key pg_dump issue and serial column type Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Jun 2005 00:25:55.0696 (UTC) FILETIME=[47C1DF00:01C57D0A] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/364 X-Sequence-Number: 21965 Hi, As a relative newbie to postgres, I've run into to weirdisms that I don't quite know how to handle: 1. I have a many-to-many table 'people_roles' containing fields 'person_code' and 'role_code'. It links tables 'people' and 'roles'. There are foreign key constraints: ALTER TABLE PEOPLE_ROLES add CONSTRAINT PRO_PEE_FK FOREIGN KEY(PERSON_CODE) REFERENCES PEOPLE(PERSON_CODE) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE; ALTER TABLE PEOPLE_ROLES add CONSTRAINT PRO_ROE_FK FOREIGN KEY(ROLE_CODE) REFERENCES ROLES(ROLE_CODE) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE; 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? 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 However, I can create new tables with the 'serial' type without a hitch. Is it a bug or a feature? I'm running postgres 8.0.3 on Fedora Core 4. Thanks, Simon -- Simon (Vsevolod ILyushchenko) simonf@cshl.edu http://www.simonf.com Terrorism is a tactic and so to declare war on terrorism is equivalent to Roosevelt's declaring war on blitzkrieg. Zbigniew Brzezinski, U.S. national security advisor, 1977-81