You are html tracking Visitor

Saturday, August 9, 2008

Fixed record format

Fixed record format:-
-------------------------

Fixed Record Format would look like the below. In this case you give a specific position where the Control file can expect a data field.

1001 PHANI CLERK
1002 REDDY SALESMAN
1003 USER1 SALESMAN
1004 USER2 MANAGER
1005 USER3 SALESMAN
1006 USER4 MANAGER
1007 USER5 MANAGER
1008 USER6 ANALYST
1009 USER7 PRESIDENT
2010 USER8 SALESMAN
1011 USER9 CLERK

Structure of a Control file:

Sample CONTROL/CTL file for loading a Fixed record data file.

OPTIONS (SKIP = 2) --The first 2 rows will be skipped in data file.
LOAD DATA -- It’s kind of the BEGIN statement in CTL file.
INFILE '$FILE' -- Specify the data file path and name
APPEND -- Type of loading (INSERT, APPEND, REPLACE, TRUNCATE
INTO TABLE ‘Your Table Name’ -- the table to be loaded into
( COL1 POSITION(01:04) INTEGER EXTERNAL,
COL2 POSITION(06:10) CHAR,
COL3 POSITION(16:24) CHAR
)

OPTION statement precedes the LOAD DATA statement. The OPTIONS parameter allows you to specify runtime arguments in the control file, rather than on the command line. The following arguments can be specified using the OPTIONS parameter.

SKIP = n -- Number of logical records to skip (Default 0)

LOAD = n -- Number of logical records to load (Default all)

ERRORS = n -- Number of errors to allow (Default 50)

ROWS = n -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional Path 64, direct path all)

BINDSIZE = n -- Size of conventional path bind array in bytes (System-dependent default)

SILENT = {FEEDBACK | ERRORS | DISCARDS | ALL} -- Suppress messages during run (header, feedback, errors, discards, partitions, all)

DIRECT = {TRUE | FALSE} --Use direct path (Default FALSE)

PARALLEL = {TRUE | FALSE} -- Perform parallel load (Default FALSE)

LOAD DATA statement is required at the beginning of the control file.

INFILE: INFILE keyword is used to specify location and name of the data-file.

INFILE * specifies that the data is found in the control file and not in an external file. You will find the data in the same CONTROL file.

INFILE '$FILE', can be used to send the file path and filename as a parameter when registered as a concurrent program in the Oracle Application.

INFILE '/home/demo/phani/file01.txt' specifies the file-path and the filename.

TYPE OF LOADING:

INSERT -- If the table you are loading is empty, INSERT can be used.

APPEND -- If data already exists in the table, SQL*Loader appends the new rows to it. If data doesn't already exist, the new rows are simply loaded.

REPLACE -- All rows in the table are deleted and the new data is loaded

TRUNCATE -- SQL*Loader uses the SQL TRUNCATE command.

INTO TABLE is required to identify the table to be loaded.

Command to run the SQL*Loader:-

sqlldr USERID='User_name'/'Password' CONTROL='Your control filename' LOG='Log file name'

Example:- sqlldr USERID=scott/tiger CONTROL=aottest.ctl

1) You provide the Username and password to connect to the database.
2) Control file name should be given which you want to run. In the above Example aottest.ctl control file name.
3) Log file name can be given. So that when log file is create by the command would create with same name as given. But this is not the default parameter. If log name is not given then by default name would be given by the system.



PREVIOUS
                                    SQLLOADER-HOME                               NEXT

No comments: