---
title: "9i SQL notes"
author: "linsea"
date: "2009-09-12T21:59:22Z"
tags: []
slug: "9i-sql-notes"
draft: false
lastmod: "2009-09-12T21:59:22Z"
id: 467549
url: "https://linsea.iteye.com/blog/467549"
---

General functions:  
– NVL  
– NVL2  
– NULLIF  
– COALSECE  
– CASE  
– DECODE

CONCAT('Hello', 'World')  
SUBSTR('HelloWorld',1,5)  
LENGTH('HelloWorld')  
INSTR('HelloWorld', 'W')  
LPAD(salary,10,'\*')  
RPAD(salary, 10, '\*')  
TRIM('H' FROM 'HelloWorld')

HelloWorld  
Hello  
10  
6  
\*\*\*\*\*24000  
24000\*\*\*\**  
elloWorld

   
TRIM(leading|trailing|both, trim\_character FROM trim\_source)  
Enables you to trim heading or trailing characters (or both)  
from a character string. If  trim\_character or  
trim\_source is a  character literal, you must enclose it in  
single quotes.  
This is a feature available from Oracle8i and later.

INSTR: Finds numeric position of a named character

Number Functions  
• ROUND: Rounds value to specified decimal  
ROUND(45.926, 2) 45.93  
• TRUNC: Truncates value to specified decimal  
TRUNC(45.926, 2) 45.92

SQL&gt; select trunc(124.1666,-2) trunc1,trunc(124.16666,2) from dual;

TRUNC1 TRUNC(124.16666,2)

\--------- ------------------

100 124.16

 

Date Functions  
Number of months  
between two dates  
MONTHS\_BETWEEN  
ADD\_MONTHS  
NEXT\_DAY  
LAST\_DAY  
ROUND  
TRUNC  
Add calendar months to  
date  
Next day of the date  
specified  
Last day of the month  
Round date  
Truncate date  
Function Description

• MONTHS\_BETWEEN ('01-SEP-95','11-JAN-94')  
Using Date Functions  
• ADD\_MONTHS ('11-JAN-94',6)  
• NEXT\_DAY ('01-SEP-95','FRIDAY')  
• LAST\_DAY('01-FEB-95')  
19.6774194  
'11-JUL-94'  
'08-SEP-95'  
'28-FEB-95'

• ROUND(SYSDATE,'MONTH')         01-AUG-95  
• ROUND(SYSDATE ,'YEAR')         01-JAN-96  
• TRUNC(SYSDATE ,'MONTH')        01-JUL-95  
• TRUNC(SYSDATE ,'YEAR')         01-JAN-95  
Using Date Functions  
Assume SYSDATE = '25-JUL-95':

日期类型的几个转换及格式函数还需要重新看看!!

NVL  Converts a null value to an actual value  
NVL2  If  expr1 is not null,  NVL2 returns  expr2. If  expr1 is null,  NVL2  
returns expr3. The argument expr1can have any data type.  
NULLIF  Compares two expressions and returns null if they are equal, or the first  
expression if they are not equal  
COALESCE  Returns the first non-null expression in the expression list 

Note: The NULLIF function is logically equivalent to the following CASE expression. The CASE  
expression is discussed in a subsequent page:  
CASE WHEN expr1 = expr 2 THEN NULL ELSE expr1 END  
\==========================  
The CASE Expression  
Facilitates conditional inquiries by doing the work of  
an IF-THEN-ELSE statement:  
CASE expr WHEN comparison\_expr1 THEN return\_expr1  
[WHEN comparison\_expr2 THEN return\_expr2  
WHEN comparison\_exprn THEN return\_exprn  
ELSE else\_expr]  
END

SELECT last\_name, job\_id, salary,  
CASE job\_id WHEN 'IT\_PROG'  THEN  1.10\*salary  
WHEN 'ST\_CLERK' THEN  1.15\*salary  
WHEN 'SA\_REP'   THEN  1.20\*salary  
ELSE      salary  
END     "REVISED\_SALARY"  
FROM   employees;  
\====================  
The DECODE Function  
Facilitates conditional inquiries by doing the work of  
a CASE or IF-THEN-ELSE statement:  
DECODE(col|expression, search1, result1  
\[, search2, result2,...,]  
\[, default])

