Home / Learn Secure SQL / Read-Only vs Read-Write Accounts

Read-Only vs Read-Write Accounts

Splitting access by what an operation actually needs to do.

In shortSplitting access by what an operation actually needs to do.

What's actually going on

Scoping by purposefeature: salesdashboardneeds: read-onlyaccount granted:SELECT only, no…
Scoping by purpose

In plain terms

Many parts of a system only ever need to read data (dashboards, reports, search); giving those parts a read-only account removes the possibility of them ever modifying data, even by accident or bug.

Why we use it

A reporting feature with a read-write account is one bug away from accidentally corrupting data it was only ever meant to display; a read-only account makes that category of bug structurally impossible.

Under the hood

Identify which parts of your system genuinely need to write data, and give everything else (reports, dashboards, search, analytics) a dedicated account with only SELECT granted.

Real-world use

  • Web application code review
  • Backend development
  • Database administration
A read-only account (PostgreSQL)
CREATE ROLE dashboard_ro LOGIN PASSWORD '...';
GRANT SELECT ON orders, order_items, products TO dashboard_ro;
-- No INSERT, UPDATE, or DELETE granted: structurally cannot write

Quick quiz

1. A read-only account mainly protects against...