Other functions

## currentDatabase[​](#currentDatabase "Direct link to currentDatabase")

Introduced in: v1.1.0

Returns the name of the current database.
Useful in table engine parameters of `CREATE TABLE` queries where you need to specify the database.

Also see the [`SET` statement](/docs/sql-reference/statements/use).

**Syntax**

```
currentDatabase()
```

**Aliases**: `current_database`, `SCHEMA`, `DATABASE`

**Arguments**

- None.

**Returned value**

Returns the current database name. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT currentDatabase()
```

```
┌─currentDatabase()─┐
│ default           │
└───────────────────┘
```

**SQL standard syntax without parentheses**

```
SELECT CURRENT_DATABASE
```

```
┌─CURRENT_DATABASE─┐
│ default          │
└──────────────────┘
```

## currentProfiles[​](#currentProfiles "Direct link to currentProfiles")

Introduced in: v21.9.0

Returns an array of the setting profiles for the current user.

**Syntax**

```
currentProfiles()
```

**Arguments**

- None.

**Returned value**

Returns an array of setting profiles for the current user. [`Array(String)`](/docs/sql-reference/data-types/array)

**Examples**

**Usage example**

```
SELECT currentProfiles();
```

```
┌─currentProfiles()─────────────────────────────┐
│ ['default', 'readonly_user', 'web_analytics'] │
└───────────────────────────────────────────────┘
```

## currentQueryID[​](#currentQueryID "Direct link to currentQueryID")

Introduced in: v25.2.0

Returns current Query id.

**Syntax**

```
currentQueryID()
```

**Aliases**: `current_query_id`

**Arguments**

- None.

**Returned value**

**Examples**

**Example**

```
SELECT currentQueryID();
```

```
┌─currentQueryID()─────────────────────┐
│ 1280d0e8-1a08-4524-be6e-77975bb68e7d │
└──────────────────────────────────────┘
```

## currentRoles[​](#currentRoles "Direct link to currentRoles")

Introduced in: v21.9.0

Returns an array of the roles which are assigned to the current user.

**Syntax**

```
currentRoles()
```

**Arguments**

- None.

**Returned value**

Returns an array of the roles which are assigned to the current user. [`Array(String)`](/docs/sql-reference/data-types/array)

**Examples**

**Usage example**

```
SELECT currentRoles();
```

```
┌─currentRoles()─────────────────────────────────┐
│ ['sql-console-role:[email protected]'] │
└────────────────────────────────────────────────┘
```

## currentSchemas[​](#currentSchemas "Direct link to currentSchemas")

Introduced in: v23.7.0

Same as function [`currentDatabase`](#currentDatabase) but

- accepts a boolean argument which is ignored
- returns the database name as an array with a single value.

Function `currentSchemas` only exists for compatibility with PostgreSQL.
Please use `currentDatabase` instead.

Also see the [`SET` statement](/docs/sql-reference/statements/use).

**Syntax**

```
currentSchemas(bool)
```

**Aliases**: `current_schemas`

**Arguments**

- `bool` — A boolean value, which is ignored. [`Bool`](/docs/sql-reference/data-types/boolean)

**Returned value**

Returns a single-element array with the name of the current database. [`Array(String)`](/docs/sql-reference/data-types/array)

**Examples**

**Usage example**

```
SELECT currentSchemas(true)
```

```
┌─currentSchemas(true)─┐
│ ['default']          │
└──────────────────────┘
```

## currentUser[​](#currentUser "Direct link to currentUser")

Introduced in: v20.1.0

Returns the name of the current user.
In case of a distributed query, the name of the user who initiated the query is returned.

**Syntax**

```
currentUser()
```

**Aliases**: `current_user`, `user`

**Arguments**

- None.

**Returned value**

Returns the name of the current user, otherwise the login of the user who initiated the query. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT currentUser()
```

```
┌─currentUser()─┐
│ default       │
└───────────────┘
```

**SQL standard syntax without parentheses**

```
SELECT CURRENT_USER
```

```
┌─CURRENT_USER─┐
│ default      │
└──────────────┘
```

