运维联盟俱乐部

 找回密码
 立即注册
查看: 2741|回复: 0

pg参考之psql快捷命令

[复制链接]
  • TA的每日心情
    开心
    2023-8-9 11:05
  • 发表于 2020-5-25 11:21:45 | 显示全部楼层 |阅读模式
    1. zhyu=# \?
    2. General
    3.   \copyright             show PostgreSQL usage and distribution terms
    4.   \crosstabview [COLUMNS] execute query and display results in crosstab
    5.   \errverbose            show most recent error message at maximum verbosity
    6.   \g [FILE] or ;         execute query (and send results to file or |pipe)
    7.   \gdesc                 describe result of query, without executing it
    8.   \gexec                 execute query, then execute each value in its result
    9.   \gset [PREFIX]         execute query and store results in psql variables
    10.   \gx [FILE]             as \g, but forces expanded output mode
    11.   \q                     quit psql
    12.   \watch [SEC]           execute query every SEC seconds

    13. Help
    14.   \? [commands]          show help on backslash commands
    15.   \? options             show help on psql command-line options
    16.   \? variables           show help on special variables
    17.   \h [NAME]              help on syntax of SQL commands, * for all commands

    18. Query Buffer
    19.   \e [FILE] [LINE]       edit the query buffer (or file) with external editor
    20.   \ef [FUNCNAME [LINE]]  edit function definition with external editor
    21.   \ev [VIEWNAME [LINE]]  edit view definition with external editor
    22.   \p                     show the contents of the query buffer
    23.   \r                     reset (clear) the query buffer
    24.   \s [FILE]              display history or save it to file
    25.   \w FILE                write query buffer to file

    26. Input/Output
    27.   \copy ...              perform SQL COPY with data stream to the client host
    28.   \echo [STRING]         write string to standard output
    29.   \i FILE                execute commands from file
    30.   \ir FILE               as \i, but relative to location of current script
    31.   \o [FILE]              send all query results to file or |pipe
    32.   \qecho [STRING]        write string to query output stream (see \o)

    33. Conditional
    34.   \if EXPR               begin conditional block
    35.   \elif EXPR             alternative within current conditional block
    36.   \else                  final alternative within current conditional block
    37.   \endif                 end conditional block

    38. Informational
    39.   (options: S = show system objects, + = additional detail)
    40.   \d[S+]                 list tables, views, and sequences
    41.   \d[S+]  NAME           describe table, view, sequence, or index
    42.   \da[S]  [PATTERN]      list aggregates
    43.   \dA[+]  [PATTERN]      list access methods
    44.   \db[+]  [PATTERN]      list tablespaces
    45.   \dc[S+] [PATTERN]      list conversions
    46.   \dC[+]  [PATTERN]      list casts
    47.   \dd[S]  [PATTERN]      show object descriptions not displayed elsewhere
    48.   \dD[S+] [PATTERN]      list domains
    49.   \ddp    [PATTERN]      list default privileges
    50.   \dE[S+] [PATTERN]      list foreign tables
    51.   \det[+] [PATTERN]      list foreign tables
    52.   \des[+] [PATTERN]      list foreign servers
    53.   \deu[+] [PATTERN]      list user mappings
    54.   \dew[+] [PATTERN]      list foreign-data wrappers
    55.   \df[anptw][S+] [PATRN] list [only agg/normal/procedures/trigger/window] functions
    56.   \dF[+]  [PATTERN]      list text search configurations
    57.   \dFd[+] [PATTERN]      list text search dictionaries
    58.   \dFp[+] [PATTERN]      list text search parsers
    59.   \dFt[+] [PATTERN]      list text search templates
    60.   \dg[S+] [PATTERN]      list roles
    61.   \di[S+] [PATTERN]      list indexes
    62.   \dl                    list large objects, same as \lo_list
    63.   \dL[S+] [PATTERN]      list procedural languages
    64.   \dm[S+] [PATTERN]      list materialized views
    65.   \dn[S+] [PATTERN]      list schemas
    66.   \do[S]  [PATTERN]      list operators
    67.   \dO[S+] [PATTERN]      list collations
    68.   \dp     [PATTERN]      list table, view, and sequence access privileges
    69.   \dP[itn+] [PATTERN]    list [only index/table] partitioned relations [n=nested]
    70.   \drds [PATRN1 [PATRN2]] list per-database role settings
    71.   \dRp[+] [PATTERN]      list replication publications
    72.   \dRs[+] [PATTERN]      list replication subscriptions
    73.   \ds[S+] [PATTERN]      list sequences
    74.   \dt[S+] [PATTERN]      list tables
    75.   \dT[S+] [PATTERN]      list data types
    76.   \du[S+] [PATTERN]      list roles
    77.   \dv[S+] [PATTERN]      list views
    78.   \dx[+]  [PATTERN]      list extensions
    79.   \dy     [PATTERN]      list event triggers
    80.   \l[+]   [PATTERN]      list databases
    81.   \sf[+]  FUNCNAME       show a function's definition
    82.   \sv[+]  VIEWNAME       show a view's definition
    83.   \z      [PATTERN]      same as \dp

    84. Formatting
    85.   \a                     toggle between unaligned and aligned output mode
    86.   \C [STRING]            set table title, or unset if none
    87.   \f [STRING]            show or set field separator for unaligned query output
    88.   \H                     toggle HTML output mode (currently off)
    89.   \pset [NAME [VALUE]]   set table output option
    90.                          (border|columns|csv_fieldsep|expanded|fieldsep|
    91.                          fieldsep_zero|footer|format|linestyle|null|
    92.                          numericlocale|pager|pager_min_lines|recordsep|
    93.                          recordsep_zero|tableattr|title|tuples_only|
    94.                          unicode_border_linestyle|unicode_column_linestyle|
    95.                          unicode_header_linestyle)
    96.   \t [on|off]            show only rows (currently off)
    97.   \T [STRING]            set HTML <table> tag attributes, or unset if none
    98.   \x [on|off|auto]       toggle expanded output (currently off)

    99. Connection
    100.   \c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}
    101.                          connect to new database (currently "zhyu")
    102.   \conninfo              display information about current connection
    103.   \encoding [ENCODING]   show or set client encoding
    104.   \password [USERNAME]   securely change the password for a user

    105. Operating System
    106.   \cd [DIR]              change the current working directory
    107.   \setenv NAME [VALUE]   set or unset environment variable
    108.   \timing [on|off]       toggle timing of commands (currently off)
    109.   \! [COMMAND]           execute command in shell or start interactive shell

    110. Variables
    111.   \prompt [TEXT] NAME    prompt user to set internal variable
    112.   \set [NAME [VALUE]]    set internal variable, or list all if no parameters
    113.   \unset NAME            unset (delete) internal variable

    114. Large Objects
    115.   \lo_export LOBOID FILE
    116.   \lo_import FILE [COMMENT]
    117.   \lo_list
    118.   \lo_unlink LOBOID      large object operations
    复制代码



    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    运维联盟俱乐部 ( 冀ICP备19036648号 )

    GMT+8, 2024-5-3 00:20 , Processed in 0.048405 second(s), 21 queries , Gzip On.

    Powered by Discuz! X3.4

    © 2001-2023 Discuz! Team.

    快速回复 返回顶部 返回列表