ms sqlserver:
declare @i int declare cur cursor for select spid from sysprocesses where db_name(dbid)= 'dbname ' open cur fetch next from cur into @i while @@fetch_status=0 begin exec( 'kill '+@i) fetch next from cur into @i end close cur deallocate cur
oracle中列出当前数据库建立的会话情况:
select sid,serial#,username,program,machine,status from v$session;
其中,
SID 会话(session)的ID号;
SERIAL# 会话的序列号,和SID一起用来唯一标识一个会话;
USERNAME 建立该会话的用户名;
PROGRAM 这个会话是用什么工具连接到数据库的;
STATUS 当前这个会话的状态,ACTIVE表示会话正在执行某些任务,INACTIVE表示当前会话没有执行任何
如果DBA要手工断开某个会话,则执行:
alter system kill session '100,88';
上面一条命令将断开 sid为100,serial为88的那条连接。