gpt4 book ai didi

mysql - 在 MySQL 数据库中存储文章的字段/数据类型

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

我忍不住相信这个话题已经被反复讨论过,但我很难找到任何好的、可靠的信息。

我应该使用什么数据类型来存储 200 到 400 个单词的文本?可能接近两三千字的较长文章怎么样?

哪些选项会影响我的决定?我不打算搜索这些数据,但我不能完全排除我以后可能想搜索的可能性。

不幸的是,我的背景是 MS Access,其中唯一的选择是备注字段。使用 MySQL 似乎并不那么简单。

最佳答案

如果您使用的是 MySQL 5.0.3 或更高版本,请转到 VARCHAR .它可以容纳 65k 字节。只要每行只有 1 个 long VARCHAR,就没问题。

否则使用文本。

摘自mysql手册:

BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways:

There is no trailing-space removal for BLOB and TEXT columns when values are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored.

On comparisons, TEXT is space extended to fit the compared object, exactly like CHAR and VARCHAR.

For indexes on BLOB and TEXT columns, you must specify an index prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 7.5.1, “Column Indexes”.

BLOB and TEXT columns cannot have DEFAULT values.

也很高兴知道(来自 the manual ):

Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types

在制定使用 TEXT 的查询时,您确实应该考虑到这一点。

关于mysql - 在 MySQL 数据库中存储文章的字段/数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4547565/

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