数据库 
首页 > 数据库 > 浏览文章

MySQL一个语句查出各种整形占用字节数及最大最小值的实例

(编辑:jimmy 日期: 2024/11/16 浏览:3 次 )

直接上码:

select 'bigint unsigned' as type ,'8' as bytes ,~0 as max_num,0 as min_num union
select 'int unsigned','4',~032,0 union
select 'mediumint unsigned','3',~040,0 union
select 'smallint unsigned','2',~048,0 union
select 'tinyint unsigned','1',~056,0 union
select 'signed bigint','8',~01,-(1<<63) union
select 'signed int','4',~033,-(1<<31) union
select 'signed mediumint','3',~041,-(1<<23) union
select 'signed smallint','2',~049,-(1<<15) union
select 'signed tinyint','1',~057,-(1<<7);

 

+--------------------+-------+----------------------+----------------------+
| type    | bytes | max_num    | min_num    |
+--------------------+-------+----------------------+----------------------+
| bigint unsigned | 8  | 18446744073709551615 |     0 |
| int unsigned  | 4  |   4294967295 |     0 |
| mediumint unsigned | 3  |    16777215 |     0 |
| smallint unsigned | 2  |    65535 |     0 |
| tinyint unsigned | 1  |     255 |     0 |
| signed bigint  | 8  | 9223372036854775807 | -9223372036854775808 |
| signed int   | 4  |   2147483647 |   -2147483648 |
| signed mediumint | 3  |    8388607 |    -8388608 |
| signed smallint | 2  |    32767 |    -32768 |
| signed tinyint  | 1  |     127 |     -128 |
+--------------------+-------+----------------------+----------------------+
rows in set (0.00 sec)

以上这篇MySQL一个语句查出各种整形占用字节数及最大最小值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

上一篇:对MySql经常使用语句的全面总结(必看篇)
下一篇:mysql 5.6.21 安装与配置详细步骤
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。