Re: How do I write a script that .....

From: "Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com>
To: "David Brusowankin" <david(at)brusowankin(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org, pgsql-novice-owner(at)postgresql(dot)org
Subject: Re: How do I write a script that .....
Date: 2002-11-26 19:17:44
Message-ID: OF88FA7455.DCF35D59-ON86256C7D.00691FA9@ipaper.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


1. if you are using shell script, you could just do: psql -l|grep
"<dbname_you_are_checking> " . Then check the return value of grep. If
it's 0 it found the database, if it's 1...well you know what happened then.
Notice the space after the dbname inside the double quotes...it's an
attempt to avoid returning something if you were looking for foo and only
foobar acutally existed. You could do this better in Perl.

2. \c <dbname> (from psql prompt)

3. \d <tablename> (from psql prompt)

see \? question for a lot more options.

regards,

Devinder Rajput
Stores Division Corporate Offices
Chicago, IL
(773) 442-6474


"David Brusowankin"
<david(at)brusowankin(dot)net To: pgsql-novice(at)postgresql(dot)org
> cc:
Sent by: Subject: [NOVICE] How do I write a script that .....
pgsql-novice-owner(at)pos
tgresql.org


11/25/2002 08:28 PM

A couple of newbie questions here:

1. How do I write a script that creates a database if it doesn't exist,
but if it does, then check to see if the tables are there ?

2. How do I change databases from within psql ?

3. How do I list the tables in a database ?

Please respond directly vie email (david(at)cenozoa(dot)com).

Thanks so much for any help.

David
--
____________________________
David Brusowankin
Voice: 201.287.1527
Email: david(at)brusowankin(dot)net

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-11-27 03:48:34 Re: BusinessWeek - Postgres mentioned
Previous Message D. Duccini 2002-11-26 18:56:54 Re: What is the maximum amount of connections a postgres