Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C809364FEDB for ; Wed, 20 Aug 2008 10:01:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 53536-05-5 for ; Wed, 20 Aug 2008 10:01:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by postgresql.org (Postfix) with ESMTP id C024B65013E for ; Wed, 20 Aug 2008 10:00:17 -0300 (ADT) Received: from perhan.alvh.no-ip.org (190-95-19-36.bk17-dsl.surnet.cl [190.95.19.36]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id m7KD2uHU025646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Aug 2008 06:03:03 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 6B59147C9A; Wed, 20 Aug 2008 08:59:57 -0400 (CLT) Date: Wed, 20 Aug 2008 08:59:57 -0400 From: Alvaro Herrera To: "Masis, Alexander (US SSA)" Cc: pgsql-interfaces@postgresql.org Subject: Re: schema name in the SQL statement. Message-ID: <20080820125957.GB4169@alvh.no-ip.org> References: <738m08$3l61o@dmzms99802.na.baesystems.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <738m08$3l61o@dmzms99802.na.baesystems.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Wed, 20 Aug 2008 06:03:03 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/15 X-Sequence-Number: 6790 Masis, Alexander (US SSA) wrote: > My db has one schema. In fact I deleted the default "public" and created > my own: "schema_1". > In my SQL query I have to explicitly specify schema name: > "select my_colomn from schema_1.table_name;" > Can't schema be specified as default value during connection, or can I > set the schema before I send the query? You can change the database so that everybody connecting to it will use that schema: ALTER DATABASE your_db SET search_path = 'schema_1'; You can do that per-user, too: ALTER DATABASE username SET search_path = 'schema_1'; You can also change it in the application, by sending SET search_path TO 'schema_1'; There are other options too, but that should suffice. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support