...

/

PostgreSQL: Setup on the Local Machine

PostgreSQL: Setup on the Local Machine

Learn how to set up a local environment for PostgreSQL and the psqlrc file for your specific use case.

Setting up a local environment

We’re providing you with an execution environment with PostgreSQL running. If you want to later practice on your own machine, you will need a database server to play along with.

  • If you’re using MacOSX, check out Postgres App to install a PostgreSQL server and the psql tool.

  • For Windows, check this link.

  • If you’re mainly running Linux, you know what you’re doing already, right? Look at the PostgreSQL packages for Debian and Ubuntu and install the most recent version of PostgreSQL on your station so that you have something to play with locally. For Red Hat packaging-based systems, check this out.

You might prefer a more visual tool such as pgAdminpgAdmin is an administration and development platform for PostgreSQL. or OmniDBOmniDB is a web tool that simplifies database management, focusing on interactivity, designed to be powerful and lightweight.; the key here is to be able to easily edit SQL queries, run them, edit them in order to fix them, see the explain plan for the query, etc.

The psqlrc setup

Here we begin with a full setup of psql—we’re going to get back to each important point separately. Doing so allows us to have a fully working environment from the get-go and play around in our PostgreSQL console.

\set PROMPT1 '%~%x%# '
\x auto
\set ON_ERROR_STOP on
\set ON_ERROR_ROLLBACK interactive

\pset null '¤'
\pset linestyle 'unicode'
\pset
...