The query hit the database like a bullet. Pgcli lit up your terminal, results streaming in fast, clean, and colored. But the truth sat in plain sight: the table contained columns that not every user should see. Column-level access in PostgreSQL is no joke, and Pgcli handles it with sharp precision when configured right.
PostgreSQL lets you strip visibility down to individual columns. This means you can give one role access to the “name” and “email” fields while hiding “salary” and “ssn” entirely. Pgcli, the popular command-line client for Postgres, works seamlessly with those rules. If PostgreSQL denies a column to a user, Pgcli will never return it—whether you run SELECT * or specify individual fields.
To implement column-level access, start where it matters: PostgreSQL roles and permissions. Use GRANT and REVOKE commands to control who can read or write each column. For example:
REVOKE SELECT ON TABLE employees FROM analyst_role;
GRANT SELECT (name, email) ON employees TO analyst_role;
From there, Pgcli doesn’t need any special configuration—it respects PostgreSQL security boundaries by default. This keeps sensitive data invisible without breaking workflows. Queries, auto-completion, and table previews only show what the current role can access.