当前位置:网站首页>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;
边栏推荐
- Missing value filling in data analysis (focus on multiple interpolation method, miseforest)
- NRF24L01 troubleshooting
- Minio文件下载问题——inputstream:closed
- Esp8266 uses Arduino to connect Alibaba cloud Internet of things
- JS正则表达式基础知识学习
- AMBA、AHB、APB、AXI的理解
- I2C bus timing explanation
- Variable parameter principle of C language function: VA_ start、va_ Arg and VA_ end
- JS function promotion and declaration promotion of VaR variable
- ORA-02030: can only select from fixed tables/views
猜你喜欢

Missing value filling in data analysis (focus on multiple interpolation method, miseforest)

Générateur d'identification distribué basé sur redis

Redis based distributed ID generator

JS function promotion and declaration promotion of VaR variable

MySQL时间、时区、自动填充0的问题

(三)R语言的生物信息学入门——Function, data.frame, 简单DNA读取与分析

ES6 grammar summary -- Part I (basic)

Page performance optimization of video scene

(1) Introduction Guide to R language - the first step of data analysis

Characteristics, task status and startup of UCOS III
随机推荐
Characteristics, task status and startup of UCOS III
Use of lists
Detailed explanation of truncate usage
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图
RT thread API reference manual
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
(五)R语言入门生物信息学——ORF和序列分析
Pat 1097 duplication on a linked list (25 points)
The dolphin scheduler remotely executes shell scripts through the expect command
Pytorch four commonly used optimizer tests
[esp32 learning-2] esp32 address mapping
[899]有序队列
Basic operations of databases and tables ----- view data tables
I2C bus timing explanation
MySQL takes up too much memory solution
ES6语法总结--上篇(基础篇)
Kconfig Kbuild
AMBA、AHB、APB、AXI的理解
Who says that PT online schema change does not lock the table, or deadlock