> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/system-tables/sys-schema/sys-schema-stored-functions/ps_thread_account.md).

# ps\_thread\_account

{% hint style="info" %}
Sys Schema is available from MariaDB 10.6.
{% endhint %}

## Syntax

```
sys.ps_thread_account(thread_id)
```

## Description

`ps_thread_account` is a [stored function](/docs/server/server-usage/stored-routines/stored-functions.md) available with the [Sys Schema](/docs/server/reference/system-tables/sys-schema.md) that returns the account (username\@hostname) associated with the given *thread\_id*.

Returns `NULL` if the thread\_id is not found.

## Examples

```sql
SELECT sys.ps_thread_account(sys.ps_thread_id(CONNECTION_ID()));
+----------------------------------------------------------+
| sys.ps_thread_account(sys.ps_thread_id(CONNECTION_ID())) |
+----------------------------------------------------------+
| msandbox@localhost                                       |
+----------------------------------------------------------+

SELECT sys.ps_thread_account(sys.ps_thread_id(2042));
+-----------------------------------------------+
| sys.ps_thread_account(sys.ps_thread_id(2042)) |
+-----------------------------------------------+
| NULL                                          |
+-----------------------------------------------+

SELECT sys.ps_thread_account(sys.ps_thread_id(NULL));
+-----------------------------------------------+
| sys.ps_thread_account(sys.ps_thread_id(NULL)) |
+-----------------------------------------------+
| msandbox@localhost                            |
+-----------------------------------------------+
```

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
