dw sqlldr example02 basic

2)dw sqlldr
1@@@@easy example02
@@@
@@@<1>create directory object.
@@@
SYS@ocp> !mkdir -p /home/oracle/dwdir
SYS@ocp> create directory dir01 as '/home/oracle/dwdir';
Directory created.
SYS@ocp> grant read,write on directory dir01 to hr;
Grant succeeded.


@@@
@@@<2>create table for loading data.
@@@
HR@ocp> conn hr/hr
Connected.
HR@ocp> ed
  1  create table product
  2  (
  3   product_id  varchar2(20),
  4   product_name  varchar2(20),
  5   category     varchar2(20),
  6   cost_price  number(9,2),
  7   sell_price  number(9,2),
  8   weight  number(9,2),
  9   shipping_charge  number(9,2),
 10   manufacturer varchar2(20),
 11   supplier    varchar2(20)
 12* )
HR@ocp> /
Table created.


@@@
@@@<3>make a specified flat file.
@@@
@@@make sure the data file have Stream format.
@@@the comma is the delimiter character.
[oracle@station78 dwdir]$ pwd
/home/oracle/dwdir
[oracle@station78 dwdir]$ cat product.dat
'SP1242', 'CD LX1', 'MUSC', 8.90, 15.67, 2.5, 2.95, 'RTG', 'CD Inc'
'SP1243', 'CD LX2', 'MUSC', 8.91, 15.68, 2.6, 2.97, 'RTG', 'CD Inc'
'SP1244', 'CD LX3', 'MUSC', 8.92, 15.69, 2.7, 2.99, 'RTG', 'CD Inc'
'SP1245', 'CD LX4', 'MUSC', 8.93, 15.70, 2.8, 2.93, 'RTG', 'CD Inc'


@@@
@@@<4>write the control file, and loading data.
@@@
@@@as the data is read, it is converted from data type in input file
@@@to the data type of the column in database.
[oracle@station78 dwdir]$ cat ctl_product.ctl
LOAD DATA
INFILE 'product.dat' append
INTO TABLE product
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY "'"
(
 product_id,
 product_name,
 category,
 cost_price,
 weight,
 shipping_charge,
 manufacturer,
 supplier
)

@@@
[oracle@station78 dwdir]$ ls
ctl_product.ctl  product.dat
[oracle@station78 dwdir]$ sqlldr hr/hr control=ctl_product.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 22 17:27:39 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Commit point reached - logical record count 4


@@@
@@@<5>check the result.
@@@
[oracle@station78 dwdir]$ cat ctl_product.log
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 22 17:27:39 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Control File:   ctl_product.ctl
Data File:      product.dat
  Bad File:     product.bad
  Discard File:  none specified
 
 (Allow all discards)

Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array:     64 rows, maximum of 256000 bytes
Continuation:    none specified
Path used:      Conventional

Table PRODUCT, loaded from every logical record.
Insert option in effect for this table: APPEND

   Column Name                  Position   Len  Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
PRODUCT_ID                          FIRST     *   ,  O(') CHARACTER           
PRODUCT_NAME                         NEXT     *   ,  O(') CHARACTER           
CATEGORY                             NEXT     *   ,  O(') CHARACTER           
COST_PRICE                           NEXT     *   ,  O(') CHARACTER           
WEIGHT                               NEXT     *   ,  O(') CHARACTER           
SHIPPING_CHARGE                      NEXT     *   ,  O(') CHARACTER           
MANUFACTURER                         NEXT     *   ,  O(') CHARACTER           
SUPPLIER                             NEXT     *   ,  O(') CHARACTER           


Table PRODUCT:
  4 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  0 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.


Space allocated for bind array:                 132096 bytes(64 rows)
Read   buffer bytes: 1048576

Total logical records skipped:          0
Total logical records read:             4
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Wed Aug 22 17:27:39 2012
Run ended on Wed Aug 22 17:27:39 2012

Elapsed time was:     00:00:00.04
CPU time was:         00:00:00.00


你可能感兴趣的:(oracle,sqlldr)