# Secondary Functions

- [Bit Functions and Operators](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators.md): Perform bitwise logic and manipulation. This section covers operators like AND, OR, XOR, and functions for shifting bits or counting set bits in binary data.
- [BIT\_COUNT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bit_count.md): Count the set bits. This function returns the number of bits that are set to 1 in the binary representation of a number.
- [~](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-not.md): Invert all bits. This unary operator flips every bit in the operand, changing 1s to 0s and 0s to 1s.
- [|](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-or.md): Perform bitwise OR. This operator compares bits and returns 1 if at least one of the corresponding bits is 1.
- [^](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-xor.md): Perform bitwise exclusive OR. This operator returns 1 only if the corresponding bits of the operands are different.
- [&](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise_and.md): Perform bitwise AND. This operator compares bits of two operands and returns 1 only if both corresponding bits are 1.
- [Parentheses](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/parentheses.md): Control operator precedence. Parentheses are used to group expressions and enforce the order of evaluation in complex operations.
- [<<](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-left.md): Shift bits to the left. This operator shifts the binary representation of a number to the left by a specified number of positions, filling with zeros.
- [>>](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-right.md): Shift bits to the right. This operator shifts the binary representation of a number to the right by a specified number of positions.
- [TRUE FALSE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/true-false.md): Boolean literal for 1 = TRUE or 0 = FALSE, respectively.
- [Encryption, Hashing and Compression Functions](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions.md): Learn about encryption, hashing, and compression functions. This section details SQL functions for securing data, generating hashes, and compressing/decompressing information within your database.
- [AES\_DECRYPT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_decrypt.md): Decrypt data using AES. This function decrypts a string that was encrypted using the Advanced Encryption Standard (AES) algorithm.
- [AES\_ENCRYPT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/aes_encrypt.md): Encrypt data using AES. This function encrypts a string using the Advanced Encryption Standard (AES) algorithm and returns a binary string.
- [COMPRESS](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/compress.md): Compress a string. This function compresses a string argument and returns the result as a binary string, useful for saving storage space.
- [DECODE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/decode.md): Decrypt a string. This function decrypts an encrypted string using a password. It is the reverse of the ENCODE function.
- [DES\_DECRYPT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_decrypt.md): Decrypt data using DES. This function decrypts a string that was encrypted using the Data Encryption Standard (DES) algorithm.
- [DES\_ENCRYPT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/des_encrypt.md): Encrypt data using DES. This function encrypts a string using the Data Encryption Standard (DES) algorithm.
- [ENCODE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encode.md): Encrypt a string. This function encrypts a string using a password, returning a binary string. It is the reverse of the DECODE function.
- [ENCRYPT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/encrypt.md): Encrypt a string using Unix crypt(). This function encrypts a string using the Unix crypt() system call, typically used for password hashing.
- [KDF](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/kdf.md): Derive a key. This function derives a key from a password using a Key Derivation Function (KDF), enhancing security for password storage.
- [MD5](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/md5.md): Calculate MD5 checksum. This function returns the MD5 hash of a string as a 32-character hexadecimal number.
- [OLD\_PASSWORD](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/old_password.md): Generate pre-4.1 password hash. This function creates a password hash compatible with the hashing method used in MySQL versions prior to 4.1.
- [PASSWORD](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/password.md): Calculate password hash. This function calculates a password hash string for a plaintext password.
- [RANDOM\_BYTES](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/random_bytes.md): Generate random bytes. This function returns a binary string of random bytes of a specified length, suitable for cryptographic use.
- [SHA1](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha1.md): Calculate SHA-1 checksum. This function computes the SHA-1 160-bit checksum for a string, returning a 40-character hexadecimal string.
- [SHA2](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/sha2.md): Calculate SHA-2 checksum. This function computes the SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512).
- [UNCOMPRESS](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompress.md): Uncompress a compressed string. This function uncompresses a binary string compressed by the COMPRESS function.
- [UNCOMPRESSED\_LENGTH](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/encryption-hashing-and-compression-functions/uncompressed_length.md): Return length of uncompressed string. This function returns the length of a compressed string before it was compressed.
- [Information Functions](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions.md): Retrieve system and session metadata. This section details functions to access database names, user details, version info, and query statistics like row counts.
- [BENCHMARK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/benchmark.md): Execute an expression repeatedly. This function runs a scalar expression a specified number of times, primarily for measuring query execution speed.
- [BINLOG\_GTID\_POS](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/binlog_gtid_pos.md): Retrieve GTID position from a binary log file. This function returns the Global Transaction ID corresponding to a specific file and position in the binlog.
- [CHARSET](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/charset.md): Return the character set of a string. This function identifies the character set encoding used by the argument.
- [COERCIBILITY](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/coercibility.md): Determine collation coercibility. This function returns a numeric value indicating the priority of the argument's collation in comparison operations.
- [COLLATION](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/collation.md): Return the collation of a string. This function outputs the name of the collation rule used for sorting and comparing the string argument.
- [CONNECTION\_ID](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/connection_id.md): Return the connection ID. This function retrieves the unique thread identifier for the current client connection.
- [CURRENT\_ROLE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_role.md): Returns the current role. The current role can be set with SET ROLE or SET DEFAULT ROLE.
- [CURRENT\_USER](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user.md): Return the authenticated user name. This function displays the user name and host name combination used by the server to authenticate the current client.
- [DATABASE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/database.md): Return the default database name. This function outputs the name of the currently selected database for the session.
- [DECODE\_HISTOGRAM](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/decode_histogram.md): Inspect histogram data. This function allows viewing the distribution statistics stored in a histogram for query optimization analysis.
- [DEFAULT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/default.md): Return the default value for a column. This function retrieves the value assigned to a column if no explicit value is provided during insertion.
- [FOUND\_ROWS](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/found_rows.md): Count rows found by the last SELECT statement. This function returns the total number of rows matching the query, disregarding any LIMIT clause.
- [LAST\_INSERT\_ID](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_insert_id.md): Return the last automatically generated value. This function retrieves the most recent AUTO\_INCREMENT value generated by an INSERT statement.
- [LAST\_VALUE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/last_value.md): Return the last value from a sequence. This function retrieves the most recently generated value from a sequence object.
- [PROCEDURE ANALYSE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/procedure-analyse.md): Analyze query results. This procedure examines the result set and suggests optimal data types for columns based on the data.
- [ROW\_COUNT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/row_count.md): Count rows affected by the last statement. This function returns the number of rows inserted, updated, or deleted by the previous DML operation.
- [ROWNUM](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/rownum.md)
- [SCHEMA](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/schema.md): Synonym for DATABASE(). Returns the name of the default database currently in use.
- [SESSION\_USER](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user.md): Return the current user name. This function returns the user name and host name as provided by the client when connecting.
- [SYSTEM\_USER](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/system_user.md): Synonym for USER(). Returns the MariaDB user name and host name associated with the current session.
- [USER](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/user.md): Return the current MariaDB user. This function returns the user name and host name provided by the client upon connection.
- [VERSION](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/version.md): Complete VERSION reference for MariaDB. Complete function guide with syntax, parameters, return values, and usage examples with comprehensive examples and.
- [Miscellaneous Functions](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions.md): Explore specialized utilities. This category includes functions for benchmarking, managing UUIDs, converting IP addresses, and handling binary data formats.
- [FORMAT\_BYTES](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes.md): Convert bytes to a human-readable string. This function formats a numeric byte count into units like KiB, MiB, GiB, up to EiB.
- [GET\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock.md): Acquire a named user-level lock. This function attempts to obtain a lock with a specified name and timeout, returning 1 on success or 0 on timeout.
- [INET6\_ATON](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_aton.md): Convert an IPv6 address to binary. This function takes an IPv6 (or IPv4) address string and returns it as a VARBINARY(16) string.
- [INET6\_NTOA](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet6_ntoa.md): Convert a binary IPv6 address to string. This function takes a binary IPv6 address (like from INET6\_ATON) and returns its human-readable string representation.
- [INET\_ATON](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_aton.md): Convert an IPv4 address to an integer. This function takes a dotted-quad IP string (e.g., '1.2.3.4') and returns its numeric representation.
- [INET\_NTOA](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/inet_ntoa.md): Convert an integer to an IPv4 address. This function takes a numeric IP value and returns its dotted-quad string representation.
- [IS\_FREE\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_free_lock.md): Check if a named lock is free. This function returns 1 if the specified lock is available (not currently held), and 0 if it is in use.
- [IS\_IPV4](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4.md): Check validity of an IPv4 address. This function returns 1 if the argument is a valid IPv4 address string, and 0 otherwise.
- [IS\_IPV4\_COMPAT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_compat.md): Check if an IPv6 address is IPv4-compatible. This function returns 1 if the binary IPv6 address represents an IPv4-compatible address.
- [IS\_IPV4\_MAPPED](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv4_mapped.md): Check if an IPv6 address is IPv4-mapped. This function returns 1 if the binary IPv6 address represents an IPv4-mapped address.
- [IS\_IPV6](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_ipv6.md): Check validity of an IPv6 address. This function returns 1 if the argument is a valid IPv6 address string, and 0 otherwise.
- [IS\_USED\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_used_lock.md): Check who holds a named lock. This function returns the connection identifier of the client holding the lock, or NULL if the lock is free.
- [MASTER\_GTID\_WAIT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_gtid_wait.md): Wait for a replica to apply a GTID. This function blocks until the replica has executed transactions up to the specified Global Transaction ID.
- [MASTER\_POS\_WAIT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait.md): Wait for a replica to reach a log position. This function blocks until the replica has read and applied updates up to a specified position in the master's binary log.
- [NAME\_CONST](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const.md): Force a column name for an expression. This function is primarily used internally for replication to ensure consistent column naming.
- [OLD\_VALUE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value.md): Access values in ON DUPLICATE KEY UPDATE. This function retrieves the value that would have been inserted into a column if no key conflict occurred.
- [RELEASE\_ALL\_LOCKS](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks.md): Release all named locks held by the session. This function frees all user-level locks acquired with GET\_LOCK() in the current connection.
- [RELEASE\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock.md): Release a specific named lock. This function frees a user-level lock previously obtained with GET\_LOCK(), allowing others to acquire it.
- [SLEEP](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep.md): Pause query execution. This function pauses the script for a specified number of seconds, returning 0 if successful or 1 if interrupted.
- [SYS\_GUID](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid.md): Generate a UUID without hyphens. This Oracle-compatible function returns a globally unique identifier as a 32-character hexadecimal string.
- [UUID](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid.md): Official UUID() function reference: generate UUIDv1 values, 128-bit 36-character format (aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee), and replication safety.
- [UUID\_SHORT](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short.md): Generate a short 64-bit UUID. This function returns a unique, monotonically increasing integer suitable for use as a compact identifier.
- [UUID\_v4](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4.md): Generate a random UUID (v4). This function returns a version 4 UUID, which is generated using random numbers.
- [UUID\_v7](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7.md): Generate a time-ordered UUID (v7). This function returns a version 7 UUID, which is sortable by creation time.
- [VALUES / VALUE](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value.md): Access values in ON DUPLICATE KEY UPDATE. This function retrieves the value that would have been inserted into a column if no key conflict occurred.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/secondary-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
