存储空间消耗磁盘比较 int varchar date
小结:
1、日期类型按照date存储节省空间,仅3字节,而按照字符串型char 8字节 20190316 , varchar 20190316 9字节;
2、对于小于32768的整数,按照smallint仅仅为2字节,较字符型节约空间;
3、时间戳 1552187447 用int ,而非char(12);整数ip,长ip,用bigint;能数字,不字符型;
2019-03-16 20190316
https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
Table 11.1 Required Storage and Range for Integer Types Supported by MySQL
Type | Storage (Bytes) | Minimum Value Signed | Minimum Value Unsigned | Maximum Value Signed | Maximum Value Unsigned |
---|---|---|---|---|---|
TINYINT |
1 | -128 |
0 |
127 |
255 |
SMALLINT |
2 | -32768 |
0 |
32767 |
65535 |
MEDIUMINT |
3 | -8388608 |
0 |
8388607 |
16777215 |
INT |
4 | -2147483648 |
0 |
2147483647 |
4294967295 |
BIGINT |
8 | -263 |
0 |
263-1 |
264-1 |
>>> 2**32
4294967296
>>> 2**31
2147483648
>>>
>>> 2**15
32768
>>>
https://dev.mysql.com/doc/refman/8.0/en/char.html
Value | CHAR(4) |
Storage Required | VARCHAR(4) |
Storage Required |
---|---|---|---|---|
'' |
' ' |
4 bytes | '' |
1 byte |
'ab' |
'ab ' |
4 bytes | 'ab' |
3 bytes |
'abcd' |
'abcd' |
4 bytes | 'abcd' |
5 bytes |
'abcdefgh' |
'abcd' |
4 bytes | 'abcd' |
5 bytes |
The values shown as stored in the last row of the table apply only when not using strict mode; if MySQL is running in strict mode, values that exceed the column length are not stored, and an error results.
https://dev.mysql.com/doc/refman/8.0/en/storage-requirements.html#data-types-storage-reqs-date-time
Date and Time Type Storage Requirements
For TIME
, DATETIME
, and TIMESTAMP
columns, the storage required for tables created before MySQL 5.6.4 differs from tables created from 5.6.4 on. This is due to a change in 5.6.4 that permits these types to have a fractional part, which requires from 0 to 3 bytes.
Data Type | Storage Required Before MySQL 5.6.4 | Storage Required as of MySQL 5.6.4 |
---|---|---|
YEAR |
1 byte | 1 byte |
DATE |
3 bytes | 3 bytes |
TIME |
3 bytes | 3 bytes + fractional seconds storage |
DATETIME |
8 bytes | 5 bytes + fractional seconds storage |
TIMESTAMP |
4 bytes | 4 bytes + fractional seconds storage |
As of MySQL 5.6.4, storage for YEAR
and DATE
remains unchanged. However, TIME
, DATETIME
, andTIMESTAMP
are represented differently. DATETIME
is packed more efficiently, requiring 5 rather than 8 bytes for the nonfractional part, and all three parts have a fractional part that requires from 0 to 3 bytes, depending on the fractional seconds precision of stored values.
Fractional Seconds Precision | Storage Required |
---|---|
0 | 0 bytes |
1, 2 | 1 byte |
3, 4 | 2 bytes |
5, 6 | 3 bytes |
For example, TIME(0)
, TIME(2)
, TIME(4)
, and TIME(6)
use 3, 4, 5, and 6 bytes, respectively. TIME
andTIME(0)
are equivalent and require the same storage.
存储空间消耗磁盘比较 int varchar date的更多相关文章
- 定义私有属性: *String name; * int age; * String gender; * int salary; Date hiredate;//入职时间
import java.text.SimpleDateFormat; import java.util.Date; /** * 定义私有属性: * String name; * int age; * ...
- SQL data reader reading data performance test
/*Author: Jiangong SUN*/ As I've manipulated a lot of data using SQL data reader in recent project. ...
- php怎么做网站?如何用PHP开发一个完整的网站?
1.PHPer应具备的知识 (1)PHP知识: 熟练掌握基础函数,PHP语句(条件.循环),数组(排序.读取),函数(内部 构造),运算(数学 逻辑),面向对象(继承 接口 封装 多态静态属性)等. ...
- PHP面试题 – 培训学校真实面试内部资料
1.PHP解析URL是哪个函数? parse_url() 是讲URL解析成有固定键值的数组的函数. $ua=parse_url('http://username:password@hostname/p ...
- KingbaseES函数如何返回结果集
函数返回值一般是某一类型值,如int,varchar,date等,返回结果集时就需要用到setof语法. 创建数据 create table class(id number primary key, ...
- oracle查询使用频率和磁盘消耗需要缓存大小
SELECT * FROM (SELECT Sql_Text, Sql_Id, Cpu_Time FROM V$sql ORDER BY Cpu_Time DESC) ORDER BY Rownum ...
- Hyper-V启动虚拟机,消耗C盘大量磁盘空间
问题描述 经常使用Hyper-V虚拟机的朋友,可能会碰到这样的现象,当启动某些虚拟机的是否,发现C盘的空间突然减少,减少的空间与虚拟机的内存一样大少. 通过分析C盘空间的磁盘文件,发现在Hyper-V ...
- Linux常用命令_(磁盘管理)
磁盘信息:df.du df命令–功能:检查文件系统的磁盘空间占用情况–语法:df [选项]–选项:-a 显示所有文件系统的磁盘使用情况,包括0块(block)的文件系统,如/proc文件系统.-k 以 ...
- centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpfs ,nr_inodes, LVM,传统方式扩容文件系统 第七节课
centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpf ...
随机推荐
- Ethereum Dapp Tutorial — Part 1
在上一篇文章中,通过和传统的 web程序相比较解释了以太坊平台的结构.作为一个开发者,学习新技术的最好的方式就是构建一个玩具程序. 在这篇文章中我们将会构建一个简单的“hello word”程序,这个 ...
- [k8s]k8s pod的4种网络模式最佳实战(externalIPs )
hostPort相当于docker run -p 8081:8080,不用创建svc,因此端口只在容器运行的vm上监听 缺点: 没法多pod负载 $ cat pod-hostport.yaml api ...
- Sass编译时Invalid US-ASCII character解决办法
编译scss文件时,如果出现如下错误 Error: Invalid US-ASCII character "\xC2" on line 63 of src/assets/_scss ...
- audio video 控制播放和停止
<audio id="audio" src="waring.wav" preload="auto" controls loop> ...
- MYSQL + MHA +keepalive + VIP安装配置(三)--keepalived安装配置
一.概述 keepalived介绍:Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的web 服务器从系统中剔除 ...
- Python爬虫学习——使用selenium和phantomjs爬取js动态加载的网页
1.安装selenium pip install selenium Collecting selenium Downloading selenium-3.4.1-py2.py3-none-any.wh ...
- jenkins 启动slave时,找不到合适的java程序
今天添加slave 又不成功,我用右键,发现随意点了java的那个打开,结果刚弹出来就关闭了窗口,显示未启动成功. 真是小白的想法,不过跟工具打交道久了,多少逻辑上想一下不对. 一定是用了不合适的程序 ...
- 【代码审计】YUNUCMS_v1.0.6 前台反射型XSS跨站脚本漏洞分析
0x00 环境准备 QYKCMS官网:http://www.yunucms.com 网站源码版本:YUNUCMSv1.0.6 程序源码下载:http://www.yunucms.com/Downl ...
- 【转载】Eclipse快捷键 10个最有用的快捷键
Eclipse中10个最有用的快捷键组合 一个Eclipse骨灰级开发者总结了他认为最有用但又不太为人所知的快捷键组合.通过这些组合可以更加容易的浏览源代码,使得整体的开发效率和质量得到提升. ...
- EGit系列第三篇——远程提交代码
接着上篇,把本地项目提交一次才能Pull,为什么要Pull而不直接Remote Push呢,因为本地和远程仓库内容不一样(通常在远程仓库第一次新建项目会带一个README.md), 要先把远程仓库的东 ...