MySQL 数据类型

发布于 2024-12-27 07:43:13 字数 2175 浏览 9 评论 0

整型

类型声明里面的 int(5) 代表的意思。INT is always four bytes wide.The 5 is the "display width" What does INT(5) in mysql mean

字符

mysql 中 varchar 类型最大是多少(这是一个复杂的问题) What is the MySQL VARCHAR max size

  • Keep in mind that MySQL has a maximum row size limit : The internal representation of a MySQL table has a maximum row size limit of 65,535 bytes, not counting BLOB and TEXT types. BLOB and TEXT columns only contribute 9 to 12 bytes toward the row size limit because their contents are stored separately from the rest of the row. Read more about Limits on Table Column Count and Row Size .
  • Maximum size a single column can occupy, is different before and after MySQL 5.0.3 : Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions. The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes(65K), which is shared among all columns) and the character set used. However, note that the limit is lower if you use a multi-byte character set like utf8 or utf8mb4: VARCHAR(21844) CHARACTER SET utf8
  • Use TEXT types inorder to overcome row size limit. : The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements.

bool

mysql 可以在 ddl 的时候设置 bool 类型,但是 mysql 解释器会将其转译成 tinyint(1) ,也可以使用 bit 类型实现, 参考

decimal

DECIMAL(13,4) : This means that the column will have a total size of 13 digits where 4 of these will be used for precision representation. have a max value of: 999999999.9999

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

不即不离

暂无简介

文章
评论
25 人气
更多

推荐作者

alipaysp_snBf0MSZIv

文章 0 评论 0

梦断已成空

文章 0 评论 0

瞎闹

文章 0 评论 0

寄意

文章 0 评论 0

似梦非梦

文章 0 评论 0

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