WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Oracle Database · Basic · question 18 of 100

How do you grant and revoke user privileges in an Oracle database?

📕 Buy this interview preparation book: 100 Oracle Database questions & answers — PDF + EPUB for $5

In Oracle database, user privileges can be granted and revoked using the ‘GRANT‘ and ‘REVOKE‘ statements respectively. These statements allow database administrators to control the permissions of individual database users and can be used to ensure that sensitive information remains protected.

To grant a privilege to a user, the ‘GRANT‘ statement is used. Below is the basic syntax for granting a privilege to a user.

GRANT privilege_name TO user_name;

For example, to grant the ‘SELECT‘ privilege on the ‘customers‘ table to the user ‘mike‘:

GRANT SELECT ON customers TO mike;

In the above example, the ‘SELECT‘ privilege has been granted to the user ‘mike‘ on the ‘customers‘ table. The ‘SELECT‘ privilege allows the user to read data from the table.

To revoke a privilege from a user, the ‘REVOKE‘ statement is used. Below is the basic syntax for revoking a privilege from a user.

REVOKE privilege_name FROM user_name;

For example, to revoke the ‘SELECT‘ privilege on the ‘customers‘ table from the user ‘mike‘:

REVOKE SELECT ON customers FROM mike;

In the above example, the ‘SELECT‘ privilege has been revoked from the user ‘mike‘ on the ‘customers‘ table. The ‘SELECT‘ privilege no longer allows the user to read data from the table.

It is also possible to grant and revoke privileges to and from individual database roles, which can be granted to multiple users. For example, to grant the ‘SELECT‘ privilege on the ‘customers‘ table to a database role ‘readers‘:

GRANT SELECT ON customers TO readers;

And to grant the ‘readers‘ role to the user ‘jim‘:

GRANT readers TO jim;

In the above example, the ‘SELECT‘ privilege has been granted to the ‘readers‘ role and the ‘readers‘ role has been granted to the user ‘jim‘. This allows the user ‘jim‘ to have the ‘SELECT‘ privilege on the ‘customers‘ table.

Finally, it is worth noting that privileges can also be granted and revoked on system-level operations, such as creating and modifying database objects, and performing administrative tasks. These privileges are typically reserved for database administrators and are granted carefully, to ensure that sensitive information and operations remain protected.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Oracle Database interview — then scores it.
📞 Practice Oracle Database — free 15 min
📕 Buy this interview preparation book: 100 Oracle Database questions & answers — PDF + EPUB for $5

All 100 Oracle Database questions · All topics