MySQL Blob:如何仅获取存储数据的子集 [英] MySQL blob: how to get just a subset of the stored data

查看:72
本文介绍了MySQL Blob:如何仅获取存储数据的子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将MYSQL用作存储大量文件的存储系统. 我只想读/写存储在列中的一部分数据(数据存储为字节),所以我不必将整个文件加载到应用程序中(因为它可以大于GB). 因此,总而言之,我希望在blob列中具有随机读取/写入访问权限,而无需将整个数据加载到内存中. 是否有执行这些操作的功能?谢谢.

I would like to use MYSQL as a storage system for a huge number of files. I would like to read/write just a portion of the data stored in a column (data is stored as bytes) so I don't have to load the entire file into the application (because it can be > than a GB). So, in brief, I would like to have random read/write access in a blob column without loading the entire data into memory. Are there functions available to perform these operations? Thank you.

推荐答案

MySQL对待

BLOB值被视为二进制字符串(字节字符串).它们没有字符集,并且排序和比较基于列值中字节的数字值.

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.

因此所有常用的字符串函数都可在blob上运行.特别是,您可以使用 substring 只是抓住斑点的一部分.

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

也就是说,将数千兆字节的数据文件作为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:如何仅获取存储数据的子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