Postgres GRANT Statement Generator
Pick a role, database, schema and privilege preset and get a complete, correctly ordered PostgreSQL permission script: CREATE ROLE, GRANT CONNECT ON DATABASE, GRANT USAGE ON SCHEMA, GRANT ... ON ALL TABLES / SEQUENCES / FUNCTIONS IN SCHEMA, plus ALTER DEFAULT PRIVILEGES so tables created later are covered too. Matching verification queries and a REVOKE script are generated alongside. Everything runs in your browser — nothing is sent to a server.
Do more than postgres grant statement generator — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Enter the role name, database and schema, then choose a preset: read-only, read-write, full access, or tick individual privileges.
- Optionally restrict the grant to specific tables, add WITH GRANT OPTION, or set the owner role for ALTER DEFAULT PRIVILEGES.
- Copy the GRANT script and run it as a superuser or the object owner; use the verification queries to confirm, and the REVOKE script to undo.
Frequently asked questions
Why does GRANT ALL PRIVILEGES ON DATABASE not give access to tables?
Database-level privileges in PostgreSQL are only CONNECT, CREATE (schemas) and TEMP. Tables live inside schemas, so a user also needs USAGE on the schema and SELECT/INSERT/... on the tables themselves — usually via GRANT ... ON ALL TABLES IN SCHEMA. This generator emits all three layers in the right order, which is why the typical 'permission denied for table' error disappears.
How do I grant privileges on tables that will be created in the future?
GRANT ... ON ALL TABLES IN SCHEMA only affects tables that exist right now. For future tables use ALTER DEFAULT PRIVILEGES IN SCHEMA schema GRANT SELECT ON TABLES TO role. Note that default privileges apply to objects created by the role that ran the ALTER DEFAULT PRIVILEGES statement; if another role (for example a migration user) creates the tables, add FOR ROLE that_role, which this tool supports via the Owner role field.
How can I check which privileges a PostgreSQL user has?
In psql, \du lists roles and attributes, \dp schema.* shows table/sequence ACLs, and \ddp shows default privileges. In SQL, query information_schema.role_table_grants or call has_table_privilege('role', 'schema.table', 'SELECT') and has_schema_privilege('role', 'schema', 'USAGE'). If you prefer a GUI, Chat2DB — a free AI-powered database client — lets you browse roles and run these checks visually; download it at https://chat2db.ai/download or use the web version at https://app.chat2db.ai.
