SQL reference (MySQL and MariaDB dialects)

UUID, INET4 and INET6 types

The MariaDB types UUID, INET4 and INET6: accepted forms, the form they are kept in, errors, and the difference from MySQL.

Syntax#

SQL
UUID
INET4
INET6

These are MariaDB types. Raft DB reads them in both dialects (MySQL has none of them).

Remarks#

  • UUID reads 32 hexadecimal digits with or without dashes (up to four, in any place) in any case, and keeps one form: lower case with dashes (123e4567-e89b-12d3-a456-426614174000). Anything else is error 1292 (The uuid value 'nonsense' given for column 'id' (row 1) is not valid). The length is 36.
  • INET4 reads a dotted IPv4 address (192.168.1.5) and keeps it. Anything else is error 1292 ('1.2.3' is refused).
  • INET6 reads an IPv6 address (2001:db8::1) and keeps it in compressed form; an IPv4 address is kept as an IPv4-mapped IPv6 address (1.2.3.4 becomes ::ffff:1.2.3.4). Anything else is error 1292.
  • Comparison. The values are text in their one form, so id = id is 1 and WHERE a = '10.0.0.1' finds the row. A UUID() function result can be stored, and DEFAULT UUID() is allowed (see Miscellaneous functions).
  • Not supported yet: the functions UUID_TO_BIN, BIN_TO_UUID, IS_UUID, INET6_ATON and INET6_NTOA.
  • SHOW CREATE TABLE and DESCRIBE show uuid, inet4, inet6.

Examples#

SQL
CREATE TABLE u (id UUID, a INET4, b INET6);
INSERT INTO u VALUES ('123E4567-E89B-12D3-A456-426614174000', '192.168.1.5', '2001:db8::1');
INSERT INTO u VALUES ('123e4567e89b12d3a456426614174001', '10.0.0.1', '::ffff:1.2.3.4');
INSERT INTO u VALUES (UUID(), '1.1.1.1', '1.2.3.4');
INSERT INTO u (id) VALUES ('nonsense');        -- error 1292
SELECT a FROM u WHERE a = '10.0.0.1';

The output is identical to MariaDB 11.4.13.

See also#