当前位置:网站首页>MySQL数据类型
MySQL数据类型
2022-07-17 07:26:00 【我的天才女友】
mysql数据类型主要有:
- 数值类型
- 日期和时间类型
- 字符串类型
- 数值类型
数值类型
数值类型主要包括整型、浮点数和定点数类型。
整数类型
TINYINT、SMALLINT、MEDIUMINT和INT(INTEGER)和BIGINT。
类型 | 储存空间 |
---|---|
TINYINT | 1字节 |
SMALLINT | 2字节 |
MEDIUMINT | 3字节 |
INT(INTEGER) | 4字节 |
BIGINT | 8字节 |
整型类型指定长度与数据取值无关,如果指定的长度超出取值范围,依然可以正确的插入
属性:
- ZEROFILL指定,显示的位数不够的时候使用字符0填充
- UNSIGNED 整型是无符号类型
- AUTO_INCREMENT 自动增长,默认从1开始增加
浮点数类型
float 4个字节
double 8个字节
大小范围(M,D) M表示小数和整数的位数,D表示小数的位数
定点数类型
DECINAL 定点数,和浮点数一样(M,D) ,不过在mysql中内存中是用字符表示的,所以可以保存高精度的数字。
日期时间类型
类型 | 名称 | 字节 |
---|---|---|
YEAR | 年 | 1 |
TIME | 时间 | 3 |
DATE | 日期 | 3 |
DATETIME | 日期时间 | 8 |
TIMESTAMP | 日期时间 | 4 |
文本字符串类型
类型 | 长度 |
---|---|
char | 长度 |
varchar | 长度+1 |
tinytext | 长度+2 |
text | 长度+2 |
mediumtext | 长度+3 |
longtext | 长度+4 |
enum | 1或2 |
set | 1、2、4或8个字节 |
varchar和char:char是定长,不足长度,右侧自动补空格,varchar是变长。
enum:枚举,定义如下
create table t(
e enum('a','b','c')
);
二进制字符串类型
bit、bitary、varbinary、tinyblob、tinyblob、blob、mediumblob、longblob
边栏推荐
- Redis常用数据类型——Redis列表(List)和Redis 集合(Set)
- visual studio 2022(VS 2022)无法读取内存的问题
- 从 B 站崩溃报告看分布式系统的技术栈
- 5G正当时,无人驾驶未来将驶向何方?
- Address monitoring API: how to trace and monitor uniswap hacker addresses
- 本地存储 sessionStorage
- Database review -- database recovery technology
- Interview question: outer margin folding problem (bug of block level elements in ordinary document flow)
- openpyxl跨工作簿复制sheet页
- 如何将读取列表中的str转化为float
猜你喜欢
Classic general pbootcms flower website template source code, adaptive mobile terminal, with background management
Real case: how to check the soaring usage of CPU after the system goes online?
Unity: WebGL发布后在浏览器上运行时窗口大小自适应
Application of SCA on devsecops platform
From the casino logic, analyze the investment value of platform currency 2020-03-03
Redis常用数据类型——Redis列表(List)和Redis 集合(Set)
Will it be a little late to realize your "wonderful" 360?
Deep learning 7 deep feedforward network
US pressure surges, tiktok changes global safety director
Why does the Fed cut interest rates benefit the digital money market in the long run? 2020-03-05
随机推荐
Spark miscellaneous -- why reuse exchange and subquery
【Kernel】驱动开发学习之字符设备
Leetcode daily question 2021/7/11-2021/7/17
DP动态规划企业级模板分析(数字三角,上升序列,背包,状态机,压缩DP)
Dark horse programmer - software testing -16 stage 3 - function testing -175-198, URL composition introduction, request content and composition description line function test and database, URL composi
黑马程序员-软件测试-16阶段3-功能测试-175-198,URL组成介绍,请求内容以及组成说明行功能测试与数据库,url组成扩展说明,客户端与服务器请求与响应,-Fiddler按照以及功能检查确认,
With this "programmer code interview guide" from Zuo Chengyun (Zuo Shen), I joined byte
[C # console] - C # console class
Array exercise 3
Obtain the home location through IP
Eureka基础知识
Viewing the technology stack of distributed system from the crash report of station B
剑指 Offer 42. 连续子数组的最大和-动态规划法
[C# Console]-C# 控制臺類
SPARK闲杂--为什么复用Exchange和subquery
be vigilant! Another phishing attack: uniswap stolen $8.1 million
5G正当时,无人驾驶未来将驶向何方?
Redis master-slave replication
C # read and write txt files
QT related problems encountered when writing code