Re: [GENERAL] Switch database inside psql?

Поиск
Список
Период
Сортировка
От Tom Good
Тема Re: [GENERAL] Switch database inside psql?
Дата
Msg-id Pine.LNX.3.95.980807082624.1047A-100000@mailhost.nrnet.org
обсуждение исходный текст
Ответ на Re: [GENERAL] Switch database inside psql?  (Maarten Boekhold <maartenb@dutepp2.et.tudelft.nl>)
Список 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@q8.nrnet.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


В списке pgsql-general по дате отправления:

Предыдущее
От: Maarten Boekhold
Дата:
Сообщение: Re: [GENERAL] Switch database inside psql?
Следующее
От: "David Ben-Yaacov"
Дата:
Сообщение: Re: [GENERAL] Design