> 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.arkannis.net/database/oracle-sql-pl-sql/oracle-sql-kill-sessions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