SELECT last\_name, job\_id, salary,  
DECODE(job\_id, 'IT\_PROG',  1.10\*salary,  
'ST\_CLERK', 1.15\*salary,  
'SA\_REP',   1.20\*salary,  
salary)  
REVISED\_SALARY  
FROM   employees;

The same statement can be expressed in psuedocode as an IF-THEN-ELSE statement:  
IF job\_id = 'IT\_PROG'     THEN  salary = salary\*1.10  
IF job\_id = 'ST\_CLERK'    THEN  salary = salary\*1.15  
IF job\_id = 'SA\_REP'      THEN salart = salary\*1.20  
ELSE salary = salary

==========================

Equijoins  
To determine an employee’ s department name, you compare the value in the DEPARTMENT\_ID column in  
the EMPLOYEES table with the DEPARTMENT\_ID values in the DEPARTMENTS table. The relationship  
between the EMPLOYEES and DEPARTMENTS tables is an equijoin, that is, values in the  
DEPARTMENT\_ID column on both tables must be equal. Frequently, this type of join involves primary and  
foreign key complements.  
Note: Equijoins are also called simple joins or inner joins.

CROSS JOIN Returns a Cartesian product(叉积,笛卡尔积) from the two tables  
NATURAL JOIN Joins two tables based on the same column name

Retrieving Records with Natural Joins  
SELECT department\_id, department\_name,  
location\_id, city  
FROM   departments  
NATURAL JOIN locations;

In the example in the slide, the LOCATIONS table is joined to the DEPARTMENT table by the  
LOCATION\_ID column, which is the only column of the same name in both tables. If other common  
columns were present, the join would have used them all.

SELECT l.city, d.department\_name  
FROM   locations l JOIN departments d USING (location\_id)  
WHERE  location\_id = 1400;

SELECT e.employee\_id, e.last\_name, e.department\_id,  
d.department\_id, d.location\_id  
FROM   employees e JOIN departments d  
ON     (e.department\_id = d.department\_id);

SELECT  department\_id, department\_name,  
location\_id, city  
FROM    departments  
NATURAL JOIN locations  
WHERE   department\_id IN (20, 50);

Three-Way Joins with the ON Clause  
SELECT employee\_id, city, department\_name  
FROM   employees e  
JOIN   departments d  
ON     d.department\_id = e.department\_id  
JOIN   locations l  
ON     d.location\_id = l.location\_id;  
This can also be written as a three-way equijoin:  
SELECT employee\_id, city, department\_name  
FROM   employees, departments, locations  
WHERE  employees.department\_id = departments.department\_id  
AND    departments.location\_id = locations.location\_id;  
\=================

LEFT OUTER JOIN  
SELECT e.last\_name, e.department\_id, d.department\_name  
FROM employees e  
LEFT OUTER JOIN departments d  
ON (e.department\_id = d.department\_id);

This query retrieves all rows in the EMPLOYEES table, which is the left table even if there is no match in  
the DEPARTMENTS table.  
This query was completed in earlier releases as follows:  
SELECT e.last\_name, e.department\_id, d.department\_name  
FROM employees e, departments d  
WHERE d.department\_id (+) = e.department\_id;  
\=================

RIGHT OUTER JOIN  
SELECT e.last\_name, e.department\_id, d.department\_name  
FROM employees e  
RIGHT OUTER JOIN departments d  
ON (e.department\_id = d.department\_id);  
This query retrieves all rows in the DEPARTMENTS table, which is the right table even if there is no match  
in the EMPLOYEES table.  
This query was completed in earlier releases as follows:  
SELECT e.last\_name, e.department\_id, d.department\_name  
FROM employees e, departments d  
WHERE d.department\_id = e.department\_id  (+);

============  
FULL OUTER JOIN  
A join between two tables that returns the results  
of an inner join as well as the results of a left and  
right join is a full outer join.

SELECT e.last\_name, e.department\_id, d.department\_name  
FROM employees e  
FULL OUTER JOIN departments d  
ON (e.department\_id = d.department\_id);

===============

You cannot use group functions in the WHERE clause.  
SELECT department\_id, AVG(salary)  
FROM   employees  
WHERE  AVG(salary) &gt; 8000  
GROUP BY department\_id;  
WHERE  AVG(salary) &gt; 8000  
\*  
ERROR at line 3:  
ORA-00934: group function is not allowed here

================  
Types of Group Functions  
STDDEV(\[DISTINCT|ALL]x)  Standard deviation of n, ignoring null values  
VARIANCE(\[DISTINCT|ALL]x)  Variance of n, ignoring null values

===========  
Using a Subquery in an INSERT Statement  
INSERT INTO  
(SELECT employee\_id, last\_name,  
email, hire\_date, job\_id, salary,  
department\_id  
FROM   employees  
WHERE  department\_id = 50)  
VALUES (99999, 'Taylor', 'DTAYLOR',  
TO\_DATE('07-JUN-99', 'DD-MON-RR'),  
'ST\_CLERK', 5000, 50);  
1 row created.  
\=============

如果视图定义包括条件（譬如 WHERE 子句）并且其意图是确保任何引用该视图的 INSERT 或 UPDATE 语句都应用 WHERE 子句，则必须使用 WITH CHECK OPTION 定义该视图。这个选项可以确保数据库中正在修改的数据的完整性。如果在 INSERT 或 UPDATE 操作期间违反了条件，则返回 SQL 错误。

INSERT INTO  (SELECT employee\_id, last\_name, email,  
hire\_date, job\_id, salary  
FROM   employees  
WHERE  department\_id = 50 WITH CHECK OPTION)  
VALUES (99998, 'Smith', 'JSMITH',  
TO\_DATE('07-JUN-99', 'DD-MON-RR'),  
'ST\_CLERK', 5000);  
INSERT INTO  
\*  
ERROR at line 1:  
ORA-01402: view WITH CHECK OPTION where-clause violation

===============

MERGE Statement Syntax:  
MERGE INTO table\_name AS table\_alias  
USING (table|view|sub\_query) AS alias  
ON (join condition)  
WHEN MATCHED THEN  
UPDATE SET  
col1 = col\_val1,  
col2 = col2\_val  
WHEN NOT MATCHED THEN  
INSERT (column\_list)  
VALUES (column\_values);  
\=================

ALTER TABLE dept80 ADD (job\_id VARCHAR2(9));

ALTER TABLE dept80 MODIFY (last\_name VARCHAR2(30));

ALTER TABLE dept80 DROP  COLUMN   job\_id;

ALTER TABLE table SET   UNUSED (column);  
OR  
ALTER TABLE  table SET UNUSED COLUMN column;

ALTER TABLE table DROP  UNUSED COLUMNS;

Changing the Name of an Object  
RENAME    old\_name TO  new\_name;

COMMENT ON TABLE employees IS 'Employee Information';

Defining Constraints

column \[CONSTRAINT constraint\_name] constraint\_type,

column,...  
\[CONSTRAINT constraint\_name] constraint\_type  
(column, ...),

CONSTRAINT emp\_dept\_fk FOREIGN KEY (department\_id)  
REFERENCES departments(department\_id),

ALTER TABLE table ADD \[CONSTRAINT constraint] type (column);  
ALTER TABLE     employees  
ADD CONSTRAINT  emp\_manager\_fk  
FOREIGN KEY(manager\_id)  
REFERENCES employees(employee\_id);

LTER TABLE employees  
DISABLE CONSTRAINT emp\_emp\_id\_pk CASCADE;

ALTER TABLE      employees  
DROP CONSTRAINT  emp\_manager\_fk;

ALTER TABLE departments  
DROP PRIMARY KEY CASCADE;

ALTER TABLE test1  
DROP (pk) CASCADE CONSTRAINTS;

ALTER TABLE test1  
DROP (pk, fk, col1) CASCADE CONSTRAINTS;

SELECT constraint\_name, constraint\_type,  
search\_condition  
FROM user\_constraints  
WHERE table\_name = 'EMPLOYEES';

 

==============================  
Volumn 2  
\==============================

CREATE \[OR REPLACE] \[FORCE|NOFORCE] VIEW view  
\[(alias\[, alias]...)]  
AS subquery  
\[WITH CHECK OPTION \[CONSTRAINT constraint]]  
\[WITH READ ONLY \[CONSTRAINT constraint]];

CREATE OR REPLACE VIEW empvu80  
(id\_number, name, sal, department\_id)  
AS SELECT  employee\_id, first\_name || ' ' || last\_name,  
salary, department\_id  
FROM    employees  
WHERE   department\_id = 80;

• An inline view is a subquery with an alias (or  
correlation name) that you can use within a SQL  
statement.  
• A named subquery in the FROM clause of the main  
query is an example of an inline view.  
• An inline view is not a schema object.

