An example of using a MySQL statement to find out the number of bytes occupied by various integers and their maximum and minimum values

An example of using a MySQL statement to find out the number of bytes occupied by various integers and their maximum and minimum values

Directly code:

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)

The above example of using a MySQL statement to find out the number of bytes occupied by various integers and their maximum and minimum values ​​is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • A comprehensive summary of frequently used statements in MySQL (must read)
  • Count the classification of SQL statements in MySQL
  • A complete collection of MySQL query statements
  • The most complete MySQL query statement collection
  • Common command line statements for mysql
  • MySQL statement quick review tutorial (full)
  • View the frequently used SQL statements in MySQL (detailed explanation)

<<:  Handtrack.js library for real-time monitoring of hand movements (recommended)

>>:  Install OpenSSH on Windows and log in to the Linux server by generating an SSH key

Recommend

VUE+Canvas realizes the whole process of a simple Gobang game

Preface In terms of layout, Gobang is much simple...

Detailed explanation of map overlay in openlayers6

1. Overlay Overview Overlay means covering, as th...

TABLE tags (TAGS) detailed introduction

Basic syntax of the table <table>...</tab...

MySQL database migration quickly exports and imports large amounts of data

Database migration is a problem we often encounte...

jQuery plugin to achieve image suspension

This article shares the specific code of the jQue...

Native js realizes the drag and drop of the nine-square grid

Use native JS to write a nine-square grid to achi...

MySQL 8.0.18 stable version released! Hash Join is here as expected

MySQL 8.0.18 stable version (GA) was officially r...

CSS3+Bezier curve to achieve scalable input search box effect

Without further ado, here are the renderings. The...

vue uses Ele.me UI to imitate the filtering function of teambition

Table of contents Problem Description The general...

MySQL database implements OLTP benchmark test based on sysbench

Sysbench is an excellent benchmark tool that can ...

Summary of Creating and Using Array Methods in Bash Scripts

Defining an array in Bash There are two ways to c...

Practice of multi-layer nested display of element table

There is a requirement for a list containing mult...