- 浏览: 87166 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
guji528:
可以这样监控某Oracle用户已执行的sql:
--TEST用 ...
v$sql,v$sqlarea,v$sqltext区别 -
xiaoliu216:
印象深刻。。。
爱情守则
On the Oracle-L mailing list a user requested a procedure to allow a developer to kill his own process. This contributed quite a few comments which I will list below and I posted a method that I use when I have the same requirement.
To create the stored procedure logon as a sysdba through sqlplus and explicitly grant the required rights to system and then create the procedure.
grant alter system to system;
grant select on sys.v_$session to system;
create or replace procedure system.killsession (killsid IN VARCHAR2)
as
killserial varchar2(20);
begin
killserial:='none';
select serial#
into killserial
from sys.v_$session
where sid = killsid
and username = 'WES';
execute immediate 'alter system kill session ''' || to_char (killsid) || ', ' || to_char (killserial) || '''' ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('The SID ' || killsid || ' does not exist or cannot be killed');
end ;
Grant execute on the procedure to the user
For example, userxxx needs access to kill sessions so you would type the following:-
grant execute on system.killsession to userxxx;
The user needs to know the sid of the session being killed. For example, if a user needs to kill a session with a SID of 140 they would type:-
set serveroutput on
exec system.killsession ('140');
If they get the following error then there is no SID with a username of WES currently connected:-
The SID 140 does not exist or cannot be killed
The various thoughts on allowing such a procedure centred on two strands, security and practical considerations
Security issues
• Why do they need to kill jobs, what is causing the issue
What will developers want next
Sarbanes-Oxley considerations
Practical
• How do you know the developer will kill one of his own processes and not a co-worker (think apps or sysadm job)
Can you use resource profiles to limit CPU usage
Use a standby to allow unrestricted resource usage
My view is that in certain development environments, for certain users it is reasonable to allow them to kill a process that is running rogue and as such I am happy to provide such a facility. This would not be allowed either unrestricted or in any sort of controlled environment such as production and pre-production.
To create the stored procedure logon as a sysdba through sqlplus and explicitly grant the required rights to system and then create the procedure.
grant alter system to system;
grant select on sys.v_$session to system;
create or replace procedure system.killsession (killsid IN VARCHAR2)
as
killserial varchar2(20);
begin
killserial:='none';
select serial#
into killserial
from sys.v_$session
where sid = killsid
and username = 'WES';
execute immediate 'alter system kill session ''' || to_char (killsid) || ', ' || to_char (killserial) || '''' ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('The SID ' || killsid || ' does not exist or cannot be killed');
end ;
Grant execute on the procedure to the user
For example, userxxx needs access to kill sessions so you would type the following:-
grant execute on system.killsession to userxxx;
The user needs to know the sid of the session being killed. For example, if a user needs to kill a session with a SID of 140 they would type:-
set serveroutput on
exec system.killsession ('140');
If they get the following error then there is no SID with a username of WES currently connected:-
The SID 140 does not exist or cannot be killed
The various thoughts on allowing such a procedure centred on two strands, security and practical considerations
Security issues
• Why do they need to kill jobs, what is causing the issue
What will developers want next
Sarbanes-Oxley considerations
Practical
• How do you know the developer will kill one of his own processes and not a co-worker (think apps or sysadm job)
Can you use resource profiles to limit CPU usage
Use a standby to allow unrestricted resource usage
My view is that in certain development environments, for certain users it is reasonable to allow them to kill a process that is running rogue and as such I am happy to provide such a facility. This would not be allowed either unrestricted or in any sort of controlled environment such as production and pre-production.
发表评论
-
Hp unix中问题解决方案讲解
2010-08-13 18:29 1097当我们经常操作Hp unix的时候,就会遇到在操作系统上rm掉 ... -
HP-UX下删除文件无法释放空间
2010-08-13 18:28 25551 引言 很多人会遇到在操作系统上rm掉一个大的文件,以解决 ... -
v$sql,v$sqlarea,v$sqltext区别
2009-12-17 13:11 3113v$sqltext 存储的是完整的SQL,SQL被分割 SQ ... -
oracle SYS_CONTEXT列表
2009-10-16 10:27 979select SYS_CONTEXT('USERENV', ... -
Oracle CONNECT BY 循环 错误
2009-10-10 23:16 1681java.sql.SQLException: ORA-0143 ... -
Oracle创建索引要做到三个适当
2009-09-28 11:59 2415在Oracle数据库中,创建 ... -
分布式oracle中databaselink
2009-09-21 20:31 1183数据库链接定义从一个Oracle数据库到另一个数据库的单行通信 ... -
oracle:java stored procedure or function
2009-09-20 14:35 1188--java source hasn't return val ... -
create oracle package
2009-09-20 14:15 4284一、程序包的相关知识 1.定义与说明 a. 相关对象的封装 ... -
oracle 动态SQL
2009-09-06 19:47 803sql_update := 'update ' || tabl ... -
1.Oracle游标大全;2.分析Oracle日志文件
2009-07-17 16:28 13371.Oracle游标大全 SELECT语句用于从数据库 ... -
PI 实时数据库系统
2009-07-17 10:21 2355PI 实时数据库系统(Plant Information Sy ... -
rlwrap使用方法
2008-12-04 15:45 1192在Windows操作系统上,当在DOS命令窗口中运行SQL*P ... -
recovery
2008-09-27 15:31 758Understanding the types of fail ... -
backup
2008-09-27 15:30 794The control files contain the m ... -
Database Maintenance
2008-09-24 16:11 805Oracle 10g provides many tools ... -
Assigning a Profile to a User
2008-09-19 15:04 958A profile serves two purposes: ... -
Sizing the Large Pool
2008-09-19 09:35 762select sum(value) "Max MTS ... -
Oracle Net manages
2008-09-18 12:06 1087Oracle Net manages the flow of ... -
Heterogeneous Services
2008-09-16 12:12 845Heterogeneous Services provide ...
相关推荐
You can now kill a session with the "immediate" option. Connection Enhancements A "Set current schema" item has been added to the connection popup menu. It will set the current schema for all windows...
You can now kill a session with the "immediate" option. Connection Enhancements A "Set current schema" item has been added to the connection popup menu. It will set the current schema for all windows...
You can now kill a session with the "immediate" option. Connection Enhancements A "Set current schema" item has been added to the connection popup menu. It will set the current schema for all windows ...
You can now kill a session with the "immediate" option. Connection Enhancements A "Set current schema" item has been added to the connection popup menu. It will set the current schema for all windows ...
- **NAMESPACE**: 库缓存中对象的命名空间,例如`TABLE`、`PROCEDURE`等。 - **TYPE**: 对象的类型,如`INDEX`、`TABLE`等。 - **SHARABLE_MEM**: 对象在共享池中消耗的共享内存数量。 - **LOADS**: 对象被加载的...
select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT' ``` 这个查询返回当前正在等待对象锁的会话ID(SPID)以及它们...
alter system kill session ,把那个session给杀掉,不过你要先查出她的session id or 把该过程重新改个名字就可以了。 57. SQL Reference是个什么东西? 是一本sql的使用手册,包括语法、函数等等,oracle官方...
- 使用`ALTER SYSTEM KILL SESSION`命令可以强制结束指定的会话。 - 需要提供会话的SID和序列号(serial#)。 ##### 2.2 杀死操作系统进程 ```sql SELECT a.username, c.spid AS os_process_id, c.pid AS oracle_...
2. **终止会话**:使用`ALTER SYSTEM KILL SESSION`命令来终止锁定的会话。例如: ```sql ALTER SYSTEM KILL SESSION 'sid, serial#'; ``` 这里需要注意的是,`sid`和`serial#`应替换为实际查询到的值。 #### ...
SQL> alter system kill session 'sid,serial#'; 如果这命令不行,找它UNIX的进程数 SQL> select pro.spid from v$session ses,v$process pro where ses.sid=21 and ses.paddr=pro.addr; 说明:21是某个连接的sid...
99乘法表java源码OracleDBUtils ...killSession( tSid in number ); 此过程将会话 SID(来自视图 V$SESSION)作为参数并通过调用 orakill.exe(在 Windows 服务器上)或 kill -9(在 UNIX 机器上)来终止相应的会话。
7. **解决死锁问题**:首先,通过查询`v$locked_object`和`v$session`视图找到死锁的会话信息,然后使用`ALTER SYSTEM KILL SESSION 'sid,serial#';`终止会话。 8. **连接字符**:在Oracle中,连接两个字符串通常...
- `ALTER SYSTEM KILL SESSION`:强制结束会话。 - `DBA_HIST_SYSMETRIC_SUMMARY` 视图可用于性能历史分析。 9. **权限和角色管理**: - `CREATE ROLE` 和 `DROP ROLE`:创建和删除角色。 - `GRANT ROLE TO` 和...
- `ALTER SYSTEM KILL SESSION`:结束特定会话以解除死锁。 8. **分区表管理**: - `CREATE TABLE ... PARTITION BY`:创建分区表,提高大规模数据的查询和维护效率。 9. **存储过程和函数**: - `CREATE ...
要为用户授予调试任何过程的权限,使用`GRANT debug any procedure, debug connect session TO USER XXX;`。 8. **查询用户信息** `SELECT username, password FROM dba_users;`可查看所有用户及其密码(注意:在...
阻塞通常由于长时间未提交的事务或高优先级锁导致,可以通过`KILL SESSION`解除。死锁则是两个或更多事务相互等待对方释放资源的情况,Oracle会检测并自动解决死锁,可能将其中一个会话回滚。 关于Undo管理,Oracle...
当对象被其他会话锁定时,可以使用`SELECT * FROM v$locked_object`查询锁定的对象,并通过`ALTER SYSTEM KILL SESSION 'session_id,serial#'`终止相关会话,但需谨慎操作,避免数据丢失。 4. **查看对象状态**: ...