Difference between revisions of "Amazon Redshift: show permissions"

From wikieduonline
Jump to navigation Jump to search
Line 6: Line 6:
 
  FROM
 
  FROM
 
     [[pg_user]] u
 
     [[pg_user]] u
  CROSS JOIN
+
  [[CROSS JOIN]]
     (SELECT DISTINCT schemaname FROM pg_tables) s
+
     (SELECT DISTINCT schemaname FROM [[pg_tables]]) s
 
  WHERE
 
  WHERE
 
     u.usename = 'myUserName'
 
     u.usename = 'myUserName'

Revision as of 16:01, 13 December 2021

SELECT
    u.usename,
    s.schemaname,
    has_schema_privilege(u.usename,s.schemaname,'create') AS user_has_select_permission,
    has_schema_privilege(u.usename,s.schemaname,'usage') AS user_has_usage_permission
FROM
    pg_user u
CROSS JOIN
    (SELECT DISTINCT schemaname FROM pg_tables) s
WHERE
    u.usename = 'myUserName'
    AND s.schemaname = 'mySchemaName'
;


Grant privileges:

grant select on all tables in schema YOUR_SCHEMA to YOUR_USER;
grant create on all tables in schema YOUR_SCHEMA to YOUR_USER;
grant all on schema YOUR_SCHEMA to group YOUR_USER;

Related

See also

Advertising: