String Handling Functions ========================== 1) trim(): ---------- => leading white spaces: the spaces in left side and right side to the string called as "leading white spaces". => to make remove leading white spaces we can use trim(). => trim() can remove the white spaces from left side and right side to the string but not in between string. Syntax: trim(string-data); Ex: 'ravi kumar' ' abc' 'abc ' ' abc ' Queries: --------- select trim('abc def') from dual; select trim(' abc') from dual; select trim('abc ') from dual; select trim(' abc ') from dual; 2) ltrim(): ----------- => ltrim() can remove the white spaces from the left side to the string only. Syntax: ltrim(string-data); 3) rtrim(): ---------- => rtrim() can remove the spaces from right side of the string only. Syntax: rtrim(string-data); Note: ----- While validating the user-names or any other text information to avoid whitespaces (leading) we can use "trim" functions. lpad(): ------- => to pad the information with specified character to the left side of the original string/data we can use "lpad()". Ex: original data: "java Fullstack" "************ java Fullstack ********" Syntax: lpad(string-data, length-padding, specified-character); Ex: select lpad('Ashok IT',30,'*') from dual; rpad(): ------- Syntax: rpad('string-data', length-padding, 'specified-character'); Ex: select rpad('Hyderabad',30,'*') from dual; Q: Write a SQL query to remove the leading spaces from the employee name and job-title. And add padding in left and right side to the job-title with '#'. select trim(empName),trim(jobTitle),lpad(jobTitle,20,'#'),rpad(jobTitle, 20, '#') from employeeTable; translate(): ------------ => can use to translate the selected character with new-character. (it can translate only one character at a time). Syntax: translate(string-data, selected-character, replace-character); Ex: select translate('Jack', 'J', 'P') from dual; replace(): ---------- => can use to replace/translate with group characters at specified character group (sub-string). Syntax: replace(original-string, old-sub-string, new-sub-string); Ex: select replace('Java is Difficult', 'Difficult', 'Easy') from dual;