IPv6
IPv6 addresses. Stored in 16 bytes as UInt128 big-endian.Basic Usage
CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url;
DESCRIBE TABLE hits;
โโnameโโฌโtypeโโโโฌโdefault_typeโโฌโdefault_expressionโโฌโcommentโโฌโcodec_expressionโโ
โ url โ String โ โ โ โ โ
โ from โ IPv6 โ โ โ โ โ
โโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโ
IPv6 domain as a key:
CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY from;
IPv6 domain supports custom input as IPv6-strings:
INSERT INTO hits (url, from) VALUES ('https://wikipedia.org', '2a02:aa08:e000:3100::2')('https://clickhouse.com', '2001:44c8:129:2632:33:0:252:2')('https://clickhouse.com/docs/en/', '2a02:e980:1e::1');
SELECT * FROM hits;
โโurlโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโfromโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ https://clickhouse.com โ 2001:44c8:129:2632:33:0:252:2 โ
โ https://clickhouse.com/docs/en/ โ 2a02:e980:1e::1 โ
โ https://wikipedia.org โ 2a02:aa08:e000:3100::2 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
SELECT toTypeName(from), hex(from) FROM hits LIMIT 1;
โโtoTypeName(from)โโฌโhex(from)โโโโโโโโโโโโโโโโโโโโโโโโโ
โ IPv6 โ 200144C8012926320033000002520002 โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
SELECT toIPv4('127.0.0.1') = toIPv6('::ffff:127.0.0.1');
โโequals(toIPv4('127.0.0.1'), toIPv6('::ffff:127.0.0.1'))โโ
โ 1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