SQL database inspection and utility functions
Inspect tables and column types, identify the current database, and compare values with Haybarn SQL utility functions.
Choose a function
Use metadata queries when you need to understand a database before querying its data. Restrict results by database and schema to avoid confusing objects with the same name.
duckdb_tables()Find tables in the connected databases.duckdb_columns()Inspect column names and declared types.current_database()Identify the selected database.greatest()Choose the largest value within a row.least()Choose the smallest value within a row.
Catalog metadata describes the connected engine and loaded extensions. Function availability can differ between the browser runtime and a native installation; select the matching reference snapshot.
Inspect table column names and types
Query column metadata to inspect a table’s column names, declared types, and positions without scanning its rows.
Use column_index to preserve schema order. Filter the database, schema, and table to identify one object.
Guide example · Run to view results.
| column_name | data_type |
|---|---|
product | VARCHAR |
quantity | INTEGER |
Watch for: Alphabetical column order is not schema order. Include ORDER BY column_index when generating a schema listing.
All database & utility functions
562 functions in Haybarn WASM 2.0.0-rc12. Browse the filtered catalog →
add_parquet_key()ago()alias()Returns the name of a given expression
arrow_kv_metadata()arrow_scan()arrow_scan_dumb()assert_true()binom()Returns binom(n,k)
bitstring()Pads the bitstring until the specified length
bitstring_byte_comparable()Converts a BIT to a binary comparable sort key
can_cast_implicitly()Whether or not we can implicitly cast from the source type to the other type
cardinality()Returns the size of the map (or the number of entries in the map)
cast_to_type()Casts the first argument to the type of the second argument
century()Extract the century component from a date or timestamp
checkpoint()collate_aa()collate_af()collate_am()collate_ar()collate_ar_sa()collate_as()collate_az()collate_bal()collate_be()collate_bg()collate_blo()collate_bn()collate_bo()collate_br()collate_bs()collate_ca()collate_ceb()collate_chr()collate_cs()collate_cu()collate_cy()collate_da()collate_de()collate_de_at()collate_dsb()collate_dz()collate_ee()collate_el()collate_en()collate_en_us()collate_eo()collate_es()collate_et()collate_fa()collate_fa_af()collate_ff()collate_fi()collate_fil()collate_fo()collate_fr()collate_fr_ca()collate_fy()collate_ga()collate_gl()collate_gu()collate_ha()collate_haw()collate_he()collate_he_il()collate_hi()collate_hr()collate_hsb()collate_hu()collate_hy()collate_id()collate_id_id()collate_ig()collate_is()collate_it()collate_ja()collate_ka()collate_kk()collate_kl()collate_km()collate_kn()collate_ko()collate_kok()collate_ku()collate_ky()collate_lb()collate_lij()collate_lkt()collate_ln()collate_lo()collate_lt()collate_lv()collate_mk()collate_ml()collate_mn()collate_mr()collate_ms()collate_mt()collate_my()collate_nb()collate_nb_no()collate_ne()collate_nl()collate_nn()collate_no()collate_noaccent()collate_nso()collate_om()collate_or()collate_pa()collate_pa_in()collate_pl()collate_ps()collate_pt()collate_ro()collate_ru()collate_sa()collate_se()collate_sgs()collate_si()collate_sk()collate_sl()collate_smn()collate_sq()collate_sr()collate_sr_ba()collate_sr_me()collate_sr_rs()collate_ssy()collate_st()collate_sv()collate_sw()collate_ta()collate_te()collate_th()collate_tk()collate_tn()collate_to()collate_tr()collate_ug()collate_uk()collate_ur()collate_uz()collate_vi()collate_vo()collate_wae()collate_wo()collate_xh()collate_yi()collate_yo()collate_zh()collate_zh_cn()collate_zh_hk()collate_zh_mo()collate_zh_sg()collate_zh_tw()collate_zu()collations()combine()constant_or_null()If arg2 is NULL, return NULL. Otherwise, return arg1.
copy_database()cot()Computes the cotangent of x
create_external_resource()create_sort_key()Constructs a binary-comparable sort key based on a set of input parameters and sort qualifiers
cume_dist()The number of partition rows preceding or peer with current row / total partition rows.
current_catalog()current_connection_id()Get the current connection_id
current_database()Returns the name of the currently active database
current_query()Returns the current query as a string
current_query_id()Get the current query_id
current_role()current_schema()Returns the name of the currently active schema. Default is main
current_schemas()Returns list of schemas. Pass a parameter of True to include implicit schemas
current_setting()Returns the current value of the configuration setting
current_transaction_id()Get the current global transaction_id
current_user()currval()Return the current value of the sequence. Note that nextval must be called at least once prior to calling currval.
damerau_levenshtein()Extension of Levenshtein distance to also include transposition of adjacent characters as an allowed edit operation. In other words, the minimum number of edit operations (insertions, deletions, substitutions or transpositions) required to change one string to another. Characters of different cases (e.g.,
aandA) are considered different.database_list()database_size()decade()Extract the decade component from a date or timestamp
decimal_division()Divides two DECIMAL values using exact integer arithmetic and round-half-to-even, returning a DECIMAL result with scale determined by SQL Server semantics (result_scale = max(6, s1 + p2 + 1)).
dense_rank()The rank of the current row without gaps
deregister_external_resource()destroy_external_resource()disable_checkpoint_on_shutdown()disable_logging()disable_object_cache()disable_optimizer()disable_print_progress_bar()disable_profile()disable_profiling()disable_progress_bar()disable_verification()disable_verify_parallelism()duckdb_approx_database_count()duckdb_available_metrics()duckdb_columns()Query column metadata to inspect a table’s column names, declared types, and positions without scanning its rows.
duckdb_connection_count()duckdb_constraints()duckdb_coordinate_systems()duckdb_databases()duckdb_dependencies()duckdb_dialects()duckdb_eviction_queues()duckdb_extension_repositories()duckdb_extensions()duckdb_external_file_cache()duckdb_external_resource_types()duckdb_external_resources()duckdb_functions()duckdb_grammar_extensions()duckdb_indexes()duckdb_keywords()duckdb_log_contexts()duckdb_logs()duckdb_logs_parsed()duckdb_memory()duckdb_optimizers()duckdb_prepared_statements()duckdb_profiling_settings()duckdb_schemas()duckdb_secret_type_parameters()duckdb_secret_types()duckdb_secrets()duckdb_sequences()duckdb_settings()duckdb_table_sample()duckdb_tables()List table metadata, including database, schema, and table names. Use it to inspect the connected database without reading table data.
duckdb_temporary_files()duckdb_triggers()duckdb_types()duckdb_variables()duckdb_views()editdist3()The minimum number of single-character edits (insertions, deletions or substitutions) required to change one string to the other. Characters of different cases (e.g.,
aandA) are considered different.element_at()Returns a list containing the value for a given key or an empty list if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map’s keys else an error is returned
enable_checkpoint_on_shutdown()enable_logging()enable_object_cache()enable_optimizer()enable_print_progress_bar()enable_profile()enable_profiling()enable_progress_bar()enable_verification()enum_code()Returns the numeric value backing the given enum value
enum_first()Returns the first value of the input enum type
enum_last()Returns the last value of the input enum type
enum_range()Returns all values of the input enum type as an array
enum_range_boundary()Returns the range between the two given enum values as an array. The values must be of the same enum type. When the first parameter is NULL, the result starts with the first value of the enum type. When the second parameter is NULL, the result ends with the last value of the enum type
equi_width_bins()Generates bin_count equi-width bins between the min and max. If enabled nice_rounding makes the numbers more readable/less jagged
era()Extract the era component from a date or timestamp
error()Throws the given error message
extension_versions()fdiv()fill()Fill in missing values using linear interpolation with ORDER BY as the X-axis.
finalize()first_value()The first value of expr in the frame. Can IGNORE or RESPECT NULLS.
force_checkpoint()functions()gamma()Interpolation of (x-1) factorial (so decimal inputs are allowed)
gen_random_uuid()Returns a random UUID v4 similar to this: eeccb8c5-9943-b2bb-bb5e-222f4e14b687
generate_subscripts()geomean()geometric_mean()get_bit()Extracts the nth bit from bitstring; the first (leftmost) bit is indexed 0
get_block_size()get_type()Returns the type of the result of the expression
getvariable()greatest()Compare multiple expressions and return their greatest value. Use this for comparisons within one row rather than across many rows.
histogram_values()icu_calendar_names()icu_collate_aa()icu_collate_af()icu_collate_am()icu_collate_ar()icu_collate_ar_sa()icu_collate_as()icu_collate_az()icu_collate_bal()icu_collate_be()icu_collate_bg()icu_collate_blo()icu_collate_bn()icu_collate_bo()icu_collate_br()icu_collate_bs()icu_collate_ca()icu_collate_ceb()icu_collate_chr()icu_collate_cs()icu_collate_cu()icu_collate_cy()icu_collate_da()icu_collate_de()icu_collate_de_at()icu_collate_dsb()icu_collate_dz()icu_collate_ee()icu_collate_el()icu_collate_en()icu_collate_en_us()icu_collate_eo()icu_collate_es()icu_collate_et()icu_collate_fa()icu_collate_fa_af()icu_collate_ff()icu_collate_fi()icu_collate_fil()icu_collate_fo()icu_collate_fr()icu_collate_fr_ca()icu_collate_fy()icu_collate_ga()icu_collate_gl()icu_collate_gu()icu_collate_ha()icu_collate_haw()icu_collate_he()icu_collate_he_il()icu_collate_hi()icu_collate_hr()icu_collate_hsb()icu_collate_hu()icu_collate_hy()icu_collate_id()icu_collate_id_id()icu_collate_ig()icu_collate_is()icu_collate_it()icu_collate_ja()icu_collate_ka()icu_collate_kk()icu_collate_kl()icu_collate_km()icu_collate_kn()icu_collate_ko()icu_collate_kok()icu_collate_ku()icu_collate_ky()icu_collate_lb()icu_collate_lij()icu_collate_lkt()icu_collate_ln()icu_collate_lo()icu_collate_lt()icu_collate_lv()icu_collate_mk()icu_collate_ml()icu_collate_mn()icu_collate_mr()icu_collate_ms()icu_collate_mt()icu_collate_my()icu_collate_nb()icu_collate_nb_no()icu_collate_ne()icu_collate_nl()icu_collate_nn()icu_collate_no()icu_collate_noaccent()icu_collate_nso()icu_collate_om()icu_collate_or()icu_collate_pa()icu_collate_pa_in()icu_collate_pl()icu_collate_ps()icu_collate_pt()icu_collate_ro()icu_collate_ru()icu_collate_sa()icu_collate_se()icu_collate_sgs()icu_collate_si()icu_collate_sk()icu_collate_sl()icu_collate_smn()icu_collate_sq()icu_collate_sr()icu_collate_sr_ba()icu_collate_sr_me()icu_collate_sr_rs()icu_collate_ssy()icu_collate_st()icu_collate_sv()icu_collate_sw()icu_collate_ta()icu_collate_te()icu_collate_th()icu_collate_tk()icu_collate_tn()icu_collate_to()icu_collate_tr()icu_collate_ug()icu_collate_uk()icu_collate_ur()icu_collate_uz()icu_collate_vi()icu_collate_vo()icu_collate_wae()icu_collate_wo()icu_collate_xh()icu_collate_yi()icu_collate_yo()icu_collate_zh()icu_collate_zh_cn()icu_collate_zh_hk()icu_collate_zh_mo()icu_collate_zh_sg()icu_collate_zh_tw()icu_collate_zu()icu_sort_key()if()import_database()in_search_path()Returns whether or not the database/schema are in the search path
index_key()Generate index keys for a named index on a table (specified by a path struct with required 'table' and optional 'catalog'/'schema' fields) from key column arguments. Currently only supports ART indexes.
invoke()Invokes a lambda function with the given arguments
IS DISTINCT FROM()Returns whether left is distinct from right, treating null as a comparable value.
IS NOT DISTINCT FROM()Returns whether left is not distinct from right, treating null as a comparable value.
is_histogram_other_bin()Whether or not the provided value is the histogram "other" bin (used for values not belonging to any provided bin)
isodow()Extract the isodow component from a date or timestamp
julian()Extract the Julian Day number from a date or timestamp
lag()The value of expr n rows after the current row, or the default. Can IGNORE or RESPECT NULLS.
last_value()The last value of expr in the frame. Can IGNORE or RESPECT NULLS.
lead()The value of expr n rows after the current row, or the default. Can IGNORE or RESPECT NULLS.
least()Returns the smallest value. For strings lexicographical ordering is used. Note that uppercase characters are considered “smaller” than lowercase characters, and collations are not supported.
lgamma()Computes the log of the gamma function
make_type()Construct a type from its name and optional parameters
map()Creates a map from a set of keys and values
metadata_info()microsecond()Extract the microsecond component from a date or timestamp
millennium()Extract the millennium component from a date or timestamp
millisecond()Extract the millisecond component from a date or timestamp
mismatches()The Hamming distance between to strings, i.e., the number of positions with different characters for two strings of equal length. Strings must be of equal length. Characters of different cases (e.g.,
aandA) are considered different.nanoarrow_version()nanosecond()Extract the nanosecond component from a date or timestamp
nextafter()Returns the next floating point value after x in the direction of y
nextval()Return the following value of the sequence.
normalized_interval()Normalizes an INTERVAL to an equivalent interval
now()Returns the current timestamp
nth_value()The nth value of expr in the frame. Can IGNORE or RESPECT NULLS.
ntile()The row bucket in a window partition for a given bucket count
nullif()octet_length()Returns the number of bytes in the
bitstring.parse_duckdb_log_message()Parse the message into the expected logical type
percent_rank()The relative rank of the current row as a fraction
platform()pragma_collations()pragma_database_size()pragma_metadata_info()pragma_platform()pragma_show()pragma_storage_info()pragma_table_info()pragma_user_agent()pragma_version()query()query_table()rank()The rank of the current row with gaps
rank_dense()The rank of the current row without gaps
register_external_resource()register_external_resource_type()remap_struct()Map a struct to another struct type, potentially re-ordering, renaming and casting members and filling in defaults for missing values
row()Create an unnamed STRUCT (tuple) containing the argument values.
row_number()The row number in a window partition
scan_arrow_ipc()seq_scan()session_user()set_bit()Sets the nth bit in bitstring to newvalue; the first (leftmost) bit is indexed 0. Returns a new bitstring
setval()Set the value of the sequence to the specified value. If is_called is true, the sequence is called. If is_called is false, the sequence is not called.
show()show_databases()show_tables()show_tables_expanded()sleep_ms()Sleeps for the specified number of milliseconds and returns NULL
st_asbinary()Returns the Well-Known Binary (WKB) representation of the geometry
st_astext()Returns the Well-Known Text (WKT) representation of the geometry
st_aswkb()Returns the Well-Known Binary (WKB) representation of the geometry
st_aswkt()Returns the Well-Known Text (WKT) representation of the geometry
st_crs()Returns the Coordinate Reference System (CRS) identifier of the geometry
st_geomfromwkb()Creates a geometry from Well-Known Binary (WKB) representation
st_intersects_extent()Returns true if the geometries bounding boxes intersect
st_setcrs()Sets the Coordinate Reference System (CRS) identifier of the geometry
stats()Returns a string with statistics about the expression. Expression can be a column, constant, or SQL expression
storage_info()summary()switch()Creates a switch statement similar to CASE WHEN/THEN
table_info()test_all_types()test_vector_types()to_aggregate_state()Converts a value into the aggregate state of the aggregate function with the given name and signature. The type of the value must exactly match the state layout of the aggregate function. An optional fourth argument supplies constant parameter values (e.g. string_agg's separator) as a list with one entry per argument, using NULL for arguments that are not bound to a constant.
to_arrow_ipc()to_centuries()Construct a century interval
to_decades()Construct a decade interval
to_hours()Construct a hour interval
to_microseconds()Construct a microsecond interval
to_millennia()Construct a millenium interval
to_milliseconds()Construct a millisecond interval
to_minutes()Construct a minute interval
to_quarters()Construct a quarter interval
to_seconds()Construct a second interval
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
typeof()Returns the name of the data type of the result of the expression
user()user_agent()uuid()Returns a random UUID v4 similar to this: eeccb8c5-9943-b2bb-bb5e-222f4e14b687
uuid_extract_version()Extract a version for the given UUID.
uuidv4()Returns a random UUIDv4 similar to this: eeccb8c5-9943-b2bb-bb5e-222f4e14b687
uuidv7()Returns a random UUID v7 similar to this: 019482e4-1441-7aad-8127-eec99573b0a0
variant_array_length()variant_bytes_to_variant()variant_comparator()Returns a binary sort key that orders
input_variantaccording to the logical ordering of VARIANT values (used internally for comparison and ordering).variant_contains()variant_exists()variant_extract()variant_extract_string()variant_group_array()variant_keys()variant_normalize()Normalizes the
input_variantto a canonical representation.variant_to_parquet_variant()variant_type()variant_typeof()Returns the internal type of the
input_variant.vector_type()Returns the VectorType of a given column
verify_parallelism()version()Returns the currently active version of DuckDB in this format: v0.3.2
vertex_extract()Extracts the specified coordinate (X, Y, Z, M) from a point geometry
wavg()weighted_avg()which_secret()write_log()Writes to the logger
xor()Bitwise XOR
__between()Returns whether or not input is between lower and upper.
__cast()Casts value to the target type of the expression.
__internal_barrier()Returns arg unchanged, and marks it as an optimizer barrier: the expression is never evaluated on rows removed by the operators around it
__internal_compress_geometry_point()__internal_compress_integral_ubigint()__internal_compress_integral_uinteger()__internal_compress_integral_usmallint()__internal_compress_integral_utinyint()__internal_compress_string_hugeint()__internal_compress_string_ubigint()__internal_compress_string_uhugeint()__internal_compress_string_uinteger()__internal_compress_string_usmallint()__internal_compress_string_utinyint()__internal_compressed_materialization_cast()__internal_decompress_geometry_point()__internal_decompress_integral_bigint()__internal_decompress_integral_hugeint()__internal_decompress_integral_integer()__internal_decompress_integral_smallint()__internal_decompress_integral_ubigint()__internal_decompress_integral_uhugeint()__internal_decompress_integral_uinteger()__internal_decompress_integral_usmallint()__internal_decompress_string()__internal_tablefilter_bloom_filter()__internal_tablefilter_dynamic()__internal_tablefilter_optional()__internal_tablefilter_prefix_range()__internal_tablefilter_selectivity_optional()