Difference between revisions of "Find another process and kill it."
Jump to navigation
Jump to search
(Created page with "Change the default schema/database. <div class='ht'> <div class=params>schema:gisq</div> <div> Sometimes users set off queries that may take a very long time to complete. We m...") |
|||
Line 22: | Line 22: | ||
ALTER SYSTEM KILL SESSION '12,33' | ALTER SYSTEM KILL SESSION '12,33' | ||
-- 12,33 is the sid and serial# | -- 12,33 is the sid and serial# | ||
</source> | |||
<source lang='sql' class='def e-sqlserver'>USE master; | <source lang='sql' class='def e-sqlserver'>USE master; | ||
SELECT spid , nt_username, | SELECT spid , nt_username, |
Revision as of 13:34, 17 July 2012
Change the default schema/database.
schema:gisq
Sometimes users set off queries that may take a very long time to complete. We may want to find such long running processes and stop them. Some kind of administrative account is usually required.
LIST APPLICATION;
-- 294 and 306 are "Appl Handle" values
FORCE APPLICATION (294,306)
SELECT * FROM pg_stat_activity;
SELECT sid, serial#, username,
TO_CHAR(logon_time,'Month dd hh24:mi:ss')
FROM sys.v_$session;
ALTER SYSTEM KILL SESSION '12,33'
-- 12,33 is the sid and serial#
USE master;
SELECT spid , nt_username,
datediff(s,login_time,GETDATE())
FROM sysprocesses;
DECLARE @var1 int
SELECT @var1 = spid
FROM sysprocesses
WHERE nt_username='andrew'
AND spid<>@@spid
EXEC ('kill '+@var1);
SELECT spid , nt_username,
datediff(s,login_time,GETDATE())
FROM sysprocesses;
SHOW PROCESSLIST;
KILL 16318