当前位置:网站首页>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 .
边栏推荐
- Basic settings of pycharm [detailed explanation with pictures and words]
- Comply with medical reform and actively layout -- insight into the development of high-value medical consumables under the background of centralized purchase 2022
- Example analysis of SQL injection error reporting
- NumPy 学习笔记
- Solve the problem that idea is stuck in opening a project
- Hidden Markov model and its training (1)
- CAN总线协议基础
- Smart Scenic Spot Video Monitoring 5G Smart lamp Gateway Network Integrated pole
- Basic use of pycharm
- Shit, jialichuang's price is reduced again
猜你喜欢

Postman common assertions

Docker安装Redis镜像详细步骤(简单易懂,适合新手快速上手)

Technology sharing | quick intercom, global intercom

Rethinking atlas revolution for semantic image segmentation (deeplobv3) personal summary

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

HTML+PHP+Mysql登录注册页面

Fiddler set breakpoint

postman切换主题

Xinsi technology helps Israel visuality systems promote the "left shift" of security

【BSP视频教程】BSP视频教程第17期:单片机bootloader专题,启动,跳转配置和调试下载的各种用法(2022-06-10)
随机推荐
VBA将字符串分割、存入数组、写入文件并保存
Knowledge based bert: a method to extract molecular features like a computational chemist
VBA judge whether the file exists and ask for the idea of file backup
Thread interview related questions
复利最高的保险产品是什么?一年要交多少钱?
Comply with medical reform and actively layout -- insight into the development of high-value medical consumables under the background of centralized purchase 2022
Create and install the visual studio offline installation package
Fiddler set breakpoint
ahk常用函数
Mm main tables and main fields_ SAP LIUMENG_
面试题-笔试
Institute of automation, Chinese Academy of Sciences: a review of the latest visual language pre training
[web security self-study] section 1 building of basic Web Environment
Fiddler创建AutoResponder
mysql数据库实现设置字段长度
几个对程序员的误解,害人不浅!
如何用Pygame制作简单的贪吃蛇游戏
College entrance examination that year
Postman parameterization
ADB is not an internal or external command, nor is it a runnable program or batch file