What is REVOKE Command in SQL?

Learn via video course
FREE
View all courses
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
Topics Covered

The REVOKE command in SQL is used to revoke or withdraw permissions that were previously granted to an account on a database object. Therefore, we can think of REVOKE as a tool to limit a role's or user's ability to perform SELECT, INSERT, DELETE, UPDATEand CREATE statements on database objects., as well as to set constraints like foreign keys and update data records, among other operations.

The REVOKE command is the opposite of the command GRANT, which allows a user account or role access to the database object.

Syntax

This is the syntax for the writing revoke command

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Arguments Used

Following are the explanation of the various arguments used in the code:

  1. PRIVILEGES: We provide the privilege(s) that need to be revoked for a user account in this parameter. The privileges include SELECT , INSERT, DELETE, UPDATEand CREATE commands.
  2. DATABASE OBJECTS: Database objects are database entities that could range from specific tables to all the tables in a schema.
  3. ROLE | USER: The USER or the ROLE can be used to specify the user account from which the permissions have to be revoked.
  4. CASCADE | RESTRICT: We can show that the revocation of the aforementioned PRIVILEGES can also remove the other privileges which derive their powers from the revoked privilege using CASCADE. In the absence of it, we can limit/ RESTRICT revocation to just the designated privilege.

Examples to REVOKE Command in SQL

Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science

Example-1: REVOKE UPDATE Privilege

Let us suppose that you want to revoke an updated privilege granted to a user ROLE_A on the data object SALES.

The above code is used to remove all the UPDATE privileges granted to the SALES table.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example-2: REVOKE SELECT Privilege

The above code is used to revoke the SELECT privilege from a user ROLE_A.

Example-3: REVOKE INSERT Privilege

The above code is used to revoke the INSERT privilege from a user ROLE_A in the EMPLOYEE Data object.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Example-4: REVOKE DELETE Privilege

The above code is used to revoke the DELETE privilege from a user USER_A in the EMPLOYEE Data object.

Example-5: REVOKE TRUNCATE Privilege

The above code is used to revoke the TRUNCATE privilege from a user USER_A in the EMPLOYEE Data object.

Conclusion

  • The REVOKE command in SQL is used to revoke or withdraw permissions that were previously granted to an account on a database object.
  • REVOKE command is the opposite of the command GRANT
  • Privileges, database objects, role, cascade/restrict are a few of the arguments for the revoke clause.
  • REVOKE can be used to update, select, insert, delete and truncate privileges.
  • One can cancel the grants of others if your SQL authorization ID has SYSADM or an equal level of authority.

Learn more