> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for SESSION_USER function

# SESSION_USER

Returns the name of the user running the current query.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
SESSION_USER()
```

## Return Types

`TEXT`

## Examples

<div className="query-window">
  ```
  SELECT SESSION_USER() as user;
  ```

  | user <span>text</span> |
  | :--------------------- |
  | demoproxy              |

  <p><span>Rows: 1</span><span>Execution time: 5.75ms</span></p>
</div>

The following code example shows the effective privileges of the roles directly assigned to the user running the query:

<div className="query-window">
  ```
  SELECT
  AR.grantee,
    AR.role_name,
    OP.privilege_type,
    OP.object_type,
    OP.object_name
  FROM information_schema.applicable_roles AS AR
  JOIN information_schema.object_privileges AS OP
  ON (AR.role_name = OP.grantee)
  WHERE
    AR.grantee = session_user();

  ```

  | grantee <span>text</span> | role\_name <span>text</span> | privilege\_type <span>text</span> | object\_type <span>text</span> | object\_name <span>text</span> |
  | :------------------------ | :--------------------------- | :-------------------------------- | :----------------------------- | :----------------------------- |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | usaccidentdata                 |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | tournaments                    |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | t                              |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | rankings                       |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | playstats                      |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | players                        |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | levels                         |
  | demoproxy                 | proxy\_role                  | SELECT                            | table                          | games                          |
  | demoproxy                 | proxy\_role                  | USAGE                             | schema                         | public                         |

  <p><span>Rows: 9</span><span>Execution time: 40.41ms</span></p>
</div>

**Example**

Dynamic security through a view which uses `session_user()`.

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
-- user bob created view:
create view my_employee_data as select * from employees where user_name = session_user();

-- user alice queries it:
select * from my_employee_data; -- session_user() will be evaluated to 'alice' for this query
```

**Returns**

| user\_name | ... |
| :--------- | :-- |
| alice      | ... |
