SQL * load usage

Source: Internet
Author: User
Tags how to use sql

 

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 -- Supdivss 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 by default)

Skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (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 example of the former is 'sqlload scott/tiger foo ';

The latter example is 'sqlload control = foo userid = scott/tiger '.

The specified location parameter must be earlier than but cannot be later than the parameter specified by the keyword. For example,

'Sqlload SCott/tiger control = foo logfile = log ',

However, 'the sqlload scott/tiger control = foo log ',

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.

Related Article

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.