Re: How do I write a script that ..... - Mailing list pgsql-novice

From Devinder K Rajput
Subject Re: How do I write a script that .....
Date
Msg-id OF88FA7455.DCF35D59-ON86256C7D.00691FA9@ipaper.com
Whole thread Raw
In response to How do I write a script that .....  (David Brusowankin <david@brusowankin.net>)
List 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@brusowankin.net        To:       pgsql-novice@postgresql.org
                    
                      >                             cc:
                    
                      Sent by:                      Subject:  [NOVICE] How do I write a script that .....
                    
                      pgsql-novice-owner@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@cenozoa.com).

Thanks so much for any help.

David
--
____________________________
David Brusowankin
Voice: 201.287.1527
Email: david@brusowankin.net


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







pgsql-novice by date:

Previous
From: "D. Duccini"
Date:
Subject: Re: What is the maximum amount of connections a postgres
Next
From: Tom Lane
Date:
Subject: Re: BusinessWeek - Postgres mentioned