![]() ![]() How to export database and table schemas in SQLite.How to update existing data with SQLite.How to perform basic queries with `SELECT` with SQLite. ![]() Inserting and deleting data with SQLite.Creating and deleting databases and tables with SQLite.Profiling and optimizing slow queries in MySQL.Using joins to combine data from different tables in MySQL.How to perform basic queries with `SELECT` in MySQL.An introduction to MySQL column and table constraints.How to create and delete databases and tables in MySQL.Introduction to optimizing PostgreSQL performance.Using joins to combine data from different tables in PostgreSQL.How to filter query results in PostgreSQL.How to perform basic queries with `SELECT` in PostgreSQL.An introduction to PostgreSQL column and table constraints.An introduction to PostgreSQL data types.How to create and delete databases and tables in PostgreSQL.How to configure a PostgreSQL database on RDS.Comparing relational and document databases.Glossary of common database terminology.Comparing database types: how database types evolved to meet different needs.W, -password force password prompt (should happen automatically)įor more information, type "\?" (for internal commands) or "\help" (for SQLĬommands) from within psql, or consult the psql section in the PostgreSQLĪs you can see, the help list contains further commands you can use to get help about specific areas.įor example, you can use psql -help=commands to return a list of commands, or psql -V to return the psql version.Īnd while you’re using psql, you can type \? to get a list of internal commands, or \help to return a list of SQL commands. w, -no-password never prompt for password U, -username=USERNAME database user name (default: "barney") p, -port=PORT database server port (default: "5432") h, -host=HOSTNAME database server host or socket directory (default: "local socket") 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.
0 Comments
Leave a Reply. |