不解,对于 binary 类型,如果位数定成5,插入 ff,却在低位补0呢?应该高位补0呀?
create table tb(f1 binary(5))
insert tb
select 0xaabbccddee
insert tb
select 0xaabbccddinsert tb
select 0xa
insert tb
select 0xffselect *
from tbf1
------------
0xAABBCCDDEE
0xAABBCCDD00
0x0A00000000
0xFF00000000(所影响的行数为 4 行)不明白,按理插入 oxff,应该在低位补0,为何在高位补呢?
ff是255,select cast(0xFF as bigint)
select cast(0xFF00000000 as bigint)
--------------------
255(所影响的行数为 1 行)
--------------------
1095216660480(所影响的行数为 1 行)
create table tb(f1 binary(5))
insert tb
select 0xaabbccddee
insert tb
select 0xaabbccddinsert tb
select 0xa
insert tb
select 0xffselect *
from tbf1
------------
0xAABBCCDDEE
0xAABBCCDD00
0x0A00000000
0xFF00000000(所影响的行数为 4 行)不明白,按理插入 oxff,应该在低位补0,为何在高位补呢?
ff是255,select cast(0xFF as bigint)
select cast(0xFF00000000 as bigint)
--------------------
255(所影响的行数为 1 行)
--------------------
1095216660480(所影响的行数为 1 行)
binary 資料類型不是針對十六進位資料,而是針對位元模式。儲存為二進位資料的十六進位數字轉換和計算,可能不可靠。