Multiple choice technology databases

Which of the following statements enables the role user_admin in the current session?

  1. alter session enable role user_admin;

  2. alter session set role user_admin;

  3. alter role user_admin enable;

  4. set role user_admin;

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In Oracle SQL, the 'SET ROLE' statement is used to enable or disable roles for the current session. 'ALTER SESSION' is not used for enabling roles; the correct syntax is simply 'SET ROLE role_name;'.

AI explanation

To enable the role user_admin in the current session, you would use the SET ROLE statement.

Let's go through each option to understand why it is correct or incorrect:

Option A) alter session enable role user_admin; - This option is incorrect because the ENABLE ROLE statement is used to enable a role for a specific user, not for the current session.

Option B) alter session set role user_admin; - This option is incorrect because the SET ROLE statement is missing. The correct syntax for enabling a role using the SET ROLE statement would be ALTER SESSION SET ROLE user_admin;.

Option C) alter role user_admin enable; - This option is incorrect because the ALTER ROLE statement is used to modify the properties of a role, not to enable it for the current session.

Option D) set role user_admin; - This option is correct because the SET ROLE statement is used to enable a role for the current session. Therefore, the correct answer is option D.

The correct answer is option D.