Syntax\n------\n\nINET6\n\nDescription\n-----------\n\nThe INET6 data type is intended for storage of IPv6 addresses, as well as IPv4 addresses assuming conventional mapping of IPv4 addresses into IPv6 addresses.\n\nBoth short and long IPv6 notation are permitted, according to RFC-5952.\n\n Values are stored as a 16-byte fixed length binary string, with most significant byte first.\n Storage engines see INET6 as BINARY(16).\n Clients see INET6 as CHAR(39) and get text representation on retrieval.\n\nThe IPv4-compatible notation is considered as deprecated. It is supported for compatibility with the INET6_ATON function, which also understands this format. It's recommended to use the mapped format to store IPv4 addresses in INET6.\n\nWhen an IPv4 mapped (or compatible) value is stored in INET6, it still occupies 16 bytes:\n\nRetrieval\n\nOn retrieval, in the client-server text protocol, INET6 values are converted to the short text representation, according to RFC-5952, that is with all leading zeroes in each group removed and with consequent zero groups compressed.\n\nBesides creating one's own stored function, there is no a way to retrieve an INET6 value using long text representation.\n\nCasting\n\n CAST from a character string to INET6 understands addresses in short or long text notation (including IPv4 mapped and compatible addresses). NULL is returned if the format is not understood.\n CAST from a binary string to INET6 requires a 16-byte string as an argument. NULL is returned if the argument length is not equal to 16.\n CAST from other data types to INET6 first converts data to a character string, then CAST from character string to INET6 is applied.\n CAST from INET6 to CHAR returns short text address notation.\n CAST from INET6 to BINARY returns its 16-byte binary string representation.\n CAST from INET6 to data types other than CHAR (e.g. SIGNED, UNSIGNED, TIME, etc) returns an error.\n\nComparisons\n\nAn INET6 expression can be compared to:\n\n another INET6 expression\n a character string expression with a text (short or long) address representation:\n a 16-byte binary string expression.\n\nAttempting to compare INET6 to an expression of any other data type returns an error.\n\nMixing INET6 Values for Result\n\nAn INET6 expression can be mixed for result (i.e. UNION, CASE..THEN, COALESCE etc) with:\n\n another INET6 expression. The resulting data type is INET6.\n a character string in text (short or long) address representation. The result data type is INET6. The character string counterpart is automatically converted to INET6. If the string format is not understood, it's converted with a warning to either NULL or to '::', depending on the NULL-ability of the result.\n a 16-byte binary string. The resulting data type is INET6. The binary string counterpart is automatically converted to INET6. If the length of the binary string is not equal to 16, it's converted with a warning to NULL or to '::' depending on the NULL-ability of the result.\n\nAttempts to mix INET6 for result with other data types will return an error.\n\nMixing INET6 with other data types for LEAST and GREATEST, when mixing for comparison and mixing for result are involved at the same time, uses the same rules with mixing for result, described in the previous paragraphs.\n\nFunctions and Operators\n\n HEX() with an INET6 argument returns a hexadecimal representation of the underlying 16-byte binary string\n Arithmetic operators (+,-,\\,/,MOD,DIV) are not supported for INET6. This may change in the future.\n The INET6_ATON function now understands INET6 values as an argument\n The prototypes of the IS_IPV4_COMPAT and I S_IPV4_MAPPED functions have changed from a BINARY(16) to a INET6,\n\nWhen the argument for the aforementioned two functions is not INET6, automatic implicit CAST to INET6 is applied. As a consequence, both functions understand arguments in both text representation and binary(16) representation.\n\nWhen the argument for the aforementioned two functions is not INET6, automatic implicit CAST to INET6 is not applied.\n\nPrepared Statement Parameters\n\nINET6 understands both text and binary(16) address representation in prepared statement parameters (PREPARE..EXECUTE and EXECUTE IMMEDIATE statements).\n\nMigration between BINARY(16) and INET6\n\nYou may have used BINARY(16) as a storage for IPv6 internet addresses, in combination with INET6_ATON and INET6_NTOA to respectively insert and retrieve data.\n\nHowever, you can ALTER BINARY(16) columns storing IPv6 addresses to INET6. After such an alter, there is no a need to use INET6_ATON() and INET6_NTOA(). Addresses can be inserted and retrieved directly.\n\nYou may use BINARY(16) as a storage for IPv6 internet addresses, in combination with INET6_ATON and INET6_NTOA to respectively insert and retrieve data.\n\nIt is also possible to convert INET6 columns to BINARY(16) and continue using the data in combination with INET6_NTOA() and INET6_ATON().\n\nExamples\n--------\n\nCREATE TABLE t1 (a INET6);\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/inet6