A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/postgresql/postgresql-revoke/ below:

PostgreSQL - REVOKE - GeeksforGeeks

PostgreSQL - REVOKE

Last Updated : 15 Jul, 2025

In PostgreSQL, the REVOKE statement plays a crucial role in managing database security by removing previously granted privileges from roles or users.

Let us better understand the REVOKE Statement in PostgreSQL from this article.

Syntax

The following shows the syntax of the REVOKE statement:

REVOKE privilege | ALL
ON TABLE tbl_name | ALL TABLES IN SCHEMA schema_name
FROM role_name;

Let's analyze the above syntax:

PostgreSQL REVOKE Statement Example

Let us look into an example of REVOKE statement in PostgreSQL.

1. Log into PostgreSQL

First, log into the dvdrental sample database as Postgres:

psql -U postgres -d dvdrental
2. Create a Role

Now initialize a role called 'abhishek' with the LOGIN and PASSWORD attributes as shown below:

CREATE ROLE abhishek
LOGIN
PASSWORD 'geeks12345';
3. Grant Privileges

Now grant all privileges on the 'film' table to the role 'abhishek' as shown below:

GRANT ALL 
ON film
TO abhishek;

Now provide the SELECT privilege on the actor table to the role 'abhishek' as shown below:

GRANT SELECT
ON actor
TO abhishek;
4. Revoke Specific Privileges

Here we will revoke the SELECT privilege on the 'actor' table from the role 'abhishek', as shown below:

REVOKE SELECT
ON actor
FROM abhishek;
5. Revoke All Privileges

If you wish to revoke all privileges on the film table from the role 'abhishek', make use of the REVOKE statement with the ALL option as shown below:

REVOKE ALL
ON film
FROM abhishek;

Output:

Important Points About PostgreSQL REVOKE Statement


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4