Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Undocumented CREATE ROLE IF NOT EXISTS

According to https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/CREATE-ROLE.html the IF NOT EXISTS clause is not supported.

However, it seems to work partially (I guess the IF NOT EXISTS is tolerated but ignored) as the following example shows.

Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0

SQL> select role from dba_roles where role = 'XYZ';

no rows selected

SQL> create role if not exists xyz;

Role created.

SQL> select role from dba_roles where role = 'XYZ';

ROLE
--------------------------------------------------------------------------------
XYZ

SQL> create role if not exists xyz;
create role if not exists xyz
*
ERROR at line 1:
ORA-01921: role name 'XYZ' conflicts with another user or role name


SQL>

Question: Is it planned to support IF NOT EXISTS when releasing SE/EE of 23c? If not, I suggest throwing an error when trying to use the IF NOT EXISTS clause for unsupported statements.

This post has been answered by Loïc Lefèvre-Oracle on Apr 28 2023
Jump to Answer
Comments
Post Details
Added on Apr 27 2023
2 comments
1,153 views