SQL> create table departments
2 ( deptno NUMBER(2) constraint D_PK
3 primary key
4 , dname VARCHAR2(10)
5 , location VARCHAR2(8)
6 , mgr NUMBER(4)
7 ) ;
Table created.
SQL>
SQL> insert into departments values (10,'ACCOUNTING','NEW YORK',7);
1 row created.
SQL> insert into departments values (20,'TRAINING', 'DALLAS', 4);
1 row created.
SQL> insert into departments values (30,'SALES', 'CHICAGO', 6);
1 row created.
SQL> insert into departments values (40,'HR', 'BOSTON', 9);
1 row created.
SQL>
SQL> col substr2 format a7
SQL> select dname
2 , substr(dname,4) as substr1
3 , substr(dname,4,3) as substr2
4 , instr(dname,'I') as instr1
5 , instr(dname,'I',5) as instr2
6 , instr(dname,'I',3,2) as instr3
7 from departments;
DNAME SUBSTR1 SUBSTR2 INSTR1 INSTR2 INSTR3
---------- ------- ------- ---------- ---------- ----------
ACCOUNTING OUNTING OUN 8 8 0
TRAINING INING INI 4 6 6
SALES ES ES 0 0 0
HR 0 0 0
SQL>
SQL> drop table departments;
Table dropped.
|