用于在(postgresql)数据库中存储EUI-64地址的数据类型

时间:2022-10-18 00:04:19

What would be a good datatype for storing an EUI-64 address (for ZigBee nodes)?

什么是用于存储EUI-64地址(对于ZigBee节点)的良好数据类型?

EUI-64 address are basically 8 octets. From what I can gather they should not be considered an integer as such, though obviously you can make a 64 bit integer out of them. It seems obvious then to use a bigint, though they are "signed" unfortunately so that makes it a bit messy.

EUI-64地址基本上是8个八位字节。从我可以收集的内容来看,它们不应该被视为整数,尽管很明显你可以从中得到64位整数。然后使用bigint似乎很明显,但不幸的是它们被“签名”,这使得它有点混乱。

I could use numeric(8), but there are no built in conversions to represent to hex (though I could write one).

我可以使用数字(8),但没有内置的转换来表示十六进制(虽然我可以写一个)。

I could use a char(16), but that seems wasteful.

我可以使用char(16),但这似乎很浪费。

All of these options are usable but each seems a bit messy. I'm just wondering if anyone has any thoughts on this or a way I haven't thought of. I am currently using bigint, which is working fine as so far. It allows me to use "to_hex" to represent the address, but I can foresee problems unless I handle the sign-ness properly.

所有这些选项都可以使用,但每个选项看起来都有些混乱。我只是想知道是否有人对此有任何想法,或者我没想过的方式。我目前正在使用bigint,到目前为止工作正常。它允许我使用“to_hex”来表示地址,但除非我正确处理符号,否则我可以预见到问题。

Thanks.

1 个解决方案

#1


1  

I would write my own data type for it, using the code for macaddr as a template.

我会使用macaddr的代码作为模板为它编写自己的数据类型。

#1


1  

I would write my own data type for it, using the code for macaddr as a template.

我会使用macaddr的代码作为模板为它编写自己的数据类型。