|
用图形界面,做控制文件模板。
日期的格式和字符集往往要改:
- LOAD DATA
- characterset ZHS16GBK
- INFILE 'ccb.dat'
- APPEND
- INTO TABLE HR.T_BANK_INVOICE
- trailing nullcols
- (
- ACCOUNT_NUMBER "4367421823250099999",
- SUB_NUMBER "00000",
- TRANSAC_DATE position(1:8) DATE(8) "YYYYMMDD" terminated by ',' ,
- TRANSAC_ADDRESS position(10) CHAR terminated by ',',
- TRANSAC_COMMENT CHAR TERMINATED BY whitespace,
- CURRENCY CHAR terminated by ',',
- IN_AMOUNT decimal EXTERNAL terminated by ',',
- OUT_AMOUNT decimal EXTERNAL terminated by ',',
- BALANCE decimal EXTERNAL terminated by ',',
- OPPOSITE_NUMBER terminated by ',',
- OPPOSITE_USERNAME terminated by ','
- )
复制代码- [oracle@station90 ~]$ sqlldr hr/oracle_4U control=ccb.ctl direct=true
复制代码- [oracle@station90 ~]$ ls -l ccb.*
- -rw-r--r-- 1 oracle oinstall 135 10月 18 21:12 ccb.bad
- -rw-r--r-- 1 oracle oinstall 611 10月 18 21:12 ccb.ctl
- -rwxr-xr-x 1 root root 324 10月 18 20:34 ccb.dat
- -rw-r--r-- 1 oracle oinstall 3042 10月 18 21:12 ccb.log
复制代码 ccb.log :
- SQL*Loader: Release 11.2.0.3.0 - Production on Thu Oct 18 21:12:25 2018
- Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
- Control File: ccb.ctl
- Character Set ZHS16GBK specified for all input.
- Data File: ccb.dat
- Bad File: ccb.bad
- Discard File: none specified
-
- (Allow all discards)
- Number to load: ALL
- Number to skip: 0
- Errors allowed: 50
- Continuation: none specified
- Path used: Direct
- Table HR.T_BANK_INVOICE, loaded from every logical record.
- Insert option in effect for this table: APPEND
- TRAILING NULLCOLS option in effect
- Column Name Position Len Term Encl Datatype
- ------------------------------ ---------- ----- ---- ---- ---------------------
- ACCOUNT_NUMBER FIRST 1 CHARACTER
- SQL string for column : "4367421823250099999"
- SUB_NUMBER NEXT 1 CHARACTER
- SQL string for column : "00000"
- TRANSAC_DATE 1:8 8 , DATE YYYYMMDD
- TRANSAC_ADDRESS 10 * , CHARACTER
- TRANSAC_COMMENT NEXT * WHT CHARACTER
- CURRENCY NEXT * , CHARACTER
- IN_AMOUNT NEXT * , CHARACTER
- OUT_AMOUNT NEXT * , CHARACTER
- BALANCE NEXT * , CHARACTER
- OPPOSITE_NUMBER NEXT * , CHARACTER
- OPPOSITE_USERNAME NEXT * , CHARACTER
- Record 1: Rejected - Error on table HR.T_BANK_INVOICE, column ACCOUNT_NUMBER.
- Multibyte character error.
- Record 2: Rejected - Error on table HR.T_BANK_INVOICE, column ACCOUNT_NUMBER.
- Multibyte character error.
- Record 3: Rejected - Error on table HR.T_BANK_INVOICE, column ACCOUNT_NUMBER.
- Multibyte character error.
- Record 4: Rejected - Error on table HR.T_BANK_INVOICE, column ACCOUNT_NUMBER.
- Multibyte character error.
- Record 9: Discarded - all columns null.
- Table HR.T_BANK_INVOICE:
- 4 Rows successfully loaded.
- 4 Rows not loaded due to data errors.
- 0 Rows not loaded because all WHEN clauses were failed.
- 1 Row not loaded because all fields were null.
- Date cache:
- Max Size: 1000
- Entries : 4
- Hits : 0
- Misses : 0
- Bind array size not used in direct path.
- Column array rows : 5000
- Stream buffer bytes: 256000
- Read buffer bytes: 1048576
- Total logical records skipped: 0
- Total logical records read: 9
- Total logical records rejected: 4
- Total logical records discarded: 1
- Total stream buffers loaded by SQL*Loader main thread: 1
- Total stream buffers loaded by SQL*Loader load thread: 0
- Run began on Thu Oct 18 21:12:25 2018
- Run ended on Thu Oct 18 21:12:26 2018
- Elapsed time was: 00:00:00.52
- CPU time was: 00:00:00.01
复制代码- [oracle@station90 dir1]$ sqlldr
- SQL*Loader: Release 11.2.0.3.0 - Production on Thu Oct 18 21:42:45 2018
- Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
- Usage: SQLLDR keyword=value [,keyword=value,...]
- Valid Keywords:
- userid -- ORACLE username/password
- control -- control file name
- log -- log file name
- bad -- bad file name
- data -- data file name
- discard -- discard file name
- discardmax -- number of discards to allow (Default all)
- skip -- number of logical records to skip (Default 0)
- load -- number of logical records to load (Default all)
- errors -- number of errors to allow (Default 50)
- rows -- number of rows in conventional path bind array or between direct path data saves
- (Default: Conventional path 64, Direct path all)
- bindsize -- size of conventional path bind array in bytes (Default 256000)
- silent -- suppress messages during run (header,feedback,errors,discards,partitions)
- direct -- use direct path (Default FALSE)
- parfile -- parameter file: name of file that contains parameter specifications
- parallel -- do parallel load (Default FALSE)
- file -- file to allocate extents from
- skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (Default FALSE)
- skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (Default FALSE)
- commit_discontinued -- commit loaded rows when load is discontinued (Default FALSE)
- readsize -- size of read buffer (Default 1048576)
- external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE (Default NOT_USED)
- columnarrayrows -- number of rows for direct path column array (Default 5000)
- streamsize -- size of direct path stream buffer in bytes (Default 256000)
- multithreading -- use multithreading in direct path
- resumable -- enable or disable resumable for current session (Default FALSE)
- resumable_name -- text string to help identify resumable statement
- resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
- date_cache -- size (in entries) of date conversion cache (Default 1000)
- no_index_errors -- abort load on any index errors (Default FALSE)
- PLEASE NOTE: Command-line parameters may be specified either by
- position or by keywords. An example of the former case is 'sqlldr
- scott/tiger foo'; an example of the latter is 'sqlldr control=foo
- userid=scott/tiger'. One may specify parameters by position before
- but not after parameters specified by keywords. For example,
- 'sqlldr scott/tiger control=foo logfile=log' is allowed, but
- 'sqlldr scott/tiger control=foo log' is not, even though the
- position of the parameter 'log' is correct.
- [oracle@station90 dir1]$
复制代码- sqlldr hr/oracle_4U control=tpasswd.ctl log=tpasswd.sql external_table=GENERATE_ONLY
复制代码
SYS:
- create directory dir1 as '/home/oracle/dir1';
- grant read,write on directory dir1 to hr;
复制代码- CREATE TABLE tpasswd
- (
- "I_USERNAME" VARCHAR2(30),
- "I_PASSWORD" CHAR(1),
- "I_UID" NUMBER(6),
- "I_GID" NUMBER(6),
- "I_COMMENT" VARCHAR2(40),
- "I_HOME" VARCHAR2(50),
- "I_SHELL" VARCHAR2(20)
- )
- ORGANIZATION external
- (
- TYPE oracle_loader
- DEFAULT DIRECTORY dir1
- ACCESS PARAMETERS
- (
- RECORDS DELIMITED BY NEWLINE CHARACTERSET AL32UTF8
- BADFILE 'passwd_%a_%p.bad'
- LOGFILE 'passwd_%a_%p.log'
- READSIZE 1048576
- FIELDS TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"' LDRTRIM
- MISSING FIELD VALUES ARE NULL
- REJECT ROWS WITH ALL NULL FIELDS
- (
- "I_USERNAME" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"',
- "I_PASSWORD" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"',
- "I_UID" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"',
- "I_GID" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"',
- "I_COMMENT" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"',
- "I_HOME" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"',
- "I_SHELL" CHAR(255)
- TERMINATED BY ":" OPTIONALLY ENCLOSED BY '"'
- )
- )
- location
- (
- 'passwd.dat'
- )
- )parallel REJECT LIMIT UNLIMITED;
复制代码
|
|