MySQL
Conversion24 fungsi

Fungsi Conversion MySQL

Fungsi untuk konversi tipe data. Temukan semua 24 fungsi conversion di MySQL lengkap dengan syntax, contoh, dan penjelasan bahasa Indonesia.

24 fungsi conversion di MySQL

← Semua fungsi MySQL

BIN

Conversion

Converts a decimal number to its binary string representation. This is shorthand for CONV(num, 10, 2).

Tipe hasil: VARCHAR

BINARY

Conversion

Mengkonversi ekspresi ke tipe BINARY string. Membuat perbandingan string menjadi case-sensitive dan byte-by-byte.

Tipe hasil: BINARY

BIN_TO_UUID

Conversion

Converts a BINARY(16) UUID back to its string representation. The inverse of UUID_TO_BIN().

Tipe hasil: VARCHAR(36)

CAST

Conversion

Mengkonversi nilai ke tipe data tertentu. Standar SQL untuk type casting.

Tipe hasil: Specified type

CONNECTION_ID

Conversion

Returns the connection ID (thread ID) for the current connection.

Tipe hasil: BIGINT UNSIGNED

CONV

Conversion

Converts a number from one base to another. Supports bases from 2 to 36.

Tipe hasil: VARCHAR

CONVERT

Conversion

Mengkonversi nilai ke tipe data atau charset tertentu. Alternatif untuk CAST dengan sintaks berbeda.

Tipe hasil: Specified type

DATABASE

Conversion

Returns the name of the currently active (selected) database.

Tipe hasil: VARCHAR

FORMAT

Conversion

Formats a number with thousands separators and a specified number of decimal places. Useful for displaying numbers in a human-readable format.

Tipe hasil: VARCHAR

FROM_UNIXTIME

Conversion

Converts a Unix timestamp to a DATETIME value or a formatted string. The inverse of UNIX_TIMESTAMP().

Tipe hasil: DATETIME | VARCHAR

INET6_ATON

Conversion

Converts an IPv4 or IPv6 address string to binary format. Supports both IP address formats.

Tipe hasil: VARBINARY(16)

INET6_NTOA

Conversion

Converts a binary IP address to string format. This is the reverse of INET6_ATON().

Tipe hasil: VARCHAR

INET_ATON

Conversion

Converts an IPv4 address string to an unsigned integer. Useful for efficient storage and range-based IP queries.

Tipe hasil: BIGINT UNSIGNED

INET_NTOA

Conversion

Converts an unsigned integer to an IPv4 address string. The inverse of INET_ATON().

Tipe hasil: VARCHAR(15)

LAST_INSERT_ID

Conversion

Returns the last AUTO_INCREMENT value generated for a column in the current connection.

Tipe hasil: BIGINT UNSIGNED

OCT

Conversion

Converts a decimal number to its octal string representation. Shorthand for CONV(num, 10, 8).

Tipe hasil: VARCHAR

STR_TO_DATE

Conversion

Converts a string to a DATE, DATETIME, or TIME value based on the provided format string. The inverse of DATE_FORMAT.

Tipe hasil: DATE | DATETIME | TIME

TIME_FORMAT

Conversion

Formats a TIME value into a string according to the specified format. Similar to DATE_FORMAT but designed specifically for time values.

Tipe hasil: VARCHAR

UNIX_TIMESTAMP

Conversion

Returns the Unix timestamp (seconds since 1970-01-01 00:00:00 UTC). When called with no argument, returns the current Unix timestamp.

Tipe hasil: BIGINT

USER

Conversion

Returns the username and hostname of the current MySQL connection.

Tipe hasil: VARCHAR

UUID

Conversion

Generates a version 1 Universal Unique Identifier (UUID). The returned value follows the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Tipe hasil: VARCHAR(36)

UUID_SHORT

Conversion

Generates a unique 64-bit unsigned integer. Faster and more compact than UUID().

Tipe hasil: BIGINT UNSIGNED

UUID_TO_BIN

Conversion

Converts a UUID string to BINARY(16) format for more efficient storage.

Tipe hasil: BINARY(16)

VERSION

Conversion

Returns a string indicating the MySQL server version.

Tipe hasil: VARCHAR