Re: Creating a table in a different database

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Simon Dale" <sdale(at)rm(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Creating a table in a different database
Date: 2006-06-06 08:57:50
Message-ID: bf05e51c0606060157y2dca378cs6c347aeeff85f550@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)rm(dot)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?
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Callis 2006-06-06 12:32:16 Re: postgres dying
Previous Message Simon Dale 2006-06-06 07:27:02 Creating a table in a different database