Presentation on theme: "Loading & organising data. Objectives Loading data using direct-load insert Loading data into oracle tables using SQL*Loader conventional and direct paths."— Presentation transcript:
Loading & organising data
Objectives Loading data using direct-load insert Loading data into oracle tables using SQL*Loader conventional and direct paths Reorganising data using export and import
Overview Other applications Oracle database Oracle Database SQL* Loader Export Import Direct loader
Using direct-Load inserts Insert /*+append */into emmajane.emp NOLOGGING Select * from scott.emp Note: you do not use ‘insert into values’ only ‘insert into select’ Can be used on non-partitioned and partitioned tables Maintains indexes and enforces constraints Allows concurrent modification of rows while insert occurring.
Parallel direct-load insert Alter session enable parallel DML; Must be executed at beginning of transaction INSERT /*+parallel(emmajane.emp2) */ INTO emmajane.emp NOLOGGING SELECT * FROM scott.emp;
SQL*Loader One or more input files can be used Several input records can be combined into one logical record for loading Input fields can be fixed or variable length Input data can be in any format – char, binary etc Data can be loaded from different types of media such as disk, tape or named pipes Data can be loaded into several tables in one run Options are available to replace or append to existing data in tables SQL functions can be applied on input data before row is stored in DB
SQL*loader files Control file Data files Parameter file Bad file Log file
SQL* loader methods Conventional Direct path
Direct vs. Conventional load Conventional loadDirect path load Uses Commits to make changes permanent Uses data saves Redo logs generatedRedo logs only generated under specific conditions Enforces all constraintsEnforces only PK, unique and NOT NULL constraints INSERT triggers fireTriggers not fired Can load into clustered tablesCan not load into clustered tables Other users can amend tablesOther users can not amend tables (locked)
SQL*loader input files Parameter files Load options Control file Data files Input records LOAD DATA APPEND INTO TABLE sales FIELDS TERMINATED BY "|" ( PROD_ID, CUST_ID, TIME_ID, CHANNEL_ID, PROMO_ID, QUANTITY_SOLD, AMOUNT_SOLD)
SQL*loader usage guidelines Use a parameter file to specify commonly used commands Place data within the control file only for small one-time loads Improve performance by Allocating sufficient space Sorting data on largest index Using different files for temporary segments in parallel loads
SQL*loader trouble shooting Insufficient space for table or index Instance failure during the load If the SORTED INDEXES clause is used and data is not in the order specified Duplicate keys found in unique index etc Errors or discards exceed specified limit.
Moving Data using EXP/IMP Data files O/S file Export Import
Uses of Import and Export Re-organise tables Move data owned by one user to another user Move data between DBs Development to production OLTP system to Data Warehouse Migrate to a different platform or release of oracle Repeat test runs during development or upgrade Perform logical backup.
Guidelines for Export and Import Use a parameter file to specify command line options Use CONSISTENT=Y only if exporting a small volume of data Do not use COMPRESS=Y if there are many deleted rows Improve performance by Allocating large buffer size Using direct path if using only or higher