$ ./guess_the_languageSQL & Databases
SQL & Databases · medium · #53

What effect does this policy have on queries?

-- PostgreSQL
ALTER TABLE docs ENABLE ROW LEVEL SECURITY;
CREATE POLICY own ON docs
  USING (owner = current_user);
  1. Users see only their own rows
  2. Only the owner can alter docs
  3. Docs are encrypted per user
  4. Each user gets a private copy
Row-level security adds the USING condition to every query, filtering rows per user (table owners bypass it by default).
Play SQL & Databases ▸