在一个字段中以二进制形式存储多个值

发布于 2024-08-05 00:28:56 字数 208 浏览 1 评论 0原文

我有一个项目需要存储大量值。 数据是包含 1024 个 2Byte 无符号整数值的数据集。现在,我将一个值与时间戳和 Unik ID 一起存储在一行中。 该数据根据时间触发器连续存储。

我想做的是将所有 1024 个值存储在一个字段中。那么是否可以执行一些例程,将所有 1024 个 2 字节整数值作为二进制存储在一个字段中。也许是一个斑点域。 谢谢。

Br。 恩赫赫

I have a project where I need to store a large number of values.
The data is a dataset holding 1024 2Byte Unsigned integer values. Now I store one value at one row together with a timestamp and a unik ID.
This data is continously stored based on a time trigger.

What I would like to do, is store all 1024 values in one field. So would it be possible to do some routine that stores all the 1024 2byte integer values in one field as binary. Maybe a blobfield.
Thanks.

Br.
Enghoej

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自演自醉 2024-08-12 00:28:56

是的。您可以将数据序列化为字节数组,并将其存储在 BLOB 中。大多数数据库中的 BLOB 支持 2048 字节。

Yes. You can serialize your data into a byte array, and store it in a BLOB. 2048 bytes will be supported in a BLOB in most databases.

微凉 2024-08-12 00:28:56

要问自己的一个大问题是“我需要如何检索这些数据?”任何报告或查询(例如“哪些 ID 的值 X 设置为 Y”)都必须从表中加载所有行并解析数据 AFAIK。例如,如果这是用户配置数据,您可能需要知道哪些用户的特定设置设置不正确。

在 SQL Server 中,我建议考虑使用 XML 数据类型并存储已知模式,因为可以使用 XPath 进行查询。 MySQL 自 2007 年起不支持此功能,因此这可能不适合您。

我肯定会考虑将您可能需要以这种方式查询的任何数据分解到单独的列中。

另请注意,如果没有客户端应用程序,您将无法解释 BLOB 数据。

你总是想考虑报告。多年来,数据库通常会拥有多个客户端。

One big question to ask yourself is "how will I need to retrieve this data?" Any reports or queries such as "what IDs have value X set to Y" will have to load all rows from the table and parse the data AFAIK. For instance, if this were user configuration data, you might need to know which users had a particular setting set incorrectly.

In SQL Server, I'd suggest considering using an XML data type and storing a known schema, since this can be queried with XPath. MySQL did not support this as of 2007, so that may not be an option for you.

I would definitely consider breaking out any data that you might possibly need to query in such a manner into separate columns.

Note also that you will be unable to interpret BLOB data without a client application.

You always want to consider reporting. Databases often end up with multiple clients over the years.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文