Difficulty: Beginner
Estimated Time: 10 minutes

In this tutorial you will connect to Postgres using the psql command line interface. You will create a new table, insert, select, update and delete data and then finally drop (remove) the table.

Commands to run are shown in grey boxes throughout the tutorial. Click on the boxes or copy and paste the commands into the terminal to execute each command.

Congratulations! Using PostgreSQL you have now learnt how to:

  • Create a table
  • Insert data into a table
  • Select data from a table
  • Update data in a table
  • Delete data from a table
  • Drop a table

Tables in Postgres

Step 1 of 7

Step 1 - Connect to Postgres

By default on a Linux system, Postgres' authentication is setup to allow trusted access from the postgres user account that the database server runs under. So, let's become the postgres user:

su - postgres

Now, run the psql command line interface for Postgres. The default values for user, host and port will work in this case so we don't need to provide any command line options. For more information on the psql command line tool, please see the psql documentation:


You should now see the psql command prompt and be able to move to the next step.