Pular para o conteúdo

Retorna a string sem ocorrências iniciais ou finais da string de remoção especificada. Se a string de remoção for omitida, os espaços são removidos.

A função do Analyze remove automaticamente os espaços iniciais e finais.

func.trim(str)
func.trim(' plaidcloud ')
┌────────────────────────────────┐
│ func.trim(' plaidcloud ') │
├────────────────────────────────┤
│ 'plaidcloud' │
└────────────────────────────────┘
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str)

Observação: TODOS os exemplos desta seção retornam a string ‘databend’.

O exemplo a seguir remove a string ‘xxx’ do início e do final da string ‘xxxdatabendxxx’:

SELECT TRIM(BOTH 'xxx' FROM 'xxxdatabendxxx');

O exemplo a seguir remove a string ‘xxx’ do início da string ‘xxxdatabend’:

SELECT TRIM(LEADING 'xxx' FROM 'xxxdatabend' );

O exemplo a seguir remove a string ‘xxx’ do final da string ‘databendxxx’:

SELECT TRIM(TRAILING 'xxx' FROM 'databendxxx' );

Se nenhuma string de remoção for especificada, a função remove todos os espaços iniciais e finais. Os exemplos a seguir removem os espaços iniciais e/ou finais:

SELECT TRIM(' databend ');
SELECT TRIM(' databend');
SELECT TRIM('databend ');