To zapytanie będzie lista wszystkich tabel we wszystkich baz danych i schematów (Odkomentuj linii (i) w klauzuli WHERE
filtrowania dla określonych baz danych, schematów lub tabel), z uprawnieniami pokazano na kolejność tak, że jest to łatwe, aby zobaczyć, czy dany przywilej udzielenia lub nie: wyjście
SELECT grantee
,table_catalog
,table_schema
,table_name
,string_agg(privilege_type, ', ' ORDER BY privilege_type) AS privileges
FROM information_schema.role_table_grants
WHERE grantee != 'postgres'
-- and table_catalog = 'somedatabase' /* uncomment line to filter database */
-- and table_schema = 'someschema' /* uncomment line to filter schema */
-- and table_name = 'sometable' /* uncomment line to filter table */
GROUP BY 1, 2, 3, 4;
Próbka:
grantee |table_catalog |table_schema |table_name |privileges |
--------|----------------|--------------|---------------|---------------|
PUBLIC |adventure_works |pg_catalog |pg_sequence |SELECT |
PUBLIC |adventure_works |pg_catalog |pg_sequences |SELECT |
PUBLIC |adventure_works |pg_catalog |pg_settings |SELECT, UPDATE |
...
chcesz uruchomić to bezpośrednio z okienka sQL lub wiersza poleceń pg? –
@ DanielL.VanDenBosch: wszystkie meta-komendy, takie jak '\ z', są dla psql. A psql to interfejs wiersza poleceń do PostgreSQL. –