mysql資料型別範圍導致失敗

2021-07-05 23:20:29 字數 1369 閱讀 9968



最近一直使用mysql,如果沒有碰上大的資料量,我想一般人都不會注意到資料型別範圍大小的問題。

使用mediumint 型別碰上了上千萬的資料,所以導致了資料的失敗。手冊上說:

the signed range is -8388608 to 8388607.

the unsigned range is 0 to 16777215.

是範圍超過了限制。

型別 大小 範圍(有符號) 範圍(無符號) 用途 

tinyint 1 位元組 (-128,127) (0,255) 小整數值 

smallint 2 位元組 (-32 768,32 767) (0,65 535) 大整數值 

mediumint 3 位元組 (-8 388 608,8 388 607) (0,16 777 215) 大整數值 

int或integer 4 位元組 (-2 147 483 648,2 147 483 647) (0,4 294 967 295) 大整數值 

bigint 8 位元組 (-9 233 372 036 854 775 808,9 223 372 036 854 775 807) (0,18 446 744 073 709 551 615) 極大整數值 

float 4 位元組 (-3.402 823 466 e+38,1.175 494 351 e-38),0,(1.175 494 351 e-38,3.402 823 466 351 e+38) 0,(1.175 494 351 e-38,3.402 823 466 e+38) 單精度

浮點數值 

double 8 位元組 (1.797 693 134 862 315 7 e+308,2.225 073 858 507 201 4 e-308),0,(2.225 073 858 507 201 4 e-308,1.797 693 134 862 315 7 e+308) 0,(2.225 073 858 507 201 4 e-308,1.797 693 134 862 315 7 e+308) 雙精度

char 0-255位元組 定長字串 

varchar 0-255位元組 變長字串 

tinyblob 0-255位元組 不超過 255 個字元的二進位制字串 

tinytext 0-255位元組 短文本字串 

blob 0-65 535位元組 二進位制形式的長文字資料 

text 0-65 535位元組 長文字資料 

mediumblob 0-16 777 215位元組 二進位制形式的中等長度文字資料 

mediumtext 0-16 777 215位元組 中等長度文字資料 

logngblob 0-4 294 967 295位元組 二進位制形式的極大文字資料 

longtext 0-4 294 967 295位元組 極大文字資料

資料型別範圍

char 128 127 1 byte short 32767 32768 2 bytes unsigned short 0 65536 2 bytes int 2147483648 2147483647 4 bytes unsigned int 0 4294967295 4 bytes long ...

資料型別範圍

若要了解有關 visual studio 2017 rc 的最新文件,請參閱 visual studio 2017 rc 文件 visual c 32 位和 64 位編譯器可識別本文後面的表中的型別。如果其名稱以兩個下劃線 開始,則資料型別是非標準的。下表中指定的範圍均包含起始值和結束值。位元組其他...

資料型別範圍

對 32 位和 64 位編譯器,microsoft visual c 識別在下表中顯示的型別。注意以下型別還具有無符號形式 型別名稱 位元組其他名稱 值的範圍 int4 簽名 2,147,483,648 到 2,147,483,647 unsigned int 4unsigned 0 到 4,294...