问题描述
我刚刚发现除了 我有很多列,插入后不会改变,但可能会很大。而不是使用所有 我想在c ++中将数据操作为 如何在c ++中进行这些转换? 如果您查看MySQL文档,您会看到 让我们取一个64位的值,如0xDEADBEEF2B84F00D。如果将它存储在 如果你将它存储为 让我们看看相反的情况下,0x01。存储在 只是不要这样做。按照设计的方式使用数据库。 I've just discovered that all but I have many columns that won't change once they're inserted but have the potential to be large. Instead of using all I want to manipulate the data as an How can these conversions be made in c++? I would highly recommend against this. If you look at the MySQL documentation for Let's take a 64-bit value like 0xDEADBEEF2B84F00D. If you store that in a If you store that as a Let's look at the opposite case, 0x01. Stored in a Just don't do it. Use the database the way it was designed. 这篇关于将c ++ int转换为VARBINARY并再次返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! VAR
之外的所有数据类型都不会改变它们的 LENGTH
。这让我非常低效,因为可能有 INT
字段,如 autoincrement
PRIMARY
不会改变其中
1
在 BIGINT
列中将占用整个8字节。 p>
BIGINT
列,我想使用 VARBINARY
。
int
,然后将它存储为 VARBINARY
mysql。
BIGINT
字段中,它需要8个字节(存储为二进制值。)
VARCHAR
,即使你假设数字总是十六进制,我们说的长度字段为1或2字节,然后另一个16字节十六进制字符! 18字节,并且由于不得不转换为/从ASCII转换,性能损失,这是一个可怕的折衷!
BIGINT
字段中,它仍然是8个字节。使用与以前相同的约定,它可能在您的数据库中3个字节。甚至不值得,在我看来。特别是当你考虑数据库如何用一堆ASCII数据执行时。
VAR
data types do not vary their LENGTH
s. This strikes me as extremely inefficient since there may be INT
fields like an autoincrement
PRIMARY
that never change where a 1
in a BIGINT
column will take the full 8 bytes.BIGINT
columns, I'd like to use VARBINARY
instead.int
in c++ yet store it as VARBINARY
in mysql.VARCHAR
, you'll see that BIGINT
field, it takes 8 bytes (it's stored as a binary value.)VARCHAR
, even if you assume the numbers are always hexadecimal, we're talking 1 or 2 bytes for the length field, and then another 16 bytes for the hexadecimal characters! 18 bytes, and the performance lost by having to convert to/from ASCII, this is a terrible trade-off!BIGINT
field, it's still 8 bytes. Using the same convention from before, it's probably going to be 3 bytes in your database. Not even close to being worth it, in my opinion. Especially when you consider how poorly the database would perform with a bunch of ASCII data.