📄 type_bit_innodb.result
字号:
select 0 + b'1';0 + b'1'1select 0 + b'0';0 + b'0'0select 0 + b'000001';0 + b'000001'1select 0 + b'000011';0 + b'000011'3select 0 + b'000101';0 + b'000101'5select 0 + b'000000';0 + b'000000'0select 0 + b'10000000';0 + b'10000000'128select 0 + b'11111111';0 + b'11111111'255select 0 + b'10000001';0 + b'10000001'129select 0 + b'1000000000000000';0 + b'1000000000000000'32768select 0 + b'1111111111111111';0 + b'1111111111111111'65535select 0 + b'1000000000000001';0 + b'1000000000000001'32769drop table if exists t1;create table t1 (a bit(65)) engine=innodb;ERROR 42000: Display width out of range for column 'a' (max = 64)create table t1 (a bit(0)) engine=innodb;show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `a` bit(1) default NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1drop table t1;create table t1 (a bit(64)) engine=innodb;insert into t1 values (b'1111111111111111111111111111111111111111111111111111111111111111'),(b'1000000000000000000000000000000000000000000000000000000000000000'),(b'0000000000000000000000000000000000000000000000000000000000000001'),(b'1010101010101010101010101010101010101010101010101010101010101010'),(b'0101010101010101010101010101010101010101010101010101010101010101');select hex(a) from t1;hex(a)FFFFFFFFFFFFFFFF80000000000000001AAAAAAAAAAAAAAAA5555555555555555drop table t1;create table t1 (a bit) engine=innodb;insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001');Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 4select hex(a) from t1;hex(a)01011alter table t1 add unique (a);ERROR 23000: Duplicate entry '' for key 1drop table t1;create table t1 (a bit(2)) engine=innodb;insert into t1 values (b'00'), (b'01'), (b'10'), (b'100');Warnings:Warning 1264 Out of range value adjusted for column 'a' at row 4select a+0 from t1;a+00123alter table t1 add key (a);explain select a+0 from t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 2 NULL 4 Using indexselect a+0 from t1;a+00123drop table t1;create table t1 (a bit(7), b bit(9), key(a, b)) engine=innodb;insert into t1 values (94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), (75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), (111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), (116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499),(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), (44, 307), (68, 454), (57, 135);explain select a+0 from t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 5 NULL 38 Using indexselect a+0 from t1;a+00459232428293031344449565759606168687577787987889494104106108111116118119122123127explain select b+0 from t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 5 NULL 38 Using indexselect b+0 from t1;b+01772451783633639849939983438202307345379135188343152206454421331233493514114646828044667368390380368118411403explain select a+0, b+0 from t1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 index NULL a 5 NULL 38 Using indexselect a+0, b+0 from t1;a+0 b+00 1774 2455 1789 36323 3624 39828 49929 39930 8331 43834 20244 30749 34556 37957 13559 18860 34361 15268 20668 45475 4277 13378 12379 34987 35188 41194 4694 468104 280106 446108 67111 368116 390118 380119 368122 118123 411127 403explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range a a 2 NULL 19 Using where; Using index; Using filesortselect a+0, b+0 from t1 where a > 40 and b > 200 order by 1;a+0 b+044 30749 34556 37960 34368 20668 45479 34987 35188 41194 468104 280106 446111 368116 390118 380119 368123 411127 403explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 range a a 2 NULL 8 Using where; Using index; Using filesortselect a+0, b+0 from t1 where a > 40 and a < 70 order by 2;a+0 b+057 13561 15259 18868 20644 30760 34349 34556 37968 454set @@max_length_for_sort_data=0;select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;a+0 b+057 13561 15259 18868 20644 30760 34349 34556 37968 454select hex(min(a)) from t1;hex(min(a))0select hex(min(b)) from t1;hex(min(b))24select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1;hex(min(a)) hex(max(a)) hex(min(b)) hex(max(b))0 7F 24 1F3drop table t1;create table t1 (a int not null, b bit, c bit(9), key(a, b, c)) engine=innodb;insert into t1 values(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54),(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34);select a+0, b+0, c+0 from t1;a+0 b+0 c+01 1 1002 1 44 NULL 14 0 34 0 234 0 344 0 544 1 10023 0 156 0 22select hex(min(b)) from t1 where a = 4;hex(min(b))0select hex(min(c)) from t1 where a = 4 and b = 0;hex(min(c))3select hex(max(b)) from t1;hex(max(b))1select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2;a+0 b+0 c+04 0 34 0 23select a+0, b+0, c+0 from t1 where a = 4 and b = 1;a+0 b+0 c+04 1 100select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100;a+0 b+0 c+04 1 100select a+0, b+0, c+0 from t1 order by b desc;a+0 b+0 c+02 1 41 1 1004 1 1004 0 34 0 234 0 5456 0 2223 0 14 0 344 NULL 1select a+0, b+0, c+0 from t1 order by c;a+0 b+0 c+04 NULL 123 0 14 0 32 1 456 0 224 0 234 0 344 0 541 1 1004 1 100drop table t1;create table t1(a bit(2), b bit(2)) engine=innodb;insert into t1 (a) values (0x01), (0x03), (0x02);update t1 set b= concat(a);select a+0, b+0 from t1;a+0 b+01 13 32 2drop table t1;create table t1 (a bit(7), key(a)) engine=innodb;insert into t1 values (44), (57);select a+0 from t1;a+04457drop table t1;create table t1 (a bit(3), b bit(12)) engine=innodb;insert into t1 values (7,(1<<12)-2), (0x01,0x01ff);select hex(a),hex(b) from t1;hex(a) hex(b)7 FFE1 1FFselect hex(concat(a)),hex(concat(b)) from t1;hex(concat(a)) hex(concat(b))07 0FFE01 01FFdrop table t1;create table t1(a int, b bit not null) engine=innodb;alter table t1 add primary key (a);drop table t1;create table t1 (a bit, b bit(10)) engine=innodb;show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `a` bit(1) default NULL, `b` bit(10) default NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1alter table t1 engine=heap;show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `a` bit(1) default NULL, `b` bit(10) default NULL) ENGINE=MEMORY DEFAULT CHARSET=latin1alter table t1 engine=innodb;show create table t1;Table Create Tablet1 CREATE TABLE `t1` ( `a` bit(1) default NULL, `b` bit(10) default NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1drop table t1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -