1

通过一个错误的脚本,我在 Oracle 9i 系统上创建了一个用户,其用户名周围有单引号(即他的用户名是“用户名”,而不是用户名)。现在我想删除该用户。"DROP USER 'username'" 和 "DROP USER \'username\'" 和 "DROP USER (SELECT username FROM all_users where user_id = 123)" 都不起作用。如何摆脱该用户?

4

7 回答 7

4
create user "'bla'" identified by bla;

drop user "'bla'";
于 2009-07-22T14:51:12.157 回答
2

根据甲骨文的文档...

"带引号的标识符以双引号 (") 开头和结尾。如果您使用带引号的标识符命名架构对象,则在引用该对象时必须使用双引号。”

所以这...

DROP USER "username" CASCADE;
于 2009-07-22T14:59:02.347 回答
2

我知道这是一篇旧帖子,但对于任何因搜索此问题而偶然发现此问题的人 - 问题似乎是数据库触发器正在触发删除用户。我已经发布了我为 Oracle XE 找到的解决方案(可能与其他 10g 版本相同) here

希望有人觉得这很有用,

麦克风

于 2010-02-18T00:09:48.280 回答
1

尝试DROP USER "'username'"DROP USER ''username''。(注意最后的那些引号都是单引号)

于 2009-07-22T14:53:38.937 回答
0

再次以更好的格式:

declare 

   sel_username varchar2(30); 

   r_user_id    varchar2(30); 

   r_username   varchar2(30); 

   user_cmd     varchar2(200); 

BEGIN

/* 

   This procedure will delete a single userid and can be used to delete a user 
   with none displayable characters in the name 

   **Replace the user_id  in this script !!** 

   Author: Ulrich Henkenjohann  -  March 2010 / tested on ORACLE 10.2.0.4 

*/      
-- select the username for a special user_id. Ther username may contain none displayed characters

   select username into sel_username from dba_users where user_id = 34; 

   select user_id, username into r_user_id , r_username from dba_users where username = sel_username ; 

   DBMS_OUTPUT.PUT_LINE('Selected user: ' || r_user_id || ' ' || r_username); 

-- If a test is needed, an alter passwort command may be usefull 

-- user_cmd := 'ALTER USER "' || r_username || '" IDENTIFIED BY PASSWORDX '; 

-- Drop the selected user 

   user_cmd := 'DROP USER "' || r_username || '" CASCADE '; 

   DBMS_OUTPUT.PUT_LINE('Executing user_cmd: ' || user_cmd ); 

   execute immediate user_cmd ; 

END;
/
于 2010-03-24T11:12:20.593 回答
0

以下代码可能会对您有所帮助:

declare 

   sel_username varchar2(30); 
   r_user_id    varchar2(30); 
   r_username   varchar2(30); 
   user_cmd     varchar2(200); 

BEGIN
/* 
   This procedure will delete a single user_id and can be used to delete a user 
   with none displayable characters in the name 

   **Replace** the user_id  in this script to that you want to delete !! 

   Author: Ulrich Henkenjohann  -  March 2010 / tested on ORACLE 10.2.0.4 

*/      
-- select the username for a special user_id. Ther username may contain none displayed characters

   select username into sel_username from dba_users where user_id = 34; 
   select user_id, username into r_user_id , r_username from dba_users where username = sel_username ; 
   DBMS_OUTPUT.PUT_LINE('Selected user: ' || r_user_id || ' ' || r_username); 

-- If a test is needed, an alter passwort command may be usefull 
-- user_cmd := 'ALTER USER "' || r_username || '" IDENTIFIED BY PASSWORDX '; 

-- Drop the selected user 

   user_cmd := 'DROP USER "' || r_username || '" CASCADE '; 
   DBMS_OUTPUT.PUT_LINE('Executing user_cmd: ' || user_cmd ); 
   execute immediate user_cmd ; 

END;
/
于 2010-03-24T11:06:24.103 回答
0

我不了解 Oracle,但您可以尝试用双引号将其括起来吗?

(如果有错,我会删除这个答案)

于 2009-07-22T14:51:50.253 回答