Rya*_*yan 5 sql oracle amazon-s3 oracle11g amazon-web-services
所以我有一个配置了 oracle 数据库的 AWS RDS 服务器实例,我试图强行断开给定用户的所有连接,以便我可以删除该用户并重新创建用户及其架构。
根据 AWS RDS 文档,而不是使用
ALTER SYSTEM KILL SESSION ' sid, serial#' immediate
Run Code Online (Sandbox Code Playgroud)
我们应该使用
exec rdsadmin.rdsadmin_util.kill(sid, serial#)
Run Code Online (Sandbox Code Playgroud)
所以,我尝试了以下两种方法来杀死所有连接,但它们都不起作用:
BEGIN
for session_to_drop in (select 'exec rdsadmin.rdsadmin_util.kill('|| sid ||',' || serial# || ')' command from v$session where username in ('SCHEMA_NAME'))
loop
dbms_output.put_line(session_to_drop.command);
execute immediate session_to_drop.command;
end loop;
end;
Error report -
ORA-00900: invalid SQL statement
ORA-06512: at line 5
00900. 00000 - "invalid SQL statement"
*Cause:
*Action:
exec rdsadmin.rdsadmin_util.kill(22,48087)
Run Code Online (Sandbox Code Playgroud)
BEGIN
for session_to_drop in (select sid, serial# from v$session where username in ('PERFLAB')) loop
dbms_output.put_line('exec rdsadmin.rdsadmin_util.kill(' || session_to_drop.sid || ',' || session_to_drop.serial# ||')');
exec rdsadmin.rdsadmin_util.kill(session_to_drop.sid, session_to_drop.serial#);
end loop;
end;
Error report -
ORA-06550: line 4, column 10:
PLS-00103: Encountered the symbol "RDSADMIN" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "RDSADMIN" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Run Code Online (Sandbox Code Playgroud)
理想情况下,这些循环会遍历所有现有连接并杀死每个连接;但是,循环中似乎无法识别 exec 命令。
有没有其他人能够解决这个问题?
您不在exec
PL/SQL 块内使用。 exec
是一个 SQL*Plus 命令,它不是 SQL 或 PL/SQL 语言的一部分。您只需在循环中调用该过程
BEGIN
for session_to_drop in (select sid, serial#
from v$session
where username in ('PERFLAB'))
loop
rdsadmin.rdsadmin_util.kill(session_to_drop.sid, session_to_drop.serial#);
end loop;
end;
Run Code Online (Sandbox Code Playgroud)
我猜想您可能希望在终止会话之前锁定帐户,以防止用户在终止会话的过程中重新登录。
归档时间: |
|
查看次数: |
5390 次 |
最近记录: |