![]() ![]() Set record separator for unaligned output to zero byte Set field separator for unaligned output to zero byte x, -expanded turn on expanded table output T, -table-attr=TEXT set HTML table tag attributes (e.g., width, border) Record separator for unaligned output (default: newline) P, -pset=VAR set printing option VAR to ARG (see \pset command) csv CSV (Comma-Separated Values) table output modeįield separator for unaligned output (default: "|") A, -no-align unaligned table output mode S, -single-line single-line mode (end of line terminates SQL command) s, -single-step single-step mode (confirm each query) q, -quiet run quietly (no messages, only query output) o, -output=FILENAME send query results to file (or |pipe) n, -no-readline disable enhanced command line editing (readline) L, -log-file=FILENAME send session log to file E, -echo-hidden display queries that internal commands generate e, -echo-queries echo commands sent to server help=variables list special variables, then exit help=commands list backslash commands, then exit X, -no-psqlrc do not read startup file (~/.psqlrc)Įxecute as a single transaction (if non-interactive) V, -version output version information, then exit l, -list list available databases, then exit f, -file=FILENAME execute commands from file, then exit d, -dbname=DBNAME database name to connect to (default: "barney") c, -command=COMMAND run only single command (SQL or internal) and exit Result: psql is the PostgreSQL interactive terminal. You can type the following to return the help list: psql -help Now that we’ve connected to the music database, we can run SQL queries against it.Įxample: ~ % psql -d music -U barney Here it is again, but this time showing the full terminal input and output: ~ % psql -d music -U barney This connects to the music database using the user called barney. Here’s an example of using psql to connect to a PostgreSQL database: psql -d music -U barney So you can simply open up a terminal window and type psql, or you can type psql, followed an option. The syntax for psql goes like this: psql. For example, you can specify a database to connect to, the user name, a file name to read, and much more. Enter other shell like features to help with administration, scripting, etc.Meta-commands can be useful for administration and scripting. ![]() Enter meta-commands (also known as “slash commands” and “backslash commands”).Run commands from a file (instead of standard input).Use SQL to administer users, roles, etc.Create database objects, such as tables, views, indexes, triggers, etc.Psql enables you to administer PostgreSQL from the command line interface (CLI) as an alternative to using a graphical user interface (GUI), such as pgAdmin, Postico, Azure Data Studio, etc. Psql is a terminal based interface for PostgreSQL. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |