Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Sina

Technical User
Jan 2, 2001
309
0
0
CA
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.
 
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)
Nothing Runs Like the Fox
 
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..."
(
 
Thanks so much for your wonderfull help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top