跳到主要内容

IS_IPV6_STRING

描述

接收一个表示形式为字符串的IPv6地址作为参数,如果为格式正确且合法的IPv6地址,返回true;反之,返回false。

语法

IS_IPV6_STRING(<ipv6_str>)

参数

ParameterDescription
<ipv6_str>字符串类型的ipv6地址

返回值

如果为格式正确且合法的IPv6地址,返回1 (true);反之,返回0 (false)。

  • 如果输入为NULL, 则返回NULL

举例

CREATE TABLE `test_is_ipv6_string` (
`id` int,
`ip_v6` string
) ENGINE=OLAP
DISTRIBUTED BY HASH(`id`) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);

insert into test_is_ipv6_string values(0, NULL), (1, '::'), (2, ''), (3, '2001:1b70:a1:610::b102:2'), (4, 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffffg');

select id, ip_v6, is_ipv6_string(ip_v6) from test_is_ipv6_string order by id;
+------+------------------------------------------+-----------------------+
| id | ip_v6 | is_ipv6_string(ip_v6) |
+------+------------------------------------------+-----------------------+
| 0 | NULL | NULL |
| 1 | :: | 1 |
| 2 | | 0 |
| 3 | 2001:1b70:a1:610::b102:2 | 1 |
| 4 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffffg | 0 |
+------+------------------------------------------+-----------------------+