Database Practice Exercise: Character String Functions
Several of the following questions refer to a demonstration table named Student.
[For background on character string functions, refer to chapter 9.]
1. Project all columns from Student for the sName that sounds like 'foreman'.
2. Query the Student table for a list of names and majors. Use the LOWER(string)
function to show the major column in lower case letters.
3. Apply the CONCAT(str1,str2,...) function to concatenate student name and
class year which are to be listed under the synonym 'Advisees'.
4. Retrieve a list of student names and majors from Student. Apply the right
pad function -- RPAD (string,length[,'chars'] -- to the string sName using
length 30 and fill with period characters.
5. Query Student for name and name length. Determine the length with the
LENGTH(string) function. Order by descending length value.
6. Apply LOCATE('charS',charVar[,start]) to find the column position for each
student's initial (follows a comma) in the table named StudentWithInit
(version having sName with lastName value then a comma followed by an
initial).
7. Project student initial and last name from StudentWithInit. Extract with
SUBSTRING(strVar,startPos[,len]) nesting LOCATE() to point to the position
of the initial. Last name starts in position 1 and ends before the comma.