sql 在 BLOB(数字列表)中搜索数字
我已将长整型(ID)的 ArrayList 存储到 Blob 列中。 (以下问题:BLOB 与 VARCHAR用于在 MySQL 表中存储数组)
这可行,但现在我遇到了一个问题:如何搜索该 BLOB?
想象一下我已将这些数字存储到 BLOB 中:1,2,3,4 而我想做的是:
SELECT * FROM table WHERE blob_column CONTAINS 3
可能吗?
I've stored an ArrayList of longs (ID's) into a Blob column.
(followed question: BLOB vs. VARCHAR for storing arrays in a MySQL table)
That works, but now I've a problem: how can I search into that BLOB?
Imagine I've stored this numbers into the BLOB: 1,2,3,4
And what I want to do is:
SELECT * FROM table WHERE blob_column CONTAINS 3
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的答案是“不,这是不可能的”。您的 BLOB 包含一个序列化的 java 对象 - 并且数据库对其实现一无所知。
设计数据库时,您应该始终考虑如何访问数据。就您的情况而言,最好有一个单独的表,该表将列表中的 ID 包含在单独的行中。然后您只需将该表连接到您的查询中即可。
The simple answer is "No, it's not possible". Your BLOB contains a serialised java object - and the database knows nothing about it's implementation.
When designing a database, you should always think about how you will need to access the data. In your case, you would be much better off having a separate table, which would contain your ID's from the list in separate rows. Then you could simply join that table into your query.