trim
函式
適用於:Databricks SQL Databricks Runtime
去除 str
的前置或尾端空格字元。
從 str
移除前置或尾端 trimStr
字元。
語法
trim(str)
trim(BOTH FROM str)
trim(LEADING FROM str)
trim(TRAILING FROM str)
trim(trimStr FROM str)
trim(BOTH trimStr FROM str)
trim(LEADING trimStr FROM str)
trim(TRAILING trimStr FROM str)
引數
-
trimStr
:包含要修剪字符集的STRING
表示式。 -
str
:要修剪的STRING
表示式。
傳回
STRING
。
範例
> SELECT '+' || trim(' SparkSQL ') || '+';
+SparkSQL+
> SELECT '+' || trim(BOTH FROM ' SparkSQL ') || '+';
+SparkSQL+
> SELECT '+' || trim(LEADING FROM ' SparkSQL ') || '+';
+SparkSQL +
> SELECT '+' || trim(TRAILING FROM ' SparkSQL ') || '+';
+ SparkSQL+
> SELECT trim('SL' FROM 'SSparkSQLS');
parkSQ
> SELECT trim(BOTH 'SL' FROM 'SSparkSQLS');
parkSQ
> SELECT trim(LEADING 'SL' FROM 'SSparkSQLS');
parkSQLS
> SELECT trim(TRAILING 'SL' FROM 'SSparkSQLS');
SSparkSQ
> SELECT trim(BOTH 'sl' COLLATE UTF8_BINARY FROM 'SSparkSQLS');
SSparkSQLS
> SELECT trim(BOTH 'sl' COLLATE UTF8_LCASE FROM 'SSparkSQLS');
parkSQ