Thursday 11 December 2014

Solved: ORA-01918,ORA-00911 Error User Does not exist I was trying to drop a user , which was created with junk character

Solved: ORA-01918,ORA-00911 Error User Does not exist
I was trying to drop a user , which was created with junk character

**********Recommended solution is to drop the user via OEM,*******

Below is NOT recommended by oracle, hence it may be risk
============================

Junk character would have been added by additional space/backspace keystroke by user while creating,.
example
========
username "king" while creating a space or backspace key stroke was hit by user in creation user script as junk character




SQL> select username from dba_users where username like 'king';

no rows selected


SQL> -- Notice the junk character below
SQL> select username from dba_users where username like '%king%';

USERNAME
------------------------------
king?

SQL>drop user king
ERROR at line 1:
ORA-01918: user 'king' does not exist

SQL> drop user king?;
drop user king?
              *
ERROR at line 1:
ORA-00911: invalid character

SQL> drop user "king?";
drop user "king?"
          *
ERROR at line 1:
ORA-01918: user 'king?' does not exist


SQL> -- Note : Make sure their are no segments owned by user
SQL> -- any way user would have not logged in so for,... but just saying
SQL>      
SQL> select user#,name from sys.user$ where name like 'king%';

     USER# NAME
---------- ------------------------------
        96 king?
       
SQL>-- Will update the new name in sys.user$ table, and drop the user and recreate correctly. --- This is unreommeded as we are not suppose to touch the base,.. it may create logical corruption.
SQL>-- Please make sure you DB is backed up if you dont have any other option...

SQL> update sys.user$ set name='king_new' where user#=96 and name like 'king%';

1 row updated.

SQL> commit;

Commit complete.

SQL> select username from dba_users where username like 'king_new';

USERNAME
------------------------------
king_new

SQL> select username from dba_users where username like 'king%'
  2  ;

USERNAME
------------------------------
king_new
SQL> -- Note the double quote
SQL> drop user "king_new";

User dropped.

New create the user again without junk character.


Note :
====
please use the commands carefully before executing in your server 
its advised to test in test server.

Note : 
====
Implementing or trying any of the advice from this blog is at your own risk.

4 comments:

  1. the best workaround is to follow this oracle note https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=342923145318347&id=1520925.1&displayIndex=1&_afrWindowMode=0&_adf.ctrl-state=rvhwkx6ew_175#SYMPTOM

    If you find the name in USER$, you should determine if it is a Role or a User by looking at the TYPE# column

    OR by querying DBA_USERS and DBA_ROLES

    - SQL> select * from dba_users where username = '';
    no rows selected

    - SQL> select * from DBA_ROLES where ROLE = '';
    ROLE PASSWORD AUTHENTICAT
    ------------------------------ -------- -----------
    NO NONE



    is a Role name and can be dropped using the following command :

    SQL> DROP ROLE ;

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. thanks you that help me. can user for user rename also ?

    ReplyDelete