Re: [GENERAL] Switch database inside psql?

Maarten Boekhold <maartenb@dutepp2.et.tudelft.nl>

From: Maarten Boekhold <maartenb@dutepp2.et.tudelft.nl>
To: Richard Lynch <lynch@lscorp.com>
Cc: pgsql-general@postgreSQL.org
Date: 1998-08-07T09:10:29Z
Lists: pgsql-general
On Thu, 6 Aug 1998, Richard Lynch wrote:

> I'd like to have a single file.sql that will create the same database and
> some tables on several different systems.  Is it possible to 'switch' to a
> different database after one does the create database?  So that tables
> created would go in the new database and not template1?  Or does this
> already happen and is just not documented?...  I'd be guessing a big no on
> the latter, since the psql prompt still says 'template1' after I create a
> database...

use '\connect database name' from witnin psql. Maybe you have to include a 
username, don't know.
 
> I get an error message when I try createdb from the command line, but once

Probably because of authentication problems. You can set the PGUSER and 
PGPASSWORD environment variables to use authentication always (ie. you 
don;t have to specify a '-u' switch anymore).

> I've done psql -u, I can do it, so I guess if I had to do this from some
> sort of Perl/sed/awk/??? script (none of which I could write anyway), I'd
> need to know how to convince createdb that I *am* a valid database-creator,
> by golly.

Maarten

_____________________________________________________________________________
| TU Delft, The Netherlands, Faculty of Information Technology and Systems  |
|                   Department of Electrical Engineering                    |
|           Computer Architecture and Digital Technique section             |
|                          M.Boekhold@et.tudelft.nl                         |
-----------------------------------------------------------------------------