微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PostgreSQL数据库psql的使用之二


[postgres@rhel73 data]$ psql -l       ------->>>查询认cluster下的所有数据库,并退出
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)



[postgres@rhel73 data]$ psql -xl     ------->>>以扩展的形式查询cluster下的所有数据库,并退出
List of databases
-[ RECORD 1 ]-----+----------------------
Name              | postgres
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges | 
-[ RECORD 2 ]-----+----------------------
Name              | template0
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges | =c/postgres          +
                  | postgres=CTc/postgres
-[ RECORD 3 ]-----+----------------------
Name              | template1
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges | =c/postgres          +
                  | postgres=CTc/postgres
-[ RECORD 4 ]-----+----------------------
Name              | test
Owner             | postgres
Encoding          | UTF8
Collate           | en_US.UTF-8
Ctype             | en_US.UTF-8
Access privileges | 



[postgres@rhel73 data]$ psql --help ------------>>>>psql的帮助命令.
psql is the Postgresql interactive terminal.


Usage:
  psql [OPTION]... [dbnAME [USERNAME]]


General options:
  -c,--command=COMMAND    run only single command (sql or internal) and exit
  -d,--dbname=dbnAME      database name to connect to (default: "postgres")
  -f,--file=FILENAME      execute commands from file,then exit
  -l,--list               list available databases,then exit
  -v,--set=,--variable=NAME=VALUE
                           set psql variable NAME to VALUE
                           (e.g.,-v ON_ERROR_STOP=1)
  -V,--version            output version information,then exit
  -X,--no-psqlrc          do not read startup file (~/.psqlrc)
  -1 ("one"),--single-transaction
                           execute as a single transaction (if non-interactive)
  -?,--help[=options]     show this help,then exit
      --help=commands      list backslash commands,then exit
      --help=variables     list special variables,then exit


Input and output options:
  -a,--echo-all           echo all input from script
  -b,--echo-errors        echo Failed commands
  -e,--echo-queries       echo commands sent to server
  -E,--echo-hidden        display queries that internal commands generate
  -L,--log-file=FILENAME  send session log to file
  -n,--no-readline        disable enhanced command line editing (readline)
  -o,--output=FILENAME    send query results to file (or |pipe)
  -q,--quiet              run quietly (no messages,only query output)
  -s,--single-step        single-step mode (confirm each query)
  -S,--single-line        single-line mode (end of line terminates sql command)


Output format options:
  -A,--no-align           unaligned table output mode
  -F,--field-separator=STRING
                           field separator for unaligned output (default: "|")
  -H,--html               HTML table output mode
  -P,--pset=VAR[=ARG]     set printing option VAR to ARG (see \pset command)
  -R,--record-separator=STRING
                           record separator for unaligned output (default: newline)
  -t,--tuples-only        print rows only
  -T,--table-attr=TEXT    set HTML table tag attributes (e.g.,width,border)
  -x,--expanded           turn on expanded table output
  -z,--field-separator-zero
                           set field separator for unaligned output to zero byte
  -0,--record-separator-zero
                           set record separator for unaligned output to zero byte


Connection options:
  -h,--host=HOSTNAME      database server host or socket directory (default: "local socket")
  -p,--port=PORT          database server port (default: "5432")
  -U,--username=USERNAME  database user name (default: "postgres")
  -w,--no-password        never prompt for password
  -W,--password           force password prompt (should happen automatically)


For more information,type "\?" (for internal commands) or "\help" (for sql
commands) from within psql,or consult the psql section in the Postgresql
documentation.

Report bugs to <pgsql-bugs@postgresql.org>.
[postgres@rhel73 data]$ psql -V    -------------->>>查看psql版本的命令.
psql (Postgresql) 9.6.0
[postgres@rhel73 data]$ 

原文地址:https://www.jb51.cc/postgresql/194072.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