Recording a request to kill a user session

I need to write a query that should perform the following task

select SID from v$session where username = 'some user'

and if this particular username is the SID, then destroy that SID using the following command:

alter system kill session 'sid';

I currently have an answer:

alter system kill session
    where sid = select sid from v$session where username = 'some user'

This request fails when there is no specific sid by this username

The query must be such that there is no use of braces '{' or '}'

And the query should be just one string query, without multiple queries.

DB ORACLE10g

Any suggestions

+3
source share
1 answer

I usually do:

select 'alter system kill session '''||sid||','||serial#||''';'
from v$session
where username = 'someuser';

This will return results, for example:

alter system kill session '11,222';
alter system kill session '22,444';

Then I just copy and paste the result that I want to execute.

( ?), , .

+6

Source: https://habr.com/ru/post/1764026/


All Articles