Collections:
IS_UUID() - Validating UUID String Format
How to validate a UUID (Universal Unique IDentifier) string using the IS_UUID() function?
✍: FYIcenter.com
IS_UUID(uuid) is a MySQL built-in function that
validates a UUID (Universal Unique IDentifier) string.
It only checks if the given UUID is a 32-digit hexadecimal string or not.
For example:
SELECT IS_UUID('447f9022-956d-11ee-b1eb-65d6038dbafa');
-- +-------------------------------------------------+
-- | IS_UUID('447f9022-956d-11ee-b1eb-65d6038dbafa') |
-- +-------------------------------------------------+
-- | 1 |
-- +-------------------------------------------------+
SELECT IS_UUID('aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee');
-- +-------------------------------------------------+
-- | IS_UUID('aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee') |
-- +-------------------------------------------------+
-- | 1 |
-- +-------------------------------------------------+
If the UUID string is too short (less than 32 digits) or invalid characters, IS_UUID() returns 0. For example:
SELECT IS_UUID('447f9022-956d-11ee-b1eb-65d6038d');
-- +---------------------------------------------+
-- | IS_UUID('447f9022-956d-11ee-b1eb-65d6038d') |
-- +---------------------------------------------+
-- | 0 |
-- +---------------------------------------------+
SELECT IS_UUID('aaaaaaaa-bbbb-cccc-zzzz-eeeeeeeeeeee');
-- +-------------------------------------------------+
-- | IS_UUID('aaaaaaaa-bbbb-cccc-zzzz-eeeeeeeeeeee') |
-- +-------------------------------------------------+
-- | 0 |
-- +-------------------------------------------------+
Reference information of the IS_UUID() function:
IS_UUID(uuid): boolean Returns 1 if and only if the argument is a valid UUID. Arguments, return value and availability: uuid: Required. The UUID string to be validated. boolean: Return value. 1 if and only if the argument is a valid UUID. Available since MySQL 5.7.
⇒ UUID() - Generating UUID String
⇐ BIN_TO_UUID() - Converting Binary to UUID
2023-12-08, 1474🔥, 0💬
Popular Posts:
How to download Microsoft SQL Server 2005 Express Edition in SQL Server? Microsoft SQL Server 2005 E...
Where Is the Export Dump File Located in Oracle? If you are not specifying the dump directory and fi...
How to execute statements in loops in SQL Server Transact-SQL? How to use WHILE ... loops? You can u...
How to put statements into a statement block in SQL Server Transact-SQL? You can put statements into...
How To Assign Debug Privileges to a User in Oracle? In order to run SQL Developer in debug mode, the...