Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 



TRIM Function

Description

TRIM ( [ [ LEADING | TRAILING | BOTH ] [ trim_string ] FROM ] string )

 

trim_string :

character string

NULL

 

string :

character string literal

string valued column

NULL

  • trim_string : Specifies a specific string to be removed that is in front of or at the back of the target string. If it is not specified, an empty character (' ') is automatically specified so that spaces in front of or at the back of the target string are removed.
  • string : Enters a string or string-type column to trim. If this value is NULL, NULL is returned.
  • [ LEADING | TRAILING | BOTH ] : You can specify an option to trim a specified string that is in a certain position of the target string. If it is LEADING, trimming is performed in front of a character string if it is TRAILING, trimming is performed at the back of a character string if it is BOTH, trimming is performed in front and at the back of a character string. If the option is not specified, BOTH is specified by default.
  • The character string of trim_string and string should have the same character set.
Example

--trimming NULL returns NULL

SELECT TRIM (NULL);

 trim(both  from null)

======================

  NULL

 

--trimming spaces on both leading and trailing parts

SELECT TRIM ('     Olympic     ');

 trim(both  from '     Olympic     ')

======================

  'Olympic'

 

--trimming specific strings on both leading and trailing parts

SELECT TRIM ('i' FROM 'iiiiiOlympiciiiii');

 trim(both 'i' from 'iiiiiOlympiciiiii')

======================

  'Olympic'

 

--trimming specific strings on the leading part

SELECT TRIM (LEADING 'i' FROM 'iiiiiOlympiciiiii');

 trim(leading 'i' from 'iiiiiOlympiciiiii')

======================

  'Olympiciiiii'

 

--trimming specific strings on the trailing part

SELECT TRIM (TRAILING 'i' FROM 'iiiiiOlympiciiiii');

 trim(trailing 'i' from 'iiiiiOlympiciiiii')

======================

  'iiiiiOlympic'