Sample Exam Questions

From the objective of OSS-DB Exam Silver
S3.2 Functions and operators (String functions)

Sample Question


In the following descriptions of string functions, choose three that are appropriate.

  1. The character_length function can be used to obtain the byte length of a string.

  2. The substring function can retrieve a substring, such as the second to fifth characters of a string.

  3. The lower function can be used to determine if a string is made up of all lowercase letters.

  4. The trim function returns a string with whitespace removed from both ends of the string.

  5. The replace function can replace characters in a string, for example, changing all a's to A's.

※This sample exam is different from those that appear in the actual OSS-DB Exam.

Answer and Explanation

character_length is a function that returns the length of a string, in characters. It returns the number of characters, regardless of encoding, even for multibyte characters such as Japanese.

substring is a function that retrieves a substring. A typical use is to specify a starting point and a number of characters. For example, substring(col_name, 2, 4) retrieves four characters starting from the second (that is, from the second to fifth characters) of the string in the col_name column. Another use is to retrieve a substring that matches a regular expression.

The lower function converts all uppercase characters in a string to lowercase (leaving all other characters intact). For example, lower('Abc1') returns 'abc1'.

The trim function removes whitespace from both ends of a string. You can also specify options to remove only the leading or trailing whitespace, or remove a specified character instead of whitespace.

The replace function converts all occurrences of a specified string that appear in a string to another. For example, replace('abcayz', 'a', 'A') returns 'AbcAyz'.

So the correct answers are B, D, and E.