OracleDatabaseSqlload usageThe related knowledge is what we will introduce in this article. What is sqlload? After reading the example below, we will know. When using the Oracle database to process millions of data, it is better to choose sqlload. The following is an example of self-learning sqlload for beginners.
1. Where to run sqlload?
First, at least the oracle client program is installed on the computer. Here you can run sqlload and run --> cmd ---> sqlldr. There are many annotations for your reference.
2. Control File
Write the control file. ctl or. cvs required by sqlload.
Control. ctl content:
- LOAD DATA
- INFILE 'f:\TL_FUND_MMS_BATCH.txt'
- BADFILE 'f:\BAD_TL_FUND_MMS_BATCH1.dat'
- APPEND
- INTO TABLE tl_fund_mms_batch
- Fields terminated by ","
- Optionally enclosed by '"'
- trailing nullcols
- (
- NUMBATCHSEQID ,
- VC2BATCHNAME,
- VC2RESOURCEID,
- NUMCOUNTTOTAL ,
- NUMCOUNTSUCS,
- NUMCOUNTLONG ,
- NUMCOUNTFAILD ,
- VC2BILLPATH,
- NUMCREATEUSERID ,
- NUMSENDUSERID ,
- NUMDEALFLAG,
- DATCREATETIME DATE "YYYY-MM-DD HH24:MI:SS",
- DATSENDTIME DATE "YYYY-MM-DD HH24:MI:SS"
- )
3. Data Files
- TL_FUND_MMS_BATCH.txt content: 103, "Xiao test", "0111022109240241310006", 1, 1, 0, 0,
- "../Webapps/billFiles \ data (2). xml", 900000,900 000,-4-28 15:50:26, 15:50:26
4. execute commands
I put all the files on drive F:
Run the following command: sqlldr mjjzh/mjjzh @ orcl f: \ control. ctl log = f: \ log. log
5. View logs
After the command is executed, log information is generated in the specified directory. If an error occurs during the execution, a bad data file is generated in the corresponding directory, when an error occurs, the following message is printed: commit point-logical record count 1. Do not think that the execution is successful if this sentence is printed.
Log. log Content:
- SQL * Loader: Release 10.2.0.1.0-Production on Thursday May 12 17:01:38 2011
- Copyright (c) 1982,200 5, Oracle. All rights reserved.
- Control File: f: \ control. ctl
- Data File: f: \ TL_FUND_MMS_BATCH.txt
- Error file: f: \ BAD_TL_FUND_MMS_BATCH1.dat
- Obsolete file: Not specified
- (All records can be discarded)
- Number of objects to be loaded: ALL
- Number of to be skipped: 0
- Allowed error: 50
- Bound array: 64 rows, up to 256000 bytes
- Continue: Unspecified
- Path used: General
- Table TL_FUND_MMS_BATCH, loaded from each logical record
- The insert option takes effect for this table APPEND.
- The trailing nullcols option takes effect.
- Column name location length abort packaging Data Type
- --------------------------------------------------------------------------
- Numbatchseqid first *, O (") CHARACTER
- VC2BATCHNAME NEXT *, O (") CHARACTER
- VC2RESOURCEID NEXT *, O (") CHARACTER
- Numcounttotal next *, O (") CHARACTER
- Numcountsucs next *, O (") CHARACTER
- Numcountlong next *, O (") CHARACTER
- Numcountfaild next *, O (") CHARACTER
- VC2BILLPATH NEXT *, O (") CHARACTER
- Numcreateuserid next *, O (") CHARACTER
- Numsenduserid next *, O (") CHARACTER
- Numdealflag next *, O (") CHARACTER
- Datcreatetime next *, O (") DATE YYYY-MM-DD HH24: MI: SS
- Datsendtime next *, O (") DATE YYYY-MM-DD HH24: MI: SS
- Record 1: rejected-the table TL_FUND_MMS_BATCH has an error.
- ORA-00001: unique constraint (MJJZH. PK_TL_FUND_MMS_BATCH) violated
- Note: ORA-00001: unique constraint (MJJZH. PK_TL_FUND_MMS_BATCH) violated because the primary key is duplicated.
- Table TL_FUND_MMS_BATCH:
- 0 rows are loaded successfully.
- One row is not loaded due to data errors.
- Because all the WHEN clauses fail, the 0 rows are not loaded.
- Because all fields are empty, 0 rows are not loaded.
- Space allocated to the bound array: 214656 bytes (64 rows)
- Number of bytes read from the buffer: 1048576
- Total number of skipped logical records: 0
- Total number of logical records read: 1
- Total number of rejected logical records: 1
- Total number of discarded logical records: 0
- Starting from 17:01:38, January 1, 2011, Thursday
- The operation ended at 17:01:39, January 1, 2011, on Thursday.
- Elapsed time: 00: 00: 01.20
- CPU time: 00: 00: 00.06
6. Notes:
(1) DATE Format Conversion: The last two fields in the table are DATE format, here we need to do datcreatetime date "YYYY-MM-DD HH24: MI: SS", conversion, equivalent to to_date (). The data file format is 15:50:26, not "15:50:26. Otherwise, an error occurs. Later, during the test, we found that there would be no errors on the attaching, which is strange .)
② Insert the content in the database to include ": if the data file is" Xiao test ", Optionally enclosed by '" must be added to the control file, so that when inserting the database, the content does not contain "". The following is the effect of Optionally enclosed by '"and not.
This article introduces the usage of SQL load in Oracle databases!