Skip to content

Instantly share code, notes, and snippets.

@Bpazy
Last active January 23, 2019 02:55
Show Gist options
  • Save Bpazy/ef12aa4b0ed027fc1e90ea6d23c95fcd to your computer and use it in GitHub Desktop.
Save Bpazy/ef12aa4b0ed027fc1e90ea6d23c95fcd to your computer and use it in GitHub Desktop.

有精度问题,bgint最大值263-1,而文档中说一个字符串和一个整数放在一起的情况(如下图)会被转成浮点数:

1

而浮点数比较要看软硬件平台,文档也没说得很清楚。 2

CREATE TABLE `bigint_length_test` (
  `var1` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `bigint_length_test`(`var1`) VALUES (242352963116511232);
INSERT INTO `bigint_length_test`(`var1`) VALUES (242352963116511233);
INSERT INTO `bigint_length_test`(`var1`) VALUES (242352963116511234);

select * from bigint_length_test where var1 = '242352963116511232'; // 可能查不到,看平台
select * from bigint_length_test where var1 = '242352963116511233'; // 可能查不到,看平台
select * from bigint_length_test where var1 = '242352963116511234'; // 可能查不到,看平台
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment