substr函数

---取1到3位

SQL> select job,substr(job,1,3) from emp;



JOB	  SUBSTR

--------- ------

CLERK	  CLE

SALESMAN  SAL

SALESMAN  SAL

MANAGER   MAN

SALESMAN  SAL

MANAGER   MAN

MANAGER   MAN

ANALYST   ANA

PRESIDENT PRE

SALESMAN  SAL

CLERK	  CLE



JOB	  SUBSTR

--------- ------

CLERK	  CLE

ANALYST   ANA

CLERK	  CLE



14 rows selected.





---取后2位

SQL>  select job,substr(job,length(job)-1,length(job)) from emp;



JOB	  SUBSTR(JOB,LENGTH(

--------- ------------------

CLERK	  RK

SALESMAN  AN

SALESMAN  AN

MANAGER   ER

SALESMAN  AN

MANAGER   ER

MANAGER   ER

ANALYST   ST

PRESIDENT NT

SALESMAN  AN

CLERK	  RK



JOB	  SUBSTR(JOB,LENGTH(

--------- ------------------

CLERK	  RK

ANALYST   ST

CLERK	  RK



14 rows selected.

你可能感兴趣的:(substr)