Re: [GENERAL] Switch database inside psql?

From: Maarten Boekhold <maartenb(at)dutepp2(dot)et(dot)tudelft(dot)nl>
To: Richard Lynch <lynch(at)lscorp(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Switch database inside psql?
Date: 1998-08-07 09:10:29
Views: Raw Message | Whole Thread | Download mbox | Resend email
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.


| TU Delft, The Netherlands, Faculty of Information Technology and Systems |
| Department of Electrical Engineering |
| Computer Architecture and Digital Technique section |
| M(dot)Boekhold(at)et(dot)tudelft(dot)nl |

In response to


Browse pgsql-general by date

  From Date Subject
Next Message Tom Good 1998-08-07 12:42:05 Re: [GENERAL] Switch database inside psql?
Previous Message Richard Lynch 1998-08-06 23:45:04 Switch database inside psql?