Today, we will discuss how you can define database-based authorizations for your user created on a database basis in PostgreSQL.
Authorizations defined on a database basis are used to perform operations on objects such as tables, views, functions and procedures within the database.
Authorizations on a PostgreSQL Database Basis:
SELECT: Authorization defined for querying data.
INSERT: Authorization defined for adding data..
UPDATE: Authorization defined for updating data.
DELETE: Authorization defined for deleting data.
TRUNCATE: Authorization defined for deleting data. (For the difference between delete and truncate, you can use my article titled Differences between delete and truncate).
REFERENCES: Authorization defined for operations related to references.
TEMPORARY: Authorization defined for Temp objects.
EXECUTE: Authorization defined for running procedures.
With the help of the command below, only the necessary authorization to query data is defined for the city table under the public schema.
1 | GRANT SELECT ON public.city TO farukerdem; |
The following command defines the necessary authority to query data in all tables under the public schema.
1 | GRANT SELECT ON ALL TABLES IN SCHEMA public TO farukerdem; |
You can also use the above examples for other operations.