■ 사용자 권한 조회하기 (스키마 수준)
▶ 예제 코드 (SQL)
1 2 3 4 5 6 7 8 9 10 |
SELECT N.NSPNAME AS SCHEMA, U.USENAME AS USER, HAS_SCHEMA_PRIVILEGE(U.USENAME, N.NSPNAME, 'USAGE' ) AS CAN_USE, HAS_SCHEMA_PRIVILEGE(U.USENAME, N.NSPNAME, 'CREATE') AS CAN_CREATE FROM PG_NAMESPACE N CROSS JOIN PG_USER U WHERE U.USENAME = 'testuser1'; |
▶ 실행 결과
1 2 3 4 5 6 7 8 9 10 11 |
schema | user | can_use | can_create --------------------+-----------+---------+------------ pg_toast | testuser1 | t | t pg_temp_1 | testuser1 | t | t pg_toast_temp_1 | testuser1 | t | t pg_catalog | testuser1 | t | t public | testuser1 | t | t information_schema | testuser1 | t | t (6 rows) |