How do I GRANT ALL PRIVILEGES on ALL VIEWS in one statement?

前端 未结 2 504
庸人自扰
庸人自扰 2021-01-07 02:12

In PostgreSQL 9+, is there a way to
GRANT ALL PRIVILEGES on ALL VIEWS in schema schema_name TO role_name
in a single statement?

2条回答
  •  无人及你
    2021-01-07 02:45

    You can also do this from the command line:

    1. Login as postgres:

      sudo -i -u postgres

    2. Run this command:

      psql -At -d [dbname] -c "SELECT 'GRANT ALL ON '||viewname||' TO [username];' FROM pg_views WHERE schemaname='public';" | psql -d [dbname]

提交回复
热议问题