MySQL 中的 VARCHAR(255) 和 TINYTEXT 字符串类型有什么区别? [英] What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL?

查看:57
本文介绍了MySQL 中的 VARCHAR(255) 和 TINYTEXT 字符串类型有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL 中的 VARCHAR(255) 和 TINYTEXT 字符串类型有什么区别?

What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL?

它们中的每一个都允许存储最大长度为 255 个字符的字符串.存储要求也相同.我什么时候应该更喜欢一个?

Each of them allows to store strings with a maximum length of 255 characters. Storage requirements are also the same. When should I prefer one over another?

推荐答案

您不能为 TINYTEXT 分配 DEFAULT 值,也不能在后者上创建无前缀索引.

You cannot assign a DEFAULT value to a TINYTEXT and you cannot create an unprefixed index on the latter.

在内部,额外的对象被分配到内存中来处理 TEXT(包括 TINYTEXT)列,这会导致大记录集上的内存碎片.

Internally, additional objects are allocated in memory to handle TEXT (incl. TINYTEXT) columns which can cause memory fragmentation on the large recordsets.

请注意,这仅涉及记录集中列的内部表示,而不涉及它们在磁盘上的存储方式.

Note that this only concerns the column's internal representation in the recordsets, not how they are stored on the disk.

这篇关于MySQL 中的 VARCHAR(255) 和 TINYTEXT 字符串类型有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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