Utility Functions
Version dev
Version:
FunctionDescriptionExampleResultAliases

alias(expr)

Returns the name of a given expression

alias(42 + 1)

result

current_database()

Returns the name of the currently active database

current_database()

memory

current_query()

Returns the current query as a string

current_query()

SELECT current_query() AS result

current_schema()

Returns the name of the currently active schema. Default is main

current_schema()

main

current_schemas(include_implicit)

Returns list of schemas. Pass a parameter of True to include implicit schemas

current_schemas(true)

[main, main, main, pg_catalog]

current_setting(setting_name)

Returns the current value of the configuration setting

current_setting('access_mode')

automatic

error(message)

Throws the given error message

error('access_mode')

greatest(arg1, arg2, ...)

Returns the highest value of the set of input parameters

greatest(42, 84)

84

hash(param)

Returns an integer with the hash of the value. Note that this is not a cryptographic hash

hash('🦆')

2595805878642663834

in_search_path(database_name, schema_name)

Returns whether or not the database/schema are in the search path

in_search_path('memory', 'main')

true

least(arg1, arg2, ...)

Returns the lowest value of the set of input parameters

least(42, 84)

42

random()

Returns a random number between 0 and 1

random()

0.4729174713138491

setseed()

Sets the seed to be used for the random function

setseed(0.42)

stats(expression)

Returns a string with statistics about the expression. Expression can be a column, constant, or SQL expression

stats(5)

[Min: 5, Max: 5][Has Null: false, Has No Null: true][Approx Unique: 1]

txid_current()

Returns the current transaction’s ID (a BIGINT). It will assign a new one if the current transaction does not have one already

txid_current()

56

typeof(expression)

Returns the name of the data type of the result of the expression

typeof('abc')

VARCHAR

uuid()

Returns a random UUID similar to this: eeccb8c5-9943-b2bb-bb5e-222f4e14b687

uuid()

111e1179-01dd-4f7e-9a67-139fa9b2236c

gen_random_uuid

version()

Returns the currently active version of DuckDB in this format: v0.3.2

version()

v0.8.2-dev5154

Search Shortcut cmd + k | ctrl + k