当前位置:网站首页>What is the maximum length of MySQL varchar field
What is the maximum length of MySQL varchar field
2022-07-06 12:23:00 【wx5caecf2ed0645】
varchar(n),n What does it mean ?
MySQL5.0.3 Before varchar(n) there n Represents the number of bytes
MySQL5.0.3 after varchar(n) there n Indicates the number of characters , such as varchar(200), It can be stored in both English and Chinese 200 individual
n What is the maximum
MySQL Line length
MySQL It is required that the length of a line definition cannot exceed 65535 Bytes , barring text、blob And so on ,varchar The length is limited by this length , And other non large fields cannot add up to more than 65535 Bytes .
If the above limit is exceeded, an error will be reported :
drop table if EXISTS test1111;
create table test1111(
id char(255) null,
content varchar(21830) null
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
[Err] 1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
varchar(n) Take a few bytes
varchar(n) Taking a few bytes has something to do with the character set :
If the character type is gbk, Each character occupies 2 Bytes
If the character type is utf8, Each character takes up a maximum of 3 Bytes
varchar What's the maximum length
According to character set , If the character type is gbk, Each character occupies 2 Bytes , The maximum length cannot exceed 32766, If the character type is utf8, Each character takes up a maximum of 3 Bytes , The maximum length cannot exceed 21845, If the limit is exceeded , Will automatically varchar Type to mediumtext or longtext, for example :
drop table if EXISTS test1111;
create table test1111(
id char(255) null,
content varchar(63000) null
);
desc test1111;
result :
CREATE TABLE `test1111` (
`id` char(255) DEFAULT NULL,
`content` mediumtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
边栏推荐
- @The difference between Autowired and @resource
- Cannot change version of project facet Dynamic Web Module to 2.3.
- MySQL time, time zone, auto fill 0
- MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解
- [esp32 learning-1] construction of Arduino esp32 development environment
- 程序员老鸟都会搞错的问题 C语言基础 指针和数组
- ES6语法总结--上篇(基础篇)
- Navigator object (determine browser type)
- 2022.2.12 resumption
- Understanding of AMBA, AHB, APB and Axi
猜你喜欢

程序设计大作业:教务管理系统(C语言)

js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。

STM32 how to locate the code segment that causes hard fault

MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解

基於Redis的分布式ID生成器

單片機藍牙無線燒錄

基于Redis的分布式锁 以及 超详细的改进思路

ES6语法总结--上篇(基础篇)

AMBA、AHB、APB、AXI的理解

JS function promotion and declaration promotion of VaR variable
随机推荐
Arduino gets the length of the array
Programmers can make mistakes. Basic pointers and arrays of C language
Basic knowledge of lithium battery
RuntimeError: cuDNN error: CUDNN_ STATUS_ NOT_ INITIALIZED
VSCode基础配置
Flink late data processing (3)
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
ESP learning problem record
Arduino get random number
Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
A possible cause and solution of "stuck" main thread of RT thread
[esp32 learning-2] esp32 address mapping
列表的使用
ES6语法总结--上篇(基础篇)
(1) Introduction Guide to R language - the first step of data analysis
关于Gateway中使用@Controller的问题
RT thread API reference manual
ES6语法总结--下篇(进阶篇 ES6~ES11)
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
[Offer18]删除链表的节点