在数字格式的MAC地址的db值中,对于我的查询,我需要类似于XX:XX:XX:XX:XX:XX的真正格式的值。
示例:对于数字9817108886245,实际的MAC地址值必须是08:ED:B9:49:B2:E5。
我写了下一个查询:
select regexp_replace(lpad(upper(trim(to_char(9817108886245,
'xxxxxxxxxxxx'))), 12, '0'),
'^([A-Z0-9]{2})([A-Z0-9]{2})([A-Z0-9]{2})([A-Z0-9]{2})([A-Z0-9]{2})([A-Z0-9]{2})$'
, '\1:\2:\3:\4:\5:\6') as MAC
from dual;可以简化我的查询吗?
发布于 2015-11-19 14:29:44
这将是一个较短的查询字符串,但并不完全更简单。
select substr(regexp_replace(
upper(to_char(9817108886245,'00xxxxxxxxxxxx')),'([A-F0-9]{2})',':\1'),6) as MAC
from dual;https://stackoverflow.com/questions/33803560
复制相似问题