Logo Wael's Digital Garden

PostgreSQL - Read-Only PSQL Session

Problem#

I want to connect to a database ensuring that I cannot perform any write operations

Solution#

  • Connect to a PostgreSQL server with psql or your graphical interface. This guide has only been tested with psql.
  • Connect to the database you'd like to explore with \c dbname
  • Run the following command:

    SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;

Related#