当前位置:网站首页>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
边栏推荐
猜你喜欢

才意识到自己“奇葩”的360,会不会有些晚?
![Paddleserving服务化部署 tensorrt报错, shape of trt subgraph is [-1,-1,768],](/img/15/5dde91261a44fcfeda4d8436bb8559.png)
Paddleserving服务化部署 tensorrt报错, shape of trt subgraph is [-1,-1,768],

Wvppro-zlm-gb21818-camera

History and value of forked coins | eth, BCH, BSV 2020-03-08

Will it be a little late to realize your "wonderful" 360?

【flask入门系列】异常处理

Deep learning 7 deep feedforward network 2

leetcode:287. 寻找重复数【快慢指针板子】

Deep learning 7 deep feedforward network

类型详解·自定义类型·结构体初识
随机推荐
Real case: how to check the soaring usage of CPU after the system goes online?
OpenFeign服务接口调用
没那么大的组合数
mySQL 2502 2503错误
Do online usdt and usdc want to be short? Take you to find out | tokenview
Bean、
Redis data persistence
深度学习之 7 深度前馈网络2
Redis6新数据类型——HyperLogLog
关于快慢指针的理解
Redis cluster
Dependency injection method
Ribbon负载均衡服务调用
SPARK中的FileSourceStrategy,DataSourceStrategy以及DataSourceV2Strategy
How to check whether the app has user information and data leakage vulnerabilities
Textview text up and down
[C # variable constant keyword] - variable constants and keywords in C #
WVPPRO-ZLM-GB21818-摄像头
leetcode:287. Find the repetition number [fast and slow pointer board]
Yolov5 label and establish your own data set