同一 PostgreSQL 数据库的两个所有者
是否可以使用 Postgresql 创建一个拥有 2 个用户(充当数据库所有者)的数据库?
我可以创建一个组角色并将两个用户添加到该组,然后使该组成为数据库的所有者,但这要求两个用户都必须在每个连接上手动设置其角色,以使他们创建的任何表都可以访问另一个用户。有什么方法可以使该组成为用户每次登录时的默认角色,或者有任何其他方法可以实现相同的效果?
Is it possible with Postgresql to create a database which has 2 users which act like owners to the database?
I can create a group role and add both users to that group, and then make the group the owner of the database, but this requires both users to be have to manually set their role on every connection to make any tables they have created accessible to the other user. Is there any way to make the group be the default role for a user each time they log in or any other way to achieve the same thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可以,每个数据库只能有一个所有者。如前所述,您可以拥有多个超级用户,或者您可以专门向随后继承的组角色授予权限。
您可能想查看 http://blog.hagander.net /archives/70-Faking-the-dbo-role.html,一种伪造类似于您所要求的内容的方法。它并不完美,但对您来说可能已经足够了。它至少应该能够解决对象所有权问题。
No, each database can only have one owner. As stated previously you can have more than one superuser, or you can grant permissions specifically to group roles that are then inherited.
You might want to look at http://blog.hagander.net/archives/70-Faking-the-dbo-role.html, for a way to fake something similar to what you're asking for. It's not perfect, but it might be good enough for you. It should be able to solve the object-ownership problem at least.
啊,找到了:PostgreSQL 文档:第 20 章数据库角色和权限
Ah, found it: PostgreSQL Docs: Chapter 20. Database Roles and Privileges