SELECT  a.last\_name, a.salary, a.department\_id, b. maxsal  
FROM    employees a,  
(SELECT   department\_id, max(salary) maxsal  
FROM     employees  
GROUP BY department\_id) b  
WHERE   a.department\_id = b.department\_id  
AND     a.salary &lt; b.maxsal;

========================

CREATE PUBLIC DATABASE LINK hq.acme.com USING 'sales';

SELECT *  FROM [fred.emp@HQ.ACME.COM](mailto:fred.emp@HQ.ACME.COM);

CREATE PUBLIC SYNONYM HQ\_EMP FOR [emp@HQ.ACME.COM](mailto:emp@HQ.ACME.COM);

SELECT * FROM HQ\_EMP;

=========================  
The UNION ALL operator returns results from both  
queries including all duplications.

The INTERSECT operator returns results that are common to both queries.

===============  
datetime functions:  
• CURRENT\_DATE  
• CURRENT\_TIMESTAMP  
• LOCALTIMESTAMP  
• DBTIMEZONE  
• SESSIONTIMEZONE  
• EXTRACT  
• FROM\_TZ  
• TO\_TIMESTAMP  
• TO\_TIMESTAMP\_TZ  
• TO\_YMINTERVAL  
• TZ\_OFFSET

ALTER SESSION SET NLS\_DATE\_FORMAT = 'DD-MON-YYYY HH24:MI:SS';  
ALTER SESSION SET TIME\_ZONE = '-5:0';  
SELECT SESSIONTIMEZONE, CURRENT\_DATE FROM DUAL;  
SELECT DBTIMEZONE FROM DUAL;  
SELECT SESSIONTIMEZONE FROM DUAL;

The syntax of the EXTRACT function is:  
SELECT  EXTRACT (\[YEAR] \[MONTH]\[DAY] \[HOUR] \[MINUTE]\[SECOND]  
\[TIMEZONE\_HOUR] \[TIMEZONE\_MINUTE]  
\[TIMEZONE\_REGION] \[TIMEZONE\_ABBR]  
FROM \[datetime\_value\_expression]  
\[interval\_value\_expression]);  
SELECT EXTRACT (YEAR FROM SYSDATE) FROM DUAL;  
SELECT last\_name, hire\_date,  
EXTRACT (MONTH FROM HIRE\_DATE)  
FROM employees;

SELECT   
FROM DUAL;  
SELECT TO\_TIMESTAMP ('2000-12-01 11:00:00',  
'YYYY-MM-DD HH:MI:SS')  
FROM DUAL;  
TO\_TIMESTAMP\_TZ('1999-12-01 11:00:00 -8:00',  
'YYYY-MM-DD HH:MI:SS TZH:TZM')

SELECT hire\_date,  
hire\_date + TO\_YMINTERVAL('01-02') AS  
HIRE\_DATE\_YMININTERVAL  
FROM EMPLOYEES  
WHERE department\_id = 20;  
The example in the slide calculates a date that is one year two months after the hire date for the employees  
working in the department 20 of the EMPLOYEES table.

SELECT hire\_date, hire\_date +  TO\_YMINTERVAL('-02-04') AS     
HIRE\_DATE\_YMINTERVAL  
FROM EMPLOYEES WHERE department\_id = 20;  
Observe that the character string passed to the TO\_YMINTERVAL function has a negative value. The  
example returns a date that is two years and four months before the hire date for the employees working in  
the department 20 of the EMPLOYEES table.

SELECT TZ\_OFFSET('US/Eastern') FROM DUAL;  
SELECT TZ\_OFFSET('Canada/Yukon') FROM DUAL;  
SELECT TZ\_OFFSET('Europe/London') FROM DUAL;

The TZ\_OFFSET function returns the time zone offset corresponding to the value entered.

========================

SELECT   department\_id, job\_id, SUM(sal)  
FROM     employees   
WHERE department\_id &lt; 60  
GROUP BY ROLLUP(department\_id, job\_id);

SELECT  department\_id, job\_id, SUM(salary)  
FROM    employees   
WHERE   department\_id &lt; 60  
GROUP BY CUBE (department\_id, job\_id);

GROUPING Function  
• Using it, you can find the groups forming the  
subtotal in a row.  
• Using it, you can differentiate stored NULL values  
from NULL values created by ROLLUP or CUBE.  
• It returns 0 or 1.

