This article contains information about revoke command usage in PostgreSQL. You may want to revoke permissions of users. In this case, you can use the plpgsql commands below. First, let’s see the sytanx and then the examples.
1 2 3 | REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM username; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM username; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM username; |
In the example below, we use the following commands to revoke f_user’s all the permissions in table sequences and functions.
1 2 3 | REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA Personel_tablosu FROM f_user; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA publicsemasi FROM f_user; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA publicsemasi FROM f_user; |
We can use the command below to revoke create permission on the schema.
1 | REVOKE CREATE ON SCHEMA public FROM PUBLIC; |
With the help of the command below, we will revoke the select, insert, update, delete permission on the products table from f_user.
Revoke Select Permission from user:
1 | REVOKE SELECT ON products TO f_user; |
Revoke Insert Permission from user:
1 | REVOKE INSERT ON products TO f_user; |
Revoke Update Permission from user:
1 | REVOKE UPDATE ON products TO f_user; |
Revoke Delete Permission from user:
1 | REVOKE DELETE ON products TO f_user; |
To revoke the permissions such as select and insert in the same script, you can edit and run the command by seperating permissions with a comma as follows.
1 | REVOKE SELECT, INSERT ON products TO f_user; |