删除用户名中带单引号的 oracle-user

发布于 2024-07-29 17:36:44 字数 214 浏览 4 评论 0 原文

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

Through a faulty script I have created a user with single quotes around his username (i.e. his username is 'username', not username) on an Oracle 9i system. Now I want to remove that user. Neither "DROP USER 'username'" nor "DROP USER \'username\'" nor "DROP USER (SELECT username FROM all_users where user_id = 123)" worked. How do I get rid of that user?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

以为你会在 2024-08-05 17:36:44
create user "'bla'" identified by bla;

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

drop user "'bla'";
北城半夏 2024-08-05 17:36:44

根据 Oracle 文档.. 。

“带引号的标识符开始和结束
带双引号 (")。如果
您使用以下方式命名模式对象
带引号的标识符,那么您必须使用
每当双引号
你引用那个对象。”

所以这个......

DROP USER "username" CASCADE;

According to Oracle's Documentation...

"A quoted identifier begins and ends
with double quotation marks ("). If
you name a schema object using a
quoted identifier, then you must use
the double quotation marks whenever
you refer to that object."

So this...

DROP USER "username" CASCADE;
﹉夏雨初晴づ 2024-08-05 17:36:44

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

希望有人觉得这很有用,

迈克

I know this is an old post, but for anyone stumbling across this as the result of a search on this problem - the issue appears to be that a database trigger is firing on drop user.
I've posted the solution I found for Oracle XE ( probably the same for other 10g releases)
here

Hope someone finds this useful,

Mike

淡水深流 2024-08-05 17:36:44

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

Try DROP USER "'username'" or DROP USER ''username''. (Note that those last quotes are all single quotes)

独闯女儿国 2024-08-05 17:36:44

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

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

I don't know Oracle off-hand, but might you try enclosing it in double quotes?

(I'll delete this answer if its wrong)

滿滿的愛 2024-08-05 17:36:44

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

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;
/

The following code might help you :

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;
/
愁以何悠 2024-08-05 17:36:44

再次采用更好的格式:

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;
/

Once again with better format:

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;
/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文