The value range of bigint, int, mediumint, smallint and tinyint in mysql

MySQL database design, among which, for data performance optimization, the consideration of field types is very important. I collected some information and organized and shared it. This is the syntax introduction about mysql integer types bigint, int, mediumint, smallint and tinyint, as follows:
1. bigint

Integer data (all numbers) from -2^63 (-9223372036854775808) to 2^63-1 (9223372036854775807), unsigned in the range 0 to

18446744073709551615. One bit is 8 bytes.

2、int

A normal-sized integer. Signed range is -2^31 (-2,147,483,648) to 2^31 - 1 (2,147,483,647) integer data (all numbers), unsigned range is 0 to 4294967295. One bit is 4 bytes in size. The SQL-92 synonym for
int is integer .

3. mediumint is
a medium-sized integer with a signed range of -8388608 to 8388607 and an unsigned range of 0 to 16777215. One bit is 3 bytes in size.

4、smallint

a small integer. Signed range is -2^15 (-32,768) to 2^15 - 1 (32,767) integer data, unsigned range is 0 to 65535. One bit is 2 bytes in size. MySQL provides more than enough features, and since MySQL is open source software, it can greatly reduce the total cost of ownership.

5、tinyint

The signed range is -128 - 127, and the unsigned range is integer data from 0 to 255. One bit is 1 byte in size.


Note that all arithmetic operations are done with signed BIGINT or DOUBLE values, so you should never use signed big integers larger than 9223372036854775807 (63 bits), except for bit functions! Note that -, + and * will use the BIGINT operation when both arguments are INTEGER values! This means that if you multiply 2 large integers (or from a function that returns an integer), you can get unexpected results if the result is greater than 9223372036854775807. A floating-point number, which cannot be unsigned, can be <= 24 for a single-precision floating-point number, and between 25 and 53 for a double-precision floating-point number. These types such as FLOAT and DOUBLE are immediately Described below. FLOAT(X) has the same range as FLOAT and DOUBLE, but the display size and scale are undefined. In MySQL 3.23, this is a true floating point value. In earlier MySQL versions, FLOAT(precision) always had 2 decimal places. This syntax is provided for ODBC compatibility.

 

 

The range of 

TINYINT 
-128 - 127 
TINYINT UNSIGNED 
0 - 255 
SMALLINT 
-32768 - 32767 
SMALLINT UNSIGNED 
0 - 65535 
MEDIUMINT 
-8388608 - 8388607 
MEDIUMINT UNSIGNED 
0 - 16777215  INT
or INTEGER 
-2147483648 
UNSIGNED 
0 - 4294967295 
BIGINT 
-9223372036854775808 - 9223372036854775807 
BIGINT UNSIGNED 
0 - 18446744073709551615 
FLOAT 
-3.402823466E + 38 is - 38,0,1.175494351E--1.175494351E-38 is - 3.402823466E + 38 is 
DOUBLE or DOUBLE PRECISION or REAL 
-1.7976931348623157E+308 - -2.2250738585072014E-308,0,2.2250738585072014E-308 - 1.7976931348623157E+308 
DECIMAL[(M,[D])] or NUMERIC(M,D) 
length of the whole number, including the decimal point by M( , the number of digits to the left of the decimal point, the number of digits to the right of the decimal point, but not including the negative sign) and D (the number of digits to the right of the decimal point) to decide, M defaults to 10, D defaults to 0 
DATE 
1000-01-01 - 9999 -12-31 
DATETIME 
1000-01-01 00:00:00 - 9999-12-31 23:59:59 
TIMESTAMP 
1970-01-01 00:00:00 - a day in 2037 I don't know, huh) 
TIME
-838:59:59' to 838:59:59 
YEAR[(2|4)] 
The default is 4-bit format, the value range of 4-bit format is 1901 - 2155,0000, 2-bit format The value range is 70-69 (1970-2069) 
CHAR(M) [BINARY] or NCHAR(M) [BINARY] 
The range of M is 1 - 255. If there is no BINARY item, it is case-insensitive. The provincial character set. Filled with spaces in the database, but trailing spaces will be automatically removed when fetched. 
[NATIONAL] VARCHAR(M) [BINARY] 
The range of M is 1 - 255. Trailing spaces will be automatically removed in the database remove. 
TINYBLOB or TINYTEXT 
255 (2^8-1) characters 
BLOB or TEXT 
65535 (2^16-1) characters 
MEDIUMBLOB or MEDIUMTEXT 
16777215 (2^24-1) characters 
LONGBLOB or LONGTEXT 
4294967295 (2^32-1) characters 
ENUM('value1','value2',...) 
can have a total of 65535 distinct values 
​​SET('value1','value2',...) 
has a maximum of 64 members 

 
 
G
M
T
 
 
Detect languageAfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanLaoLatinLatvianLithuanianMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPersianPolishPortuguesePunjabiRomanianRussianSerbianSesothoSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshYiddishYorubaZulu
 
AfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanLaoLatinLatvianLithuanianMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPersianPolishPortuguesePunjabiRomanianRussianSerbianSesothoSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshYiddishYorubaZulu
 
 
 
 
 
 
 
 
 
Text-to-speech function is limited to 200 characters
 
 
Options : History : Feedback : Donate Close

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325383718&siteId=291194637