Linux client connects to the corresponding parameters of the pg library

1. Command parameter
-c command: Specify psql to execute an SQL command (enclosed in double quotes) and exit after execution.
-d database name: the name of the database to be connected.
-f filename: Use the data in the file as the input source of the command. After processing the file, psql ends and exits.
-h hostname: declares the hostname of the running server
-l: lists all available databases and then exits.
-L filename: In addition to the normal output source, output all query records to a file.
-o filename: Redirect all query output to a file.
-p port: Specify the listening port of the PostgreSQL server.
-q: Let psql quietly perform the tasks it handles. By default psql will print a welcome and many other messages.
-U username: Use the specified user instead of the default user to establish a connection with the database.
-V: Output version information, and then exit
2. Built-in command
#\c Database name: Switch database, equivalent to mysql's use dbname
#\q: Exit psql
#\l: List databases, equivalent to mysql's show databases
#\dt : List tables, equivalent to show tables
#\d Table name: View table structure, equivalent to desc tblname
#\conninfo: Display relevant information about the current connection
#\timing: Switch the command timing switch (currently off)
#! [Command] : Execute commands in the shell or open a shell
#\a: Switch between non-aligned mode and aligned mode
#\C [Title]: Set the data table title or cancel
#\f [Separator]: Display or set the column delimiter in non-aligned mode
#\ H: Switch the HTML output mode (currently off)
#\o [file name]: Write all query results to the file or pipe "pipe"
#\db [database name]: List the table space
#\du [database name] ]: List roles
#\p: Display the contents of the query cache, that is, print the previous SQL command
#\cd [directory]: Change the current working directory
#\i File name: Execute the command from the file
#\echo [Word string]: Write the string to the standard output
#\w [file name]: Output the previous SQL command to the specified file or pipe "pipe"
#\g [file name]: Output the result of the previous SQL command to Specify file or pipe "pipe"

#\o [文件名]    :将后面的全部查询结果输出到指定文件或管道"pipe",直到遇到下一个单独的 #\o

#\unset 变量名称 : 清空(删除)内部变量

#\encoding [编码名称] :显示或设定客户端编码

#\password [用户名称] :安全地为用户改变口令   
#\prompt [变量名称]   :提示用户设定内部变量 
#\set [变量名称 [变量值]] :设定内部,若无参数则列出全部变量

Guess you like

Origin blog.csdn.net/weixin_45163291/article/details/131051552