Mysql或sqlite Blob数据类型可以在其中存储varchar数据吗?

发布于 2024-07-30 17:56:42 字数 68 浏览 7 评论 0原文

谁能提供关于我们是否可以在 mysql 或 sqlite Blob 数据类型中存储普通文本数据(varchar)的任何信息

Can one anyone provide any information on whether can we store normal text data(varchar) in mysql or sqlite Blob data type

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

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

发布评论

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

评论(4

囚我心虐我身 2024-08-06 17:56:43

BLOB 只是一堆字节——没有任何阻碍,也没有帮助以任何方式处理它们; VARCHAR 已知是文本,因此字符编码和排序规则等内容会发挥作用。 因此,将字节串(例如图像)存储为 BLOB,将文本串存储为 TEXT 或 VARCHAR!

A BLOB is just a bunch of bytes -- no hindrance no help dealing with them in any way; a VARCHAR is known to be text so such things as character encoding and collation come into play. So, store bunches of bytes (e.g. images) as BLOBs, bunches of text as TEXT or VARCHAR!

两仪 2024-08-06 17:56:43

在 mysql 中,您可以在 blob 数据类型中插入 text/varchar。

blob 可以支持二进制数据。 这意味着mysql也支持非二进制或二进制数据。

text/varchar 可以建立索引,但不能对 blob 建立索引。

进一步阅读此处

in mysql you can insert text/varchar in a blob data type.

blob can support binary data. meaning that non binary or binary data are also supported in mysql.

text/varchar can be indexed but not for blob.

further readings here

最单纯的乌龟 2024-08-06 17:56:43

SQLite 使用 清单输入,因此您可以将任何类型的数据放入任何类型的列中, 实际上。 然后你必须自己解释返回的数据,就像每个人都为 MySQL 指出的那样。

SQLite uses manifest typing, so you can put any type of data in any type of column, actually. Then you'll have to interpret the returned data yourself, just like everyone pointed out for MySQL.

绻影浮沉 2024-08-06 17:56:42

您可以将任何二进制数据存储在 blob 中。 这将包括 ascii 和 unicode 文本。 但是,您需要在代码中将其显式解释为文本,因为 SQL 接口不知道其二进制字段中存储的数据类型。

为什么要使用它而不是普通的 varchar 或文本字段?

You can store any binary data in a blob. This would include both ascii and unicode text. However, you would need to explicitly interpret this as text in your code since an SQL interface would have no idea what type of data was stored inside its binary field.

Why would you want to use this rather than a normal varchar or text field?

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