当前位置:网站首页>Mysql database implementation setting field length
Mysql database implementation setting field length
2022-06-10 17:15:00 【1024 Q】
mysql Set the field length
1. About char and varchar
2. About the length of numeric types
mysql Field length understanding
int type
varchar type
mysql Set the field length 1. About char and varcharchar Is a fixed length character ,varchar Is a variable length character .
stay mysql4.0 Before the release ,char and varchar The following length represents bytes , stay utf-8 Coding format : Three bytes store a Chinese character ( Including the symbols under Chinese characters ), A byte stores an English letter , A number .
stay mysql5.0 After the version ,char and varchar The following length represents one character , A Chinese character 、 English letter 、 Numbers or symbols , It's all one character .
2. About the length of numeric typesThe length of a number type does not mean that , It's more complicated .
int type : Set value range of length 1~255( Set up 0 Automatically switch to 11, Automatically change to the default when not set 11), This setting is actually the setting width , The so-called width is when the numerical value is displayed , When the width of the value is shorter than the width of the setting , The left padding will be performed automatically 0. However, to see the effect, you need to add zerofill This value , To express with 0 fill , Otherwise, no effect will be seen . We usually do not add this value when creating a database .
No matter how much width we set , Will not affect the scope of storage .int The storage range is -2147483648~2147483647( namely -2 Of 31 Power ~ 2 Of 31 Power -1).
tinyint The field value range of any length value within this range is -128~127(-2 The seventh power of -1 ~ 2 The seventh power of -1).
mysql Field length understandingKnowledge with notes
When designing data sheets , Whether through table design or sql Statement design , Will involve the design of field length , The field length is the value in parentheses after the data type , Such as int(10),varchar(10), Field length has different meanings under different data types , Here only MySQL Medium int as well as varchar Type , Please learn the rest by yourself .
int typeint The length of the type only indicates the display width , No impact on actual storage , Such as int(10) and int(11) The data of all accounts for 4 Bytes , Only the difference of data display effect
varchar typevarchar The length of the type is the character length ( English characters ), It is also the display width , Such as varchar(3) It can only be stored at most 3 Characters , Show 3 Character length ,varchar(3) The space occupied by inserting a character in the type field and varchar(10) Type data takes the same space to insert a character .
The above is personal experience , I hope I can give you a reference , I also hope you can support the software development network .
边栏推荐
- 新思科技在《 2022 年 Gartner 应用安全测试关键能力报告》中表现优异 在五个常见用例中荣获最高分
- Basic use of pycharm
- 全链路追踪 & 性能监控工具 SkyWalking 实战
- 【BSP视频教程】BSP视频教程第17期:单片机bootloader专题,启动,跳转配置和调试下载的各种用法(2022-06-10)
- Xinsi technology helps Israel visuality systems promote the "left shift" of security
- 亦舒作品经典语句
- 毕业季:致走向辽远未知的你
- PHP实现多张图片上传功能的示例代码
- Rethinking atlas revolution for semantic image segmentation (deeplobv3) personal summary
- 【Proteus仿真】DS18B20+报警温度可调+LM016显示
猜你喜欢

Make good use of the industrial chain to attract investment, create industrial cluster effect and realize the coordinated development of industries

“禁塑令”下,中宝新材深挖可降解塑料,港交所买单吗?

Can deleted wechat friends be recovered? How to retrieve wechat friends after they are accidentally deleted

SOA架构/测试阶段接口描述语言转换方案

Thread interview related questions

Do you know the five GoLand shortcuts to improve efficiency?

Postman parameterization

Then, we will cooperate with impulse online and Feiteng to complete partner certification and jointly create a private computing ecosystem for Xinchuang

品牌难立,IPO难行,中国茶企困于“传统”?

直播预告 | 社交新纪元,共探元宇宙社交新体验
随机推荐
Smart Scenic Spot Video Monitoring 5G Smart lamp Gateway Network Integrated pole
Can deleted wechat friends be recovered? How to retrieve wechat friends after they are accidentally deleted
[play with Huawei cloud] Kunpeng devkit migration practice
Docker安装Redis镜像详细步骤(简单易懂,适合新手快速上手)
Shit, jialichuang's price is reduced again
Basic use of pycharm
sql注入报错之注入原理实例解析
为 Chocolatey 设置代理
MySQL如何修改字段类型和字段长度
AHK common functions
Web3最全搞钱秘籍,看这一篇就够了
解决idea打开某个项目卡住的问题
Fiddler set breakpoint
PHP实现多张图片上传功能的示例代码
fail-fast和fail-safe
Nat. Rev. Drug Discov. | Application of AI in small molecule drug discovery: an upcoming wave?
一文带你了解J.U.C的FutureTask、Fork/Join框架和BlockingQueue
线程面试相关问题
提升园区服务水平,优化营商环境该从哪些方面入手
Pytorch Foundation (I) -- anaconda and pytorch installation