问题
I have a user in a database who only can select datas on all tables. I want to alow him to create views and not tables. Is it possible to grant to a specific user privileges for only creating views in a database schema?
Regards.
回答1:
Not in PostgreSQL at time of writing, no. The CREATE right in a schema lets them create any object type. There's no way to limit what objects they can create - functions, operators, operator classes, tables, views, etc.
You could implement an executor hook to enforce these kinds of rules, but you'll have to do it as a loadable module written in C. ProcessUtility_hook is probably the hook you want. There will be a significant learning curve to this approach, as you'll need to understand how PostgreSQL's statements are described in their internal parsed form.
来源:https://stackoverflow.com/questions/19811683/cannot-grant-create-view-on-schema