How to Quickly Peek Inside Your Database Like a Pro Using psql

This is a premium course, which you can purchase below.

Buy Now

Now that the data is in the database, let's poke around and see what we have, using simple select statements and getting to know the Postgres client tool psql.


Postgres ships with a powerful binary client, psql. If you're not a command line person, it can take a little getting used to. It's worth the investment, however, because the speed and scriptability of psql is extremely powerful.

You can login to your database with a simple command:

psql cassini

Once you're in, you can have a look around and see what's there:

\d
\d csvs.*

If you run a query on our master_plan table, you'll quickly find the results unreadable, which means we should use expanded display using \x - and sometimes that doesn't even help!

The easiest thing to do is to specify what you want to see, and to be sure you limit the results. This is our first select query!

select start_time_utc, duration, date from csvs.master_plan limit 5;

If you want to use a web-based GUI, you can run PG Web using Docker:

pgweb:
  container_name: pgweb
  restart: always
  image: sosedoff/pgweb
  ports:
    - "8080:8081"
  environment:
    - DATABASE_URL=postgres://rob@host.docker.internal/cassini?sslmode=disable