×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Newbie Questions (need your help) easy questions for you gurus.

Newbie Questions (need your help) easy questions for you gurus.

Newbie Questions (need your help) easy questions for you gurus.

(OP)
Hello everyone.
I have couple of newbie questions, if you could kindly help.
here they are:
1. what is the command to get a list of the
database and tables in each database in postgres?
2. How do I get a list of all the primary keys on a table ?
3. How do I get a list of all the foriegn keys on a table ?
4. How do I get a list of all the indexes on a table ?
5. How do I get a description on a table in postgres (like field defenitions).
6. How do I find out the list of users with access to a specific table / database (get user privilages on each db)?
7. How do I get a list of all the valid table fileds TYPES in postgres?

thank you all very much.

RE: Newbie Questions (need your help) easy questions for you gurus.

Hi Sina,

If you have a windows box in the same network as your postgres database, the easy way is to download pgAdmin II.  It is a GUI that will give you all the info you want and lots more with easy point and click functionality.


If you have a stand alone Linux System, give phpPgAdmin a try.  It is a browser base tool that can be used with your Apache Web Server.  It is written in php so you would need to download php and install it and configure you apache web server.  PhpPgAdmin is a little more difficult to set up, but once done it can be used as easily from a remote location and locally.  I'm sure there are folks here that can help you set up phpPgAdmin.

Both of these tools make database administration of a postgres server easy.

Also, you might take a look at the postgres html doc. as it has all the command needed to accomplish what you want.  However, obtaining the info from an command prompt that is connected to a postgres server is the hard way to do it.



Leland F. Jackson, CPA
Software - Master (TM)
http://www.smvfp.com
Nothing Runs Like the Fox

RE: Newbie Questions (need your help) easy questions for you gurus.

Here is a list of the system catalog tables.  You can query them just like normal tables.  These tables are where PostgreSQL stores information about the other tables, fields, indexes, etc.

http://www.postgresql.org/idocs/index.php?catalogs.html

RE: Newbie Questions (need your help) easy questions for you gurus.

When logged into the PostgreSQL command-line (psql [databasename]), there are a number of useful commands that start with a slash:

>1. what is the command to get a list of the
database and tables in each database in postgres?
  \l  (or 'psql -l' from the terminal)

>2. How do I get a list of all the primary keys on a table ?
>3. How do I get a list of all the foriegn keys on a table ?
>4. How do I get a list of all the indexes on a table ?
>5. How do I get a description on a table in postgres (like field defenitions).
  \d tablename will give you all table attribs

 or, to be more specific:

  \dt Show Tables
  \dT list datatypes
  \df list functions
  \di list indexes
  \dv list views

>6. How do I find out the list of users with access to a specific table / database (get user privilages on each db)?
  \dp [object name]

>7. How do I get a list of all the valid table fileds TYPES in postgres?
  See \dT above

Try \? from inside the psql command line for additional info, and also try psql --help for more commandline switches.

-------------------------------------------

"Now, this might cause some discomfort..."
(http://www.wired.com/news/politics/0,1283,51274,00.html)

RE: Newbie Questions (need your help) easy questions for you gurus.

(OP)
Thanks so much for your wonderfull help

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close