Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] Switch database inside psql?

From: Tom Good <tomg(at)nrnet(dot)org>
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 12:42:05
Message-ID: Pine.LNX.3.95.980807082624.1047A-100000@mailhost.nrnet.org (view raw or flat)
Thread:
Lists: pgsql-general
> On Thu, 6 Aug 1998, Richard / Maarten 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.

Hello Rich, goedemorgen Maarten... 

Just a footnote, as a clumsy typist I prefer the short form: \c new_db_name
BTW, one can do this from a dump file.  Or you can make calls from perl
scripts...I like to build things both ways.  

I often do psql -e db < makedb.sql  (when I'm too lazy to connect to 
a db and run \i...)

> > 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.

Rich, I'd be very pleased to be able to assist with perl - if you like.
As a guy accustomed to procedural languages (PROGRESS, et al.) I am rather
fond of Edmund Mergl's dbd-Pg module.  I use perl as a sort of 4GL.
(Rather nifty, if functions like a 4GL but has syntax reminiscent of ESQL/C.)

All of the code we develop here is public domain stuff so I'd be happy
to pass along whatever is of interest, including my dba.pl script.
Just say the word, big guy...I owe ya.  ;-)

 Cheers,
 Tom

    ----------- Sisters of Charity Medical Center ----------
                    Department of Psychiatry
                              ----     
 Thomas Good, System Administrator            <tomg(at)q8(dot)nrnet(dot)org>
 North Richmond CMHC/Residential Services     Phone: 718-354-5528
 75 Vanderbilt Ave, Quarters 8                Fax:   718-354-5056
 Staten Island, NY   10304                    www.panix.com/~ugd
                              ----     
 Powered by PostgreSQL 6.3.2 / Perl 5.004 / DBI-0.91::DBD-PG-0.69 


In response to

pgsql-general by date

Next:From: David Ben-YaacovDate: 1998-08-07 13:25:10
Subject: Re: [GENERAL] Design
Previous:From: Maarten BoekholdDate: 1998-08-07 09:10:29
Subject: Re: [GENERAL] Switch database inside psql?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group