0% found this document useful (0 votes)
109 views

PSQLQuickRef PDF

Uploaded by

SergioLoest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

PSQLQuickRef PDF

Uploaded by

SergioLoest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PSQL Quick Reference 

General  Informational 
\copyright  show PostgreSQL usage and distribution terms  (options: S = show system objects, + = additional detail) 
\g [FILE] or ;  execute query (and send results to file or |pipe)  \d[S+]  list tables, views, and sequences 
\h [NAME]  help on syntax of SQL commands, * for all commands  \d[S+] NAME  describe table, view, sequence, or index 
\q  quit psql  \da[S] [PATTERN]  list aggregates 
\db[+] [PATTERN]  list tablespaces 
Query Buffer  \dc[S] [PATTERN]  list conversions 
\e [FILE]  edit the query buffer (or file) with external editor  \dC [PATTERN]  list casts 
\ef [FUNCNAME]  edit function definition with external editor  \ dd[ S]  [P ATTER N]  show comments on objects 
\p  show the contents of the query buffer  \ddp [PATTERN]  list default privileges 
\r  reset (clear) the query buffer  \dD[S] [PATTERN]  list domains 
\s [FILE]  display history or save it to file  \des[+] [PATTERN]  list foreign servers 
\w FILE  write query buffer to file  \deu[+] [PATTERN]  list user mappings 
\dew[+] [PATTERN]  list foreign­data wrappers 
Input/Output  \df[antw][S+] [PATTERN]  list [only agg/normal/trigger/window] functions 
\copy ...  perform SQL COPY with data stream to the client  \ dF[ +]  [P ATTER N]  list text search configurations 
host  \ dFd [+]  [ PATTE RN]  list text search dictionaries 
\echo [STRING]  write string to standard output  \ dFp [+]  [ PATTE RN]  list text search parsers 
\i FILE  execute commands from file  \dg[+] [PATTERN]  list roles (groups) 
\o [FILE]  send all query results to file or |pipe  \ dFt [+]  [ PATTE RN]  list text search templates 
\qecho [STRING]  write string to query output stream (see ​ \o​ )  \ di[ S+]  [ PATTE RN]  list indexes 
\dl  list large objects, same as \lo_list 
\do[S] [PATTERN]  list operators 
Formatting  \dp [PATTERN]  list table, view, and sequence access privileges 
\a  toggle between unaligned and aligned output mode  \dr[S+] [PATTERN]  list foreign tables 
\C [STRING]  set table title, or unset if none  \drds [PATTERN1 [PATTERN2]]  list per­database role settings 
\f [STRING]  show or set field separator for unaligned query output  \ds[S+] [PATTERN]  list sequences 
\H  toggle HTML output mode  \dt[S+] [PATTERN]  list tables 
\pset NAME [VALUE]  set table output option (​ NAME​
 ​
:= {format | border  \dT[S+] [PATTERN]  list data types 
| expanded | fieldsep | footer | null | 
\du[+] [PATTERN]  list roles (users) 
numericlocale | recordsep | tuples_only | 
\dv[S+] [PATTERN]  list views 
title | tableattr | pager}​ ) 
\dx [PATTERN]  list external tables 
\t [on|off]  show only rows 
\l[+]  list all databases 
\T [STRING]  set HTML <table> tag attributes, or unset if none 
\z [PATTERN]  same as \dp 
\x [on|off]  toggle expanded output 
Operating System 
Connection  \cd [DIR]  change the current working directory 
\c[onnect] [DBNAME |  connect to new database  \timing [on|off]  toggle timing of commands 
­​
 USER | ­​  HOST | ­​
 PORT |  \! [COMMAND]  execute command in shell or start interactive 
­]   shell 
\encoding [ENCODING]  show or set client encoding 
\password [USERNAME]  securely change the password for a user 
Large Objects 
\conninfo  display information about current connection 
\lo_export LOBOID FILE  Large Object Operations 
MENT] 
\lo_import FILE [COM​
Variables  \lo_list 
\prompt [TEXT] NAME  prompt user to set internal variable  \lo_unlink LOBOID 
\set [NAME [VALUE]]  set internal variable, or list all if no parameters   
\unset NAME  unset (delete) internal variable 
 
Rev. A01 

You might also like