Comments(0) » | Add Comment » | Permalink » | Blog Home Page » Blog Post

Posted: 2007-01-08 08:43:41
Tags: sql   postgreSQL   rdbms   technical  
PostgreSQL - psql - Some Indispensable Commands

I just keep on forgetting some of the following useful commands when using psql, simply because they are just too darn cryptic. Might as well etch them on this blog for future recall purpose in order to avoid performing the glorious art of indefinite google query formulations and scouring the postgreSQL documentation to obtain these commands.

  • See all the available tables (includes base table & views) in your database:
    select * from information_schema.tables;
  • See the definitions  of your views (provided you're using public schema) in the database:
    select * from information_schema.views where table_schema='public';
  • See all the sequences in your database:
    select * from information_schema.sequences;
  • See current activities on the database:
    select * from pg_stat_activity;
  • See access privileges or a quick overview of tables, views and sequences in your database, a psql shortcut:
    \z
  • See table, views or sequence properties in details, a psql shortcut:
    \d [table|views|sequence name]
  • See role properties of users in the database
    select * from pg_roles;

Happy Querying!!

 

Comments

No comments posted for this post

Comment Form

Name: (Required)
Email:
Website:
Captcha Text: (Required)
Your Comments: (Required)
Try Me