当前位置:网站首页>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;
边栏推荐
- Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
- Esp8266 uses Arduino to connect Alibaba cloud Internet of things
- By v$rman_ backup_ job_ Oracle "bug" caused by details
- Missing value filling in data analysis (focus on multiple interpolation method, miseforest)
- AMBA、AHB、APB、AXI的理解
- Minio file download problem - inputstream:closed
- Basic operations of databases and tables ----- classification of data
- JS变量类型以及常用类型转换
- Pytorch four commonly used optimizer tests
- Use of lists
猜你喜欢
Esp8266 connect onenet (old mqtt mode)
C language callback function [C language]
JS数组常用方法的分类、理解和运用
Symbolic representation of functions in deep learning papers
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
编译原理:源程序的预处理及词法分析程序的设计与实现(含代码)
Redis cache update strategy, cache penetration, avalanche, breakdown problems
Whistle+switchyomega configure web proxy
JS正则表达式基础知识学习
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
随机推荐
Oppo vooc fast charging circuit and protocol
RT thread API reference manual
MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解
Page performance optimization of video scene
Imgcat usage experience
History object
js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
【ESP32学习-2】esp32地址映射
About using @controller in gateway
CUDA C programming authoritative guide Grossman Chapter 4 global memory
Pytorch four commonly used optimizer tests
. elf . map . list . Hex file
map文件粗略分析
ORA-02030: can only select from fixed tables/views
程序员老鸟都会搞错的问题 C语言基础 指针和数组
Générateur d'identification distribué basé sur redis
E-commerce data analysis -- salary prediction (linear regression)
Gateway fails to route according to the service name, and reports an error service unavailable, status=503
Talking about the startup of Oracle Database
关于Gateway中使用@Controller的问题