IS_IPV6() function in MySQL
Last Updated :
14 Dec, 2020
IS_IPV6() :
This function in MySQL is used to check whether a specified string is a valid IPv6 address. If it is a valid IPv6 address then it will return 1. Otherwise, it will return 0.
Syntax :
IS_IPV6(expr)
Parameter :
This method accepts only one parameter.
- expr –Input string which we want to check.
Returns :
It returns 1 if the string is a valid IPv6 address. If the string is not a valid IPv6 address then it will return 0.
Example-1 :
Checking whether the given address is valid or not using IS_IPV6 Function.
SELECT IS_IPV6('10.4.2.256')
AS ValidOrNot;
Output :
So, we can see the given address is not a valid IPv6 address.
Example-2 :
Checking whether the given address is valid or not using IS_IPV6 Function.
SELECT IS_IPV6('::2')
AS ValidOrNot;
Output :
So, we can see the given address is a valid IPv6 address.
Example-3 :
Checking whether a IPv4 address is valid IPv6 address or not using IS_IPV6 Function.
SELECT IS_IPV6('2001:0db8:85a3:0000:0000:8a2e:0370:7334')
IPv6ValidOrNot,
IS_IPV4('2001:0db8:85a3:0000:0000:8a2e:0370:7334')
AS IPv4ValidOrNot;
Output :
IPV6VALIDORNOT |
IPV4VALIDORNOT |
1 |
0 |
Share your thoughts in the comments
Please Login to comment...