当前位置:网站首页>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;
边栏推荐
- Who says that PT online schema change does not lock the table, or deadlock
- Minio文件下载问题——inputstream:closed
- Kaggle competition two Sigma connect: rental listing inquiries
- ES6语法总结--下篇(进阶篇 ES6~ES11)
- Kaggle competition two Sigma connect: rental listing inquiries (xgboost)
- 基于Redis的分布式ID生成器
- C language callback function [C language]
- map文件粗略分析
- ARM PC=PC+8 最便于理解的阐述
- Amba, ahb, APB, Axi Understanding
猜你喜欢

Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍

Reno7 60W super flash charging architecture

ESP learning problem record

Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer
![Several declarations about pointers [C language]](/img/9b/ace0abbd1956123a945a98680b1e86.png)
Several declarations about pointers [C language]

ARM PC=PC+8 最便于理解的阐述

RT thread API reference manual

【ESP32学习-2】esp32地址映射

ORA-02030: can only select from fixed tables/views

Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
随机推荐
Remember an experience of ECS being blown up by passwords - closing a small black house, changing passwords, and changing ports
[Offer29] 排序的循环链表
Cannot change version of project facet Dynamic Web Module to 2.3.
NRF24L01故障排查
MySQL time, time zone, auto fill 0
VIM command line notes
Keyword inline (inline function) usage analysis [C language]
Basic operations of databases and tables ----- classification of data
JS function promotion and declaration promotion of VaR variable
Arm pc=pc+8 is the most understandable explanation
基於Redis的分布式ID生成器
The first simple case of GNN: Cora classification
Programmers can make mistakes. Basic pointers and arrays of C language
MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解
Rough analysis of map file
Detailed explanation of truncate usage
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
Pytoch temperature prediction
HCIP Day 12