SELECT   department\_id DEPTID, job\_id JOB, SUM(salary),  
FROM     employees  
WHERE department\_id &lt; 50  
GROUP BY ROLLUP(department\_id, job\_id);  
GROUPING(department\_id) GRP\_DEPT,GROUPING(job\_id) GRP\_JOB

GROUPING SETS

SELECT department\_id, job\_id, manager\_id, AVG(salary)  
FROM employees  
GROUP BY  
GROUPING SETS  
((department\_id, job\_id, manager\_id),  
(department\_id, manager\_id),(job\_id, manager\_id));  
This statement calculates aggregates over three groupings:  
(department\_id, job\_id, manager\_id), (department\_id, manager_ id)  
and (job\_id, manager\_id)

CUBE(a, b, c)  
is equivalent to  
GROUPING SETS  
((a, b, c), (a, b), (a, c), (b, c),  
(a), (b), (c), ())

 ROLLUP(a, b,c)  
is equivalent to  
GROUPING SETS ((a, b, c), (a, b),(a), ())

SELECT department\_id, job\_id, manager\_id,avg(salary)  
FROM   employees  
GROUP BY   GROUPING SETS  
((department\_id,job\_id), (job\_id,manager\_id));

Composite Columns: Example  
SELECT   department\_id, job\_id, manager\_id, SUM(salary)  
FROM     employees   
GROUP BY ROLLUP( department\_id,(job\_id, manager\_id));

Concatenated Groupings  
The result is a cross-product of groupings from each grouping set.  
GROUP BY GROUPING SETS(a, b), GROUPING SETS(c, d)  
The preceding SQL defines the following groupings:  
(a, c), (a, d), (b, c), (b, d)

SELECT   department\_id, job\_id, manager\_id, SUM(salary)  
FROM     employees  
GROUP BY department\_id,ROLLUP(job\_id),CUBE(manager\_id);  
The example in the slide results in the following groupings:  
• (department\_id, manager\_id, job\_id )  
• (department\_id, manager\_id)  
• (department\_id, job\_id)  
• (department\_id)

==================  
Scalar Subqueries: Examples  
SELECT employee\_id, last\_name,  
(CASE  
WHEN department\_id =  
(SELECT department\_id FROM departments  
WHERE location\_id = 1800)

THEN 'Canada' ELSE 'USA' END) location  
FROM employees;

SELECT employee\_id, last\_name  
FROM employees e  
ORDER BY  
(SELECT department\_name  
FROM departments d  
WHERE e.department\_id = d.department\_id);  
把子查询看作一个视图,外部查询按视图的列名来排序.  
18-14

Correlated subqueries are used for row-by-row  
processing. Each subquery is executed once for  
every row of the outer query.  
Nested Subqueries Versus Correlated Subqueries  
With a normal nested subquery, the inner SELECT query runs first and executes once, returning values to  
be used by the main query. A correlated subquery, however, executes once for each candidate row  
considered by the outer query. In other words, the inner query is driven by the outer query

Find all employees who earn more than the average  
salary in their department.  
SELECT last\_name, salary, department\_id  
FROM   employees outer  
WHERE  salary &gt;(SELECT AVG(salary)  
FROM   employees  
WHERE  department\_id =   
outer.department\_id);

我們可以使用   WITH   Clause   來定義一個   query   block，然後在   SELECT   statement   的其它地方來使用這個   query   block。如果在一個很複雜的   Query   裡，我們必須重複的使用某個   subquery，使用   WITH   Clause   可以降低   Query   的複雜度以及提高   performance。WITH   Clause   所讀出的資料會暫存在   User   的   temporary   tablespace   中。    
  SQL&gt;   WITH    
      2     DEPT\_COSTS   AS   (   SELECT   D.department\_name,   SUM(E.salary)   AS   dept\_total    
      3                                         FROM   EMPLOYEES   E,   DEPARTMENTS   D    
      4       WHERE   E.department\_id   =   D.department\_id    
      5     GROUP   BY   D.department\_name),    
      6     AVG\_COST       AS   (   SELECT   SUM(dept\_total)/COUNT(\*)   AS   dept\_avg    
      7                                         FROM   DEPT\_COSTS)    
      8     SELECT   *    
      9         FROM   DEPT\_COSTS    
    10       WHERE   dept\_total   &gt;   (SELECT   dept\_avg   FROM   AVG\_COST)    
    11     ORDER   BY   department\_name;    
     
  DEPARTMENT\_NAME                                 DEPT\_TOTAL    
  ------------------------------   ----------    
  Sales--                                                         304500    
  Shipping--                                                   156400

 

Hierarchical Retrieval

SELECT \[LEVEL], column, expr...  
FROM   table  
\[WHERE condition(s)]  
\[START WITH condition(s)]  
\[CONNECT BY PRIOR condition(s)];

我们要找出员工ID为2的人及其所有下属(包括直接和间接下属)  
select ID, EMP\_NAME, MANAGER\_ID  
from employee  
start with id = 2  
connect by prior id = manager\_id ;

Prior放在那里，那一侧就是被比较的一方(父方)，另一侧就是发起比较的一方(子方)。语义上可以这样翻译：xxx字段的值必须等于当前记录XXX字段的值(prior一方)

 

Types of Multitable INSERT Statements  
Oracle9i introduces the following types of multitable insert  
statements:  
• Unconditional INSERT  
• Conditional ALL INSERT  
• Conditional FIRST INSERT  
• Pivoting INSERT

Unconditional INSERT ALL:  
INSERT ALL  
INTO sal\_history VALUES(EMPID,HIREDATE,SAL)  
INTO mgr\_history VALUES(EMPID,MGR,SAL)  
SELECT employee\_id EMPID ,hire\_date HIREDATE, salary SAL, manager\_id MGR  
FROM  employees  
WHERE employee\_id &gt; 200;

Conditional INSERT ALL:  
INSERT ALL  
WHEN SAL &gt; 10000 THEN  
INTO sal\_history VALUES(EMPID,HIREDATE,SAL)  
WHEN MGR &gt; 200 THEN  
INTO mgr\_history VALUES(EMPID,MGR,SAL)  
SELECT employee\_id EMPID ,hire\_date HIREDATE, salary SAL, manager\_id MGR  
FROM  employees  
WHERE employee\_id &gt; 200;

Conditional FIRST INSERT:  
INSERT FIRST  
WHEN SAL  &gt; 25000 THEN  
INTO special\_sal VALUES(DEPTID, SAL)  
WHEN HIREDATE like ('%00%') THEN  
INTO hiredate\_history\_00 VALUES(DEPTID,HIREDATE)  
WHEN HIREDATE like ('%99%') THEN  
INTO hiredate\_history\_99 VALUES(DEPTID, HIREDATE)  
ELSE  
INTO hiredate\_history VALUES(DEPTID, HIREDATE)  
SELECT department\_id DEPTID, SUM(salary) SAL,  
MAX(hire\_date) HIREDATE  
FROM employees  
GROUP BY department\_id;

Pivoting INSERT:  
INSERT ALL  
INTO sales\_info VALUES (employee\_id,week\_id,sales\_MON)  
INTO sales\_info VALUES (employee\_id,week\_id,sales\_TUE)  
INTO sales\_info VALUES (employee\_id,week\_id,sales\_WED)  
INTO sales\_info VALUES (employee\_id,week\_id,sales\_THUR)  
INTO sales\_info VALUES (employee\_id,week\_id, sales\_FRI)  
SELECT EMPLOYEE\_ID, week\_id, sales\_MON, sales\_TUE,  
sales\_WED, sales\_THUR,sales\_FRI  
FROM sales\_source\_data;

External Table  
External tables are read-only tables in which the             
data is stored outside the database in flat files.  
The data can be queried using SQL but you cannot  
use DML and no indexes can be created.  
CREATE DIRECTORY emp\_dir AS '/flat\_files' ;

CREATE TABLE oldemp (  
empno NUMBER, empname CHAR(20), birthdate DATE)  
ORGANIZATION EXTERNAL  
(TYPE ORACLE\_LOADER  
DEFAULT DIRECTORY emp\_dir  
ACCESS PARAMETERS  
(RECORDS DELIMITED BY NEWLINE  
BADFILE 'bad\_emp'  
LOGFILE 'log\_emp'  
FIELDS TERMINATED BY ','  
(empno CHAR,  
empname CHAR,  
birthdate CHAR date\_format date mask "dd-mon-yyyy"))  
LOCATION ('emp1.txt'))  
PARALLEL 5  
REJECT LIMIT 200;