- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-04-17T14:05:47+09:00","default:ryuichi","ryuichi")
#author("2020-04-17T14:30:18+09:00","default:ryuichi","ryuichi")
* テーブルへのアクセス権限の確認 [#bbc9b7c1]
** \l で確認する [#da7e683c]
postgres=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
- 権限の内容は以下のドキュメントにあるが、分かりづらい
- https://www.postgresql.org/docs/12/ddl-priv.html#PRIVILEGE-ABBREVS-TABLE
** information_schema の role_table_grants で確認する [#n88ef4e3]
PSQL> \connect my_db
PSQL> SELECT grantee, privilege_type
FROM information_schema.role_table_grants
PSQL> SELECT grantee, table_name, privilege_type FROM information_schema.role_table_grants
grantee | table_name | privilege_type
---------+------------+----------------
user_01 | orders | INSERT
user_01 | orders | SELECT
user_01 | orders | UPDATE
user_01 | orders | DELETE
user_01 | orders | TRUNCATE
user_01 | orders | REFERENCES
user_01 | orders | TRIGGER
user_01 | members | INSERT
user_01 | members | SELECT
user_01 | members | UPDATE
- granteeがユーザ名(=ロール名)
** 参考 [#q15c96f9]
https://dba.stackexchange.com/questions/4286/list-the-database-privileges-using-psql