Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim
ORA-01917 comes from GRANT when the name after TO is not an existing user or role. Unquoted names are uppercased, so the message shows the name Oracle actually looked for.
The three runs below are the usual causes. Check the name first: SELECT username FROM all_users for users and SELECT role FROM dba_roles for roles.
01Granting to a role that has not been created
A script granted SELECT ON orders TO app_read before the role existed and got ORA-01917: user or role 'APP_READ' does not exist. The asterisk points at the grantee.
dba_roles returned 0 rows for APP_READ. After SYSTEM ran CREATE ROLE app_read, the same GRANT succeeded and user_tab_privs_made showed APP_READ / ORDERS / SELECT.
Setup
BEGIN
EXECUTE IMMEDIATE 'DROP ROLE app_read';
EXCEPTION WHEN OTHERS THEN NULL;
END;
/PL/SQL procedure successfully completed.CREATE TABLE orders (id NUMBER PRIMARY KEY, amount NUMBER);Table created.GRANT SELECT ON orders TO app_read;GRANT SELECT ON orders TO app_read
*
ERROR at line 1:
ORA-01917: user or role 'APP_READ' does not exist
Help: https://docs.oracle.com/error-help/db/ora-01917/SELECT COUNT(*) AS role_count FROM dba_roles WHERE role = 'APP_READ';ROLE_COUNT
----------
0
1 row selected.CREATE ROLE app_read;Role created.GRANT SELECT ON orders TO app_read;
COLUMN grantee FORMAT A10
COLUMN table_name FORMAT A10
COLUMN privilege FORMAT A10
SELECT grantee, table_name, privilege FROM user_tab_privs_made WHERE table_name = 'ORDERS';Grant succeeded.
GRANTEE TABLE_NAME PRIVILEGE
---------- ---------- ----------
APP_READ ORDERS SELECT
1 row selected.02Typo in the user name
GRANT SELECT ON orders TO lab_bb failed with ORA-01917 for 'LAB_BB'.
all_users listed LAB_A and LAB_B. GRANT SELECT ON orders TO lab_b succeeded.
Setup
CREATE TABLE orders (id NUMBER PRIMARY KEY, amount NUMBER);Table created.GRANT SELECT ON orders TO lab_bb;GRANT SELECT ON orders TO lab_bb
*
ERROR at line 1:
ORA-01917: user or role 'LAB_BB' does not exist
Help: https://docs.oracle.com/error-help/db/ora-01917/COLUMN username FORMAT A10
SELECT username FROM all_users WHERE username LIKE 'LAB%' ORDER BY username;USERNAME
----------
LAB_A
LAB_B
2 rows selected.GRANT SELECT ON orders TO lab_b;Grant succeeded.03The user was created with a quoted lowercase name
The user was created as "report_user" in double quotes, so its name is stored in lowercase. GRANT CREATE SESSION TO report_user looked for REPORT_USER in uppercase and failed with ORA-01917.
dba_users showed the name as report_user in lowercase. GRANT CREATE SESSION TO "report_user" with the same quotes succeeded.
Setup
DROP USER IF EXISTS "report_user" CASCADE;
CREATE USER "report_user" IDENTIFIED BY "Lab#2026pw";User dropped.
User created.GRANT CREATE SESSION TO report_user;GRANT CREATE SESSION TO report_user
*
ERROR at line 1:
ORA-01917: user or role 'REPORT_USER' does not exist
Help: https://docs.oracle.com/error-help/db/ora-01917/COLUMN username FORMAT A12
SELECT username FROM dba_users WHERE UPPER(username) = 'REPORT_USER';USERNAME
------------
report_user
1 row selected.GRANT CREATE SESSION TO "report_user";
DROP USER "report_user" CASCADE;Grant succeeded.
User dropped.FAQ
How do I check whether a user or role exists in Oracle?
Users: SELECT username FROM all_users WHERE username = 'NAME';. Roles (needs DBA views): SELECT role FROM dba_roles WHERE role = 'NAME';.
Why does the message show my name in uppercase?
Unquoted identifiers are uppercased. If the user was created with double quotes and lowercase letters, you must use the same quotes in GRANT.
What is the difference between ORA-01917 and ORA-01918?
ORA-01917 is raised by GRANT when the grantee (user or role) is missing. ORA-01918 is raised by statements such as DROP USER or ALTER USER when the user is missing.
My install script fails with ORA-01917 on GRANT. What should I check?
The order of the script. CREATE ROLE and CREATE USER must run before the GRANT statements that use them.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0