首页 > 数据库 > mysql教程 > MySQL使用一个语句就可以查出各种整形占用字节数及最大最小值的示例代码

MySQL使用一个语句就可以查出各种整形占用字节数及最大最小值的示例代码

黄舟
发布: 2017-03-21 13:26:09
原创
1238 人浏览过

下面小编就为大家带来一篇MySQL一个语句查出各种整形占用字节数及最大最小值的实例。

直接上码:

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 &#39;signed bigint&#39;,&#39;8&#39;,~0>>1,-(1<<63) union
select &#39;signed int&#39;,&#39;4&#39;,~0>>33,-(1<<31) union
select &#39;signed mediumint&#39;,&#39;3&#39;,~0>>41,-(1<<23) union
select &#39;signed smallint&#39;,&#39;2&#39;,~0>>49,-(1<<15) union
select &#39;signed tinyint&#39;,&#39;1&#39;,~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使用一个语句就可以查出各种整形占用字节数及最大最小值的示例代码的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板