MySQL uses a single statement to identify the instances of various integer bytes and the maximum and minimum values, and mysql bytes.

Source: Internet
Author: User

MySQL uses a single statement to identify the instances of various integer bytes and the maximum and minimum values, and mysql bytes.

Direct code:

select 'bigint unsigned' as type ,'8' as bytes ,~0 as max_num,0 as min_num unionselect 'int unsigned','4',~0>>32,0 unionselect 'mediumint unsigned','3',~0>>40,0 unionselect 'smallint unsigned','2',~0>>48,0 unionselect 'tinyint unsigned','1',~0>>56,0 unionselect 'signed bigint','8',~0>>1,-(1<<63) unionselect 'signed int','4',~0>>33,-(1<<31) unionselect 'signed mediumint','3',~0>>41,-(1<<23) unionselect 'signed smallint','2',~0>>49,-(1<<15) unionselect '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)

The MySQL statement above finds out all the content occupied by various integer bytes and the maximum and minimum values. I hope it can be used as a reference and I hope you can provide more support.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.