服务器之家

服务器之家 > 正文

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

时间:2020-07-21 16:25     来源/作者:MYSQL教程网

直接上码:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
select 'bigint unsigned' as type ,'8' as bytes ,~0 as max_num,0 as min_num union
select 'int unsigned','4',~0>>32,0 union
select 'mediumint unsigned','3',~0>>40,0 union
select 'smallint unsigned','2',~0>>48,0 union
select 'tinyint unsigned','1',~0>>56,0 union
select 'signed bigint','8',~0>>1,-(1<<63) union
select 'signed int','4',~0>>33,-(1<<31) union
select 'signed mediumint','3',~0>>41,-(1<<23) union
select 'signed smallint','2',~0>>49,-(1<<15) union
select 'signed tinyint','1',~0>>57,-(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一个语句查出各种整形占用字节数及最大最小值的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意 2019-07-07
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
返回顶部