我应该选择什么数据类型? [英] What DataType should I pick?
问题描述
在通常会存储短字符串(10 到 40 个字符)但最终会存储大量文本(500 - 1000 个字符)的列中,应该使用哪种 DataType?保存此列的表只有三列.其中两个制作复合键和另一个是有问题的列.我不必根据此列进行排序或排序.
What kind of DataType should be used in a column that usually will store a short string (between 10 and 40 characters) but eventually will store a large amount of text (500 - 1000 characters)? The table that holds this column has only three columns. Two of them make a composite key and the other is the column in question. I will not have to sort or order based on this column.
那么,我应该选择什么数据类型?
So, what DataType should I pick?
提前致谢.对不起我的英语.
Thanks in advance. Sorry for my english.
推荐答案
VARCHAR (1000)
(您可能需要它大于 1000)和仅使用 VARCHAR (1000)
之间的折腾代码>文本代码>.我不知道您是否需要 NOT NULL
,但如果您需要,显然可以添加.
It's a toss-up between VARCHAR (1000)
(you might need it to be greater than 1000), and just using TEXT
. I don't know whether you require NOT NULL
, but obviously add that if you need it.
请注意,如果您将其设为 VARCHAR
,则会对列大小施加明确限制.仅当您确定不会超过该大小时才使用 VARCHAR
.如果您可能有异常值,请使用 TEXT
.
Note that if you make it VARCHAR
, you're imposing a definite limit on column size. Use VARCHAR
only if you know for sure you won't go over that size. If you might have outliers, just go with TEXT
.
这篇关于我应该选择什么数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!