## defaultProfiles[​](#defaultProfiles "Direct link to defaultProfiles")

Introduced in: v21.9.0

Returns an array of default setting profile names for the current user.

**Syntax**

```
defaultProfiles()
```

**Arguments**

- None.

**Returned value**

Returns an array of default setting profile names for the current user. [`Array(String)`](/docs/sql-reference/data-types/array)

**Examples**

**Usage example**

```
SELECT defaultProfiles();
```

```
┌─defaultProfiles()─┐
│ ['default']       │
└───────────────────┘
```

## defaultRoles[​](#defaultRoles "Direct link to defaultRoles")

Introduced in: v21.9.0

Returns an array of default roles for the current user.

**Syntax**

```
defaultRoles()
```

**Arguments**

- None.

**Returned value**

Returns an array of default roles for the current user. [`Array(String)`](/docs/sql-reference/data-types/array)

**Examples**

**Usage example**

```
SELECT defaultRoles();
```

```
┌─defaultRoles()─────────────────────────────────┐
│ ['sql-console-role:[email protected]'] │
└────────────────────────────────────────────────┘
```

## defaultValueOfArgumentType[​](#defaultValueOfArgumentType "Direct link to defaultValueOfArgumentType")

Introduced in: v1.1.0

Returns the default value for a given data type.
Does not include default values for custom columns set by the user.

**Syntax**

```
defaultValueOfArgumentType(expression)
```

**Arguments**

- `expression` — Arbitrary type of value or an expression that results in a value of an arbitrary type. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns `0` for numbers, an empty string for strings or `NULL` for Nullable types. [`UInt8`](/docs/sql-reference/data-types/int-uint) or [`String`](/docs/sql-reference/data-types/string) or [`NULL`](/docs/sql-reference/syntax#null)

**Examples**

**Usage example**

```
SELECT defaultValueOfArgumentType(CAST(1 AS Int8));
```

```
┌─defaultValueOfArgumentType(CAST(1, 'Int8'))─┐
│                                           0 │
└─────────────────────────────────────────────┘
```

**Nullable example**

```
SELECT defaultValueOfArgumentType(CAST(1 AS Nullable(Int8)));
```

```
┌─defaultValueOfArgumentType(CAST(1, 'Nullable(Int8)'))─┐
│                                                  ᴺᵁᴸᴸ │
└───────────────────────────────────────────────────────┘
```

## defaultValueOfTypeName[​](#defaultValueOfTypeName "Direct link to defaultValueOfTypeName")

Introduced in: v1.1.0

Returns the default value for the given type name.

**Syntax**

```
defaultValueOfTypeName(type)
```

**Arguments**

- `type` — A string representing a type name. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the default value for the given type name: `0` for numbers, an empty string for strings, or `NULL` for Nullable [`UInt8`](/docs/sql-reference/data-types/int-uint) or [`String`](/docs/sql-reference/data-types/string) or [`NULL`](/docs/sql-reference/syntax#null)

**Examples**

**Usage example**

```
SELECT defaultValueOfTypeName('Int8');
```

```
┌─defaultValueOfTypeName('Int8')─┐
│                              0 │
└────────────────────────────────┘
```

**Nullable example**

```
SELECT defaultValueOfTypeName('Nullable(Int8)');
```

```
┌─defaultValueOfTypeName('Nullable(Int8)')─┐
│                                     ᴺᵁᴸᴸ │
└──────────────────────────────────────────┘
```

## displayName[​](#displayName "Direct link to displayName")

Introduced in: v22.11.0

Returns the value of `display_name` from [config](/docs/operations/configuration-files) or the server's Fully Qualified Domain Name (FQDN) if not set.

**Syntax**

```
displayName()
```

**Arguments**

- None.

**Returned value**

Returns the value of `display_name` from config or server FQDN if not set. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT displayName();
```

```
┌─displayName()─┐
│ production    │
└───────────────┘
```

## dumpColumnStructure[​](#dumpColumnStructure "Direct link to dumpColumnStructure")

Introduced in: v1.1.0