X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D0CF29FA315 for ; Tue, 6 Jun 2006 05:58:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 17031-03 for ; Tue, 6 Jun 2006 05:57:52 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.175]) by postgresql.org (Postfix) with ESMTP id E7ADD9FA111 for ; Tue, 6 Jun 2006 05:57:51 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so1618078ugf for ; Tue, 06 Jun 2006 01:57:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=W2AWu5MQPAAZb3JLwGS6ALY7Egz0LPDEnZX5Mp7f12qvj4TZFN+6Zl6x+eOpHnrtZ54zOTL2ETfl9iMiSefSsYhw49qlIEnhfT3IaqCpWI1CFHNO6QCu5Ip3Akxg6oyQYEBypUhVVvk9M+NPJxDCmU0ufZkbwSC9OS743xA72Dk= Received: by 10.67.103.7 with SMTP id f7mr4263218ugm; Tue, 06 Jun 2006 01:57:50 -0700 (PDT) Received: by 10.67.20.12 with HTTP; Tue, 6 Jun 2006 01:57:50 -0700 (PDT) Message-ID: Date: Tue, 6 Jun 2006 03:57:50 -0500 From: "Aaron Bono" To: "Simon Dale" Subject: Re: Creating a table in a different database Cc: pgsql-admin@postgresql.org In-Reply-To: <416F947BF5BA9E40B5F9AA649422212E078BA5AE@ex-mail2.internal.rmplc.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_13122_5973687.1149584270298" References: <416F947BF5BA9E40B5F9AA649422212E078BA5AE@ex-mail2.internal.rmplc.net> X-Google-Sender-Auth: 1916089940cb395a X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/22 X-Sequence-Number: 21984 ------=_Part_13122_5973687.1149584270298 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I just create .sql files with all the commands I want to run and then run them in psql with the "\i myscript.sql". If you want to switch databases in psql, use the \c[onnect] [DBNAME|- [USER]] . For example "\c my_database my_user". I recommend going into psql and typing in "\?" for a list of common commands you can use. -Aaron On 6/6/06, Simon Dale wrote: > > Hi, > > > > The CREATE TABLE command creates a table in the current database. What I > want to achieve is a SQL script that will create a database and a user and > then create some tables and functions in the new database. > > > > Is it possible to do this in a single SQL file, and if so, how do I change > the database part way through the file to create the tables in the correct > database? > ------=_Part_13122_5973687.1149584270298 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I just create .sql files with all the commands I want to run and then run them in psql with the "\i myscript.sql".

If you want to switch databases in psql, use the \c[onnect] [DBNAME|- [USER]] .  For example "\c my_database my_user".

I recommend going into psql and typing in "\?" for a list of common commands you can use.

-Aaron

On 6/6/06, Simon Dale < sdale@rm.com> wrote:

Hi,

 

The CREATE TABLE command creates a table in the current database. What I want to achieve is a SQL script that will create a database and a user and then create some tables and functions in the new database.

 

Is it possible to do this in a single SQL file, and if so, how do I change the database part way through the file to create the tables in the correct database?


------=_Part_13122_5973687.1149584270298--