SQL 使用一条语句授予所有序列的 SELECT 特权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7386321/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GRANT SELECT privilege to ALL sequences using one statement
提问by markus
How can I grant the SELECT privilege on all sequences to a user using one statement? Somthing like:
如何使用一条语句将所有序列的 SELECT 权限授予用户?类似的东西:
GRANT SELECT ON <ALL SEQUENCES???> TO myUser
回答by Mike Sherrill 'Cat Recall'
回答by Oswaldo Rodriguez Gonzalez
This will be very useful in the future:
这将在未来非常有用:
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name TO your_user;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA schema_name TO your_user;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA schema_name TO your_user;
回答by Diego Quirós
The accepted answer dont worked for me on 9.1. The below sentence did work:
接受的答案在 9.1 上对我不起作用。下面的句子确实有效:
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO user;
回答by Vishnu Kumar
For Postgres versions lower than 9.0
对于低于 9.0 的 Postgres 版本
psql -d DBNAME -qAt -c "SELECT 'GRANT SELECT ON ' || relname || ' TO USER;' FROM pg_statio_all_sequences WHERE schemaname = 'public'" | psql -d DBNAME
Ref: http://gotochriswest.com/blog/2012/06/11/postgresql-granting-access-to-all-sequences/
参考:http: //gotochriswest.com/blog/2012/06/11/postgresql-granting-access-to-all-sequences/