`IPv4` is a domain based on `UInt32` type and serves as typed replacement for storing IPv4 values. It provides compact storage with human-friendly input-output format, and column type information on inspection.
`IPv6` is a domain based on `FixedString(16)` type and serves as typed replacement for storing IPv6 values. It provides compact storage with human-friendly input-output format, and column type information on inspection.
Domains are special-purpose types, that add some extra features atop of existing base type, leaving on-wire and on-disc format of underlying table intact. At the moment, ClickHouse does not support user-defined domains.
You can use domains anywhere corresponding base type can be used:
* Create a column of domain type
* Read/write values from/to domain column
* Use it as index if base type can be used as index
* Call functions with values of domain column
* etc.
### Extra Features of Domains
* Explicit column type name in `SHOW CREATE TABLE` or `DESCRIBE TABLE`
* Input from human-friendly format with `INSERT INTO domain_table(domain_column) VALUES(...)`
* Output to human-friendly format for `SELECT domain_column FROM domain_table`
* Loading data from external source in human-friendly format: `INSERT INTO domain_table FORMAT CSV ...`
### Limitations
* Can't convert index column of base type to domain type via `ALTER TABLE`.
* Can't implicitly convert string values into domain values when inserting data from another column or table.
@@ -131,7 +131,7 @@ SELECT IPv6NumToString(IPv4ToIPv6(IPv4StringToNum('192.168.0.1'))) AS addr
Accepts a FixedString(16) value containing the IPv6 address in binary format. Returns a string containing the address of the specified number of bits removed in text format. For example:
An alias to `IPv4StringToNum()` that takes a string form of IPv4 address and returns value of [IPv4](../../data_types/domains/ipv4.md) type, which is binary equal to value returned by `IPv4StringToNum()`.
An alias to `IPv6StringToNum()` that takes a string form of IPv6 address and returns value of [IPv6](../../data_types/domains/ipv6.md) type, which is binary equal to value returned by `IPv6StringToNum()`.