![]() Note: This mode is provided for those who insist on it, but you are not necessarily encouraged to use it. Runs in single-line mode where a newline terminates an SQL command, as a semicolon does. That means the user is prompted before each command is sent to the server, with the option to cancel execution as well. This is equivalent to the \pset recordsep command. ![]() Use separator as the record separator for unaligned output. This is equivalent to setting the variable QUIET to on. ![]() If this option is used, none of this happens. By default, it prints welcome messages and various informational output. Specifies that psql should do its work quietly. For example, to set the output format to LaTeX, you could write -P format=latex. Note that here you have to separate name and value with an equal sign instead of a space. Specifies printing options, in the style of \pset. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432. Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. This can be useful to turn off tab expansion when cutting and pasting. nĭo not use Readline for line editing and do not use the command history. Write all query output into file filename, in addition to the normal output destination. This is similar to the meta-command \list. Other non-connection options are ignored. This is equivalent to \pset format html or the \H command. If the value begins with a slash, it is used as the directory for the Unix-domain socket. Specifies the host name of the machine on which the server is running. This is equivalent to \pset fieldsep or \f. Use separator as the field separator for unaligned output. On the other hand, the variant using the shell's input redirection is (in theory) guaranteed to yield exactly the same output you would have received had you entered everything by hand. There is also a slight chance that using this option will reduce the start-up overhead. In general, both will do what you expect, but using -f enables some nice features such as error messages with line numbers. Using this option is subtly different from writing psql < filename. Note however that Readline is not used in this case (much as if -n had been specified). If filename is - (hyphen), then standard input is read until an EOF indication or \q meta-command. This is in many ways equivalent to the meta-command \i. After the file is processed, psql terminates. Use the file filename as the source of commands instead of reading commands interactively. This is equivalent to setting the variable ECHO_HIDDEN to on. You can use this to study psql's internal operations. ![]() EĮcho the actual queries generated by \d and other backslash commands. This is equivalent to setting the variable ECHO to queries. eĬopy all SQL commands sent to the server to standard output as well. ![]() If so, connection string parameters will override any conflicting command line options. This is equivalent to specifying dbname as the first non-option argument on the command line. Specifies the name of the database to connect to. It's better to feed multiple commands to psql's standard input, either using echo as illustrated above, or via a shell here-document, for example: psql <<EOF Also, only the result of the last SQL command is returned.īecause of these legacy behaviors, putting more than one command in the -c string often has unexpected results. This is different from the behavior when the same string is fed to psql's standard input. If the command string contains multiple SQL commands, they are processed in a single transaction, unless there are explicit BEGIN/ COMMIT commands included in the string to divide it into multiple transactions. To achieve that, you could pipe the string into psql, for example: echo '\x \\ SELECT * FROM foo ' | psql. Thus you cannot mix SQL and psql meta-commands with this option. Start-up files ( psqlrc and ~/.psqlrc) are ignored with this option.Ĭommand must be either a command string that is completely parsable by the server (i.e., it contains no psql-specific features), or a single backslash command. Specifies that psql is to execute one command string, command, and then exit. This is equivalent to setting the variable ECHO to errors. Print failed SQL commands to standard error output. (The default output mode is otherwise aligned.) -b (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all. Print all nonempty input lines to standard output as they are read. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |