gpt4 book ai didi

MySQL 获取 blob N 字节

转载 作者:行者123 更新时间:2023-11-29 05:18:49 25 4
gpt4 key购买 nike

我想知道您是否可以查询一个 blob(任何类型的大/中型)列并检索从 N 到 M 的字节,这样您就可以查询一个巨大的 blob 文件并在结果集中只获取其中的一小部分。如果这在 MySQL 中可行,您将如何做到(请举个例子!)?

我找到了这个 question对于纯文本但对字节做同样的事情呢?

最佳答案

您可以在这里找到答案:MySQL blob: how to get just a subset of the stored data

MySQL treats blobs the same as strings (more or less):

BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values.

So all the usual string functions work on blobs. In particular, you can use substring to grab just part of of a blob.

That said, storing a multi-gigabyte data file in a relational database as a BLOB isn't the best thing to do. You'd be better off storing the file's metadata in the database and leaving the file itself in the file system; file systems are pretty good at managing files, relational databases are good at handling structured data.

关于MySQL 获取 blob N 字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28884985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com