List all schemas with their priveleges for current user:
WITH "names"("name") AS (
SELECT n.nspname AS "name"
FROM pg_catalog.pg_namespace n
WHERE n.nspname !~ '^pg_'
AND n.nspname <> 'information_schema'
) SELECT "name",
pg_catalog.has_schema_privilege(current_user, "name", 'CREATE') AS "create",
pg_catalog.has_schema_privilege(current_user, "name", 'USAGE') AS "usage"
FROM "names";
The response will be for example:
name | create | usage
---------+--------+-------
public | t | t
test | t | t
awesome | f | f
(3 rows)
In this example current user is not owner of the awesome schema.
As you could guess, similar request for particular schema:
SELECT
pg_catalog.has_schema_privilege(
current_user, 'awesome', 'CREATE') AS "create",
pg_catalog.has_schema_privilege(
current_user, 'awesome', 'USAGE') AS "usage";
and response:
create | usage
--------+-------
f | f
As you know, it's possible to use pg_catalog.current_schema() for current schema.
Of all the possible privileges
-- SELECT
-- INSERT
-- UPDATE
-- DELETE
-- TRUNCATE
-- REFERENCES
-- TRIGGER
-- CREATE
-- CONNECT
-- TEMP
-- EXECUTE
-- USAGE
the only CREATE and USAGE allowed for schemas.
Like the current_schema() the current_user can be replaced with particular role.
Troubleshooting Access Errors
Sometimes users encounter “permission denied” errors after grants and revokes. Common causes include:
- Concurrent session – changes don’t affect existing sessions until reconnected
- Object ownership issues – object owner permissions take precedence
- Incorrect search path – schemas including object not referenced properly
- Function access issue – execution privileges required for functions
Checking object ownership, search paths, and currently assigned privileges can uncover certain errors. Viewing effective grants for a user in pgAdmin can also help identify problems.
BONUS with current column
WITH "names"("name") AS (
SELECT n.nspname AS "name"
FROM pg_catalog.pg_namespace n
WHERE n.nspname !~ '^pg_'
AND n.nspname <> 'information_schema'
) SELECT "name",
pg_catalog.has_schema_privilege(current_user, "name", 'CREATE') AS "create",
pg_catalog.has_schema_privilege(current_user, "name", 'USAGE') AS "usage",
"name" = pg_catalog.current_schema() AS "current"
FROM "names";
-- name | create | usage | current
-- ---------+--------+-------+---------
-- public | t | t | t
-- test | t | t | f
-- awesome | f | f | f
-- (3 rows)
WITH | System Information Functions | GRANT (privileges)
psqldoes when you do a\dp viewnamequery, by runningpsqlwith the-Eflag. Should get you started. I don't use Redshift, so not pursuing further.