Monday, September 5, 2011

Command for postgresql

Hello Guys,
         Postgres is one of the best database which i ever used. There are the some basic commands which you will use during psql session.

psql is the postgres sql console session.

psql -U <username>  to enter in postgres console session.

Basic commands which you run on psql prompt:

 \h                   - Help with SQL commands
 \c [DBNAME]    - Connect with database              
 \d [NAME]        - Describe table, index, sequence or view
 \d{t|i|s|v|S} [PATTERN]
                       - List tables/indexes/sequences/views/system tables
 \da [PATTERN]  - List aggregate functions
 \db [PATTERN]  - List tablespaces
 \dc [PATTERN]  - List conversions
 \dC                 - List casts
 \dd [PATTERN] - Show comment for object
 \dD [PATTERN] - List domains
 \df [PATTERN]  - List functions
 \dg [PATTERN] - List groups
 \dn [PATTERN] - List schemas 
 \do [NAME]      - List operators
 \dl                  - List large objects
 \dp [PATTERN] - List table, view, and sequence access privilege
 \dT [PATTERN] - List data types
 \du [PATTERN] - List users
 \l                   - List all databases
 \z [PATTERN]   - List table, view, and sequence access privilege
 \q                  - Quit
  \?                 - Help with psql commands

Query browser command
pg_tables - List all the tables
pg_namespace - List all the schemas (namespaces)
pg_views - List all the views
pg_index - List all index

Here are lots of other commands. If you want to require more information about postgres follow http://www.postgresql.org/.

No comments:

Post a Comment