> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/database/oracle-sql-pl-sql/oracle-sql-kill-sessions.md).

# Oracle SQL - Kill Sessions

{% hint style="info" %}
The <mark style="color:orange;">`KILL SESSION`</mark> command doesn't actually kill the session. It merely asks the session to kill itself. In some situations, like waiting for a reply from a remote database or rolling back transactions, the session will not kill itself immediately and will wait for the current operation to complete. In these cases the session will have a status of "marked for kill". It will then be killed as soon as possible.
{% endhint %}

* Check the status to confirm

```sql
SELECT sid, serial#, status, username FROM v$session;
```

* You can also use the <mark style="color:orange;">`IMMEDIATE`</mark> clause:

```sql
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
```

{% hint style="info" %}
The <mark style="color:orange;">`IMMEDIATE`</mark> clause does not affect the work performed by the command, but it returns control back to the current session immediately, rather than waiting for confirmation of the kill. Have a look at Killing Oracle Sessions.
{% endhint %}

* Update If you want to kill all the sessions, you could just prepare a small script:

```sql
SELECT 'ALTER SYSTEM KILL SESSION '''||sid||','||serial#||''' IMMEDIATE;' FROM v$session;
```

{% hint style="info" %}
Spool the above to a .sql file and execute it, or, copy paste the output and run it.
{% endhint %}
