Use the psql -V command to find out which version of the interface is installed on your machine.Īccessing PostgreSQL using the ‘psql’ command line interface You’ll also need to use psql, the command-line interface for PostgreSQL. You should have PostgreSQL installed, and you’ll need to have a PostgreSQL role with access to a database in order to execute the SQL statement examples found in this article. Prerequisites to using PostgreSQL SQL commands in psqlīefore we proceed with our PostgreSQL cheat sheet, let’s review a few prerequisites that are necessary to get the most out of this article.
You can press CTRL+C if you’d like to escape a command or exit from the results of a command. Using double quotes will result in a syntax error. PostgreSQL: Commands Cheat Sheet q : Quit/Exit c database : Connect to a database d table : Show table definition (columns, etc.) including. This syntax lets Postgres knows where a statement ends otherwise, PostgreSQL will interpret the next line as an extension of that same command.Īnother thing to keep in mind when constructing SQL statements is that PostgreSQL strings must always be enclosed using single quotation marks (e.g. The PostgreSQL cheat sheet provides you with the common PostgreSQL commands and statements. Note that SQL statements in psql must terminate with a semicolon.
Opening PostgreSQL console: psql -hThis handy reference guide will help you perform many common PostgreSQL tasks using the psql command-line interface. For more detailed cheat sheets there are a plenty good links at the bottom of this post. By default, PostgreSQL is configured with compatibility and stability in mind, since the performance depends a lot on the. It can be affected by the configuration, the hardware or even the design of the system.
Performance is one of the most important and most complex tasks when managing a database. Change to Postgres user and open psql prompt. A Performance Cheat Sheet for PostgreSQL. There’s no need to go searching for this information– we’ve rounded up some of the most common SQL statements and queries and created a PostgreSQL cheat sheet for you. Enjoy this cheat sheet at its fullest within Dash, the macOS documentation. If you’re using PostgreSQL to store and query your data, you might find yourself needing to look up the syntax of some common statements and queries. Introduction to the PostgreSQL cheat sheet