当前位置:网站首页>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
边栏推荐
- What if the user information in the website app database is leaked and tampered with
- SPARK闲杂--为什么复用Exchange和subquery
- No module named ‘yaml‘ 解决办法
- 5.1 security vulnerabilities and Prevention
- 关于快慢指针的理解
- Classic general pbootcms flower website template source code, adaptive mobile terminal, with background management
- Sword finger offer 42 Maximum sum dynamic programming method for continuous subarrays
- SCA在得物DevSecOps平台上应用
- 聊聊分布式锁
- New redis6 features
猜你喜欢

visual studio 2022(VS 2022)无法读取内存的问题

Wvppro-zlm-gb21818-camera

By voting for the destruction of STI by Dao, seektiger is truly community driven

Great summary! Finally, someone explained all kinds of SQL join connections clearly

Excellent résumé! Enfin quelqu'un a compris toutes les connexions SQL
![Paddleserving服务化部署 tensorrt报错, shape of trt subgraph is [-1,-1,768],](/img/15/5dde91261a44fcfeda4d8436bb8559.png)
Paddleserving服务化部署 tensorrt报错, shape of trt subgraph is [-1,-1,768],
![Conversation technology [dark horse introduction series]](/img/31/ba806652a2a836e53c7fa942770696.png)
Conversation technology [dark horse introduction series]

SCA在得物DevSecOps平台上应用

Quanzhi v3s learning record (13) use of ov2640

依赖注入方式
随机推荐
Address monitoring API: how to trace and monitor uniswap hacker addresses
依赖注入方式
Deep learning 7 deep feedforward network 2
mySQL 2502 2503错误
5.2 数据库安全
WPF 三维应用搭建(基础)
一款关于日常习惯打卡的小程序
By voting for the destruction of STI by Dao, seektiger is truly community driven
5.1 安全漏洞與防範
How to use curl in Jenkins pipeline and process response results
Openpyxl copy sheet pages across workbooks
【Kernel】驱动开发学习之字符设备
Redis的发布和订阅
黑马程序员-软件测试-16阶段3-功能测试-175-198,URL组成介绍,请求内容以及组成说明行功能测试与数据库,url组成扩展说明,客户端与服务器请求与响应,-Fiddler按照以及功能检查确认,
[kernel] character device that drives development and learning
MCU如何选型?
Redis data persistence
Understanding of fast and slow pointer
Eureka自我保护
才意识到自己“奇葩”的360,会不会有些晚?