github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_string_rtrim_ltrim.test (about) 1 #SELECT 2 SELECT RTRIM('barbar '); 3 SELECT LTRIM(' barbar'); 4 -- @separator:table 5 SELECT ' geeksforgeeks' As OriginalString, 6 LTRIM (' geeksforgeeks') AS LeftTrimmedString; 7 -- @separator:table 8 SELECT ' MySQL' AS String, RTRIM ('MySQL') AS Tstring; 9 10 #SELECT 嵌套 11 #select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a"); 12 select cast(rtrim(' 20.06 ') as decimal(19,2)); 13 select cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2)); 14 select concat_ws(':',ltrim(' left '),':',rtrim(' right '),':'); 15 16 #WHERE 17 CREATE TABLE t (a int NOT NULL); 18 INSERT INTO t values(21123); 19 SELECT 1 FROM t WHERE rtrim(a & NULL); 20 SELECT 1 FROM t WHERE ltrim(a & NULL); 21 DROP TABLE t; 22 23 #特殊字符集 24 25 drop table if exists `T1`; 26 drop table if exists `T2`; 27 drop table if exists `T3`; 28 drop table if exists `T4`; 29 drop table if exists `T5`; 30 drop table if exists `T6`; 31 drop table if exists `T7`; 32 drop table if exists `T8`; 33 drop table if exists `T9`; 34 CREATE TABLE `T1` (`C1` char(80)); 35 CREATE TABLE `T2` (`C1` char(80)); 36 CREATE TABLE `T3` (`C1` char(80)); 37 CREATE TABLE `T4` (`C1` char(80)); 38 CREATE TABLE `T5` (`C1` char(80)); 39 CREATE TABLE `T6` (`C1` char(80)); 40 CREATE TABLE `T7` (`C1` char(80)); 41 CREATE TABLE `T8` (`C1` char(80)); 42 CREATE TABLE `T9` (`C1` char(80)); 43 INSERT INTO `T1` VALUES ('アイウエオ'); 44 INSERT INTO `T1` VALUES ('アイウエオ '); 45 INSERT INTO `T1` VALUES ('アイウエオ '); 46 INSERT INTO `T1` VALUES ('アイウエオ '); 47 INSERT INTO `T1` VALUES ('アイウエオ '); 48 INSERT INTO `T1` VALUES ('アイウエオ '); 49 INSERT INTO `T1` VALUES ('アイウエオ '); 50 INSERT INTO `T2` VALUES ('あいうえお'); 51 INSERT INTO `T2` VALUES ('あいうえお '); 52 INSERT INTO `T2` VALUES ('あいうえお '); 53 INSERT INTO `T2` VALUES ('あいうえお '); 54 INSERT INTO `T2` VALUES ('あいうえお '); 55 INSERT INTO `T2` VALUES ('あいうえお '); 56 INSERT INTO `T2` VALUES ('あいうえお '); 57 INSERT INTO `T3` VALUES ('龔龖龗龞龡'); 58 INSERT INTO `T3` VALUES ('龔龖龗龞龡 '); 59 INSERT INTO `T3` VALUES ('龔龖龗龞龡 '); 60 INSERT INTO `T3` VALUES ('龔龖龗龞龡 '); 61 INSERT INTO `T3` VALUES ('龔龖龗龞龡 '); 62 INSERT INTO `T3` VALUES ('龔龖龗龞龡 '); 63 INSERT INTO `T3` VALUES ('龔龖龗龞龡 '); 64 INSERT INTO `T4` VALUES ('アイウエオ'); 65 INSERT INTO `T4` VALUES ('アイウエオ '); 66 INSERT INTO `T4` VALUES ('アイウエオ '); 67 INSERT INTO `T4` VALUES ('アイウエオ '); 68 INSERT INTO `T4` VALUES ('アイウエオ '); 69 INSERT INTO `T4` VALUES ('アイウエオ '); 70 INSERT INTO `T4` VALUES ('アイウエオ '); 71 INSERT INTO `T5` VALUES ('あいうえお'); 72 INSERT INTO `T5` VALUES ('あいうえお '); 73 INSERT INTO `T5` VALUES ('あいうえお '); 74 INSERT INTO `T5` VALUES ('あいうえお '); 75 INSERT INTO `T5` VALUES ('あいうえお '); 76 INSERT INTO `T5` VALUES ('あいうえお '); 77 INSERT INTO `T5` VALUES ('あいうえお '); 78 INSERT INTO `T6` VALUES ('龔龖龗龞龡'); 79 INSERT INTO `T6` VALUES ('龔龖龗龞龡 '); 80 INSERT INTO `T6` VALUES ('龔龖龗龞龡 '); 81 INSERT INTO `T6` VALUES ('龔龖龗龞龡 '); 82 INSERT INTO `T6` VALUES ('龔龖龗龞龡 '); 83 INSERT INTO `T6` VALUES ('龔龖龗龞龡 '); 84 INSERT INTO `T6` VALUES ('龔龖龗龞龡 '); 85 INSERT INTO `T7` VALUES ('アイウエオ'); 86 INSERT INTO `T7` VALUES ('アイウエオ '); 87 INSERT INTO `T7` VALUES ('アイウエオ '); 88 INSERT INTO `T7` VALUES ('アイウエオ '); 89 INSERT INTO `T7` VALUES ('アイウエオ '); 90 INSERT INTO `T7` VALUES ('アイウエオ '); 91 INSERT INTO `T7` VALUES ('アイウエオ '); 92 INSERT INTO `T8` VALUES ('あいうえお'); 93 INSERT INTO `T8` VALUES ('あいうえお '); 94 INSERT INTO `T8` VALUES ('あいうえお '); 95 INSERT INTO `T8` VALUES ('あいうえお '); 96 INSERT INTO `T8` VALUES ('あいうえお '); 97 INSERT INTO `T8` VALUES ('あいうえお '); 98 INSERT INTO `T8` VALUES ('あいうえお '); 99 INSERT INTO `T9` VALUES ('龔龖龗龞龡'); 100 INSERT INTO `T9` VALUES ('龔龖龗龞龡 '); 101 INSERT INTO `T9` VALUES ('龔龖龗龞龡 '); 102 INSERT INTO `T9` VALUES ('龔龖龗龞龡 '); 103 INSERT INTO `T9` VALUES ('龔龖龗龞龡 '); 104 INSERT INTO `T9` VALUES ('龔龖龗龞龡 '); 105 INSERT INTO `T9` VALUES ('龔龖龗龞龡 '); 106 SELECT RTRIM(`C1`) from `T1`; 107 SELECT RTRIM(`C1`) from `T2`; 108 SELECT RTRIM(`C1`) from `T3`; 109 SELECT RTRIM(`C1`) from `T4`; 110 SELECT RTRIM(`C1`) from `T5`; 111 SELECT RTRIM(`C1`) from `T6`; 112 SELECT RTRIM(`C1`) from `T7`; 113 SELECT RTRIM(`C1`) from `T8`; 114 SELECT RTRIM(`C1`) from `T9`; 115 DROP TABLE `T1`; 116 DROP TABLE `T2`; 117 DROP TABLE `T3`; 118 DROP TABLE `T4`; 119 DROP TABLE `T5`; 120 DROP TABLE `T6`; 121 DROP TABLE `T7`; 122 DROP TABLE `T8`; 123 DROP TABLE `T9`; 124 drop table if exists `T1`; 125 drop table if exists `T2`; 126 drop table if exists `T3`; 127 drop table if exists `T4`; 128 drop table if exists `T5`; 129 drop table if exists `T6`; 130 drop table if exists `T7`; 131 drop table if exists `T8`; 132 drop table if exists `T9`; 133 134 135 #NULL 136 SELECT RTRIM(NULL); 137 SELECT LTRIM(NULL); 138 139 #中文 140 SELECT RTRIM("你好 "); 141 SELECT LTRIM(" 你好"); 142 143 #INSERT, distinct 144 drop table if exists t1; 145 create table t1(a varchar(255)); 146 insert into t1 select (RTRIM("2017-06-15 ")); 147 insert into t1 select (LTRIM(" 2019-06-25")); 148 insert into t1 select (RTRIM("2017-06-15 ")); 149 insert into t1 select ("2017-06-15 "); 150 select distinct RTRIM(ltrim(a)),LTRIM(rtrim(a)) from t1; 151 drop table t1; 152 153 154 #HAVING & 算术运算 155 drop table if exists t1; 156 create table t1(a INT, b datetime); 157 insert into t1 values(1, "2017-06-15 "),(1, "2019-06-25 "),(2, " 2019-06-25 "),(3, " 2019-06-25 "); 158 select b from t1 group by b having rtrim(ltrim(b))>"2018-01-01"; 159 drop table t1; 160 161 #ON CONDITION 162 create table t1(a INT, b date); 163 create table t2(a INT, b date); 164 insert into t1 values(1, " 2012-10-12 "),(2, " 2004-04-24. "),(3, " 2008-12-04. "),(4, " 2012-03-23. "); 165 insert into t2 values(1, " 2013-04-30 "),(2, " 1994-10-04 "),(3, " 2018-06-04 "),(4, " 2012-10-12 "); 166 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (rtrim(ltrim(t1.b)) = ltrim(rtrim(t2.b))); 167 drop table t1; 168 drop table t2; 169 170 #EXTREME VALUE 171 SELECT RTRIM(space(100000000)+"123"); 172 SELECT LTRIM("123"+space(100000000)); 173 SELECT LTRIM(" 1241241^&@%#^*^!@#&*(!&"); 174 SELECT RTRIM("1241241^&@%#^*^!@#&*(!& "); 175 176 #DATETYPE 177 SELECT RTRIM(" 123 "); 178 SELECT RTRIM(123124); 179 SELECT RTRIM(123.41231); 180 SELECT LTRIM(" 123"); 181 SELECT LTRIM(123124); 182 SELECT LTRIM(123.41231); 183