If the tables you are loading into already contain data, you have three options:
APPEND
REPLACE
TRUNCATE
Warning: When the REPLACE or TRUNCATE keyword is specified, the entire table is replaced, not just individual rows. After the rows are successfully deleted, a commit is issued. You cannot recover the data that was in the table before the load, unless it was saved with Export or a comparable utility.
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. You must have SELECT privilege to use the APPEND option.
REPLACE:
All rows in the table are deleted and the new data is loaded. The table must be in your schema, or you must have DELETE privilege on the table. The row deletes cause any delete triggers defined on the table to fire. If DELETE CASCADE has been specified for the table, then the cascaded deletes are carried out, as well.
Updating Existing Rows:
The REPLACE method is a table replacement, not a replacement of individual rows. SQL*Loader does not update existing records, even if they have null columns. To update existing rows, use the following procedure:
- Load your data into a work table.
- Use the SQL language UPDATE statement with correlated subqueries.
- Drop the work table.
TRUNCATE:
Using this method, SQL*Loader uses the SQL TRUNCATE command to achieve the best possible performance. For the TRUNCATE command to operate, the table's referential integrity constraints must first be disabled. If they have not been disabled, SQL*Loader returns an error.
Once the integrity constraints have been disabled, DELETE CASCADE is no longer defined for the table. If the DELETE CASCADE functionality is needed, then the contents of the table must be manually deleted before the load begins.
The table must be in your schema, or you must have the DELETE ANY TABLE privilege.
Notes:
Unlike the SQL TRUNCATE option, this method re-uses a table's extents.
INSERT is SQL*Loader's default method. It requires the table to be empty before loading. SQL*Loader terminates with an error if the table contains rows.
Steps to Run a SQL loader:
- Open Command prompt.
- Then enter the Database details in the below mentioned format.
SQLLDR Database Username/Password@Database Name.
Eg: SQLLDR SYSADM/SYSADM&HRMS90DM
- Press enter.
- You will see
Control= (in the Next Line, Enter the Control file Path.)
Eg: Control=X:\appserv\prcs\HRMS90DM\files\Course_Catalog_Control.CTL (And
Enter)
- System takes the input from the file path mentioned in the control file and start loading the file with data accordingly.
Sample CTL (Control) File:
File name should be stored with the extension *.CTL.
LOAD DATA
INFILE 'X:\appserv\prcs\HRMS90DM\files\Course_Catalog.txt'
BADFILE 'X:\appserv\prcs\HRMS90DM\files\Course_Catalog.BAD'
DISCARDFILE 'X:\appserv\prcs\HRMS90DM\files\Course_Catalog.DIS'
APPEND
INTO TABLE PS_PMR_AD_CRS_CATL
fields terminated by "|"
TRAILING NULLCOLS
(
INSTITUTION,
ACAD_CAREER,
CU_SUBJECT,
CU_CATALOG_NUM,
EFFDT DATE,
EFF_STATUS,
CU_DESCR_CRSE,
CU_ACAD_GROUP,
CU_DEPT_ACAD,
CU_CRS_TYPE_CD,
CU_SCHEDULE_SEQ_NM,
CU_ACAD_LVL_CD,
CU_CREDIT,
CU_HOUR,
CU_EQ_CREDS,
CU_VR_CRED_INDC,
CU_LST_TERM_OFF,
CU_GRADE_MTH_CD,
CU_FIRST_TERM_OFFR,
CU_BHE_APPROVAL_DT,
CU_CREDT_ONLY_INDC,
CU_ATTND_REQ_CD,
CU_SPL_FEES,
CU_ROOM_REQ_CD,
CU_ESL_INDC,
CU_VAR_DESR_INDC,
CU_UPDAT_TIME,
CU_LIBERAL_ARTS_IN,
CU_REPEAT_ALLOW_IN,
CU_REQUISIT_OF_IND,
CU_REQUISITE_FLAG,
CU_BLCK_PRG_OFF_CD,
CU_SAT_LIB_ART,
CU_CPI_SUBJECT,
CU_CPI_UNIT,
CU_CPI_ELECTIVE,
CU_UP_LOW_CD,
CU_SPC_EFF_EXP_DTE,
CU_WAIT_LST_ALW_IN,
CU_PRE_REG_ALW_IND,
CU_BLK_BOARD_ALLOW,
CU_SCH_CLS_BLK_IND
)
URL’s you can refer:
The contents written above were taken from the following mentioned URLs.Please go through them for the details.