Setting User Permissions
- To grant permissions for an object to a user, use GRANT.
When permissions for a table or view in a schema are granted to a user or role, the USAGE permission of the schema must be granted together. Otherwise, the user or role can only see these objects but cannot access them.
In the following example, permissions for the schema tpcds are first granted to user joe, and then the SELECT permission for the tpcds.web_returns table is also granted.
1 2
openGauss=# GRANT USAGE ON SCHEMA tpcds TO joe; openGauss=# GRANT SELECT ON TABLE tpcds.web_returns to joe;
- Grant a role to a user to allow the user to inherit the object permissions of the role.
- Create a role.
Create a role lily and grant the system permission CREATEDB to the role.
1
openGauss=# CREATE ROLE lily WITH CREATEDB PASSWORD "xxxxxxxxx";
- Grant object permissions to the role by using GRANT.
For example, first grant permissions for the schema tpcds to the role lily, and then grant the SELECT permission of the tpcds.web_returns table to lily.
1 2
openGauss=# GRANT USAGE ON SCHEMA tpcds TO lily; openGauss=# GRANT SELECT ON TABLE tpcds.web_returns to lily;
- Grant the role permissions to a user.
1
openGauss=# GRANT lily to joe;
When the permissions of a role are granted to a user, the attributes of the role are not transferred together.
- Create a role.
- To revoke user permissions, use REVOKE.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot