【练习】简单的函数1

1.连接函数CONCAT

SQL> select concat('Hello','World') from dual;

CONCAT('HE
----------
HelloWorld

2.截取字符串长度SUBSTR

SQL> select substr('HelloWorld',1,5) from dual;

SUBST
-----
Hello

3.长度LENGTH

SQL> select length('HelloWorld') from dual;

LENGTH('HELLOWORLD')
--------------------
                  10

4.某个字符第一次出现的位置数INSTR

SQL> select instr('HelloWorld','W') from dual; 

INSTR('HELLOWORLD','W')
-----------------------
                      6

5.左补齐和右补齐LPAD,RPAD

SQL> select lpad(salary,10,'#') from employees where employee_id=206;

LPAD(SALARY,10,'#')
----------------------------------------
######8300

SQL> select rpad(salary,10,'#') from employees where employee_id=206;

RPAD(SALARY,10,'#')
----------------------------------------
8300######

6.删除字符串首尾的空白TRIM

SQL> select trim('H' from 'HelloWorld') from dual;

TRIM('H'F
---------
elloWorld

 

原文地址:https://www.cnblogs.com/tomatoes-/p/6065201.html