如何向数据库中的所有表授予某些权限? [英] How do I grant certain privileges to all tables in a database?
问题描述
我需要类似于mysql的 GRANT SELECT ON db。* TO user
在postgresql 8.4。我发现在线的解决方案使用一个for循环来选择表一次,并授予他们的权限。但是这意味着每次向数据库添加一个新表时,我都必须重新运行该命令。
有没有更直接的解决方案?
假设你没有定义任何特定的模式,你所有的表都将在'public'模式,所以你可以说: / p>
GRANT< permissions> ON SCHEMA中的所有表格public TO< roles> ;;
这只适用于9.0或以上版本,所以你在8.4运气不好。 p>
另请参阅: http ://www.postgresql.org/docs/8.4/static/ddl-schemas.html
I need something similar to mysql's GRANT SELECT ON db.* TO user
in postgresql 8.4. The solutions I find online use a for loop to select tables on at a time and grant privileges on them. But that would mean I would have to rerun the command every time a new table is added to the database.
Is there a more straightforward solution to this?
Assuming you don't have any specific schemas defined, all your tables will be in the 'public' schema, so you can say:
GRANT <permissions> ON ALL TABLES IN SCHEMA public TO <roles>;
This only works on 9.0 or above though, so you're out of luck in 8.4.
See also: http://www.postgresql.org/docs/8.4/static/ddl-schemas.html
这篇关于如何向数据库中的所有表授予某些权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!