当前位置:网站首页>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;
边栏推荐
猜你喜欢
Understanding of AMBA, AHB, APB and Axi
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
MySQL時間、時區、自動填充0的問題
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
Basic operations of databases and tables ----- modifying data tables
Vscode basic configuration
MySQL takes up too much memory solution
Redis based distributed locks and ultra detailed improvement ideas
Oppo vooc fast charging circuit and protocol
随机推荐
基於Redis的分布式ID生成器
Navigator object (determine browser type)
ESP learning problem record
STM32 how to locate the code segment that causes hard fault
【ESP32学习-2】esp32地址映射
Basic operations of databases and tables ----- view data tables
Detailed explanation of Union [C language]
JS function promotion and declaration promotion of VaR variable
PT OSC deadlock analysis
Kconfig Kbuild
Variable parameter principle of C language function: VA_ start、va_ Arg and VA_ end
open-mmlab labelImg mmdetection
Basic operations of databases and tables ----- modifying data tables
MySQL replacement field part content
@Autowired 和 @Resource 的区别
JS变量类型以及常用类型转换
[leetcode622]设计循环队列
Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
C language, log print file name, function name, line number, date and time
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.