Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EEB95476381 for ; Tue, 12 Nov 2002 09:08:55 -0500 (EST) Received: from wolff.to (unknown [66.93.197.35]) by postgresql.org (Postfix) with SMTP id B59B947639F for ; Tue, 12 Nov 2002 09:08:54 -0500 (EST) Received: (qmail 27968 invoked by uid 500); 12 Nov 2002 14:18:43 -0000 Date: Tue, 12 Nov 2002 08:18:43 -0600 From: Bruno Wolff III To: LR Cc: pgsql-sql@postgresql.org Subject: Re: execute a query in an other db Message-ID: <20021112141843.GA27903@wolff.to> Mail-Followup-To: LR , pgsql-sql@postgresql.org References: <3dcd3c60_4@news.bluewin.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3dcd3c60_4@news.bluewin.ch> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/183 X-Sequence-Number: 10325 On Sat, Nov 09, 2002 at 17:51:40 +0100, LR wrote: > Hi, > > When I'm connected to a postgreSQL db ( e.g. myDB ), how could I execute > "select * from myTable;" in an other db (e.g. myOtherDB). > > In other words, what is the postgreSQL equivalent of the MS SQL Server > statement "USE myOtherDB SELECT * FROM myTable" ? Stock postgresql doesn't support cross database queries. There is a contrib package which does. In the example you gave, you were combining information from two databases. If it is the case that your application will be combining data from the two databases, then you can open a separate connection to each database and use the appropiate connection for your queries.