X-Original-To: pgsql-sql@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id E6C81925519 for ; Fri, 23 May 2003 01:18:57 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 53461-05 for ; Fri, 23 May 2003 01:18:25 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by developer.postgresql.org (Postfix) with ESMTP id 6DFD29251DE for ; Thu, 22 May 2003 21:48:49 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D95A5D61E; Thu, 22 May 2003 18:48:48 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C8E415C10; Thu, 22 May 2003 18:48:48 -0700 (PDT) Date: Thu, 22 May 2003 18:48:48 -0700 (PDT) From: Stephan Szabo To: Dan S Cc: Subject: Re: Referencing a column from another table in a different In-Reply-To: <247f0de3.0305190339.6b131f99@posting.google.com> Message-ID: <20030522184805.C51260-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/450 X-Sequence-Number: 13615 On 19 May 2003, Dan S wrote: > I am trying to write a foreign key table constraint which references > another column from a table in another database from within > PostgreSQL. > > Within the database 'rsg_auth', there is a table called 'user_table' > which has a column (amongst others) called 'username'. > > In another database called 'browser perm' I am trying to create the > following: > > CREATE TABLE user_agreement ( > ua_name VARCHAR(16) NOT NULL, > ua_desc TEXT NOT NULL, > sat_name VARCHAR(20) DEFAULT '', > contract VARCHAR(30) DEFAULT '', > filetype VARCHAR(30) NOT NULL, > areacode VARCHAR(30) NOT NULL, > nrt CHAR NOT NULL DEFAULT 'N' CONSTRAINT chkcons_nrt_y_n CHECK > (nrt IN ('Y', 'N')), > PRIMARY KEY (ua_name), > CONSTRAINT fk_uaname_username FOREIGN KEY (ua_name) > REFERENCES rsg_auth.user_table(username) ON UPDATE CASCADE > ON DELETE CASCADE > ) > > When I submitt it, I get the following error: > ERROR: parser: parse error at or near "." > > Obviously this has something to do with my reference to the other > table. You can't do this currently. If they were in separate schemas of the same database you should be able to do it with something like the above, but across databases it won't work.