current position:Home>Explore the vachar, test, longtext storage limits of the database mysql
Explore the vachar, test, longtext storage limits of the database mysql
2023-01-25 11:20:10【source world】
If you feel a little interesting, please pay attention,一键三连吧!蟹蟹!!!
背景
Want to understand clearly,使用longtext类型,Save rich text data tomysqlIs the database sufficient,And how is it enough.I searched the Internet for a long time and found no answer,自己尝试了一下,Although not to the limit,但是完全够用.
longtest类型,对应java和mybatisThe frame type is string.
介绍
mysql5.0版本以前,longtext可以储存127个文字.5.0以上版本longtext可以储存32767个文字,utf8编码下最多支持10921个字符(不为空).
mysql5.0版本以前,longtextThe maximum can be defined255字节长度.5.0以上版本支持65535字节长度,utf8编码下最多支持21843个字符(不为空).
Because a literal occupies two bytes,因此mysql5.0版本以前,longtext可以储存127个文字.5.0以上版本longtext可以储存32767个文字,utf8编码下最多支持10921个字符(不为空).
扩展资料:
longtextUse than fixed length type(text)Take up more storage space(除了使用ROW_FORMAT=FIXED创建的MyISAM表).节约空间,So performance will help.Additional work will be generated when updating.
5.0以上版本,longtextGet value or set value will preserve the space at the end of the string,4.1之前的版本longtextwill remove the spaces at the end of the string.The maximum length is much larger than the average length,Suitable for use when updates are rarelongtext,Because there are fewer fragments.
简单了解下
varcharIt is a variable-length byte,所占空间为字符串Actual length plus1,最长为65535个字节
而longtextIt is also variable-length character storage,只保存字符数据,最长为4294967295字节,More suitable for storing large content
换句话来说(理想状态下):
4294967295除以3得到,1431655765个汉字,14亿多.
项目实操
You can create a table however you like,id,content两个字段,It can also be created as per my table.
Problems you may have,For example, the auto-increment of the primary key is not according to what you want,可以看这一篇博客:idea中mybatisPlusThe auto-increment primary key fails
创建表
DROP TABLE IF EXISTS `duck_message`;
CREATE TABLE `duck_message` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`message_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标题',
`message_content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '内容',
`message_images` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片地址',
`status` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态(L-message list,P-排行榜,T-推荐榜)',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
`creation_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`user_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户id',
`type_push` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'Is it on the list(Y-上榜,N-Not on the list)',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'Duck friends list' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
注意:longtextIt is not necessary to set the length
代码很简单,It's just an insert statement:创建一个Springboot项目,使用mybatis-plus自动生成.Then insert table data.
如何自动生成,可以看下这篇博客:mybatisPlus自动生成代码
I use rich text to call,可以参考博客:summernote富文本使用.也可以使用apipost进行测试,下面有介绍.
完整代码
getInputValue() {
var that = this;
// 获取summernoteThe method of entering the value $('#summernote2').summernote('code')
that.contant = $("#summernote2").summernote("code");
console.log(that.contant);
that.axios({
url: "http://localhost:8081/duckMessage/text",
method: "POST",
data: that.contant,
headers: {
// "Content-Type": "application/x-www-form-urlencoded",
"Content-Type": "text/plain",
},
success: function (data) {
console.log("返回的数据" + data.data);
},
});
},
//Controller层
//测试,The maximum insert data that can be inserted
@PostMapping("/text")
public Result textInsert(@RequestBody String contant){
System.out.println("值:"+contant);
int num= duckMessageService.textInsert(contant);
return new Result("200",num,"成功");
}
//serveceimp层
@Override
public int textInsert(String contant) {
DuckMessage duckMessage = new DuckMessage().setMessageContent(contant).setCreationTime(new Date());
int num = duckMessageMapper.insert(duckMessage);
return num;
}
接近78万个字
我是用的SummernoteRich text to try to call,文件显示2.3M(也可以直接使用Apipost调用)
Logs printed in the background
表数据
I'm ready to double again,但是复制粘贴,Display speed is too slow.不再尝试.
If want to try it yourself,使用Apipost工具,调用接口测试即可
官方下载地址:https://www.apipost.cn/
注意:The client must be downloaded to debug locally,Only non-local interfaces are supported on the web side
表数据
mysql类型
数字类型
辨別Null与Not Null :Null为允许储存空值(Null)
数值日期时间
Pay attention if you find it useful,一键三连吧!蟹蟹!!!
各位看官》创作不易,点个赞!!!
诸君共勉:万事开头难,只愿肯放弃.
免责声明:本文章仅用于学习参考
copyright notice
author[source world],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2023/025/202301251109140390.html
The sidebar is recommended
- Based on VirtualBox centos7 virtual machine installation
- JVM process cache - Caffeine
- Code Caprice No24 | Backtracking Algorithm Theoretical Basis, 77. Combination
- The Road to Algorithm Practice——[String] Leetcode 824 Goat Latin
- Git summary - Prompt to submit or temporarily store changes when switching to a branch
- Productivity tools - [gitlab configuration] One-time configuration of GitLab account
- Echo+Vue+ElementUI management background source code
- Revel+Vue+ElementUI framework use and build tutorial
- Basic practice tutorial of Revel+Vue+ElementUI framework
- Go Web Development Revel+Vue+ElementUI Framework Practical Tutorial
guess what you like
Construction and deployment tutorial of Revel+Vue+ElementUI framework
8. Java loop advanced comprehensive exercises - infinite loop and jump control statement, every seven passes, square root, judging whether it is a prime number, guessing number games
Control statement + exception handling perfect lucky draw applet-java basics
9. Java Array Knowledge Encyclopedia
Lucky draw applet-java basics
Java basic implementation calculator applet
The front end of actual combat: copy write millet's official website on the first day
1. Linux application programming and network programming---file IO notes in Linux system
7. Linux application programming and network programming --- thread full solution Notes
[Front-end notes - CSS] 10. Cascading and inheritance + selector
Random recommended
- 8. Linux application programming and network programming---Linux network programming notes
- [Java|golang] 1828. Count the number of points in a circle
- Add environment variables under Linux system and will not overwrite the previous method of adding environment variables
- 2 · Linux application programming and network programming - file attributes notes
- Redis interview questions (classic 7 questions)
- [Front-end notes——CSS] 11. Box model + background and border
- C + + large Numbers together, according to a combined
- 3. Linux application programming and network programming --- get system information notes
- The use and principle of Kafka message queue
- 5. Linux application programming and network programming---signal notes in Linux
- 6 · Linux application programming and system programming - senior IO notes
- Java collection common interview questions (4)
- 072-JAVA project training: Imitation QQ instant messaging software series lecture 7 (explaining the realization of the chat interface and functions)
- Coordination center performance comparison: how zookeeper solves the load balancing problem
- 070-JAVA project training: imitation QQ instant messaging software series lecture five (explain user registration function)
- Ubuntu installation and configuration (brief)
- 073-JAVA project training: imitation QQ instant messaging software series lecture eight (explain query and add friend function)
- SQL injection classification and error injection EXP
- All basic commands in linux fail, showing that the command cannot be found
- 4. Linux application programming and network programming---Linux process full solution notes (difference between process and program)
- Linux system - basic IO
- Hanlp's understanding of user-defined dictionaries (java version)
- Brief description and configuration of Maven
- 071-JAVA project training: imitation QQ instant messaging software series lecture six (explaining the function of QQ main interface)
- 【Maximum LeetCode】January Algorithm Training (12) Linked List
- 【Max LeetCode】January Algorithm Training (13) Doubly Linked List
- [Big Data Management] Java implements Bloom filter
- [Maximum LeetCode] Algorithm training in January (14) stack
- [Machine Learning] Adaboost Integrated Algorithm
- [Big Data Management] Java implements cuckoo filter (CF)
- Chaozhou Xiangqiao: "Charming Ancient City, Cultural Sharing" Spring Festival Intangible Cultural Heritage Market Opens
- [Big data management] Java realizes the dictionary tree TireTree
- [Max LeetCode] January Algorithm Training (11) Matrix
- New Express (Web framework based on HTTP module encapsulation NodeJS)
- JavaScript error-prone questions (stack processing, call function, prototype chain questions)
- Space "travel", lion and crane dance, intangible cultural heritage experience...During the Spring Festival, Zhuhai Jinwan is so fun!
- Wine 8.0 official release: better support for running Windows applications on Linux and other systems
- Zhongke Sugon: Sugon's new computer "participates in" "The Wandering Earth 2"
- Linux actual combat notes finishing (1.24)
- Automatically execute the specified sql when the springBoot project starts