Quick tutorial on SQL * Loader

Source: Internet
Author: User
Tags how to use sql

Quick tutorial on SQL * Loader
Text/Fan Sheng
SQL * loader is a data loading tool for Oracle. It is usually used to migrate operating system files to Oracle databases. SQL * loader is large data
Repository selection method, because it provides the fastest way (direct, parallel ). Now, let's leave aside its theory and use instances to make
You can quickly learn how to use SQL * loader.
First, let's get to know SQL * loader.
In NT, the SQL * loader command is sqlldr, and in UNIX it is generally sqlldr/sqlload.
For example, run: D: \ oracle> sqlldr.
SQL * Loader: Release 8.1.6.0.0-production on Tuesday January 8 11:06:42 2002
(C) copyright 1999 Oracle Corporation. All rights reserved.

Usage: sqlload 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 (all default values)
Skip -- number of logical records to skip (0 by default)
Load -- number of logical records to load (all default values)
Errors -- number of errors to allow (50 by default)
Rows -- number of rows in conventional path bind array or between direct P
Ath data saves
(Default: general path 64, all direct paths)
Bindsize -- size of conventional path bind array in bytes (65536 by default)
Silent -- suppress messages during run (header, feedback, errors, discards, part
Itions)
Direct -- use direct path (default: false)
Parfile -- parameter file: name of file that contains parameter Specification
S
Parallel -- do parallel load (default: false)
File -- file to allocate extents from
Skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (
False)
Skip_index_maintenance -- do not maintain indexes, mark affected indexes as unus
Able (false by default)
Commit_discontinued -- commit loaded rows when load is discontinued (default value: false)
Readsize -- size of read buffer (1048576 by default)
Please note: the command line parameters can be specified by the location or keyword.
. The former example is 'sqlload
Scott/tiger Foo '; the latter example is 'sqlload control = foo
Userid = Scott/tiger '. The specified location parameter must be earlier
However, it cannot be later than the parameter specified by the keyword. For example,
'Sqlload Scott/tiger control = Foo logfile = log',
'Sqlload Scott/tiger control = Foo log' is not allowed, even if
The location of the 'log' parameter is correct.
D: \ oracle>
We can see some basic help information, here, I use the Chinese Win2000 adv server.
We know that SQL * loader can only import plain text, so we will start to explain its usage with instances.
Once the data source result.csv exists, it will be imported to the fancy user in Oracle.
Result.csv content:
1. Default web site, 192.168.2.254: 80:, running
2, other, 192.168.2.254: 80: test.com, stopped
3, third, 192.168.2.254: 81: thirdabc.com, running
We can see that the four columns are separated by commas as variable-length strings.
2. Create the control file Result. CTL.
Result. CTL content:
Load data
Infile 'result.csv'
Into Table resultxt
(Resultid char terminated ',',
Website char terminated ',',
Ipport char terminated ',',
Status char terminated by whitespace)
Note:
Infile index data source file here we omit the default discardfile result. DSC badfile result. Bad
Into Table resultxt is insert by default, or into Table resultxt append is the append method, or replace
Terminated by ',' is separated by commas
Terminated by whitespace is separated by Spaces
3. Execute loading:
D: \> sqlldr userid = fancy/testpass control = result. CTL log = resulthis. Out
SQL * Loader: Release 8.1.6.0.0-production on Tuesday January 8 10:25:42 2002
(C) copyright 1999 Oracle Corporation. All rights reserved.
SQL * loader-941: An error occurred while describing the resultxt table.
ORA-04043: the object resultxt does not exist
An error is prompted because the database does not have the corresponding table.
4. Create a table in the database
Create Table resultxt
(Resultid varchar2 (500 ),
Website varchar2 (500 ),
Ipport varchar2 (500 ),
Status varchar2 (500 ))
/
5. Reload
D: \> sqlldr userid = fancy/k1i7l6l8 control = result. CTL log = resulthis. Out
SQL * Loader: Release 8.1.6.0.0-production on Tuesday January 8 10:31:57 2002
(C) copyright 1999 Oracle Corporation. All rights reserved.
The submission point is reached, and the logical record count is 2
Reaching the submission point, the logical record count is 3
Successful! We can analyze the process through the log file: resulthis. out content is as follows:
SQL * Loader: Release 8.1.6.0.0-production on Tuesday January 8 10:31:57 2002
(C) copyright 1999 Oracle Corporation. All rights reserved.
Control File: result. CTL
Data File: result.csv
Error file: result. Bad
Obsolete file: Not specified
:
(All records can be discarded)
Quantity: All
Skipped count: 0
Allowed error: 50
Bound array: 64 rows, up to 65536 bytes
Continue: Unspecified
Path used: General
Table resultxt
Loaded from each logical record
The insert option takes effect for this table.
Column name location length abort packaging Data Type
--------------------------------------------------------------------------
Resultid first *, Character
Website next *, Character
Ipport next *, Character
Status next * WHT character

Table resultxt:
3 rows loaded successfully
Zero rows are 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 for the combined array: 65016 bytes (63 rows)
Memory space allocation except bound array: 0 bytes
Total number of skipped logical records: 0
Total number of logical records read: 3
Total number of rejected logical records: 0
Total number of discarded logical records: 0
Starting from 10:31:57, January 1, 2002, Tuesday
The operation ended at 10:32:00, January 1, January 08, 2002.
Elapsed time: 00: 00: 02.70
CPU time: 00: 00: 00.10 (optional
Vi. concurrent operations
Sqlldr userid =/control = result1.ctl direct = true parallel = true
Sqlldr userid =/control = result2.ctl direct = true parallel = true
Sqlldr userid =/control = result2.ctl direct = true parallel = true
When loading a large amount of data (about 10 Gb), it is best to suppress log generation:
SQL> ALTER TABLE resultxt nologging;
In this way, no redo log is generated, which can improve the efficiency. Add an unrecoverable line to load data in the control file.
This option must be applied together with direct.
During concurrent operations, Oracle claims to be able to process GB of data per hour! In fact, it is estimated that it will be good to reach 1-10 Gb, and the available structure will start.
The same file, but only a small amount of data, starts to load a large amount of data after success, this can avoid the waste of time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.