📄 comparisons.out
字号:
C1 |C2 -----------------------------------------0 |0 9223372036854775807 |9223372036854775807 -9223372036854775808|-9223372036854775808ij> -- test bigint = int semanticsselect c1 from biginttab where c1 = 0;C1 --------------------0 ij> select c1 from biginttab where c1 = c3;C1 --------------------0 ij> -- test int = bigint semanticsselect c1 from biginttab where 0 = c1;C1 --------------------0 ij> select c1 from biginttab where c3 = c1;C1 --------------------0 ij> -- test bigint = smallint semanticsselect c1 from biginttab where c1 = c4;C1 --------------------0 ij> -- test smallint = bigint semanticsselect c1 from biginttab where c4 = c1;C1 --------------------0 ij> -- Now test <>select c1, c2 from biginttab where c1 <> c2;C1 |C2 -----------------------------------------ij> -- test bigint <> int semanticsselect c1 from biginttab where c1 <> 0;C1 --------------------9223372036854775807 -9223372036854775808ij> select c1 from biginttab where c1 <> c3;C1 --------------------9223372036854775807 -9223372036854775808ij> -- test int <> bigint semanticsselect c1 from biginttab where 0 <> c1;C1 --------------------9223372036854775807 -9223372036854775808ij> select c1 from biginttab where c3 <> c1;C1 --------------------9223372036854775807 -9223372036854775808ij> -- test bigint <> smallint semanticsselect c1 from biginttab where c1 <> c4;C1 --------------------9223372036854775807 -9223372036854775808ij> -- test smallint <> bigint semanticsselect c1 from biginttab where c4 <> c1;C1 --------------------9223372036854775807 -9223372036854775808ij> -- Now test <select c1, c2 from biginttab where c1 < c2;C1 |C2 -----------------------------------------ij> -- test bigint < int semanticsselect c1 from biginttab where c1 < 0;C1 ---------------------9223372036854775808ij> select c1 from biginttab where c1 < c3;C1 ---------------------9223372036854775808ij> -- test int < bigint semanticsselect c1 from biginttab where 0 < c1;C1 --------------------9223372036854775807 ij> select c1 from biginttab where c3 < c1;C1 --------------------9223372036854775807 ij> -- test bigint < smallint semanticsselect c1 from biginttab where c1 < c4;C1 ---------------------9223372036854775808ij> -- test smallint < bigint semanticsselect c1 from biginttab where c4 < c1;C1 --------------------9223372036854775807 ij> -- Now test >select c1, c2 from biginttab where c1 > c2;C1 |C2 -----------------------------------------ij> -- test bigint > int semanticsselect c1 from biginttab where c1 > 0;C1 --------------------9223372036854775807 ij> select c1 from biginttab where c1 > c3;C1 --------------------9223372036854775807 ij> -- test int > bigint semanticsselect c1 from biginttab where 0 > c1;C1 ---------------------9223372036854775808ij> select c1 from biginttab where c3 > c1;C1 ---------------------9223372036854775808ij> -- test bigint > smallint semanticsselect c1 from biginttab where c1 > c4;C1 --------------------9223372036854775807 ij> -- test smallint > bigint semanticsselect c1 from biginttab where c4 > c1;C1 ---------------------9223372036854775808ij> -- Now test <=select c1, c2 from biginttab where c1 <= c2;C1 |C2 -----------------------------------------0 |0 9223372036854775807 |9223372036854775807 -9223372036854775808|-9223372036854775808ij> -- test bigint <= int semanticsselect c1 from biginttab where c1 <= 0;C1 --------------------0 -9223372036854775808ij> select c1 from biginttab where c1 <= c3;C1 --------------------0 -9223372036854775808ij> -- test int <= bigint semanticsselect c1 from biginttab where 0 <= c1;C1 --------------------0 9223372036854775807 ij> select c1 from biginttab where c3 <= c1;C1 --------------------0 9223372036854775807 ij> -- test bigint <= smallint semanticsselect c1 from biginttab where c1 <= c4;C1 --------------------0 -9223372036854775808ij> -- test smallint <= bigint semanticsselect c1 from biginttab where c4 <= c1;C1 --------------------0 9223372036854775807 ij> -- Now test >=select c1, c2 from biginttab where c1 >= c2;C1 |C2 -----------------------------------------0 |0 9223372036854775807 |9223372036854775807 -9223372036854775808|-9223372036854775808ij> -- test bigint >= int semanticsselect c1 from biginttab where c1 >= 0;C1 --------------------0 9223372036854775807 ij> select c1 from biginttab where c1 >= c3;C1 --------------------0 9223372036854775807 ij> -- test int >= bigint semanticsselect c1 from biginttab where 0 >= c1;C1 --------------------0 -9223372036854775808ij> select c1 from biginttab where c3 >= c1;C1 --------------------0 -9223372036854775808ij> -- test bigint >= smallint semanticsselect c1 from biginttab where c1 >= c4;C1 --------------------0 9223372036854775807 ij> -- test smallint >= bigint semanticsselect c1 from biginttab where c4 >= c1;C1 --------------------0 -9223372036854775808ij> -- test is null semanticsselect c1 from biginttab where c1 is null;C1 --------------------NULL ij> select c1 from biginttab where c1 is not null;C1 --------------------0 9223372036854775807 -9223372036854775808ij> select c1 from biginttab where not c1 is null;C1 --------------------0 9223372036854775807 -9223372036854775808ij> -- create a table with char columns of different lengthscreate table chartab (c1 char(1), c2 char(5));0 rows inserted/updated/deletedij> -- insert some valuesinsert into chartab values (' ', ' ');1 row inserted/updated/deletedij> insert into chartab values ('a', 'a ');1 row inserted/updated/deletedij> insert into chartab values ('b', 'bcdef');1 row inserted/updated/deletedij> insert into chartab values (null, null);1 row inserted/updated/deletedij> -- select each one in turnselect c1 from chartab where c1 = ' ';C1 ----ij> select c2 from chartab where c2 = ' ';C2 -----ij> select c1 from chartab where c1 = 'a';C1 ----a ij> select c2 from chartab where c2 = 'a ';C2 -----a ij> select c1 from chartab where c1 = 'b';C1 ----b ij> select c2 from chartab where c2 = 'bcdef';C2 -----bcdefij> -- now check for end-of-string blank semanticsselect c1 from chartab where c1 = '';C1 ----ij> select c1 from chartab where c1 = ' ';C1 ----ij> select c2 from chartab where c2 = '';C2 -----ij> select c2 from chartab where c2 = ' ';C2 -----ij> select c2 from chartab where c2 = ' ';C2 -----ij> select c1 from chartab where c1 = 'a ';C1 ----a ij> select c2 from chartab where c2 = 'a ';C2 -----a ij> select c1 from chartab where c1 = 'b ';C1 ----b ij> select c2 from chartab where c2 = 'bcdef ';C2 -----bcdefij> select c2 from chartab where c2 = 'bcde ';C2 -----ij> -- now check null = null semanticsselect c1, c2 from chartab where c1 = c2;C1 |C2 ---------- | a |a ij> -- test is null semanticsselect c1 from chartab where c1 is null;C1 ----NULLij> select c1 from chartab where c1 is not null;C1 ----a b ij> select c1 from chartab where not c1 is null;C1 ----a b ij> -- Now test <>select c1 from chartab where c1 <> ' ';C1 ----a b ij> select c2 from chartab where c2 <> ' ';C2 -----a bcdefij> select c1 from chartab where c1 <> 'a';C1 ----b ij> select c2 from chartab where c2 <> 'a ';C2 -----bcdefij> select c1 from chartab where c1 <> 'b';C1 ----a ij> select c2 from chartab where c2 <> 'bcdef';C2 -----a ij> select c1 from chartab where c1 != ' ';C1 ----a b ij> select c2 from chartab where c2 != ' ';C2 -----a bcdefij> select c1 from chartab where c1 != 'a';C1 ----b ij> select c2 from chartab where c2 != 'a ';C2 -----bcdefij> select c1 from chartab where c1 != 'b';C1 ----a ij> select c2 from chartab where c2 != 'bcdef';C2 -----a ij> -- now check for end-of-string blank semanticsselect c1 from chartab where c1 <> '';C1 ----a b ij> select c1 from chartab where c1 <> ' ';C1 ----a b ij> select c2 from chartab where c2 <> '';C2 -----a bcdefij> select c2 from chartab where c2 <> ' ';C2 -----a bcdefij> select c2 from chartab where c2 <> ' ';C2 -----a bcdefij> select c1 from chartab where c1 <> 'a ';C1 ----b ij> select c2 from chartab where c2 <> 'a ';C2 -----bcdefij> select c1 from chartab where c1 <> 'b ';C1 ----a ij> select c2 from chartab where c2 <> 'bcdef ';C2 -----a ij> select c2 from chartab where c2 <> 'bcde ';C2 -----a bcdefij> -- now check null <> null semanticsselect c1, c2 from chartab where c1 <> c2;C1 |C2 ----------b |bcdefij> -- Now test <select c1 from chartab where c1 < ' ';C1 ----ij> select c2 from chartab where c2 < ' ';C2 -----ij> select c1 from chartab where c1 < 'a';C1 ----ij> select c2 from chartab where c2 < 'a ';C2 -----ij> select c1 from chartab where c1 < 'b';C1 ----a ij> select c2 from chartab where c2 < 'bcdef';C2 -----a ij> -- now check for end-of-string blank semanticsselect c1 from chartab where c1 < '';C1 ----ij> select c1 from chartab where c1 < ' ';C1 ----ij> select c2 from chartab where c2 < '';C2 -----ij> select c2 from chartab where c2 < ' ';C2 -----ij> select c2 from chartab where c2 < ' ';C2 -----ij> select c1 from chartab where c1 < 'a ';C1 ----ij> select c2 from chartab where c2 < 'a ';C2 -----ij> select c1 from chartab where c1 < 'b ';C1 ----a ij> select c2 from chartab where c2 < 'bcdef ';C2 -----a ij> select c2 from chartab where c2 < 'bcde ';C2 -----a ij> -- now check null < null semanticsselect c1, c2 from chartab where c1 < c2;C1 |C2 ----------b |bcdefij> -- Now test >select c1 from chartab where c1 > ' ';C1 ----a b ij> select c2 from chartab where c2 > ' ';C2 -----a bcdefij> select c1 from chartab where c1 > 'a';C1 ----b ij> select c2 from chartab where c2 > 'a ';C2 -----bcdefij> select c1 from chartab where c1 > 'b';C1 ----ij> select c2 from chartab where c2 > 'bcdef';C2 -----ij> -- now check for end-of-string blank semanticsselect c1 from chartab where c1 > '';C1 ----a b ij> select c1 from chartab where c1 > ' ';C1 ----a b ij> select c2 from chartab where c2 > '';C2 -----a bcdefij> select c2 from chartab where c2 > ' ';C2 -----a bcdefij> select c2 from chartab where c2 > ' ';C2 -----a bcdefij> select c1 from chartab where c1 > 'a ';C1 ----b ij> select c2 from chartab where c2 > 'a ';C2 -----bcdefij> select c1 from chartab where c1 > 'b ';C1 ----ij> select c2 from chartab where c2 > 'bcdef ';C2 -----ij> select c2 from chartab where c2 > 'bcde ';C2 -----bcdefij> -- now check null > null semanticsselect c1, c2 from chartab where c1 > c2;C1 |C2 ----------ij> -- Now test <=select c1 from chartab where c1 <= ' ';C1 ----ij> select c2 from chartab where c2 <= ' ';C2 -----ij> select c1 from chartab where c1 <= 'a';C1 ----a ij> select c2 from chartab where c2 <= 'a ';C2 -----a ij> select c1 from chartab where c1 <= 'b';C1 ----a b ij> select c2 from chartab where c2 <= 'bcdef';C2 -----a bcdefij> -- now check for end-of-string blank semanticsselect c1 from chartab where c1 <= '';C1 ----ij> select c1 from chartab where c1 <= ' ';C1 ----ij> select c2 from chartab where c2 <= '';C2 -----ij> select c2 from chartab where c2 <= ' ';C2 -----ij> select c2 from chartab where c2 <= ' ';C2 -----ij> select c1 from chartab where c1 <= 'a ';C1 ----a ij> select c2 from chartab where c2 <= 'a ';C2 -----a ij> select c1 from chartab where c1 <= 'b ';C1 ----a b ij> select c2 from chartab where c2 <= 'bcdef ';C2 -----a bcdefij> select c2 from chartab where c2 <= 'bcde ';C2 -----a ij> -- now check null <= null semanticsselect c1, c2 from chartab where c1 <= c2;C1 |C2 ---------- | a |a b |bcdefij> -- Now test >=select c1 from chartab where c1 >= ' ';C1 ----a b ij> select c2 from chartab where c2 >= ' ';C2 -----a bcdefij> select c1 from chartab where c1 >= 'a';C1 ----a b ij> select c2 from chartab where c2 >= 'a ';C2 -----a bcdefij> select c1 from chartab where c1 >= 'b';C1 ----b ij> select c2 from chartab where c2 >= 'bcdef';C2 -----bcdefij> -- now check for end-of-string blank semanticsselect c1 from chartab where c1 >= '';C1 ----a b ij> select c1 from chartab where c1 >= ' ';C1 ----a b ij> select c2 from chartab where c2 >= '';C2 -----a bcdefij> select c2 from chartab where c2 >= ' ';C2 -----a bcdefij> select c2 from chartab where c2 >= ' ';C2 -----a bcdefij> select c1 from chartab where c1 >= 'a ';C1 ----a b ij> select c2 from chartab where c2 >= 'a ';C2 -----a bcdefij> select c1 from chartab where c1 >= 'b ';C1 ----b ij> select c2 from chartab where c2 >= 'bcdef ';C2 -----bcdefij> select c2 from chartab where c2 >= 'bcde ';C2 -----bcdefij> -- now check null >= null semanticsselect c1, c2 from chartab where c1 >= c2;C1 |C2 ---------- | a |a ij> -- create a table with a few varchar columns. All varchar vs. varchar-- comparisons must be done between columns, because there are no varchar-- constants in the languagecreate table varchartab (c1 varchar(1), c2 varchar(1), c3 varchar(5), c4 varchar(5));0 rows inserted/updated/deletedij> -- insert some valuesinsert into varchartab values ('', '', '', '');1 row inserted/updated/deletedij> insert into varchartab values ('a', 'a', 'a', 'a');1 row inserted/updated/deletedij> insert into varchartab values ('b', 'b', 'bcdef', 'bcdef');1 row inserted/updated/deletedij> insert into varchartab values (null, null, null, null);1 row inserted/updated/deletedij> insert into varchartab values ('', null, '', null);1 row inserted/updated/deletedij> insert into varchartab values ('a', 'b', 'a', 'b');1 row inserted/updated/deletedij> insert into varchartab values ('b', '', 'b', 'bcdef');1 row inserted/updated/deletedij> -- select the ones where the columns are equalselect c1 from varchartab where c1 = c2;C1 ----a b ij> select c3 from varchartab where c3 = c4;C3 -----a bcdefij> -- test varchar = char semantics. Test with trailing blanks.select c1 from varchartab where c1 = ' ';C1 ----ij> select c1 from varchartab where c1 = '';C1 ----
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -