使用OCCI在Oracle数据库11g中存储无符号64位整数的最佳方法

时间:2021-12-22 12:10:19

I'm using version 11.2 and there is no direct support for uint64 in table fields. What do you suggest to do performacewise? It must be the primary key.

我正在使用11.2版本,在表字段中没有对uint64的直接支持。你的建议是什么?它必须是主键。

Thanks

谢谢

3 个解决方案

#1


1  

possibly convert it to char, then insert it as a char, with a to_number to put it in the correct format?

可能将它转换为char,然后插入为char,并使用to_number将其以正确的格式保存?

#2


1  

I know nothing about Oracle, but MS SQL is plagued similarly, and I ended up storing my 64-bit unsigned ints in binary(8) fields. If Oracle has similar field caps (and i can't imagine it doesn't) perhaps the same would work for you.

我对Oracle一无所知,但是MS SQL也受到类似的困扰,最后我将64位的无符号ints存储在二进制(8)字段中。如果Oracle有类似的字段限制(我无法想象它没有),那么同样的情况也适用于您。

The upshot on SQL Server is binary(n) fields compared against other binary(n) fields effectively compare as byte-arrays, and if sized the same, it means they also compare as big-endian representation (if that is how you stored them, and you would be nuts not to).

SQL Server上的结果是,与其他二进制(n)字段相比,二进制(n)字段可以有效地与字节数组进行比较,如果大小相同,这意味着它们也可以与big-endian表示法进行比较(如果您就是这样存储它们的,那么您肯定会很抓狂的)。

Sorry I'm not Oracle savvy. Gotta dance with the one that brought ya =)

对不起,我不懂Oracle。我要和那个带来你的人跳舞。

#3


1  

I'm using a RAW(8) data type, and write it with:

我使用的是原始数据类型,并使用:

uint64 i;
Bytes key((unsigned char*)&i, 8);
statement->setBytes(1, key);

Fast and compact, and seems to work well.

又快又紧凑,而且似乎运行得很好。

#1


1  

possibly convert it to char, then insert it as a char, with a to_number to put it in the correct format?

可能将它转换为char,然后插入为char,并使用to_number将其以正确的格式保存?

#2


1  

I know nothing about Oracle, but MS SQL is plagued similarly, and I ended up storing my 64-bit unsigned ints in binary(8) fields. If Oracle has similar field caps (and i can't imagine it doesn't) perhaps the same would work for you.

我对Oracle一无所知,但是MS SQL也受到类似的困扰,最后我将64位的无符号ints存储在二进制(8)字段中。如果Oracle有类似的字段限制(我无法想象它没有),那么同样的情况也适用于您。

The upshot on SQL Server is binary(n) fields compared against other binary(n) fields effectively compare as byte-arrays, and if sized the same, it means they also compare as big-endian representation (if that is how you stored them, and you would be nuts not to).

SQL Server上的结果是,与其他二进制(n)字段相比,二进制(n)字段可以有效地与字节数组进行比较,如果大小相同,这意味着它们也可以与big-endian表示法进行比较(如果您就是这样存储它们的,那么您肯定会很抓狂的)。

Sorry I'm not Oracle savvy. Gotta dance with the one that brought ya =)

对不起,我不懂Oracle。我要和那个带来你的人跳舞。

#3


1  

I'm using a RAW(8) data type, and write it with:

我使用的是原始数据类型,并使用:

uint64 i;
Bytes key((unsigned char*)&i, 8);
statement->setBytes(1, key);

Fast and compact, and seems to work well.

又快又紧凑,而且似乎运行得很好。