Database Utilities
Database Utilities
Database Utilities
Database Utilities
E85946-02
Copyright © 1996, 2018, Oracle and/or its affiliates. All rights reserved.
Contributors: Lee Barton, George Claborn, Steve DiPirro, Dean Gagne, John Kalogeropoulos, Joydip Kundu,
Rod Payne, Ray Pfau, Rich Phillips, Mike Sakayeda, Marilyn Saunders, Jim Stenoish, Roy Swonger, Randy
Urbano, William Wright, Hui-ling Yu
This software and related documentation are provided under a license agreement containing restrictions on
use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your
license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify,
license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means.
Reverse engineering, disassembly, or decompilation of this software, unless required by law for
interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If
you find any errors, please report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on
behalf of the U.S. Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,
any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are
"commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-
specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the
programs, including any operating system, integrated software, any programs installed on the hardware,
and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.
No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management applications.
It is not developed or intended for use in any inherently dangerous applications, including applications that
may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you
shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its
safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this
software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of
their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are
used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron,
the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro
Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content, products,
and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly
disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise
set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be
responsible for any loss, costs, or damages incurred due to your access to or use of third-party content,
products, or services, except as set forth in an applicable agreement between you and Oracle.
Contents
Preface
Audience xliii
Documentation Accessibility xliii
Related Documentation xliv
Syntax Diagrams xliv
Conventions xliv
iii
1.5.6 Loading and Unloading of Data 1-14
1.6 Monitoring Job Status 1-14
1.6.1 Monitoring the Progress of Executing Jobs 1-15
1.7 File Allocation 1-16
1.7.1 Specifying Files and Adding Additional Dump Files 1-17
1.7.2 Default Locations for Dump, Log, and SQL Files 1-17
1.7.2.1 Oracle RAC Considerations 1-19
1.7.2.2 Using Directory Objects When Oracle Automatic Storage
Management Is Enabled 1-19
1.7.2.3 The DATA_PUMP_DIR Directory Object and Pluggable
Databases 1-20
1.7.3 Using Substitution Variables 1-20
1.8 Exporting and Importing Between Different Database Releases 1-21
1.9 SecureFiles LOB Considerations 1-23
1.10 Data Pump Exit Codes 1-23
1.11 Auditing Data Pump Jobs 1-24
1.12 How Does Data Pump Handle Timestamp Data? 1-25
1.12.1 TIMESTAMP WITH TIME ZONE Restrictions 1-25
1.12.1.1 Time Zone File Versions on the Source and Target 1-26
1.12.1.2 Data Pump Support for TIMESTAMP WITH TIME ZONE Data 1-26
1.12.2 TIMESTAMP WITH LOCAL TIME ZONE Restrictions 1-27
1.13 Character Set and Globalization Support Considerations 1-27
1.13.1 Data Definition Language (DDL) 1-28
1.13.2 Single-Byte Character Sets and Export and Import 1-28
1.13.3 Multibyte Character Sets and Export and Import 1-28
1.14 Oracle Data Pump Behavior with Data-Bound Collation 1-29
iv
2.4 Parameters Available in Export's Command-Line Mode 2-10
2.4.1 ABORT_STEP 2-13
2.4.2 ACCESS_METHOD 2-14
2.4.3 ATTACH 2-14
2.4.4 CLUSTER 2-15
2.4.5 COMPRESSION 2-16
2.4.6 COMPRESSION_ALGORITHM 2-17
2.4.7 CONTENT 2-18
2.4.8 DATA_OPTIONS 2-19
2.4.9 DIRECTORY 2-20
2.4.10 DUMPFILE 2-21
2.4.11 ENCRYPTION 2-23
2.4.12 ENCRYPTION_ALGORITHM 2-25
2.4.13 ENCRYPTION_MODE 2-25
2.4.14 ENCRYPTION_PASSWORD 2-26
2.4.15 ENCRYPTION_PWD_PROMPT 2-28
2.4.16 ESTIMATE 2-29
2.4.17 ESTIMATE_ONLY 2-30
2.4.18 EXCLUDE 2-31
2.4.19 FILESIZE 2-33
2.4.20 FLASHBACK_SCN 2-33
2.4.21 FLASHBACK_TIME 2-34
2.4.22 FULL 2-35
2.4.23 HELP 2-37
2.4.24 INCLUDE 2-37
2.4.25 JOB_NAME 2-39
2.4.26 KEEP_MASTER 2-39
2.4.27 LOGFILE 2-40
2.4.28 LOGTIME 2-41
2.4.29 METRICS 2-42
2.4.30 NETWORK_LINK 2-43
2.4.31 NOLOGFILE 2-44
2.4.32 PARALLEL 2-45
2.4.33 PARFILE 2-46
2.4.34 QUERY 2-47
2.4.35 REMAP_DATA 2-49
2.4.36 REUSE_DUMPFILES 2-50
2.4.37 SAMPLE 2-51
2.4.38 SCHEMAS 2-51
2.4.39 SERVICE_NAME 2-52
2.4.40 SOURCE_EDITION 2-53
v
2.4.41 STATUS 2-54
2.4.42 TABLES 2-54
2.4.43 TABLESPACES 2-57
2.4.44 TRANSPORT_FULL_CHECK 2-58
2.4.45 TRANSPORT_TABLESPACES 2-58
2.4.46 TRANSPORTABLE 2-60
2.4.47 VERSION 2-62
2.4.48 VIEWS_AS_TABLES 2-63
2.5 Commands Available in Export's Interactive-Command Mode 2-65
2.5.1 ADD_FILE 2-66
2.5.2 CONTINUE_CLIENT 2-66
2.5.3 EXIT_CLIENT 2-67
2.5.4 FILESIZE 2-67
2.5.5 HELP 2-67
2.5.6 KILL_JOB 2-68
2.5.7 PARALLEL 2-68
2.5.8 START_JOB 2-69
2.5.9 STATUS 2-69
2.5.10 STOP_JOB 2-70
2.6 Examples of Using Data Pump Export 2-70
2.6.1 Performing a Table-Mode Export 2-71
2.6.2 Data-Only Unload of Selected Tables and Rows 2-71
2.6.3 Estimating Disk Space Needed in a Table-Mode Export 2-71
2.6.4 Performing a Schema-Mode Export 2-72
2.6.5 Performing a Parallel Full Database Export 2-72
2.6.6 Using Interactive Mode to Stop and Reattach to a Job 2-72
2.7 Syntax Diagrams for Data Pump Export 2-73
vi
3.3.1 Data Filters 3-8
3.3.2 Metadata Filters 3-9
3.4 Parameters Available in Import's Command-Line Mode 3-9
3.4.1 ABORT_STEP 3-13
3.4.2 ACCESS_METHOD 3-14
3.4.3 ATTACH 3-15
3.4.4 CLUSTER 3-16
3.4.5 CONTENT 3-17
3.4.6 DATA_OPTIONS 3-17
3.4.7 DIRECTORY 3-19
3.4.8 DUMPFILE 3-20
3.4.9 ENCRYPTION_PASSWORD 3-21
3.4.10 ENCRYPTION_PWD_PROMPT 3-23
3.4.11 ESTIMATE 3-23
3.4.12 EXCLUDE 3-24
3.4.13 FLASHBACK_SCN 3-26
3.4.14 FLASHBACK_TIME 3-27
3.4.15 FULL 3-28
3.4.16 HELP 3-29
3.4.17 INCLUDE 3-30
3.4.18 JOB_NAME 3-31
3.4.19 KEEP_MASTER 3-32
3.4.20 LOGFILE 3-32
3.4.21 LOGTIME 3-33
3.4.22 MASTER_ONLY 3-34
3.4.23 METRICS 3-34
3.4.24 NETWORK_LINK 3-35
3.4.25 NOLOGFILE 3-37
3.4.26 PARALLEL 3-37
3.4.27 PARFILE 3-39
3.4.28 PARTITION_OPTIONS 3-40
3.4.29 QUERY 3-41
3.4.30 REMAP_DATA 3-43
3.4.31 REMAP_DATAFILE 3-44
3.4.32 REMAP_DIRECTORY 3-45
3.4.33 REMAP_SCHEMA 3-46
3.4.34 REMAP_TABLE 3-48
3.4.35 REMAP_TABLESPACE 3-48
3.4.36 REUSE_DATAFILES 3-49
3.4.37 SCHEMAS 3-50
3.4.38 SERVICE_NAME 3-51
vii
3.4.39 SKIP_UNUSABLE_INDEXES 3-52
3.4.40 SOURCE_EDITION 3-53
3.4.41 SQLFILE 3-54
3.4.42 STATUS 3-55
3.4.43 STREAMS_CONFIGURATION 3-55
3.4.44 TABLE_EXISTS_ACTION 3-56
3.4.45 TABLES 3-57
3.4.46 TABLESPACES 3-59
3.4.47 TARGET_EDITION 3-60
3.4.48 TRANSFORM 3-61
3.4.49 TRANSPORT_DATAFILES 3-65
3.4.50 TRANSPORT_FULL_CHECK 3-67
3.4.51 TRANSPORT_TABLESPACES 3-68
3.4.52 TRANSPORTABLE 3-70
3.4.53 VERSION 3-72
3.4.54 VIEWS_AS_TABLES (Network Import) 3-73
3.4.55 VIEWS_AS_TABLES (Non-Network Import) 3-75
3.5 Commands Available in Import's Interactive-Command Mode 3-76
3.5.1 CONTINUE_CLIENT 3-77
3.5.2 EXIT_CLIENT 3-77
3.5.3 HELP 3-77
3.5.4 KILL_JOB 3-78
3.5.5 PARALLEL 3-78
3.5.6 START_JOB 3-79
3.5.7 STATUS 3-79
3.5.8 STOP_JOB 3-80
3.6 Examples of Using Data Pump Import 3-80
3.6.1 Performing a Data-Only Table-Mode Import 3-80
3.6.2 Performing a Schema-Mode Import 3-81
3.6.3 Performing a Network-Mode Import 3-81
3.7 Syntax Diagrams for Data Pump Import 3-81
viii
4.3.3 Exit Status 4-12
Part II SQL*Loader
7 SQL*Loader Concepts
7.1 SQL*Loader Features 7-1
7.2 SQL*Loader Parameters 7-3
7.3 SQL*Loader Control File 7-3
7.4 Input Data and Data Files 7-4
7.4.1 Fixed Record Format 7-4
7.4.2 Variable Record Format 7-5
7.4.3 Stream Record Format 7-6
7.4.4 Logical Records 7-7
7.4.5 Data Fields 7-8
7.5 LOBFILEs and Secondary Data Files (SDFs) 7-8
7.6 Data Conversion and Data Type Specification 7-9
7.7 Discarded and Rejected Records 7-9
7.7.1 The Bad File 7-10
7.7.1.1 Records Rejected by SQL*Loader 7-10
7.7.1.2 Records Rejected by Oracle Database During a SQL*Loader
Operation 7-10
7.7.2 The Discard File 7-10
7.8 Log File and Logging Information 7-11
ix
7.9 Conventional Path Loads, Direct Path Loads, and External Table Loads 7-11
7.9.1 Conventional Path Loads 7-12
7.9.2 Direct Path Loads 7-12
7.9.2.1 Parallel Direct Path 7-12
7.9.3 External Table Loads 7-13
7.9.4 Choosing External Tables Versus SQL*Loader 7-13
7.9.5 Behavior Differences Between SQL*Loader and External Tables 7-14
7.9.5.1 Multiple Primary Input Data Files 7-14
7.9.5.2 Syntax and Data Types 7-14
7.9.5.3 Byte-Order Marks 7-15
7.9.5.4 Default Character Sets, Date Masks, and Decimal Separator 7-15
7.9.5.5 Use of the Backslash Escape Character 7-15
7.10 Loading Objects, Collections, and LOBs 7-15
7.10.1 Supported Object Types 7-16
7.10.1.1 column objects 7-16
7.10.1.2 row objects 7-16
7.10.2 Supported Collection Types 7-16
7.10.2.1 Nested Tables 7-17
7.10.2.2 VARRAYs 7-17
7.10.3 Supported LOB Data Types 7-17
7.11 Partitioned Object Support 7-17
7.12 Application Development: Direct Path Load API 7-18
7.13 SQL*Loader Case Studies 7-18
7.13.1 Case Study Files 7-19
7.13.2 Running the Case Studies 7-20
7.13.3 Case Study Log Files 7-20
7.13.4 Checking the Results of a Case Study 7-21
x
8.2.7 DEFAULTS 8-10
8.2.8 DEGREE_OF_PARALLELISM 8-11
8.2.9 DIRECT 8-12
8.2.10 DIRECT_PATH_LOCK_WAIT 8-12
8.2.11 DISCARD 8-13
8.2.12 DISCARDMAX 8-14
8.2.13 DNFS_ENABLE 8-14
8.2.14 DNFS_READBUFFERS 8-15
8.2.15 EMPTY_LOBS_ARE_NULL 8-16
8.2.16 ERRORS 8-17
8.2.17 EXTERNAL_TABLE 8-17
8.2.18 FILE 8-19
8.2.19 HELP 8-20
8.2.20 LOAD 8-20
8.2.21 LOG 8-20
8.2.22 MULTITHREADING 8-21
8.2.23 NO_INDEX_ERRORS 8-22
8.2.24 PARALLEL 8-22
8.2.25 PARFILE 8-23
8.2.26 PARTITION_MEMORY 8-23
8.2.27 READSIZE 8-24
8.2.28 RESUMABLE 8-25
8.2.29 RESUMABLE_NAME 8-25
8.2.30 RESUMABLE_TIMEOUT 8-26
8.2.31 ROWS 8-26
8.2.32 SDF_PREFIX 8-27
8.2.33 SILENT 8-28
8.2.34 SKIP 8-29
8.2.35 SKIP_INDEX_MAINTENANCE 8-30
8.2.36 SKIP_UNUSABLE_INDEXES 8-30
8.2.37 STREAMSIZE 8-31
8.2.38 TRIM 8-32
8.2.39 USERID 8-33
8.3 Exit Codes for Inspection and Display 8-34
xi
9.2.2 Specifying the Number of Default Expressions to Be Evaluated At One
Time 9-5
9.3 Specifying File Names and Object Names 9-5
9.3.1 File Names That Conflict with SQL and SQL*Loader Reserved Words 9-6
9.3.2 Specifying SQL Strings 9-6
9.3.3 Operating System Considerations 9-6
9.3.3.1 Specifying a Complete Path 9-7
9.3.3.2 Backslash Escape Character 9-7
9.3.3.3 Nonportable Strings 9-7
9.3.3.4 Using the Backslash as an Escape Character 9-7
9.3.3.5 Escape Character Is Sometimes Disallowed 9-8
9.4 Identifying XMLType Tables 9-8
9.5 Specifying Field Order 9-9
9.6 Specifying Data Files 9-10
9.6.1 Examples of INFILE Syntax 9-11
9.6.2 Specifying Multiple Data Files 9-12
9.7 Specifying CSV Format Files 9-12
9.8 Identifying Data in the Control File with BEGINDATA 9-13
9.9 Specifying Data File Format and Buffering 9-14
9.10 Specifying the Bad File 9-14
9.10.1 Examples of Specifying a Bad File Name 9-15
9.10.2 How Bad Files Are Handled with LOBFILEs and SDFs 9-16
9.10.3 Criteria for Rejected Records 9-16
9.11 Specifying the Discard File 9-17
9.11.1 Specifying the Discard File in the Control File 9-18
9.11.1.1 Limiting the Number of Discard Records 9-18
9.11.2 Examples of Specifying a Discard File Name 9-18
9.11.3 Criteria for Discarded Records 9-19
9.11.4 How Discard Files Are Handled with LOBFILEs and SDFs 9-19
9.11.5 Specifying the Discard File from the Command Line 9-19
9.12 Specifying a NULLIF Clause At the Table Level 9-19
9.13 Specifying Datetime Formats At the Table Level 9-20
9.14 Handling Different Character Encoding Schemes 9-21
9.14.1 Multibyte (Asian) Character Sets 9-21
9.14.2 Unicode Character Sets 9-21
9.14.3 Database Character Sets 9-22
9.14.4 Data File Character Sets 9-22
9.14.5 Input Character Conversion 9-23
9.14.5.1 Considerations When Loading Data into VARRAYs or Primary-
Key-Based REFs 9-24
9.14.5.2 CHARACTERSET Parameter 9-24
9.14.5.3 Control File Character Set 9-25
xii
9.14.5.4 Character-Length Semantics 9-26
9.14.6 Shift-sensitive Character Data 9-27
9.15 Interrupted Loads 9-28
9.15.1 Discontinued Conventional Path Loads 9-28
9.15.2 Discontinued Direct Path Loads 9-29
9.15.2.1 Load Discontinued Because of Space Errors 9-29
9.15.2.2 Load Discontinued Because Maximum Number of Errors
Exceeded 9-30
9.15.2.3 Load Discontinued Because of Fatal Errors 9-30
9.15.2.4 Load Discontinued Because a Ctrl+C Was Issued 9-30
9.15.3 Status of Tables and Indexes After an Interrupted Load 9-30
9.15.4 Using the Log File to Determine Load Status 9-30
9.15.5 Continuing Single-Table Loads 9-30
9.16 Assembling Logical Records from Physical Records 9-31
9.16.1 Using CONCATENATE to Assemble Logical Records 9-31
9.16.2 Using CONTINUEIF to Assemble Logical Records 9-32
9.17 Loading Logical Records into Tables 9-35
9.17.1 Specifying Table Names 9-36
9.17.1.1 INTO TABLE Clause 9-36
9.17.2 Table-Specific Loading Method 9-37
9.17.2.1 Loading Data into Empty Tables 9-37
9.17.2.2 Loading Data into Nonempty Tables 9-37
9.17.3 Table-Specific OPTIONS Parameter 9-39
9.17.4 Loading Records Based on a Condition 9-39
9.17.4.1 Using the WHEN Clause with LOBFILEs and SDFs 9-40
9.17.5 Specifying Default Data Delimiters 9-40
9.17.5.1 fields_spec 9-40
9.17.5.2 termination_spec 9-41
9.17.5.3 enclosure_spec 9-41
9.17.6 Handling Short Records with Missing Data 9-41
9.17.6.1 TRAILING NULLCOLS Clause 9-42
9.18 Index Options 9-42
9.18.1 SORTED INDEXES Clause 9-43
9.18.2 SINGLEROW Option 9-43
9.19 Benefits of Using Multiple INTO TABLE Clauses 9-43
9.19.1 Extracting Multiple Logical Records 9-44
9.19.1.1 Relative Positioning Based on Delimiters 9-45
9.19.2 Distinguishing Different Input Record Formats 9-45
9.19.2.1 Relative Positioning Based on the POSITION Parameter 9-46
9.19.3 Distinguishing Different Input Row Object Subtypes 9-46
9.19.4 Loading Data into Multiple Tables 9-48
xiii
9.19.5 Summary of Using Multiple INTO TABLE Clauses 9-48
9.20 Bind Arrays and Conventional Path Loads 9-48
9.20.1 Size Requirements for Bind Arrays 9-49
9.20.2 Performance Implications of Bind Arrays 9-49
9.20.3 Specifying Number of Rows Versus Size of Bind Array 9-49
9.20.4 Calculations to Determine Bind Array Size 9-50
9.20.4.1 Determining the Size of the Length Indicator 9-51
9.20.4.2 Calculating the Size of Field Buffers 9-52
9.20.5 Minimizing Memory Requirements for Bind Arrays 9-53
9.20.6 Calculating Bind Array Size for Multiple INTO TABLE Clauses 9-53
xiv
10.4.2.7 VARCHARC 10-20
10.4.2.8 VARRAWC 10-20
10.4.2.9 Conflicting Native Data Type Field Lengths 10-20
10.4.2.10 Field Lengths for Length-Value Data Types 10-21
10.4.3 Data Type Conversions 10-21
10.4.4 Data Type Conversions for Datetime and Interval Data Types 10-22
10.4.5 Specifying Delimiters 10-23
10.4.5.1 Syntax for Termination and Enclosure Specification 10-23
10.4.5.2 Delimiter Marks in the Data 10-25
10.4.5.3 Maximum Length of Delimited Data 10-25
10.4.5.4 Loading Trailing Blanks with Delimiters 10-25
10.4.6 How Delimited Data Is Processed 10-26
10.4.6.1 Fields Using Only TERMINATED BY 10-26
10.4.6.2 Fields Using ENCLOSED BY Without TERMINATED BY 10-26
10.4.6.3 Fields Using ENCLOSED BY With TERMINATED BY 10-27
10.4.6.4 Fields Using OPTIONALLY ENCLOSED BY With TERMINATED
BY 10-27
10.4.7 Conflicting Field Lengths for Character Data Types 10-28
10.4.7.1 Predetermined Size Fields 10-29
10.4.7.2 Delimited Fields 10-29
10.4.7.3 Date Field Masks 10-29
10.5 Specifying Field Conditions 10-30
10.5.1 Comparing Fields to BLANKS 10-31
10.5.2 Comparing Fields to Literals 10-32
10.6 Using the WHEN, NULLIF, and DEFAULTIF Clauses 10-32
10.7 Examples of Using the WHEN, NULLIF, and DEFAULTIF Clauses 10-34
10.8 Loading Data Across Different Platforms 10-36
10.9 Byte Ordering 10-36
10.9.1 Specifying Byte Order 10-38
10.9.2 Using Byte Order Marks (BOMs) 10-38
10.9.2.1 Suppressing Checks for BOMs 10-40
10.10 Loading All-Blank Fields 10-41
10.11 Trimming Whitespace 10-41
10.11.1 Data Types for Which Whitespace Can Be Trimmed 10-43
10.11.2 Specifying Field Length for Data Types for Which Whitespace Can Be
Trimmed 10-44
10.11.2.1 Predetermined Size Fields 10-44
10.11.2.2 Delimited Fields 10-44
10.11.3 Relative Positioning of Fields 10-45
10.11.3.1 No Start Position Specified for a Field 10-45
10.11.3.2 Previous Field Terminated by a Delimiter 10-45
10.11.3.3 Previous Field Has Both Enclosure and Termination Delimiters 10-46
xv
10.11.4 Leading Whitespace 10-46
10.11.4.1 Previous Field Terminated by Whitespace 10-46
10.11.4.2 Optional Enclosure Delimiters 10-47
10.11.5 Trimming Trailing Whitespace 10-47
10.11.6 Trimming Enclosed Fields 10-47
10.12 How the PRESERVE BLANKS Option Affects Whitespace Trimming 10-48
10.13 How [NO] PRESERVE BLANKS Works with Delimiter Clauses 10-48
10.14 Applying SQL Operators to Fields 10-49
10.14.1 Referencing Fields 10-51
10.14.2 Common Uses of SQL Operators in Field Specifications 10-52
10.14.3 Combinations of SQL Operators 10-53
10.14.4 Using SQL Strings with a Date Mask 10-53
10.14.5 Interpreting Formatted Fields 10-53
10.14.6 Using SQL Strings to Load the ANYDATA Database Type 10-54
10.15 Using SQL*Loader to Generate Data for Input 10-54
10.15.1 Loading Data Without Files 10-55
10.15.2 Setting a Column to a Constant Value 10-55
10.15.2.1 CONSTANT Parameter 10-55
10.15.3 Setting a Column to an Expression Value 10-56
10.15.3.1 EXPRESSION Parameter 10-56
10.15.4 Setting a Column to the Data File Record Number 10-56
10.15.4.1 RECNUM Parameter 10-56
10.15.5 Setting a Column to the Current Date 10-57
10.15.5.1 SYSDATE Parameter 10-57
10.15.6 Setting a Column to a Unique Sequence Number 10-57
10.15.6.1 SEQUENCE Parameter 10-57
10.15.7 Generating Sequence Numbers for Multiple Tables 10-58
10.15.7.1 Example: Generating Different Sequence Numbers for Each
Insert 10-58
xvi
11.2.1 Loading Object Tables with a Subtype 11-12
11.3 Loading REF Columns 11-13
11.3.1 Specifying Table Names in a REF Clause 11-13
11.3.2 System-Generated OID REF Columns 11-14
11.3.3 Primary Key REF Columns 11-15
11.3.4 Unscoped REF Columns That Allow Primary Keys 11-15
11.4 Loading LOBs 11-16
11.4.1 Loading LOB Data from a Primary Data File 11-17
11.4.1.1 LOB Data in Predetermined Size Fields 11-18
11.4.1.2 LOB Data in Delimited Fields 11-18
11.4.1.3 LOB Data in Length-Value Pair Fields 11-20
11.4.2 Loading LOB Data from LOBFILEs 11-21
11.4.2.1 Dynamic Versus Static LOBFILE Specifications 11-22
11.4.2.2 Examples of Loading LOB Data from LOBFILEs 11-22
11.4.2.3 Considerations When Loading LOBs from LOBFILEs 11-26
11.4.3 Loading Data Files that Contain LLS Fields 11-26
11.5 Loading BFILE Columns 11-28
11.6 Loading Collections (Nested Tables and VARRAYs) 11-29
11.6.1 Restrictions in Nested Tables and VARRAYs 11-29
11.6.2 Secondary Data Files (SDFs) 11-31
11.7 Dynamic Versus Static SDF Specifications 11-32
11.8 Loading a Parent Table Separately from Its Child Table 11-32
11.8.1 Memory Issues When Loading VARRAY Columns 11-33
xvii
12.3.10 Loading into Synonyms 12-7
12.4 Using Direct Path Load 12-8
12.4.1 Setting Up for Direct Path Loads 12-8
12.4.2 Specifying a Direct Path Load 12-8
12.4.3 Building Indexes 12-8
12.4.3.1 Improving Performance 12-9
12.4.3.2 Temporary Segment Storage Requirements 12-9
12.4.4 Indexes Left in an Unusable State 12-10
12.4.5 Using Data Saves to Protect Against Data Loss 12-10
12.4.5.1 Using the ROWS Parameter 12-11
12.4.5.2 Data Save Versus Commit 12-11
12.4.6 Data Recovery During Direct Path Loads 12-11
12.4.6.1 Media Recovery and Direct Path Loads 12-12
12.4.6.2 Instance Recovery and Direct Path Loads 12-12
12.4.7 Loading Long Data Fields 12-12
12.4.7.1 Loading Data As PIECED 12-13
12.4.8 Auditing SQL*Loader Operations That Use Direct Path Mode 12-13
12.5 Optimizing Performance of Direct Path Loads 12-14
12.5.1 Preallocating Storage for Faster Loading 12-14
12.5.2 Presorting Data for Faster Indexing 12-15
12.5.2.1 SORTED INDEXES Clause 12-15
12.5.2.2 Unsorted Data 12-15
12.5.2.3 Multiple-Column Indexes 12-16
12.5.2.4 Choosing the Best Sort Order 12-16
12.5.3 Infrequent Data Saves 12-16
12.5.4 Minimizing Use of the Redo Log 12-17
12.5.4.1 Disabling Archiving 12-17
12.5.4.2 Specifying the SQL*Loader UNRECOVERABLE Clause 12-17
12.5.4.3 Setting the SQL NOLOGGING Parameter 12-18
12.5.5 Specifying the Number of Column Array Rows and Size of Stream
Buffers 12-18
12.5.6 Specifying a Value for the Date Cache 12-19
12.6 Optimizing Direct Path Loads on Multiple-CPU Systems 12-20
12.7 Avoiding Index Maintenance 12-21
12.8 Direct Path Loads, Integrity Constraints, and Triggers 12-21
12.8.1 Integrity Constraints 12-22
12.8.1.1 Enabled Constraints 12-22
12.8.1.2 Disabled Constraints 12-22
12.8.1.3 Reenable Constraints 12-23
12.8.2 Database Insert Triggers 12-24
12.8.2.1 Replacing Insert Triggers with Integrity Constraints 12-24
xviii
12.8.2.2 When Automatic Constraints Cannot Be Used 12-24
12.8.2.3 Preparation 12-24
12.8.2.4 Using an Update Trigger 12-25
12.8.2.5 Duplicating the Effects of Exception Conditions 12-25
12.8.2.6 Using a Stored Procedure 12-25
12.8.3 Permanently Disabled Triggers and Constraints 12-26
12.8.4 Increasing Performance with Concurrent Conventional Path Loads 12-26
12.9 Parallel Data Loading Models 12-26
12.9.1 Concurrent Conventional Path Loads 12-27
12.9.2 Intersegment Concurrency with Direct Path 12-27
12.9.3 Intrasegment Concurrency with Direct Path 12-27
12.9.4 Restrictions on Parallel Direct Path Loads 12-28
12.9.5 Initiating Multiple SQL*Loader Sessions 12-28
12.9.6 Parameters for Parallel Direct Path Loads 12-29
12.9.6.1 Using the FILE Parameter to Specify Temporary Segments 12-29
12.9.7 Enabling Constraints After a Parallel Direct Path Load 12-30
12.9.8 PRIMARY KEY and UNIQUE KEY Constraints 12-30
12.10 General Performance Improvement Hints 12-30
13 SQL*Loader Express
13.1 What is SQL*Loader Express Mode? 13-1
13.2 Using SQL*Loader Express Mode 13-1
13.2.1 Default Values Used by SQL*Loader Express Mode 13-2
13.2.1.1 How SQL*Loader Express Mode Handles Byte Order 13-3
13.3 SQL*Loader Express Mode Parameter Reference 13-4
13.3.1 BAD 13-5
13.3.2 CHARACTERSET 13-6
13.3.3 CSV 13-7
13.3.4 DATA 13-7
13.3.5 DATE_FORMAT 13-9
13.3.6 DEGREE_OF_PARALLELISM 13-9
13.3.7 DIRECT 13-10
13.3.8 DNFS_ENABLE 13-11
13.3.9 DNFS_READBUFFERS 13-12
13.3.10 ENCLOSED_BY 13-12
13.3.11 EXTERNAL_TABLE 13-13
13.3.12 FIELD_NAMES 13-14
13.3.13 LOAD 13-15
13.3.14 NULLIF 13-16
13.3.15 OPTIONALLY_ENCLOSED_BY 13-16
xix
13.3.16 PARFILE 13-17
13.3.17 SILENT 13-17
13.3.18 TABLE 13-18
13.3.19 TERMINATED_BY 13-19
13.3.20 TIMESTAMP_FORMAT 13-19
13.3.21 TRIM 13-20
13.3.22 USERID 13-21
13.4 SQL*Loader Express Mode Syntax Diagrams 13-21
xx
15.2.18 FIELD NAMES 15-18
15.2.19 READSIZE 15-19
15.2.20 DISABLE_DIRECTORY_LINK_CHECK 15-19
15.2.21 DATE_CACHE 15-20
15.2.22 string 15-20
15.2.23 condition_spec 15-21
15.2.24 [directory object name:] [filename] 15-21
15.2.25 condition 15-22
15.2.25.1 range start : range end 15-22
15.2.26 IO_OPTIONS clause 15-23
15.2.27 DNFS_DISABLE | DNFS_ENABLE 15-23
15.2.28 DNFS_READBUFFERS 15-24
15.3 field_definitions Clause 15-24
15.3.1 delim_spec 15-28
15.3.1.1 Example: External Table with Terminating Delimiters 15-30
15.3.1.2 Example: External Table with Enclosure and Terminator
Delimiters 15-30
15.3.1.3 Example: External Table with Optional Enclosure Delimiters 15-30
15.3.2 trim_spec 15-31
15.3.3 MISSING FIELD VALUES ARE NULL 15-32
15.3.4 field_list 15-32
15.3.5 pos_spec Clause 15-33
15.3.5.1 start 15-34
15.3.5.2 * 15-34
15.3.5.3 increment 15-34
15.3.5.4 end 15-34
15.3.5.5 length 15-34
15.3.6 datatype_spec Clause 15-35
15.3.6.1 [UNSIGNED] INTEGER [EXTERNAL] [(len)] 15-37
15.3.6.2 DECIMAL [EXTERNAL] and ZONED [EXTERNAL] 15-37
15.3.6.3 ORACLE_DATE 15-38
15.3.6.4 ORACLE_NUMBER 15-38
15.3.6.5 Floating-Point Numbers 15-38
15.3.6.6 DOUBLE 15-38
15.3.6.7 FLOAT [EXTERNAL] 15-38
15.3.6.8 BINARY_DOUBLE 15-39
15.3.6.9 BINARY_FLOAT 15-39
15.3.6.10 RAW 15-39
15.3.6.11 CHAR 15-39
15.3.6.12 date_format_spec 15-40
15.3.6.13 VARCHAR and VARRAW 15-42
xxi
15.3.6.14 VARCHARC and VARRAWC 15-43
15.3.7 init_spec Clause 15-43
15.3.8 LLS Clause 15-44
15.4 column_transforms Clause 15-45
15.4.1 transform 15-45
15.4.1.1 column_name FROM 15-46
15.4.1.2 NULL 15-46
15.4.1.3 CONSTANT 15-46
15.4.1.4 CONCAT 15-47
15.4.1.5 LOBFILE 15-47
15.4.1.6 lobfile_attr_list 15-47
15.4.1.7 STARTOF source_field (length) 15-48
15.5 Parallel Loading Considerations for the ORACLE_LOADER Access Driver 15-49
15.6 Performance Hints When Using the ORACLE_LOADER Access Driver 15-49
15.7 Restrictions When Using the ORACLE_LOADER Access Driver 15-50
15.8 Reserved Words for the ORACLE_LOADER Access Driver 15-51
xxii
17 ORACLE_HDFS and ORACLE_HIVE Access Drivers
17.1 Syntax Rules for Specifying Properties 17-1
17.2 ORACLE_HDFS Access Parameters 17-2
17.2.1 Default Parameter Settings for ORACLE_HDFS 17-2
17.2.2 Optional Parameter Settings for ORACLE_HDFS 17-3
17.3 ORACLE_HIVE Access Parameters 17-3
17.3.1 Default Parameter Settings for ORACLE_HIVE 17-4
17.3.2 Optional Parameter Settings for ORACLE_HIVE 17-4
17.4 Descriptions of com.oracle.bigdata Parameters 17-4
17.4.1 com.oracle.bigdata.colmap 17-5
17.4.2 com.oracle.bigdata.datamode 17-6
17.4.3 com.oracle.bigdata.erroropt 17-7
17.4.4 com.oracle.bigdata.fields 17-8
17.4.5 com.oracle.bigdata.fileformat 17-10
17.4.6 com.oracle.bigdata.log.exec 17-11
17.4.7 com.oracle.bigdata.log.qc 17-12
17.4.8 com.oracle.bigdata.overflow 17-12
17.4.9 com.oracle.bigdata.rowformat 17-13
17.4.10 com.oracle.bigdata.tablename 17-15
xxiii
19.3.2 Getting Help 19-5
19.3.3 Using ADRCI in Batch Mode 19-6
19.4 Setting the ADRCI Homepath Before Using ADRCI Commands 19-7
19.5 Viewing the Alert Log 19-8
19.6 Finding Trace Files 19-9
19.7 Viewing Incidents 19-10
19.8 Packaging Incidents 19-11
19.8.1 About Packaging Incidents 19-11
19.8.2 Creating Incident Packages 19-12
19.8.2.1 Creating a Logical Incident Package 19-13
19.8.2.2 Adding Diagnostic Information to a Logical Incident Package 19-14
19.8.2.3 Generating a Physical Incident Package 19-15
19.9 ADRCI Command Reference 19-15
19.9.1 CREATE REPORT 19-18
19.9.2 ECHO 19-18
19.9.3 EXIT 19-19
19.9.4 HOST 19-19
19.9.5 IPS 19-19
19.9.5.1 Using the <ADR_HOME> and <ADR_BASE> Variables in IPS
Commands 19-21
19.9.5.2 IPS ADD 19-21
19.9.5.3 IPS ADD FILE 19-23
19.9.5.4 IPS ADD NEW INCIDENTS 19-24
19.9.5.5 IPS COPY IN FILE 19-24
19.9.5.6 IPS COPY OUT FILE 19-25
19.9.5.7 IPS CREATE PACKAGE 19-25
19.9.5.8 IPS DELETE PACKAGE 19-28
19.9.5.9 IPS FINALIZE 19-28
19.9.5.10 IPS GENERATE PACKAGE 19-28
19.9.5.11 IPS GET MANIFEST 19-29
19.9.5.12 IPS GET METADATA 19-29
19.9.5.13 IPS PACK 19-30
19.9.5.14 IPS REMOVE 19-32
19.9.5.15 IPS REMOVE FILE 19-33
19.9.5.16 IPS SET CONFIGURATION 19-34
19.9.5.17 IPS SHOW CONFIGURATION 19-34
19.9.5.18 IPS SHOW FILES 19-37
19.9.5.19 IPS SHOW INCIDENTS 19-38
19.9.5.20 IPS SHOW PACKAGE 19-39
19.9.5.21 IPS UNPACK FILE 19-39
19.9.6 PURGE 19-39
xxiv
19.9.7 QUIT 19-41
19.9.8 RUN 19-41
19.9.9 SELECT 19-41
19.9.9.1 AVG 19-44
19.9.9.2 CONCAT 19-45
19.9.9.3 COUNT 19-45
19.9.9.4 DECODE 19-46
19.9.9.5 LENGTH 19-46
19.9.9.6 MAX 19-47
19.9.9.7 MIN 19-47
19.9.9.8 NVL 19-47
19.9.9.9 REGEXP_LIKE 19-48
19.9.9.10 SUBSTR 19-48
19.9.9.11 SUM 19-49
19.9.9.12 TIMESTAMP_TO_CHAR 19-49
19.9.9.13 TOLOWER 19-50
19.9.9.14 TOUPPER 19-50
19.9.10 SET BASE 19-51
19.9.11 SET BROWSER 19-51
19.9.12 SET CONTROL 19-52
19.9.13 SET ECHO 19-52
19.9.14 SET EDITOR 19-53
19.9.15 SET HOMEPATH 19-53
19.9.16 SET TERMOUT 19-54
19.9.17 SHOW ALERT 19-54
19.9.18 SHOW BASE 19-57
19.9.19 SHOW CONTROL 19-57
19.9.20 SHOW HM_RUN 19-58
19.9.21 SHOW HOMEPATH 19-59
19.9.22 SHOW HOMES 19-60
19.9.23 SHOW INCDIR 19-60
19.9.24 SHOW INCIDENT 19-61
19.9.25 SHOW LOG 19-65
19.9.26 SHOW PROBLEM 19-66
19.9.27 SHOW REPORT 19-67
19.9.28 SHOW TRACEFILE 19-68
19.9.29 SPOOL 19-69
19.10 Troubleshooting ADRCI 19-70
xxv
20 DBVERIFY: Offline Database Verification Utility
20.1 Using DBVERIFY to Validate Disk Blocks of a Single Data File 20-1
20.1.1 DBVERIFY Syntax When Validating Blocks of a Single File 20-2
20.1.2 DBVERIFY Parameters When Validating Blocks of a Single File 20-2
20.1.3 Sample DBVERIFY Output For a Single Data File 20-3
20.2 Using DBVERIFY to Validate a Segment 20-4
20.2.1 DBVERIFY Syntax When Validating a Segment 20-4
20.2.2 DBVERIFY Parameters When Validating a Single Segment 20-4
20.2.3 Sample DBVERIFY Output For a Validated Segment 20-5
21 DBNEWID Utility
21.1 What Is the DBNEWID Utility? 21-1
21.2 Ramifications of Changing the DBID and DBNAME 21-1
21.2.1 Considerations for Global Database Names 21-2
21.3 DBNEWID Considerations for CDBs and PDBs 21-2
21.4 Changing the DBID and DBNAME of a Database 21-3
21.4.1 Changing the DBID and Database Name 21-3
21.4.2 Changing Only the Database ID 21-5
21.4.3 Changing Only the Database Name 21-6
21.4.4 Troubleshooting DBNEWID 21-7
21.5 DBNEWID Syntax 21-8
21.5.1 DBNEWID Parameters 21-9
21.5.2 Restrictions and Usage Notes 21-10
21.5.3 Additional Restrictions for Releases Earlier Than Oracle Database 10g 21-10
xxvi
22.4.1.1 Using the Online Catalog 22-10
22.4.1.2 Extracting a LogMiner Dictionary to the Redo Log Files 22-10
22.4.1.3 Extracting the LogMiner Dictionary to a Flat File 22-11
22.4.2 Redo Log File Options 22-12
22.5 Starting LogMiner 22-13
22.6 Querying V$LOGMNR_CONTENTS for Redo Data of Interest 22-14
22.6.1 How the V$LOGMNR_CONTENTS View Is Populated 22-16
22.6.2 Querying V$LOGMNR_CONTENTS Based on Column Values 22-17
22.6.2.1 The Meaning of NULL Values Returned by the MINE_VALUE
Function 22-18
22.6.2.2 Usage Rules for the MINE_VALUE and COLUMN_PRESENT
Functions 22-18
22.6.2.3 Restrictions When Using the MINE_VALUE Function To Get an
NCHAR Value 22-19
22.6.3 Querying V$LOGMNR_CONTENTS Based on XMLType Columns and
Tables 22-19
22.6.3.1 Restrictions When Using LogMiner With XMLType Data 22-21
22.6.3.2 Example of a PL/SQL Procedure for Assembling XMLType Data 22-21
22.7 Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS 22-24
22.7.1 Showing Only Committed Transactions 22-24
22.7.2 Skipping Redo Corruptions 22-26
22.7.3 Filtering Data by Time 22-27
22.7.4 Filtering Data by SCN 22-28
22.7.5 Formatting Reconstructed SQL Statements for Re-execution 22-28
22.7.6 Formatting the Appearance of Returned Data for Readability 22-29
22.8 Reapplying DDL Statements Returned to V$LOGMNR_CONTENTS 22-30
22.9 Calling DBMS_LOGMNR.START_LOGMNR Multiple Times 22-30
22.10 Supplemental Logging 22-31
22.10.1 Database-Level Supplemental Logging 22-32
22.10.1.1 Minimal Supplemental Logging 22-32
22.10.1.2 Database-Level Identification Key Logging 22-33
22.10.1.3 Procedural Supplemental Logging 22-34
22.10.2 Disabling Database-Level Supplemental Logging 22-34
22.10.3 Table-Level Supplemental Logging 22-35
22.10.3.1 Table-Level Identification Key Logging 22-35
22.10.3.2 Table-Level User-Defined Supplemental Log Groups 22-36
22.10.3.3 Usage Notes for User-Defined Supplemental Log Groups 22-37
22.10.4 Tracking DDL Statements in the LogMiner Dictionary 22-37
22.10.5 DDL_DICT_TRACKING and Supplemental Logging Settings 22-38
22.10.6 DDL_DICT_TRACKING and Specified Time or SCN Ranges 22-39
22.11 Accessing LogMiner Operational Information in Views 22-40
22.11.1 Querying V$LOGMNR_LOGS 22-41
xxvii
22.11.2 Querying Views for Supplemental Logging Settings 22-42
22.12 Steps in a Typical LogMiner Session 22-43
22.12.1 Typical LogMiner Session Task 1: Enable Supplemental Logging 22-44
22.12.2 Typical LogMiner Session Task 2: Extract a LogMiner Dictionary 22-45
22.12.3 Typical LogMiner Session Task 3: Specify Redo Log Files for
Analysis 22-45
22.12.4 Typical LogMiner Session Task 4: Start LogMiner 22-46
22.12.5 Typical LogMiner Session Task 5: Query V$LOGMNR_CONTENTS 22-47
22.12.6 Typical LogMiner Session Task 6: End the LogMiner Session 22-47
22.13 Examples Using LogMiner 22-47
22.13.1 Examples of Mining by Explicitly Specifying the Redo Log Files of
Interest 22-48
22.13.1.1 Example 1: Finding All Modifications in the Last Archived Redo
Log File 22-48
22.13.1.2 Example 2: Grouping DML Statements into Committed
Transactions 22-51
22.13.1.3 Example 3: Formatting the Reconstructed SQL 22-52
22.13.1.4 Example 4: Using the LogMiner Dictionary in the Redo Log
Files 22-55
22.13.1.5 Example 5: Tracking DDL Statements in the Internal Dictionary 22-62
22.13.1.6 Example 6: Filtering Output by Time Range 22-65
22.13.2 Examples of Mining Without Specifying the List of Redo Log Files
Explicitly 22-67
22.13.2.1 Example 1: Mining Redo Log Files in a Given Time Range 22-68
22.13.2.2 Example 2: Mining the Redo Log Files in a Given SCN Range 22-70
22.13.2.3 Example 3: Using Continuous Mining to Include Future Values
in a Query 22-71
22.13.3 Example Scenarios 22-72
22.13.3.1 Scenario 1: Using LogMiner to Track Changes Made by a
Specific User 22-72
22.13.3.2 Scenario 2: Using LogMiner to Calculate Table Access
Statistics 22-73
22.14 Supported Data Types, Storage Attributes, and Database and Redo Log
File Versions 22-74
22.14.1 Supported Data Types and Table Storage Attributes 22-74
22.14.1.1 Compatibility Requirements 22-76
22.14.2 Unsupported Data Types and Table Storage Attributes 22-77
22.14.3 Supported Databases and Redo Log File Versions 22-77
22.14.4 SecureFiles LOB Considerations 22-77
xxviii
23.3 Using the DBMS_METADATA API to Retrieve an Object's Metadata 23-4
23.3.1 Typical Steps Used for Basic Metadata Retrieval 23-4
23.3.2 Retrieving Multiple Objects 23-6
23.3.3 Placing Conditions on Transforms 23-7
23.3.4 Accessing Specific Metadata Attributes 23-9
23.4 Using the DBMS_METADATA API to Re-Create a Retrieved Object 23-12
23.5 Using the DBMS_METADATA API to Retrieve Collections of Different Object
Types 23-14
23.5.1 Filtering the Return of Heterogeneous Object Types 23-15
23.6 Using the DBMS_METADATA_DIFF API to Compare Object Metadata 23-16
23.7 Performance Tips for the Programmatic Interface of the DBMS_METADATA
API 23-25
23.8 Example Usage of the DBMS_METADATA API 23-25
23.8.1 What Does the DBMS_METADATA Example Do? 23-26
23.8.2 Output Generated from the GET_PAYROLL_TABLES Procedure 23-28
23.9 Summary of DBMS_METADATA Procedures 23-30
23.10 Summary of DBMS_METADATA_DIFF Procedures 23-32
24 Original Export
24.1 What is the Export Utility? 24-2
24.2 Before Using Export 24-2
24.2.1 Running catexp.sql or catalog.sql 24-2
24.2.2 Ensuring Sufficient Disk Space for Export Operations 24-3
24.2.3 Verifying Access Privileges for Export and Import Operations 24-3
24.3 Invoking Export 24-3
24.3.1 Invoking Export as SYSDBA 24-4
24.3.2 Command-Line Entries 24-4
24.3.3 Parameter Files 24-4
24.3.4 Interactive Mode 24-5
24.3.4.1 Restrictions When Using Export's Interactive Method 24-5
24.3.5 Getting Online Help 24-6
24.4 Export Modes 24-6
24.4.1 Table-Level and Partition-Level Export 24-9
24.4.1.1 Table-Level Export 24-9
24.4.1.2 Partition-Level Export 24-9
24.5 Export Parameters 24-9
24.5.1 BUFFER 24-10
24.5.1.1 Example: Calculating Buffer Size 24-11
24.5.2 COMPRESS 24-11
24.5.3 CONSISTENT 24-12
24.5.4 CONSTRAINTS 24-13
xxix
24.5.5 DIRECT 24-13
24.5.6 FEEDBACK 24-13
24.5.7 FILE 24-14
24.5.8 FILESIZE 24-14
24.5.9 FLASHBACK_SCN 24-15
24.5.10 FLASHBACK_TIME 24-15
24.5.11 FULL 24-16
24.5.11.1 Points to Consider for Full Database Exports and Imports 24-16
24.5.12 GRANTS 24-17
24.5.13 HELP 24-17
24.5.14 INDEXES 24-17
24.5.15 LOG 24-17
24.5.16 OBJECT_CONSISTENT 24-17
24.5.17 OWNER 24-18
24.5.18 PARFILE 24-18
24.5.19 QUERY 24-18
24.5.19.1 Restrictions When Using the QUERY Parameter 24-19
24.5.20 RECORDLENGTH 24-19
24.5.21 RESUMABLE 24-20
24.5.22 RESUMABLE_NAME 24-20
24.5.23 RESUMABLE_TIMEOUT 24-20
24.5.24 ROWS 24-20
24.5.25 STATISTICS 24-21
24.5.26 TABLES 24-21
24.5.26.1 Table Name Restrictions 24-22
24.5.27 TABLESPACES 24-23
24.5.28 TRANSPORT_TABLESPACE 24-23
24.5.29 TRIGGERS 24-23
24.5.30 TTS_FULL_CHECK 24-24
24.5.31 USERID (username/password) 24-24
24.5.32 VOLSIZE 24-24
24.6 Example Export Sessions 24-24
24.6.1 Example Export Session in Full Database Mode 24-25
24.6.2 Example Export Session in User Mode 24-25
24.6.3 Example Export Sessions in Table Mode 24-26
24.6.3.1 Example 1: DBA Exporting Tables for Two Users 24-26
24.6.3.2 Example 2: User Exports Tables That He Owns 24-27
24.6.3.3 Example 3: Using Pattern Matching to Export Various Tables 24-27
24.6.4 Example Export Session Using Partition-Level Export 24-28
24.6.4.1 Example 1: Exporting a Table Without Specifying a Partition 24-28
24.6.4.2 Example 2: Exporting a Table with a Specified Partition 24-29
xxx
24.6.4.3 Example 3: Exporting a Composite Partition 24-29
24.7 Warning, Error, and Completion Messages 24-30
24.7.1 Log File 24-30
24.7.2 Warning Messages 24-30
24.7.3 Nonrecoverable Error Messages 24-31
24.7.4 Completion Messages 24-31
24.8 Exit Codes for Inspection and Display 24-31
24.9 Conventional Path Export Versus Direct Path Export 24-32
24.10 Invoking a Direct Path Export 24-32
24.10.1 Security Considerations for Direct Path Exports 24-32
24.10.2 Performance Considerations for Direct Path Exports 24-33
24.10.3 Restrictions for Direct Path Exports 24-33
24.11 Network Considerations 24-33
24.11.1 Transporting Export Files Across a Network 24-34
24.11.2 Exporting with Oracle Net 24-34
24.12 Character Set and Globalization Support Considerations 24-34
24.12.1 User Data 24-34
24.12.1.1 Effect of Character Set Sorting Order on Conversions 24-35
24.12.2 Data Definition Language (DDL) 24-35
24.12.3 Single-Byte Character Sets and Export and Import 24-36
24.12.4 Multibyte Character Sets and Export and Import 24-36
24.13 Using Instance Affinity with Export and Import 24-36
24.14 Considerations When Exporting Database Objects 24-36
24.14.1 Exporting Sequences 24-37
24.14.2 Exporting LONG and LOB Data Types 24-37
24.14.3 Exporting Foreign Function Libraries 24-37
24.14.4 Exporting Offline Locally Managed Tablespaces 24-38
24.14.5 Exporting Directory Aliases 24-38
24.14.6 Exporting BFILE Columns and Attributes 24-38
24.14.7 Exporting External Tables 24-38
24.14.8 Exporting Object Type Definitions 24-38
24.14.9 Exporting Nested Tables 24-39
24.14.10 Exporting Advanced Queue (AQ) Tables 24-39
24.14.11 Exporting Synonyms 24-39
24.14.12 Possible Export Errors Related to Java Synonyms 24-39
24.14.13 Support for Fine-Grained Access Control 24-40
24.15 Transportable Tablespaces 24-40
24.16 Exporting From a Read-Only Database 24-41
24.17 Using Export and Import to Partition a Database Migration 24-41
24.17.1 Advantages of Partitioning a Migration 24-41
24.17.2 Disadvantages of Partitioning a Migration 24-41
xxxi
24.17.3 How to Use Export and Import to Partition a Database Migration 24-42
24.18 Using Different Releases of Export and Import 24-42
24.18.1 Restrictions When Using Different Releases of Export and Import 24-42
24.18.2 Examples of Using Different Releases of Export and Import 24-43
25 Original Import
25.1 What Is the Import Utility? 25-2
25.1.1 Table Objects: Order of Import 25-2
25.2 Before Using Import 25-2
25.2.1 Running catexp.sql or catalog.sql 25-2
25.2.2 Verifying Access Privileges for Import Operations 25-3
25.2.2.1 Importing Objects Into Your Own Schema 25-3
25.2.2.2 Importing Grants 25-4
25.2.2.3 Importing Objects Into Other Schemas 25-4
25.2.2.4 Importing System Objects 25-4
25.2.3 Processing Restrictions 25-5
25.3 Importing into Existing Tables 25-5
25.3.1 Manually Creating Tables Before Importing Data 25-5
25.3.2 Disabling Referential Constraints 25-6
25.3.3 Manually Ordering the Import 25-6
25.4 Effect of Schema and Database Triggers on Import Operations 25-7
25.5 Invoking Import 25-7
25.5.1 Command-Line Entries 25-8
25.5.2 Parameter Files 25-8
25.5.3 Interactive Mode 25-9
25.5.4 Invoking Import As SYSDBA 25-9
25.5.5 Getting Online Help 25-9
25.6 Import Modes 25-9
25.7 Import Parameters 25-13
25.7.1 BUFFER 25-14
25.7.2 COMMIT 25-14
25.7.3 COMPILE 25-15
25.7.4 CONSTRAINTS 25-15
25.7.5 DATA_ONLY 25-15
25.7.6 DATAFILES 25-15
25.7.7 DESTROY 25-16
25.7.8 FEEDBACK 25-16
25.7.9 FILE 25-16
25.7.10 FILESIZE 25-17
25.7.11 FROMUSER 25-17
xxxii
25.7.12 FULL 25-18
25.7.12.1 Points to Consider for Full Database Exports and Imports 25-18
25.7.13 GRANTS 25-19
25.7.14 HELP 25-19
25.7.15 IGNORE 25-19
25.7.16 INDEXES 25-20
25.7.17 INDEXFILE 25-20
25.7.18 LOG 25-21
25.7.19 PARFILE 25-21
25.7.20 RECORDLENGTH 25-21
25.7.21 RESUMABLE 25-21
25.7.22 RESUMABLE_NAME 25-21
25.7.23 RESUMABLE_TIMEOUT 25-22
25.7.24 ROWS 25-22
25.7.25 SHOW 25-22
25.7.26 SKIP_UNUSABLE_INDEXES 25-22
25.7.27 STATISTICS 25-23
25.7.28 STREAMS_CONFIGURATION 25-24
25.7.29 STREAMS_INSTANTIATION 25-24
25.7.30 TABLES 25-24
25.7.30.1 Table Name Restrictions 25-25
25.7.31 TABLESPACES 25-26
25.7.32 TOID_NOVALIDATE 25-27
25.7.33 TOUSER 25-27
25.7.34 TRANSPORT_TABLESPACE 25-28
25.7.35 TTS_OWNERS 25-28
25.7.36 USERID (username/password) 25-29
25.7.37 VOLSIZE 25-29
25.8 Example Import Sessions 25-29
25.8.1 Example Import of Selected Tables for a Specific User 25-29
25.8.2 Example Import of Tables Exported by Another User 25-30
25.8.3 Example Import of Tables from One User to Another 25-30
25.8.4 Example Import Session Using Partition-Level Import 25-31
25.8.4.1 Example 1: A Partition-Level Import 25-31
25.8.4.2 Example 2: A Partition-Level Import of a Composite Partitioned
Table 25-32
25.8.4.3 Example 3: Repartitioning a Table on a Different Column 25-33
25.8.5 Example Import Using Pattern Matching to Import Various Tables 25-34
25.9 Exit Codes for Inspection and Display 25-35
25.10 Error Handling During an Import 25-36
25.10.1 Row Errors 25-36
xxxiii
25.10.1.1 Failed Integrity Constraints 25-36
25.10.1.2 Invalid Data 25-36
25.10.2 Errors Importing Database Objects 25-37
25.10.2.1 Object Already Exists 25-37
25.10.2.2 Sequences 25-37
25.10.2.3 Resource Errors 25-37
25.10.2.4 Domain Index Metadata 25-38
25.11 Table-Level and Partition-Level Import 25-38
25.11.1 Guidelines for Using Table-Level Import 25-38
25.11.2 Guidelines for Using Partition-Level Import 25-38
25.11.3 Migrating Data Across Partitions and Tables 25-39
25.12 Controlling Index Creation and Maintenance 25-40
25.12.1 Delaying Index Creation 25-40
25.12.2 Index Creation and Maintenance Controls 25-40
25.12.2.1 Example of Postponing Index Maintenance 25-40
25.13 Network Considerations 25-41
25.14 Character Set and Globalization Support Considerations 25-41
25.14.1 User Data 25-42
25.14.1.1 Effect of Character Set Sorting Order on Conversions 25-42
25.14.2 Data Definition Language (DDL) 25-42
25.14.3 Single-Byte Character Sets 25-43
25.14.4 Multibyte Character Sets 25-43
25.15 Using Instance Affinity 25-43
25.16 Considerations When Importing Database Objects 25-44
25.16.1 Importing Object Identifiers 25-44
25.16.2 Importing Existing Object Tables and Tables That Contain Object
Types 25-45
25.16.3 Importing Nested Tables 25-46
25.16.4 Importing REF Data 25-46
25.16.5 Importing BFILE Columns and Directory Aliases 25-47
25.16.6 Importing Foreign Function Libraries 25-47
25.16.7 Importing Stored Procedures, Functions, and Packages 25-47
25.16.8 Importing Java Objects 25-48
25.16.9 Importing External Tables 25-48
25.16.10 Importing Advanced Queue (AQ) Tables 25-48
25.16.11 Importing LONG Columns 25-48
25.16.12 Importing LOB Columns When Triggers Are Present 25-49
25.16.13 Importing Views 25-49
25.16.14 Importing Partitioned Tables 25-50
25.17 Support for Fine-Grained Access Control 25-50
25.18 Snapshots and Snapshot Logs 25-50
xxxiv
25.18.1 Snapshot Log 25-50
25.18.2 Snapshots 25-51
25.18.2.1 Importing a Snapshot 25-51
25.18.2.2 Importing a Snapshot into a Different Schema 25-51
25.19 Transportable Tablespaces 25-51
25.20 Storage Parameters 25-52
25.20.1 The OPTIMAL Parameter 25-53
25.20.2 Storage Parameters for OID Indexes and LOB Columns 25-53
25.20.3 Overriding Storage Parameters 25-53
25.21 Read-Only Tablespaces 25-53
25.22 Dropping a Tablespace 25-53
25.23 Reorganizing Tablespaces 25-54
25.24 Importing Statistics 25-54
25.25 Using Export and Import to Partition a Database Migration 25-55
25.25.1 Advantages of Partitioning a Migration 25-55
25.25.2 Disadvantages of Partitioning a Migration 25-55
25.25.3 How to Use Export and Import to Partition a Database Migration 25-56
25.26 Tuning Considerations for Import Operations 25-56
25.26.1 Changing System-Level Options 25-56
25.26.2 Changing Initialization Parameters 25-57
25.26.3 Changing Import Options 25-57
25.26.4 Dealing with Large Amounts of LOB Data 25-57
25.26.5 Dealing with Large Amounts of LONG Data 25-58
25.27 Using Different Releases of Export and Import 25-58
25.27.1 Restrictions When Using Different Releases of Export and Import 25-58
25.27.2 Examples of Using Different Releases of Export and Import 25-59
Part V Appendixes
xxxv
B.7 Uninstalling Instant Client B-7
Index
xxxvi
List of Examples
2-1 Performing a Table-Mode Export 2-71
2-2 Data-Only Unload of Selected Tables and Rows 2-71
2-3 Estimating Disk Space Needed in a Table-Mode Export 2-72
2-4 Performing a Schema Mode Export 2-72
2-5 Parallel Full Export 2-72
2-6 Stopping and Reattaching to a Job 2-73
3-1 Performing a Data-Only Table-Mode Import 3-81
3-2 Performing a Schema-Mode Import 3-81
3-3 Network-Mode Import of Schemas 3-81
6-1 Performing a Simple Schema Export 6-5
6-2 Importing a Dump File and Remapping All Schema Objects 6-7
6-3 Using Exception Handling During a Simple Schema Export 6-8
6-4 Displaying Dump File Information 6-11
7-1 Loading Data in Fixed Record Format 7-5
7-2 Loading Data in Variable Record Format 7-6
7-3 Loading Data in Stream Record Format 7-7
9-1 Sample Control File 9-3
9-2 Identifying XMLType Tables in the SQL*Loader Control File 9-8
9-3 CONTINUEIF THIS Without the PRESERVE Parameter 9-34
9-4 CONTINUEIF THIS with the PRESERVE Parameter 9-34
9-5 CONTINUEIF NEXT Without the PRESERVE Parameter 9-34
9-6 CONTINUEIF NEXT with the PRESERVE Parameter 9-35
10-1 Field List Section of Sample Control File 10-2
10-2 DEFAULTIF Clause Is Not Evaluated 10-34
10-3 DEFAULTIF Clause Is Evaluated 10-35
10-4 DEFAULTIF Clause Specifies a Position 10-35
10-5 DEFAULTIF Clause Specifies a Field Name 10-35
11-1 Loading Column Objects in Stream Record Format 11-2
11-2 Loading Column Objects in Variable Record Format 11-3
11-3 Loading Nested Column Objects 11-3
11-4 Loading Column Objects with a Subtype 11-4
11-5 Specifying Attribute Nulls Using the NULLIF Clause 11-5
11-6 Loading Data Using Filler Fields 11-6
11-7 Loading a Column Object with Constructors That Match 11-7
11-8 Loading a Column Object with Constructors That Do Not Match 11-8
xxxvii
11-9 Using SQL to Load Column Objects When Constructors Do Not Match 11-9
11-10 Loading an Object Table with Primary Key OIDs 11-10
11-11 Loading OIDs 11-11
11-12 Loading an Object Table with a Subtype 11-12
11-13 Loading System-Generated REF Columns 11-14
11-14 Loading Primary Key REF Columns 11-15
11-15 Loading LOB Data in Predetermined Size Fields 11-18
11-16 Loading LOB Data in Delimited Fields 11-19
11-17 Loading LOB Data in Length-Value Pair Fields 11-20
11-18 Loading LOB DATA with One LOB per LOBFILE 11-22
11-19 Loading LOB Data Using Predetermined Size LOBs 11-23
11-20 Loading LOB Data Using Delimited LOBs 11-24
11-21 Loading LOB Data Using Length-Value Pair Specified LOBs 11-25
11-22 Example Specification of an LLS Clause 11-27
11-23 Loading Data Using BFILEs: Only File Name Specified Dynamically 11-28
11-24 Loading Data Using BFILEs: File Name and Directory Specified Dynamically 11-28
11-25 Loading a VARRAY and a Nested Table 11-30
11-26 Loading a Parent Table with User-Provided SIDs 11-32
11-27 Loading a Child Table with User-Provided SIDs 11-33
12-1 Setting the Date Format in the SQL*Loader Control File 12-4
12-2 Setting an NLS_DATE_FORMAT Environment Variable 12-4
14-1 Specifying Attributes for the ORACLE_LOADER Access Driver 14-2
14-2 Specifying Attributes for the ORACLE_DATAPUMP Access Driver 14-3
14-3 Specifying Attributes for the ORACLE_HDFS Access Driver 14-3
14-4 Specifying Attributes for the ORACLE_HIVE Access Driver 14-3
17-1 Setting Multiple Access Parameters for ORACLE_HDFS 17-3
17-2 Setting Multiple Access Parameters for ORACLE_HIVE 17-4
18-1 Using ORACLE_LOADER to Create a Partitioned External Table 18-2
18-2 Using the ORACLE_DATAPUMP Access Driver to Create Partitioned External Tables 18-4
18-3 Using the ORACLE_HDFS Access Driver to Create Partitioned External Tables 18-7
18-4 Using the ORACLE_HIVE Access Driver to Create Partitioned External Tables 18-9
18-5 Loading LOBs From External Tables 18-13
18-6 Loading Data From CSV Files With No Access Parameters 18-14
18-7 Default Date Mask For the Session Does Not Match the Format of Data Fields in the
Data File 18-15
18-8 Data is Split Across Two Data Files 18-16
18-9 Data Is Split Across Two Files and Only the First File Has a Row of Field Names 18-17
xxxviii
18-10 The Order of the Fields in the File Match the Order of the Columns in the Table 18-18
18-11 Not All Fields in the Data File Use Default Settings for the Access Parameters 18-19
23-1 Using the DBMS_METADATA Programmatic Interface to Retrieve Data 23-5
23-2 Using the DBMS_METADATA Browsing Interface to Retrieve Data 23-6
23-3 Retrieving Multiple Objects 23-6
23-4 Placing Conditions on Transforms 23-7
23-5 Modifying an XML Document 23-8
23-6 Using Parse Items to Access Specific Metadata Attributes 23-9
23-7 Using the Submit Interface to Re-Create a Retrieved Object 23-12
23-8 Retrieving Heterogeneous Object Types 23-14
23-9 Filtering the Return of Heterogeneous Object Types 23-15
23-10 Comparing Object Metadata 23-17
xxxix
List of Figures
7-1 SQL*Loader Overview 7-2
10-1 Example of Field Conversion 10-42
10-2 Relative Positioning After a Fixed Field 10-45
10-3 Relative Positioning After a Delimited Field 10-45
10-4 Relative Positioning After Enclosure Delimiters 10-46
10-5 Fields Terminated by Whitespace 10-46
10-6 Fields Terminated by Optional Enclosure Delimiters 10-47
22-1 Sample LogMiner Database Configuration 22-3
22-2 Decision Tree for Choosing a LogMiner Dictionary 22-9
xl
List of Tables
1-1 Data Pump Exit Codes 1-24
2-1 Supported Activities in Data Pump Export's Interactive-Command Mode 2-65
3-1 Supported Activities in Data Pump Import's Interactive-Command Mode 3-76
4-1 How Data Pump Export Handles Original Export Parameters 4-2
4-2 How Data Pump Import Handles Original Import Parameters 4-5
6-1 Valid Job States in Which DBMS_DATAPUMP Procedures Can Be Executed 6-3
7-1 Case Studies and Their Related Files 7-19
8-1 Exit Codes for SQL*Loader 8-34
9-1 Parameters for the INFILE Keyword 9-11
9-2 Parameters for the CONTINUEIF Clause 9-32
9-3 Fixed-Length Fields 9-52
9-4 Nongraphic Fields 9-52
9-5 Graphic Fields 9-53
9-6 Variable-Length Fields 9-53
10-1 Parameters for the Position Specification Clause 10-3
10-2 Data Type Conversions for Datetime and Interval Data Types 10-23
10-3 Parameters Used for Specifying Delimiters 10-24
10-4 Parameters for the Field Condition Clause 10-31
10-5 Behavior Summary for Trimming Whitespace 10-42
10-6 Parameters Used for Column Specification 10-57
17-1 Special Characters in Properties 17-2
17-2 Variables for com.oracle.bigdata.log.exec 17-11
17-3 Variables for com.oracle.bigdata.log.qc 17-12
18-1 Where to Find Examples of Using External Tables 18-1
19-1 ADRCI Command Line Parameters for Batch Operation 19-6
19-2 List of ADRCI commands 19-16
19-3 IPS Command Set 19-20
19-4 Arguments of IPS ADD command 19-22
19-5 Arguments of IPS CREATE PACKAGE command 19-26
19-6 Arguments of IPS PACK command 19-30
19-7 Arguments of IPS REMOVE command 19-33
19-8 IPS Configuration Parameters 19-36
19-9 Flags for the PURGE command 19-40
19-10 Flags for the SELECT command 19-42
19-11 ADRCI Utility Functions for the SELECT Command 19-44
xli
19-12 Flags for the SHOW ALERT command 19-54
19-13 Alert Fields for SHOW ALERT 19-55
19-14 Fields for Health Monitor Runs 19-58
19-15 Flags for SHOW INCIDENT command 19-61
19-16 Incident Fields for SHOW INCIDENT 19-62
19-17 Flags for SHOW LOG command 19-65
19-18 Log Fields for SHOW LOG 19-65
19-19 Flags for SHOW PROBLEM command 19-66
19-20 Problem Fields for SHOW PROBLEM 19-67
19-21 Arguments for SHOW TRACEFILE Command 19-68
19-22 Flags for SHOW TRACEFILE Command 19-69
21-1 Parameters for the DBNEWID Utility 21-9
23-1 DBMS_METADATA Procedures Used for Retrieving Multiple Objects 23-30
23-2 DBMS_METADATA Procedures Used for the Browsing Interface 23-31
23-3 DBMS_METADATA Procedures and Functions for Submitting XML Data 23-31
23-4 DBMS_METADATA_DIFF Procedures and Functions 23-32
24-1 Objects Exported in Each Mode 24-6
24-2 Sequence of Events During Updates by Two Users 24-12
24-3 Maximum Size for Dump Files 24-14
24-4 Exit Codes for Export 24-31
24-5 Using Different Releases of Export and Import 24-43
25-1 Privileges Required to Import Objects into Your Own Schema 25-3
25-2 Privileges Required to Import Grants 25-4
25-3 Objects Imported in Each Mode 25-11
25-4 Exit Codes for Import 25-35
25-5 Using Different Releases of Export and Import 25-59
B-1 Instant Client Files in the Tools Package B-3
xlii
Preface
This document describes how to use Oracle Database utilities for data transfer, data
maintenance, and database administration.
• Audience
• Documentation Accessibility
• Related Documentation
• Syntax Diagrams
• Conventions
Audience
The utilities described in this book are intended for database administrators (DBAs),
application programmers, security administrators, system operators, and other Oracle
users who perform the following tasks:
• Archive data, back up an Oracle database, or move data between Oracle
databases using the Export and Import utilities (both the original versions and the
Data Pump versions)
• Load data into Oracle tables from operating system files using SQL*Loader, or
from external sources using the external tables feature
• Perform a physical data structure integrity check on an offline database, using the
DBVERIFY utility
• Maintain the internal database identifier (DBID) and the database name
(DBNAME) for an operational database, using the DBNEWID utility
• Extract and manipulate complete representations of the metadata for database
objects, using the Metadata API
• Query and analyze redo log files (through a SQL interface), using the LogMiner
utility
• Use the Automatic Diagnostic Repository Command Interpreter (ADRCI) utility to
manage Oracle Database diagnostic data.
To use this manual, you need a working knowledge of SQL and of Oracle
fundamentals. You can find such information in Oracle Database Concepts. In
addition, to use SQL*Loader, you must know how to use the file management facilities
of your operating system.
Documentation Accessibility
xliii
Preface
Related Documentation
For more information, see these Oracle resources:
The Oracle Database documentation set, especially:
• Oracle Database Concepts
• Oracle Database SQL Language Reference
• Oracle Database Administrator's Guide
• Oracle Database PL/SQL Packages and Types Reference
Some of the examples in this book use the sample schemas of the seed database,
which is installed by default when you install Oracle Database. Refer to Oracle
Database Sample Schemas for information about how these schemas were created
and how you can use them yourself.
Syntax Diagrams
Syntax descriptions are provided in this book for various SQL, PL/SQL, or other
command-line constructs in graphic form or Backus Naur Form (BNF). See Oracle
Database SQL Language Reference for information about how to interpret these
descriptions.
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface elements associated
with an action, or terms defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or placeholder variables for
which you supply particular values.
monospace Monospace type indicates commands within a paragraph, URLs, code
in examples, text that appears on the screen, or text that you enter.
xliv
Changes in This Release for Oracle
Database Utilities
This preface lists changes in Oracle Database Utilities for Oracle Database 12c.
• Changes in Oracle Database 12c Release 2 (12.2.0.1)
• A new Data Pump import REMAP_DIRECTORY parameter lets you remap directories
when you move databases between platforms. See REMAP_DIRECTORY.
• A new TRUST_EXISTING_TABLE_PARTITIONS flag on the Data Pump Import
DATA_OPTIONS parameter enables data from multiple partitions to be loaded in
parallel into a pre-existing table, which reduces the import time. See
DATA_OPTIONS.
• A new VALIDATE_TABLE_DATA flag on the Data Pump Import DATA_OPTIONS parameter
verifies the format number and date data types in table data columns. See the
Import DATA_OPTIONS parameter.
• A new ENABLE_NETWORK_COMPRESSION option (for direct-path network imports only) on
the Data Pump DATA_OPTIONS parameter tells Data Pump to compress data before
sending it over the network. See the Import DATA_OPTIONS parameters.
• The DIRECT_PATH option on the Import ACCESS_METHOD parameter is now available for
network imports. See ACCESS_METHOD.
• A new GROUP_PARTITION_TABLE_DATA flag on the Data Pump Export DATA_OPTIONS
parameter enables data for all partitions to be loaded at once and in parallel. This
can reduce the time to import the table data. See the Export DATA_OPTIONS
parameter.
• Encrypted columns are now supported during transportable tablespace exports.
See the Export TRANSPORT_TABLESPACES and the Import
xlv
Changes in This Release for Oracle Database Utilities
Oracle SQL*Loader
• A new SQL*Loader SDF_PREFIX parameter lets you specify a directory prefix which
will be added to file names of LOBFILEs and secondary data files (SDFs) that are
opened as part of a load operation. See SDF_PREFIX.
• A new SQL*Loader DEFAULTS parameter lets you control evaluation of default
expressions. See DEFAULTS.
• A new SQL*Loader DIRECT_PATH_LOCK_WAIT parameter instructs direct path loads to
wait for table locks before proceeding with the load. See
DIRECT_PATH_LOCK_WAIT.
• A new SQL*Loader EMPTY_LOBS_ARE_NULL clause sets to NULL any LOB column for
which there is no data available. See EMPTY_LOBS_ARE_NULL.
• A new SQL*Loader control file clause, DEFAULT EXPRESSION CACHE n , allows you to
specify how many default expressions are evaluated at a time by a direct path
load. See Specifying the Number of Default Expressions to Be Evaluated At One
Time.
• SQL*Loader now supports 128-byte identifiers. This allows for longer table and
column names and lets you load databases that use 128-byte identifiers.
• A new LLS clause is available for SQL*Loader control files which lets you indicate
that a field in the data file is a LOB location specifier (LLS) field. See Loading Data
Files that Contain LLS Fields.
xlvi
Changes in This Release for Oracle Database Utilities
Oracle LogMiner
• LogMiner now captures changes for objects with long identifiers (128 bytes).
• The UTL_FILE_DIR initialization parameter is deprecated. It is still supported for
backward compatibility, but Oracle recommends that you instead use directory
objects. This deprecation affects extracting LogMiner dictionaries to flat files. See
Extracting the LogMiner Dictionary to a Flat File .
• LogMiner supports multitenant container databases (CDBs) that have pluggable
databases (PDBs) with different character sets. See Using LogMiner in a CDB.
xlvii
Part I
Oracle Data Pump
The topics discussed in this part include Data Pump Export, Data Pump Import, legacy
mode, performance, and the Data Pump API DBMS_DATAPUMP.
1-1
Chapter 1
Data Pump Components
Note:
All Data Pump Export and Import processing, including the reading and writing
of dump files, is done on the system (server) selected by the specified
database connect string. This means that for unprivileged users, the
database administrator (DBA) must create directory objects for the Data
Pump files that are read and written on that server file system. (For
security reasons, DBAs must ensure that only approved users are allowed
access to directory objects.) For privileged users, a default directory object is
available. See "Default Locations for Dump_ Log_ and SQL Files" for more
information about directory objects.
1-2
Chapter 1
How Does Data Pump Move Data?
See Also:
Note:
Data Pump does not load tables with disabled unique indexes. To load data
into the table, the indexes must be either dropped or reenabled.
1-3
Chapter 1
How Does Data Pump Move Data?
parameter) or a full mode network import (specified with the FULL and NETWORK_LINK
parameters).
When an export operation uses data file copying, the corresponding import job always
also uses data file copying. During the ensuing import operation, both the data files
and the export dump file must be loaded.
Note:
During transportable imports tablespaces are temporarily made read/write and
then set back to read-only. This is new behavior introduced as of Oracle
Database 12c Release 1 (12.1.0.2) to improve performance. However, you
should be aware that this behavior also causes the SCNs of the import job's
data files to change, which can cause issues during future transportable
imports of those files.
For example, if a transportable tablespace import fails at any point after the
tablespaces have been made read/write (even if they are now read-only again),
then the data files become corrupt. They cannot be recovered.
Since transportable jobs are not restartable, the failed job needs to be restarted
from the beginning. The corrupt datafiles must be deleted and fresh versions
must be copied to the target destination.
When transportable jobs are performed, it is best practice to keep a copy of the
data files on the source system until the import job has successfully completed
on the target system. If the import job should fail for some reason, you will still
have uncorrupted copies of the data files.
When data is moved by using data file copying, there are some limitations regarding
character set compatibility between the source and target databases.
If the source platform and the target platform are of different endianness, then you
must convert the data being transported so that it is in the format of the target platform.
You can use the DBMS_FILE_TRANSFER PL/SQL package or the RMAN CONVERT command to
convert the data.
See Also:
1-4
Chapter 1
How Does Data Pump Move Data?
Data Pump automatically uses the direct path method for loading and unloading data
unless the structure of a table does not allow it. For example, if a table contains a
column of type BFILE, then direct path cannot be used to load that table and external
tables is used instead.
The following sections describe situations in which direct path cannot be used for
loading and unloading.
• A table contains a column (including a VARRAY column) with a TIMESTAMP WITH TIME
ZONE data type and the version of the time zone data file is different between the
export and import systems.
1-5
Chapter 1
How Does Data Pump Move Data?
• Prior to the unload operation, the table was altered to contain a column that is
NOT NULL and also has a default value specified.
Note:
When Data Pump uses external tables as the data access mechanism, it uses
the ORACLE_DATAPUMP access driver. However, it is important to understand that
the files that Data Pump creates when it uses external tables are not
compatible with files created when you manually create an external table using
the SQL CREATE TABLE ... ORGANIZATION EXTERNAL statement.
See Also:
1-6
Chapter 1
How Does Data Pump Move Data?
1-7
Chapter 1
Using Data Pump With CDBs
See Also:
Note:
Data Pump does not support any CDB-wide operations. Data Pump issues the
following warning if you are connected to the root or seed database of a CDB:
ORA-39357: Warning: Oracle Data Pump operations are not typically needed when
connected to the root or seed of a container database.
1-8
Chapter 1
Using Data Pump With CDBs
When the transportable option is used, export and import use both transportable
tablespace data movement and conventional data movement; the latter for those
tables that reside in non-transportable tablespaces such as SYSTEM and SYSAUX. Using
the transportable option can reduce the export time and especially, the import time,
because table data does not need to be unloaded and reloaded and index structures
in user tablespaces do not need to be re-created.
To specify a particular PDB for the export/import operation, on the Data Pump
command line supply a connect identifier in the connect string when you start Data
Pump. For example, to import data to a PDB named pdb1, you could enter the following
on the Data Pump command line:
impdp hr@pdb1 DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp TABLES=employees
Be aware of the following requirements when using Data Pump to move data into a
CDB:
• To administer a multitenant environment, you must have the CDB_DBA role.
• Full database exports from Oracle Database 11.2.0.2 and earlier may be imported
into Oracle Database 12c (CDB or non-CDB). However, Oracle recommends the
source database first be upgraded to Oracle Database 11g release 2 (11.2.0.3 or
later) so that information about registered options and components is included in
the export.
• When migrating Oracle Database 11g release 2 (11.2.0.3 or later) to a CDB (or to
a non-CDB) using either full database export or full transportable database export,
you must set the Data Pump Export parameter VERSION=12 in order to generate a
dump file that is ready for import into Oracle Database 12c. If you do not set
VERSION=12, then the export file that is generated will not contain complete
information about registered database options and components.
• Network-based full transportable imports require use of the FULL=YES,
TRANSPORTABLE=ALWAYS, and TRANSPORT_DATAFILES=datafile_name parameters. When
the source database is Oracle Database 11g release 11.2.0.3 or later, but earlier
than Oracle Database 12c Release 1 (12.1), the VERSION=12 parameter is also
required.
• File-based full transportable imports only require use of the
TRANSPORT_DATAFILES=datafile_name parameter. Data Pump Import infers the
presence of the TRANSPORTABLE=ALWAYS and FULL=YES parameters.
• As of Oracle Database 12c release 2 (12.2), in a multitenant container database
(CDB) environment, the default Data Pump directory object, DATA_PUMP_DIR, is
defined as a unique path for each PDB in the CDB, whether or not the PATH_PREFIX
clause of the CREATE PLUGGABLE DATABASE statement is defined for relative paths.
1-9
Chapter 1
Required Roles for Data Pump Export and Import Operations
In the PDB being exported, if you have created local objects in that user's schema and
you want to import them, then either make sure a common user of the same name
already exists in the target CDB instance or use the Data Pump Import REMAP_SCHEMA
parameter on the impdp command, as follows:
REMAP_SCHEMA=C##common name:local user name
See Also:
These roles are automatically defined for Oracle databases when you run the standard
scripts that are part of database creation. (Note that although the names of these roles
contain the word FULL, these roles actually apply to any privileged operations in any
export or import mode, not only Full mode.)
The DATAPUMP_EXP_FULL_DATABASE role affects only export operations. The
DATAPUMP_IMP_FULL_DATABASE role affects import operations and operations that use the
Import SQLFILE parameter. These roles allow users performing exports and imports to
do the following:
• Perform the operation outside the scope of their schema
• Monitor jobs that were initiated by another user
• Export objects (such as tablespace definitions) and import objects (such as
directory definitions) that unprivileged users cannot reference
These are powerful roles. Database administrators should use caution when granting
these roles to users.
Although the SYS schema does not have either of these roles assigned to it, all security
checks performed by Data Pump that require these roles also grant access to the SYS
schema.
1-10
Chapter 1
What Happens During Execution of a Data Pump Job?
Note:
If you receive an ORA-39181: Only Partial Data Exported Due to Fine Grain
Access Control error message, then see the My Oracle Support note 422480.1
at http://support.oracle.com for information about security during an export of
table data with fine-grained access control policies enabled.
See Also:
Oracle Database Security Guide for more information about predefined roles in
an Oracle Database installation
1-11
Chapter 1
What Happens During Execution of a Data Pump Job?
See Also:
JOB_NAME for more information about how job names are formed
1-12
Chapter 1
What Happens During Execution of a Data Pump Job?
Within the master table, specific objects are assigned attributes such as name or
owning schema. Objects also belong to a class of objects (such as TABLE, INDEX, or
DIRECTORY). The class of an object is called its object type. You can use the EXCLUDE and
INCLUDE parameters to restrict the types of objects that are exported and imported. The
objects can be based upon the name of the object or the name of the schema that
owns the object. You can also specify data-specific filters to restrict the rows that are
exported and imported.
See Also:
When you are moving data from one database to another, it is often useful to perform
transformations on the metadata for remapping storage between tablespaces or
redefining the owner of a particular set of objects.
Note:
The ability to adjust the degree of parallelism is available only in the Enterprise
Edition of Oracle Database.
1-13
Chapter 1
Monitoring Job Status
See Also:
Note:
The value of PARALLEL is restricted to 1 in the Standard Edition of Oracle
Database.
When a worker process is assigned the task of loading or unloading a very large table
or partition, it may choose to use the external tables access method to make maximum
use of parallel execution. In such a case, the worker process becomes a parallel
execution coordinator. The actual loading and unloading work is divided among some
number of parallel I/O execution processes (sometimes called slaves) allocated from a
pool of available processes in an Oracle RAC environment.
See Also:
1-14
Chapter 1
Monitoring Job Status
See Also:
1-15
Chapter 1
File Allocation
exceeded by the actual transfer amount. The estimate value for import operations is
exact.
The V$SESSION_LONGOPS columns that are relevant to a Data Pump job are as follows:
Note:
If your Data Pump job generates errors related to Network File Storage (NFS),
then consult the installation guide for your platform to determine the correct
NFS mount settings.
1-16
Chapter 1
File Allocation
The reason that a directory object is required is to ensure data security and integrity.
For example:
• If you were allowed to specify a directory path location for an input file, then you
might be able to read data that the server has access to, but to which you should
not.
• If you were allowed to specify a directory path location for an output file, then the
server might overwrite a file that you might not normally have privileges to delete.
On UNIX and Windows operating systems, a default directory object, DATA_PUMP_DIR, is
created at database creation or whenever the database dictionary is upgraded. By
default, it is available only to privileged users. (The user SYSTEM has read and write
access to the DATA_PUMP_DIR directory, by default.) The definition of the DATA_PUMP_DIR
directory may be changed by Oracle during upgrades or when patches are applied.
If you are not a privileged user, then before you can run Data Pump Export or Data
Pump Import, a directory object must be created by a database administrator (DBA) or
by any user with the CREATE ANY DIRECTORY privilege.
After a directory is created, the user creating the directory object must grant READ or
WRITE permission on the directory to other users. For example, to allow the Oracle
database to read and write files on behalf of user hr in the directory named by
dpump_dir1, the DBA must execute the following command:
1-17
Chapter 1
File Allocation
Note that READ or WRITE permission to a directory object only means that the Oracle
database can read or write files in the corresponding directory on your behalf. You are
not given direct access to those files outside of the Oracle database unless you have
the appropriate operating system privileges. Similarly, the Oracle database requires
permission from the operating system to read and write files in the directories.
Data Pump Export and Import use the following order of precedence to determine a
file's location:
1. If a directory object is specified as part of the file specification, then the location
specified by that directory object is used. (The directory object must be separated
from the file name by a colon.)
2. If a directory object is not specified as part of the file specification, then the
directory object named by the DIRECTORY parameter is used.
3. If a directory object is not specified as part of the file specification, and if no
directory object is named by the DIRECTORY parameter, then the value of the
environment variable, DATA_PUMP_DIR, is used. This environment variable is defined
using operating system commands on the client system where the Data Pump
Export and Import utilities are run. The value assigned to this client-based
environment variable must be the name of a server-based directory object, which
must first be created on the server system by a DBA. For example, the following
SQL statement creates a directory object on the server system. The name of the
directory object is DUMP_FILES1, and it is located at '/usr/apps/dumpfiles1'.
SQL> CREATE DIRECTORY DUMP_FILES1 AS '/usr/apps/dumpfiles1';
Then, a user on a UNIX-based client system using csh can assign the value
DUMP_FILES1 to the environment variable DATA_PUMP_DIR. The DIRECTORY parameter
can then be omitted from the command line. The dump file employees.dmp, and the
log file export.log, are written to '/usr/apps/dumpfiles1'.
%setenv DATA_PUMP_DIR DUMP_FILES1
%expdp hr TABLES=employees DUMPFILE=employees.dmp
4. If none of the previous three conditions yields a directory object and you are a
privileged user, then Data Pump attempts to use the value of the default server-
based directory object, DATA_PUMP_DIR. This directory object is automatically
created at database creation or when the database dictionary is upgraded. You
can use the following SQL query to see the path definition for DATA_PUMP_DIR:
SQL> SELECT directory_name, directory_path FROM dba_directories
2 WHERE directory_name='DATA_PUMP_DIR';
If you are not a privileged user, then access to the DATA_PUMP_DIR directory object
must have previously been granted to you by a DBA.
Do not confuse the default DATA_PUMP_DIR directory object with the client-based
environment variable of the same name.
• Oracle RAC Considerations
Considerations to keep in mind when working in an Oracle RAC environment.
• Using Directory Objects When Oracle Automatic Storage Management Is Enabled
You can use Data Pump Export or Import with Oracle Automatic Storage
Management (Oracle ASM) enabled. You must define the directory object used for
the dump file so that the Oracle ASM disk group name is used (instead of an
operating system directory path).
1-18
Chapter 1
File Allocation
Then you would create a separate directory object for the log file:
SQL> CREATE or REPLACE DIRECTORY dpump_log as '/homedir/user1/';
To enable user hr to have access to these directory objects, you would assign the
necessary privileges, for example:
SQL> GRANT READ, WRITE ON DIRECTORY dpump_dir TO hr;
SQL> GRANT READ, WRITE ON DIRECTORY dpump_log TO hr;
You would then use the following Data Pump Export command (you will be prompted
for a password):
1-19
Chapter 1
File Allocation
Note:
If you simply want to copy Data Pump dump files between ASM and disk
directories, you can use the DBMS_FILE_TRANSFER PL/SQL package.
See Also:
Note:
This section uses %U to explain how Data Pump uses substitution variables.
For information about other available substitution variables, see the Data Pump
Export DUMPFILE parameter and the Data Pump Import DUMPFILE
parameter.
New dump files are created as they are needed. For example, if you are using the
substitution variable %U, then new dump files are created as needed beginning with 01
for %U, then using 02, 03, and so on. Enough dump files are created to allow all
processes specified by the current setting of the PARALLEL parameter to be active. If
1-20
Chapter 1
Exporting and Importing Between Different Database Releases
one of the dump files becomes full because its size has reached the maximum size
specified by the FILESIZE parameter, then it is closed and a new dump file (with a new
generated name) is created to take its place.
If multiple dump file templates are provided, they are used to generate dump files in a
round-robin fashion. For example, if expa%U, expb%U, and expc%U were all specified for a
job having a parallelism of 6, then the initial dump files created would be expa01.dmp,
expb01.dmp, expc01.dmp, expa02.dmp, expb02.dmp, and expc02.dmp.
For import and SQLFILE operations, if dump file specifications expa%U, expb%U, and
expc%U are specified, then the operation begins by attempting to open the dump files
expa01.dmp, expb01.dmp, and expc01.dmp. It is possible for the master table to span
multiple dump files, so until all pieces of the master table are found, dump files
continue to be opened by incrementing the substitution variable and looking up the
new file names (for example, expa02.dmp, expb02.dmp, and expc02.dmp). If a dump file
does not exist, then the operation stops incrementing the substitution variable for the
dump file specification that was in error. For example, if expb01.dmp and expb02.dmp are
found but expb03.dmp is not found, then no more files are searched for using the expb%U
specification. Once the entire master table is found, it is used to determine whether all
dump files in the dump file set have been located.
Keep the following information in mind when you are exporting and importing between
different database releases:
• On a Data Pump export, if you specify a database version that is older than the
current database version, then a dump file set is created that you can import into
that older version of the database. For example, if you are running Oracle
1-21
Chapter 1
Exporting and Importing Between Different Database Releases
Note:
Note the following about importing into earlier releases:
– Database privileges that are valid only in Oracle Database 12c Release
1 (12.1.0.2) and later (for example, the READ privilege on tables, views,
materialized views, and synonyms) cannot be imported into Oracle
Database 12c Release 1 (12.1.0.1) or earlier. If an attempt is made to
do so, then Import reports it as an error and continues the import
operation.
– When you export to a release earlier than Oracle Database 12c
Release 2 (12.2.0.1), Data Pump does not filter out object names
longer than 30 bytes. The objects are exported and at import time, an
error is returned if you attempt to create an object with a name longer
than 30 bytes.
• If you specify a database release that is older than the current database release,
then certain features and data types may be unavailable. For example, specifying
VERSION=10.1 causes an error if data compression is also specified for the job
because compression was not supported in Oracle Database 10g release 1 (10.1).
Another example would be if a user-defined type or Oracle-supplied type in the
source database is a later version than the type in the target database, then it will
not be loaded because it does not match any version of the type in the target
database.
• Data Pump Import can always read Data Pump dump file sets created by older
releases of the database.
• When operating across a network link, Data Pump requires that the source and
target databases differ by no more than two versions. For example, if one
database is Oracle Database 12c, then the other database must be 12c, 11g, or
10g. Note that Data Pump checks only the major version number (for example,
10g,11g, 12c), not specific release numbers (for example, 12.2, 12.1, 11.1, 11.2,
10.1, or 10.2).
• Importing Oracle Database 11g dump files that contain table statistics into Oracle
Database 12c Release 1 (12.1) or later may result in an Oracle ORA-39346 error.
This is because Oracle Database 11g dump files contain table statistics as
metadata, whereas Oracle Database 12c Release 1 (12.1) and later expect table
statistics to be presented as table data. The workaround is to ignore the error and
after the import operation completes, regather table statistics.
See Also:
1-22
Chapter 1
SecureFiles LOB Considerations
• If a table contains a SecureFiles LOB that is currently archived but the data is not
cached, and the Export VERSION parameter is set to a value earlier than 11.2.0.0.0,
then an ORA-45001 error is returned.
• If a table contains a SecureFiles LOB that is currently archived and the data is
cached, and the Export VERSION parameter is set to a value of 11.2.0.0.0 or later,
then both the cached data and the archive metadata is exported.
See Also:
Oracle Database SecureFiles and Large Objects Developer's Guide for more
information about SecureFiles
1-23
Chapter 1
Auditing Data Pump Jobs
After creating the audit policy, use the AUDIT and NOAUDIT SQL statements to,
respectively, enable and disable the policy.
See Also:
• Oracle Database SQL Language Reference for more information about the
SQL CREATE AUDIT POLICY,ALTER AUDIT POLICY, AUDIT, and NOAUDIT
statements
• Oracle Database Security Guide for more information about using auditing
in an Oracle database
1-24
Chapter 1
How Does Data Pump Handle Timestamp Data?
Note:
The information in this section applies only to Oracle Data Pump running on
Oracle Database 12c and later.
To identify the time zone file version of a database, you can execute the following SQL
statement:
SQL> SELECT VERSION FROM V$TIMEZONE_FILE;
See Also:
Oracle Database Globalization Support Guide for more information about time
zone files
1-25
Chapter 1
How Does Data Pump Handle Timestamp Data?
1.12.1.2 Data Pump Support for TIMESTAMP WITH TIME ZONE Data
Data Pump supports TIMESTAMP WITH TIME ZONE data during different export and import
modes like non-transportable mode, transportable tablespace and transportable table
mode, and full transportable mode.
This section describes Data Pump support for TIMESTAMP WITH TIME ZONE data during
different export and import modes when versions of the Oracle Database time zone file
are different on the source and target databases.
Non-transportable Modes
• If the dump file is created with a Data Pump version that supports TIMESTAMP WITH
TIME ZONE data (11.2.0.1 or later), then the time zone file version of the export
system is recorded in the dump file. Data Pump uses that information to determine
whether data conversion is necessary. If the target database knows about the
source time zone version, but is actually using a later version, then the data is
converted to the later version. TIMESTAMP WITH TIME ZONE data cannot be
downgraded, so if you attempt to import to a target that is using an earlier version
of the time zone file than the source used, the import fails.
• If the dump file is created with a Data Pump version prior to Oracle Database 11g
release 2 (11.2.0.1), then TIMESTAMP WITH TIME ZONE data is not supported, so no
conversion is done and corruption may occur.
1-26
Chapter 1
Character Set and Globalization Support Considerations
version used to create the dump file supports TIMESTAMP WITH TIME ZONE data.
(Release 11.2.0.1 and later support TIMESTAMP WITH TIMEZONE data.)
• If the source is earlier than Oracle Database 11g release 2 (11.2.0.1), then the
time zone file version must be the same on the source and target database for all
transportable jobs regardless of whether the transportable set uses TIMESTAMP WITH
TIME ZONE columns.
See Also:
1-27
Chapter 1
Character Set and Globalization Support Considerations
1-28
Chapter 1
Oracle Data Pump Behavior with Data-Bound Collation
Caution:
When the database character set of the export system differs from that of the
import system, the import system displays informational messages at the start
of the job that show what the database character set is.
When the import database character set is not a superset of the character set
used to generate the export file, the import system displays a warning that
possible data loss may occur due to character set conversions.
If the effective value of the Data Pump Import VERSION parameter is 12.2 and DBC is
enabled in the target database, then Data Pump Import generates DDL statements
with collation clauses referencing collation metadata from the dump file. Exported
objects are created with the original collation metadata that they had in the source
database.
No collation syntax is generated if DBC is disabled or if the Data Pump Import VERSION
parameter is set to a value lower than 12.2.
1-29
2
Data Pump Export
The Oracle Data Pump Export utility is used to unload data and metadata into a set of
operating system files called a dump file set.
• What Is Data Pump Export?
Data Pump Export (hereinafter referred to as Export for ease of reading) is a utility
for unloading data and metadata into a set of operating system files called a dump
file set.
• Invoking Data Pump Export
The Data Pump Export utility is started using the expdp command.
• Filtering During Export Operations
Data Pump Export provides data and metadata filtering capability.
• Parameters Available in Export's Command-Line Mode
This section describes the parameters available in the command-line mode of
Data Pump Export.
• Commands Available in Export's Interactive-Command Mode
In interactive-command mode, the current job continues running, but logging to the
terminal is suspended and the Export prompt (Export>) is displayed.
• Examples of Using Data Pump Export
These sections provides examples of using Data Pump Export.
• Syntax Diagrams for Data Pump Export
This section provides syntax diagrams for Data Pump Export.
2-1
Chapter 2
Invoking Data Pump Export
See Also:
• Default Locations for Dump_ Log_ and SQL Files for more information
about directory objects.
• Filtering During Export Operations for more information about using filters.
• Examples of Using Data Pump Export for examples of the various ways in
which you can use Data Pump Export.
The characteristics of the export operation are determined by the Export parameters
that you specify. These parameters can be specified either on the command line or in
a parameter file.
Note:
Do not start Export as SYSDBA, except at the request of Oracle technical
support. SYSDBA is used internally and has specialized functions; its behavior is
not the same as for general users.
2-2
Chapter 2
Invoking Data Pump Export
Note:
Several system schemas cannot be exported because they are not user
schemas; they contain Oracle-managed data and metadata. Examples of
system schemas that are not exported include SYS, ORDSYS, and MDSYS.
• Full Mode
A full database export is specified using the FULL parameter.
• Schema Mode
A schema export is specified using the SCHEMAS parameter. This is the default
export mode.
• Table Mode
A table mode export is specified using the TABLES parameter.
• Tablespace Mode
A tablespace export is specified using the TABLESPACES parameter.
• Transportable Tablespace Mode
A transportable tablespace export is specified using the TRANSPORT_TABLESPACES
parameter.
Related Topics
• Examples of Using Data Pump Export
These sections provides examples of using Data Pump Export.
See Also:
Examples of Using Data Pump Export
2-3
Chapter 2
Invoking Data Pump Export
In a full database export, the entire database is unloaded. This mode requires that you
have the DATAPUMP_EXP_FULL_DATABASE role.
• The default tablespace of the user performing the export must not be set to one of
the tablespaces being transported.
• If the database being exported contains either encrypted tablespaces or tables
with encrypted columns (either Transparent Data Encryption (TDE) columns or
SecureFiles LOB columns), then the ENCRYPTION_PASSWORD parameter must also be
supplied.
• The source and target databases must be on platforms with the same endianness
if there are encrypted tablespaces in the source database.
• If the source platform and the target platform are of different endianness, then you
must convert the data being transported so that it is in the format of the target
platform. You can use the DBMS_FILE_TRANSFER package or the RMAN CONVERT
command to convert the data.
• A full transportable export is not restartable.
• All objects with storage that are selected for export must have all of their storage
segments either entirely within administrative, non-transportable tablespaces
(SYSTEM / SYSAUX) or entirely within user-defined, transportable tablespaces. Storage
for a single object cannot straddle the two kinds of tablespaces.
• When transporting a database over the network using full transportable export,
auditing cannot be enabled for tables stored in an administrative tablespace (such
as SYSTEM and SYSAUX) if the audit trail information itself is stored in a user-defined
tablespace.
• If both the source and target databases are running Oracle Database 12c, then to
perform a full transportable export, either the Data Pump VERSION parameter must
be set to at least 12.0. or the COMPATIBLE database initialization parameter must be
set to at least 12.0 or later.
2-4
Chapter 2
Invoking Data Pump Export
Full transportable exports are supported from a source database running release
11.2.0.3. To do so, set the Data Pump VERSION parameter to at least 12.0 as shown in
the following example:
> expdp user_name FULL=y DUMPFILE=expdat.dmp DIRECTORY=data_pump_dir
TRANSPORTABLE=always VERSION=12.0 LOGFILE=export.log
Related Topics
• FULL
• TRANSPORTABLE
See Also:
Cross-schema references are not exported unless the referenced schema is also
specified in the list of schemas to be exported. For example, a trigger defined on a
table within one of the specified schemas, but that resides in a schema not explicitly
specified, is not exported. This is also true for external type definitions upon which
tables in the specified schemas depend. In such a case, it is expected that the type
definitions already exist in the target instance at import time.
Related Topics
• SCHEMAS
See Also:
SCHEMAS for a description of the Export SCHEMAS parameter
2-5
Chapter 2
Invoking Data Pump Export
In table mode, only a specified set of tables, partitions, and their dependent objects
are unloaded. Any object required to create the table, such as the owning schema, or
types for columns, must already exist.
If you specify the TRANSPORTABLE=ALWAYS parameter with the TABLES parameter, then only
object metadata is unloaded. To move the actual data, you copy the data files to the
target database. This results in quicker export times. If you are moving data files
between releases or platforms, then the data files may need to be processed by
Oracle Recovery Manager (RMAN).
You must have the DATAPUMP_EXP_FULL_DATABASE role to specify tables that are not in
your own schema. Note that type definitions for columns are not exported in table
mode. It is expected that the type definitions already exist in the target instance at
import time. Also, as in schema exports, cross-schema references are not exported.
To recover tables and table partitions, you can also use RMAN backups and the
RMAN RECOVER TABLE command. During this process, RMAN creates (and optionally
imports) a Data Pump export dump file that contains the recovered objects.
Related Topics
• TABLES
• TRANSPORTABLE
See Also:
Oracle Database Backup and Recovery User's Guide for more information on
transporting data across platforms
In tablespace mode, only the tables contained in a specified set of tablespaces are
unloaded. If a table is unloaded, then its dependent objects are also unloaded. Both
object metadata and data are unloaded. In tablespace mode, if any part of a table
resides in the specified set, then that table and all of its dependent objects are
exported. Privileged users get all tables. Unprivileged users get only the tables in their
own schemas.
Related Topics
• TABLESPACES
See Also:
2-6
Chapter 2
Invoking Data Pump Export
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
Related Topics
• How Does Data Pump Handle Timestamp Data?
This section describes factors that can affect successful completion of export and
import jobs that involve the timestamp data types TIMESTAMP WITH TIMEZONE and
TIMESTAMP WITH LOCAL TIMEZONE.
See Also:
• How Does Data Pump Handle Timestamp Data? for information about
special considerations concerning timestamp data when using
transportable tablespace mode
2-7
Chapter 2
Filtering During Export Operations
connect identifier requires that you have Oracle Net Listener running (to start the
default listener, enter lsnrctl start). The following is an example of this type of
connection, in which inst1 is the connect identifier:
expdp hr@inst1 DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp TABLES=employees
The local Export client connects to the database instance defined by the connect
identifier inst1 (a net service name), retrieves data from inst1, and writes it to the
dump file hr.dmp on inst1.
Specifying a connect identifier when you start the Export utility is different from
performing an export operation using the NETWORK_LINK parameter. When you start an
export operation and specify a connect identifier, the local Export client connects to the
database instance identified by the connect identifier, retrieves data from that
database instance, and writes it to a dump file set on that database instance.
Whereas, when you perform an export using the NETWORK_LINK parameter, the export is
performed using a database link. (A database link is a connection between two
physical database servers that allows a client to access them as one logical
database.)
Related Topics
• NETWORK_LINK
See Also:
2-8
Chapter 2
Filtering During Export Operations
Data filtering can also occur indirectly because of metadata filtering, which can include
or exclude table objects along with any associated row data.
Each data filter can be specified once per table within a job. If different filters using the
same name are applied to both a particular table and to the whole job, then the filter
parameter supplied for the specific table takes precedence.
OBJECT_GRANT
Object grants on the selected tables
PROCDEPOBJ_GRANT
Grants on instance procedural objects
PROCOBJ_GRANT
Schema procedural object grants in the selected schemas
ROLE_GRANT
Role grants to users associated with the selected schemas
SYSTEM_GRANT
System privileges granted to users associated with the selected schemas
2-9
Chapter 2
Parameters Available in Export's Command-Line Mode
Related Topics
• EXCLUDE
• INCLUDE
Related Topics
• EXCLUDE
• INCLUDE
See Also:
"EXCLUDE" and "INCLUDE"
For every parameter you enter, you must enter an equal sign (=) and a value. Data
Pump has no other way of knowing that the previous parameter specification is
complete and a new parameter specification is beginning. For example, in the
following command line, even though NOLOGFILE is a valid parameter, it would be
interpreted as another dumpfile name for the DUMPFILE parameter:
expdp DIRECTORY=dpumpdir DUMPFILE=test.dmp NOLOGFILE TABLES=employees
This would result in two dump files being created, test.dmp and nologfile.dmp.
2-10
Chapter 2
Parameters Available in Export's Command-Line Mode
such as the backslash (\). This is true both on the command line and within parameter
files. Some operating systems may require an additional set of single or double
quotation marks on the command line around the entire parameter value containing
the special characters.
The following examples are provided to illustrate these concepts. Be aware that they
may not apply to your particular operating system and that this documentation cannot
anticipate the operating environments unique to each user.
Suppose you specify the TABLES parameter in a parameter file, as follows:
TABLES = \"MixedCaseTableName\"
If you were to specify that on the command line, some operating systems would
require that it be surrounded by single quotation marks, as follows:
TABLES = '\"MixedCaseTableName\"'
To avoid having to supply additional quotation marks on the command line, Oracle
recommends the use of parameter files. Also, note that if you use a parameter file and
the parameter value being specified does not have quotation marks as the first
character in the string (for example, TABLES=scott."EmP"), then the use of escape
characters may not be necessary on some systems.
• ABORT_STEP
• ACCESS_METHOD
• ATTACH
• CLUSTER
• COMPRESSION
• COMPRESSION_ALGORITHM
2-11
Chapter 2
Parameters Available in Export's Command-Line Mode
• CONTENT
• DATA_OPTIONS
• DIRECTORY
• DUMPFILE
• ENCRYPTION
• ENCRYPTION_ALGORITHM
• ENCRYPTION_MODE
• ENCRYPTION_PASSWORD
• ENCRYPTION_PWD_PROMPT
• ESTIMATE
• ESTIMATE_ONLY
• EXCLUDE
• FILESIZE
• FLASHBACK_SCN
• FLASHBACK_TIME
• FULL
• HELP
• INCLUDE
• JOB_NAME
• KEEP_MASTER
• LOGFILE
• LOGTIME
• METRICS
• NETWORK_LINK
• NOLOGFILE
• PARALLEL
• PARFILE
• QUERY
• REMAP_DATA
• REUSE_DUMPFILES
• SAMPLE
• SCHEMAS
• SERVICE_NAME
• SOURCE_EDITION
• STATUS
• TABLES
• TABLESPACES
2-12
Chapter 2
Parameters Available in Export's Command-Line Mode
• TRANSPORT_FULL_CHECK
• TRANSPORT_TABLESPACES
• TRANSPORTABLE
• VERSION
• VIEWS_AS_TABLES
Related Topics
• PARFILE
• Default Locations for Dump, Log, and SQL Files
Data Pump is server-based rather than client-based. Dump files, log files, and
SQL files are accessed relative to server-based directory paths.
• Examples of Using Data Pump Export
These sections provides examples of using Data Pump Export.
• Syntax Diagrams for Data Pump Export
This section provides syntax diagrams for Data Pump Export.
See Also:
2.4.1 ABORT_STEP
Default: Null
Purpose
Used to stop the job after it is initialized. This allows the master table to be queried
before any data is exported.
The possible values correspond to a process order number in the master table. The
result of using each number is as follows:
• n: If the value is zero or greater, then the export operation is started and the job is
aborted at the object that is stored in the master table with the corresponding
process order number.
• -1: If the value is negative one (-1) then abort the job after setting it up, but before
exporting any objects or data.
Restrictions
• None
2-13
Chapter 2
Parameters Available in Export's Command-Line Mode
Example
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr ABORT_STEP=-1
2.4.2 ACCESS_METHOD
Default: AUTOMATIC
Purpose
Instructs Export to use a particular method to unload data.
The ACCESS_METHOD parameter is provided so that you can try an alternative method if
the default method does not work for some reason. All methods can be specified for a
network export. If the data for a table cannot be unloaded with the specified access
method, then the data displays an error for the table and continues with the next work
item.
The available options are as follows:
• AUTOMATIC — Data Pump determines the best way to unload data for each table.
Oracle recommends that you use AUTOMATIC whenever possible because it allows
Data Pump to automatically select the most efficient method.
• DIRECT_PATH — Data Pump uses direct path unload for every table.
Restrictions
• To use the ACCESS_METHOD parameter with network exports, you must be using
Oracle Database 12c Release 2 (12.2.0.1) or later.
Example
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr
ACCESS_METHOD=EXTERNAL_TABLE
2.4.3 ATTACH
Default: job currently in the user's schema, if there is only one
Purpose
Attaches the client session to an existing export job and automatically places you in
the interactive-command interface. Export displays a description of the job to which
you are attached and also displays the Export prompt.
2-14
Chapter 2
Parameters Available in Export's Command-Line Mode
The schema_name is optional. To specify a schema other than your own, you must have
the DATAPUMP_EXP_FULL_DATABASE role.
The job_name is optional if only one export job is associated with your schema and the
job is active. To attach to a stopped job, you must supply the job name. To see a list of
Data Pump job names, you can query the DBA_DATAPUMP_JOBS view or the
USER_DATAPUMP_JOBS view.
When you are attached to the job, Export displays a description of the job and then
displays the Export prompt.
Restrictions
• When you specify the ATTACH parameter, the only other Data Pump parameter you
can specify on the command line is ENCRYPTION_PASSWORD.
• If the job you are attaching to was initially started using an encryption password,
then when you attach to the job you must again enter the ENCRYPTION_PASSWORD
parameter on the command line to re-specify that password. The only exception to
this is if the job was initially started with the ENCRYPTION=ENCRYPTED_COLUMNS_ONLY
parameter. In that case, the encryption password is not needed when attaching to
the job.
• You cannot attach to a job in another schema unless it is already running.
• If the dump file set or master table for the job have been deleted, then the attach
operation will fail.
• Altering the master table in any way will lead to unpredictable results.
Example
The following is an example of using the ATTACH parameter. It assumes that the job,
hr.export_job, already exists.
See Also:
"Commands Available in Export's Interactive-Command Mode"
2.4.4 CLUSTER
Default: YES
Purpose
Determines whether Data Pump can use Oracle Real Application Clusters (Oracle
RAC) resources and start workers on other Oracle RAC instances.
2-15
Chapter 2
Parameters Available in Export's Command-Line Mode
To force Data Pump Export to use only the instance where the job is started and to
replicate pre-Oracle Database 11g release 2 (11.2) behavior, specify CLUSTER=NO.
To specify a specific, existing service and constrain worker processes to run only on
instances defined for that service, use the SERVICE_NAME parameter with the
CLUSTER=YES parameter.
Use of the CLUSTER parameter may affect performance because there is some
additional overhead in distributing the export job across Oracle RAC instances. For
small jobs, it may be better to specify CLUSTER=NO to constrain the job to run on the
instance where it is started. Jobs whose performance benefits the most from using the
CLUSTER parameter are those involving large amounts of data.
Example
The following is an example of using the CLUSTER parameter:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_clus%U.dmp CLUSTER=NO PARALLEL=3
This example starts a schema-mode export (the default) of the hr schema. Because
CLUSTER=NO is specified, the job uses only the instance on which it started. (If the
CLUSTER parameter had not been specified at all, then the default value of Y would have
been used and workers would have been started on other instances in the Oracle
RAC, if necessary.) The dump files will be written to the location specified for the
dpump_dir1 directory object. The job can have up to 3 parallel processes.
See Also:
• "SERVICE_NAME"
• "Oracle RAC Considerations"
2.4.5 COMPRESSION
Default: METADATA_ONLY
Purpose
Specifies which data to compress before writing to the dump file set.
• ALL enables compression for the entire export operation. The ALL option requires
that the Oracle Advanced Compression option be enabled.
• DATA_ONLY results in all data being written to the dump file in compressed format.
The DATA_ONLY option requires that the Oracle Advanced Compression option be
enabled.
2-16
Chapter 2
Parameters Available in Export's Command-Line Mode
• METADATA_ONLY results in all metadata being written to the dump file in compressed
format. This is the default.
• NONE disables compression for the entire export operation.
Restrictions
• To make full use of all these compression options, the COMPATIBLE initialization
parameter must be set to at least 11.0.0.
• The METADATA_ONLY option can be used even if the COMPATIBLE initialization
parameter is set to 10.2.
• Compression of data using ALL or DATA_ONLY is valid only in the Enterprise Edition
of Oracle Database 11g or later, and they require that the Oracle Advanced
Compression option be enabled.
Example
The following is an example of using the COMPRESSION parameter:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_comp.dmp COMPRESSION=METADATA_ONLY
This command will execute a schema-mode export that will compress all metadata
before writing it out to the dump file, hr_comp.dmp. It defaults to a schema-mode export
because no export mode is specified.
See Also:
Oracle Database Licensing Information for information about licensing
requirements for the Oracle Advanced Compression option
2.4.6 COMPRESSION_ALGORITHM
Default: BASIC
Purpose
Specifies the compression algorithm to be used when compressing dump file data.
2-17
Chapter 2
Parameters Available in Export's Command-Line Mode
• HIGH — Best suited for situations in which dump files will be copied over slower
networks where the limiting factor is network speed.
The performance of a compression algorithm is characterized by its CPU usage and
by the compression ratio (the size of the compressed output as a percentage of the
uncompressed input). These measures vary on the size and type of inputs as well as
the speed of the compression algorithms used. The compression ratio generally
increases from low to high, with a trade-off of potentially consuming more CPU
resources.
It is recommended that you run tests with the different compression levels on the data
in your environment. Choosing a compression level based on your environment,
workload characteristics, and size and type of data is the only way to ensure that the
exported dump file set compression level meets your performance and storage
requirements.
Restrictions
• To use this feature, database compatibility must be set to 12.0.0 or later.
• This feature requires that the Oracle Advanced Compression option be enabled.
Example 1
This example performs a schema-mode unload of the HR schema and compresses only
the table data using a compression algorithm with a low level of compression. This
should result in fewer CPU resources being used, at the expense of a less than
optimal compression ratio.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp COMPRESSION=DATA_ONLY
COMPRESSION_ALGORITHM=LOW
Example 2
This example performs a schema-mode unload of the HR schema and compresses
both metadata and table data using the basic level of compression. Omitting the
COMPRESSION_ALGORITHM parameter altogether is equivalent to specifying BASIC as the
value.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp COMPRESSION=ALL
COMPRESSION_ALGORITHM=BASIC
2.4.7 CONTENT
Default: ALL
Purpose
Enables you to filter what Export unloads: data only, metadata only, or both.
• DATA_ONLY unloads only table row data; no database object definitions are
unloaded.
2-18
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• The CONTENT=METADATA_ONLY parameter cannot be used with the
TRANSPORT_TABLESPACES (transportable-tablespace mode) parameter or with the
QUERY parameter.
Example
The following is an example of using the CONTENT parameter:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp CONTENT=METADATA_ONLY
This command will execute a schema-mode export that will unload only the metadata
associated with the hr schema. It defaults to a schema-mode export of the hr schema
because no export mode is specified.
2.4.8 DATA_OPTIONS
Default: There is no default. If this parameter is not used, then the special data
handling options it provides simply do not take effect.
Purpose
The DATA_OPTIONS parameter designates how certain types of data should be handled
during export operations.
Note:
XMLType stored as CLOB is deprecated as of Oracle Database 12c Release 1
(12.1). XMLType tables and columns are now stored as binary XML.
If a table has XMLType columns stored only in CLOB format, then it is not necessary
to specify the XML_CLOBS option because Data Pump automatically exports them in
CLOB format. If a table has XMLType columns stored as any combination of object-
relational (schema-based), binary, or CLOB formats, then Data Pump exports them
in compressed format, by default. This is the preferred method. However, if you
need to export the data in uncompressed CLOB format, you can use the XML_CLOBS
option to override the default.
• GROUP_PARTITION_TABLE_DATA — tells Data Pump to unload all table data in one
operation rather than unload each table partition as a separate operation. As a
result, the definition of the table will not matter at import time because Import will
see one partition of data that will be loaded into the entire table.
2-19
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• Using the XML_CLOBS option requires that the same XML schema be used at both
export and import time.
• The Export DATA_OPTIONS parameter requires the job version to be set to 11.0.0 or
later. See "VERSION".
Example
This example shows an export operation in which any XMLType columns in the
hr.xdb_tab1 table are exported in uncompressed CLOB format regardless of the XMLType
storage format that was defined for them.
> expdp hr TABLES=hr.xdb_tab1 DIRECTORY=dpump_dir1 DUMPFILE=hr_xml.dmp
VERSION=11.2 DATA_OPTIONS=XML_CLOBS
See Also:
Oracle XML DB Developer's Guide for information specific to exporting and
importing XMLType tables
2.4.9 DIRECTORY
Default: DATA_PUMP_DIR
Purpose
Specifies the default location to which Export can write the dump file set and the log
file.
The directory_object is the name of a database directory object (not the file path of an
actual directory). Privileged users have access to a default directory object named
DATA_PUMP_DIR. The definition of the DATA_PUMP_DIR directory may be changed by Oracle
during upgrades or when patches are applied.
Users with access to the default DATA_PUMP_DIR directory object do not need to use the
DIRECTORY parameter.
Example
The following is an example of using the DIRECTORY parameter:
2-20
Chapter 2
Parameters Available in Export's Command-Line Mode
The dump file, employees.dmp, will be written to the path that is associated with the
directory object dpump_dir1.
See Also:
• "Default Locations for Dump_ Log_ and SQL Files" for more information
about default directory objects and the order of precedence Data Pump
uses to determine a file's location
• "Oracle RAC Considerations"
• Oracle Database SQL Language Reference for information about the
CREATE DIRECTORY command
2.4.10 DUMPFILE
Default: expdat.dmp
Purpose
Specifies the names, and optionally, the directory objects of dump files for an export
job.
The directory_object is optional if one has already been established by the DIRECTORY
parameter. If you supply a value here, then it must be a directory object that already
exists and that you have access to. A database directory object that is specified as
part of the DUMPFILE parameter overrides a value specified by the DIRECTORY parameter
or by the default directory object.
You can supply multiple file_name specifications as a comma-delimited list or in
separate DUMPFILE parameter specifications. If no extension is given for the file name,
then Export uses the default file extension of .dmp. The file names can contain a
substitution variable. The following table lists the available substitution variables.
Substitution Meaning
Variable
%U The substitution variable is expanded in the resulting file names into a 2-digit,
fixed-width, incrementing integer starting at 01 and ending at 99. If a file
specification contains two substitution variables, both are incremented at the
same time. For example, exp%Uaa%U.dmp would resolve to exp01aa01.dmp,
exp02aa02.dmp, and so forth.
%d, %D Specifies the current day of the month from the Gregorian calendar in format
DD.
Note: This substitution variable cannot be used in an import file name.
%m, %M Specifies the month in the Gregorian calendar in format MM.
Note: This substitution variable cannot be used in an import file name.
2-21
Chapter 2
Parameters Available in Export's Command-Line Mode
Substitution Meaning
Variable
%t, %T Specifies the year, month, and day in the Gregorian calendar in this format:
YYYYMMDD.
Note: This substitution variable cannot be used in an import file name.
%l, %L Specifies a system-generated unique file name.
The file names can contain a substitution variable (%L), which implies that
multiple files may be generated. The substitution variable is expanded in the
resulting file names into a 2-digit, fixed-width, incrementing integer starting at
01 and ending at 99 which is the same as (%U). In addition, the substitution
variable is expanded in the resulting file names into a 3-digit to 10-digit,
variable-width, incrementing integers starting at 100 and ending at
2147483646. The width field is determined by the number of digits in the
integer.
For example if the current integer was 1, exp%Laa%L.dmp would resolve to
exp01aa01.dmp
exp02aa02.dmp
and so forth up until 99. Then, the next file name would have 3 digits
substituted:
exp100aa100.dmp
exp101aa101.dmp
and so forth up until 999 where the next file would have 4 digits substituted.
The substitution will continue up to the largest number substitution allowed,
which is 2147483646.
%y, %Y Specifies the year in this format: YYYY.
Note: This substitution variable cannot be used in an import file name.
If the FILESIZE parameter is specified, then each dump file will have a maximum of that
size and be nonextensible. If more space is required for the dump file set and a
template with a substitution variable was supplied, then a new dump file is
automatically created of the size specified by the FILESIZE parameter, if there is room
on the device.
As each file specification or file template containing a substitution variable is defined, it
is instantiated into one fully qualified file name and Export attempts to create it. The file
specifications are processed in the order in which they are specified. If the job needs
extra files because the maximum file size is reached, or to keep parallel workers
active, then additional files are created if file templates with substitution variables were
specified.
Although it is possible to specify multiple files using the DUMPFILE parameter, the export
job may only require a subset of those files to hold the exported data. The dump file
set displayed at the end of the export job shows exactly which files were used. It is this
list of files that is required to perform an import operation using this dump file set. Any
files that were not used can be discarded.
When you specify the DUMPFILE parameter, it is possible to introduce conflicting file
names, regardless of whether substitution variables are used. The following are some
examples of expdp commands that would produce file name conflicts. For all of these
examples, an ORA-27308 created file already exists error is returned:
expdp system/manager directory=dpump_dir schemas=hr DUMPFILE=foo%U.dmp,foo%U.dmp
2-22
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• Any resulting dump file names that match preexisting dump file names will
generate an error and the preexisting dump files will not be overwritten. You can
override this behavior by specifying the Export parameter REUSE_DUMPFILES=YES.
• Dump files created on Oracle Database 11g releases with the Data Pump
parameter VERSION=12 can only be imported on Oracle Database 12c Release 1
(12.1) and later.
Example
The following is an example of using the DUMPFILE parameter:
> expdp hr SCHEMAS=hr DIRECTORY=dpump_dir1 DUMPFILE=dpump_dir2:exp1.dmp,
exp2%U.dmp PARALLEL=3
The dump file, exp1.dmp, will be written to the path associated with the directory object
dpump_dir2 because dpump_dir2 was specified as part of the dump file name, and
therefore overrides the directory object specified with the DIRECTORY parameter.
Because all three parallel processes will be given work to perform during this job,
dump files named exp201.dmp and exp202.dmp will be created based on the specified
substitution variable exp2%U.dmp. Because no directory is specified for them, they will be
written to the path associated with the directory object, dpump_dir1, that was specified
with the DIRECTORY parameter.
See Also:
2.4.11 ENCRYPTION
Default: The default value depends upon the combination of encryption-related
parameters that are used. To enable encryption, either the ENCRYPTION or
ENCRYPTION_PASSWORD parameter, or both, must be specified.
If only the ENCRYPTION parameter is specified and the Oracle encryption wallet is open,
then the default mode is TRANSPARENT. If only the ENCRYPTION parameter is specified and
the wallet is closed, then an error is returned.
If neither ENCRYPTION nor ENCRYPTION_PASSWORD is specified, then ENCRYPTION defaults to
NONE.
2-23
Chapter 2
Parameters Available in Export's Command-Line Mode
Purpose
Specifies whether to encrypt data before writing it to the dump file set.
• ALL enables encryption for all data and metadata in the export operation.
• DATA_ONLY specifies that only data is written to the dump file set in encrypted
format.
• ENCRYPTED_COLUMNS_ONLY specifies that only encrypted columns are written to the
dump file set in encrypted format. This option cannot be used in conjunction with
the ENCRYPTION_ALGORITHM parameter because the columns already have an
assigned encryption format and by definition, a column can have only one form of
encryption.
To use the ENCRYPTED_COLUMNS_ONLY option, you must have Oracle Advanced
Security Transparent Data Encryption (TDE) enabled. See Oracle Database
Advanced Security Guide for more information about TDE.
• METADATA_ONLY specifies that only metadata is written to the dump file set in
encrypted format.
• NONE specifies that no data is written to the dump file set in encrypted format.
You can abort the current export operation and start a new one, specifying that the
output dump file set be encrypted.
Restrictions
• To specify the ALL, DATA_ONLY, or METADATA_ONLY options, the COMPATIBLE initialization
parameter must be set to at least 11.0.0.
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
• Data Pump encryption features require that the Oracle Advanced Security option
be enabled. See Oracle Database Licensing Information for information about
licensing requirements for the Oracle Advanced Security option.
2-24
Chapter 2
Parameters Available in Export's Command-Line Mode
Example
The following example performs an export operation in which only data is encrypted in
the dump file:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_enc.dmp JOB_NAME=enc1
ENCRYPTION=data_only ENCRYPTION_PASSWORD=foobar
2.4.12 ENCRYPTION_ALGORITHM
Default: AES128
Purpose
Specifies which cryptographic algorithm should be used to perform the encryption.
See Oracle Database Advanced Security Guide for information about encryption
algorithms.
Restrictions
• To use this encryption feature, the COMPATIBLE initialization parameter must be set
to at least 11.0.0.
• The ENCRYPTION_ALGORITHM parameter requires that you also specify either the
ENCRYPTION or ENCRYPTION_PASSWORD parameter; otherwise an error is returned.
Example
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_enc3.dmp
ENCRYPTION_PASSWORD=foobar ENCRYPTION_ALGORITHM=AES128
2.4.13 ENCRYPTION_MODE
Default: The default mode depends on which other encryption-related parameters are
used. If only the ENCRYPTION parameter is specified and the Oracle encryption wallet is
open, then the default mode is TRANSPARENT. If only the ENCRYPTION parameter is
specified and the wallet is closed, then an error is returned.
If the ENCRYPTION_PASSWORD parameter is specified and the wallet is open, then the
default is DUAL. If the ENCRYPTION_PASSWORD parameter is specified and the wallet is
closed, then the default is PASSWORD.
2-25
Chapter 2
Parameters Available in Export's Command-Line Mode
Purpose
Specifies the type of security to use when encryption and decryption are performed.
DUAL mode creates a dump file set that can later be imported either transparently or by
specifying a password that was used when the dual-mode encrypted dump file set was
created. When you later import the dump file set created in DUAL mode, you can use
either the wallet or the password that was specified with the ENCRYPTION_PASSWORD
parameter. DUAL mode is best suited for cases in which the dump file set will be
imported on-site using the wallet, but which may also need to be imported offsite
where the wallet is not available.
PASSWORD mode requires that you provide a password when creating encrypted dump
file sets. You will need to provide the same password when you import the dump file
set. PASSWORD mode requires that you also specify the ENCRYPTION_PASSWORD parameter.
The PASSWORD mode is best suited for cases in which the dump file set will be imported
into a different or remote database, but which must remain secure in transit.
TRANSPARENT mode allows an encrypted dump file set to be created without any
intervention from a database administrator (DBA), provided the required wallet is
available. Therefore, the ENCRYPTION_PASSWORD parameter is not required, and will in
fact, cause an error if it is used in TRANSPARENT mode. This encryption mode is best
suited for cases in which the dump file set will be imported into the same database
from which it was exported.
Restrictions
• To use DUAL or TRANSPARENT mode, the COMPATIBLE initialization parameter must be
set to at least 11.0.0.
• When you use the ENCRYPTION_MODE parameter, you must also use either the
ENCRYPTION or ENCRYPTION_PASSWORD parameter. Otherwise, an error is returned.
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
• Data Pump encryption features require that the Oracle Advanced Security option
be enabled. See Oracle Database Licensing Information for information about
licensing requirements for the Oracle Advanced Security option.
Example
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_enc4.dmp
ENCRYPTION=all ENCRYPTION_PASSWORD=secretwords
ENCRYPTION_ALGORITHM=AES256 ENCRYPTION_MODE=DUAL
2.4.14 ENCRYPTION_PASSWORD
Default: There is no default; the value is user-provided.
2-26
Chapter 2
Parameters Available in Export's Command-Line Mode
Purpose
Specifies a password for encrypting encrypted column data, metadata, or table data in
the export dump file. This prevents unauthorized access to an encrypted dump file set.
Note:
Data Pump encryption functionality changed as of Oracle Database 11g
release 1 (11.1). Before release 11.1, the ENCRYPTION_PASSWORD parameter
applied only to encrypted columns. However, as of release 11.1, the new
ENCRYPTION parameter provides options for encrypting other types of data. This
means that if you now specify ENCRYPTION_PASSWORD without also specifying
ENCRYPTION and a specific option, then all data written to the dump file will be
encrypted (equivalent to specifying ENCRYPTION=ALL). To re-encrypt only
encrypted columns, you must now specify ENCRYPTION=ENCRYPTED_COLUMNS_ONLY in
addition to ENCRYPTION_PASSWORD.
The password value that is supplied specifies a key for re-encrypting encrypted table
columns, metadata, or table data so that they are not written as clear text in the dump
file set. If the export operation involves encrypted table columns, but an encryption
password is not supplied, then the encrypted columns are written to the dump file set
as clear text and a warning is issued.
The password that you enter is echoed to the screen. If you do not want the password
shown on the screen as you enter it, then use the ENCRYPTION_PWD_PROMPT parameter.
The maximum length allowed for an encryption password is usually 128 bytes.
However, the limit is 30 bytes if ENCRYPTION=ENCRYPTED_COLUMNS_ONLY and either the
VERSION parameter or database compatibility is set to less than 12.2.
Note:
There is no connection or dependency between the key specified with the Data
Pump ENCRYPTION_PASSWORD parameter and the key specified with the ENCRYPT
keyword when the table with encrypted columns was initially created. For
example, suppose a table is created as follows, with an encrypted column
whose key is xyz:
CREATE TABLE emp (col1 VARCHAR2(256) ENCRYPT IDENTIFIED BY "xyz");
When you export the emp table, you can supply any arbitrary value for
ENCRYPTION_PASSWORD. It does not have to be xyz.
2-27
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
• The ENCRYPTION_PASSWORD parameter is required for the transport of encrypted
tablespaces and tablespaces containing tables with encrypted columns in a full
transportable export.
• Data Pump encryption features require that the Oracle Advanced Security option
be enabled. See Oracle Database Licensing Information for information about
licensing requirements for the Oracle Advanced Security option.
• If ENCRYPTION_PASSWORD is specified but ENCRYPTION_MODE is not specified, then it is
not necessary to have Oracle Advanced Security Transparent Data Encryption
enabled since ENCRYPTION_MODE will default to PASSWORD.
• The ENCRYPTION_PASSWORD parameter is not valid if the requested encryption mode is
TRANSPARENT.
Example
In the following example, an encryption password, 123456, is assigned to the dump file,
dpcd2be1.dmp.
Encrypted columns in the employee_s_encrypt table will not be written as clear text in
the dpcd2be1.dmp dump file. Note that to subsequently import the dpcd2be1.dmp file
created by this example, you will need to supply the same encryption password.
2.4.15 ENCRYPTION_PWD_PROMPT
Default: NO
2-28
Chapter 2
Parameters Available in Export's Command-Line Mode
Purpose
Specifies whether Data Pump should prompt you for the encryption password.
If you specify an encryption password on the export operation, you must also supply it
on the import operation.
Restrictions
• Concurrent use of the ENCRYPTION_PWD_PROMPT and ENCRYPTION_PASSWORD parameters
is prohibited.
Example
The following example shows Data Pump first prompting for the user password and
then for the encryption password.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp ENCRYPTION_PWD_PROMPT=YES
.
.
.
Copyright (c) 1982, 2016, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Production
Encryption Password:
2.4.16 ESTIMATE
Default: BLOCKS
Purpose
Specifies the method that Export will use to estimate how much disk space each table
in the export job will consume (in bytes). The estimate is printed in the log file and
2-29
Chapter 2
Parameters Available in Export's Command-Line Mode
displayed on the client's standard output device. The estimate is for table row data
only; it does not include metadata.
Restrictions
• If the Data Pump export job involves compressed tables, then the default size
estimation given for the compressed table is inaccurate when ESTIMATE=BLOCKS is
used. This is because the size estimate does not reflect that the data was stored in
a compressed form. To get a more accurate size estimate for compressed tables,
use ESTIMATE=STATISTICS.
• The estimate may also be inaccurate if either the QUERY or REMAP_DATA parameter is
used.
Example
The following example shows a use of the ESTIMATE parameter in which the estimate is
calculated using statistics for the employees table:
> expdp hr TABLES=employees ESTIMATE=STATISTICS DIRECTORY=dpump_dir1
DUMPFILE=estimate_stat.dmp
2.4.17 ESTIMATE_ONLY
Default: NO
Purpose
Instructs Export to estimate the space that a job would consume, without actually
performing the export operation.
If ESTIMATE_ONLY=YES, then Export estimates the space that would be consumed, but
quits without actually performing the export operation.
Restrictions
• The ESTIMATE_ONLY parameter cannot be used in conjunction with the QUERY
parameter.
Example
The following shows an example of using the ESTIMATE_ONLY parameter to determine
how much space an export of the HR schema will take.
2-30
Chapter 2
Parameters Available in Export's Command-Line Mode
2.4.18 EXCLUDE
Default: There is no default
Purpose
Enables you to filter the metadata that is exported by specifying objects and object
types to be excluded from the export operation.
The object_type specifies the type of object to be excluded. To see a list of valid
values for object_type, query the following views: DATABASE_EXPORT_OBJECTS for full
mode, SCHEMA_EXPORT_OBJECTS for schema mode, and TABLE_EXPORT_OBJECTS for table
and tablespace mode. The values listed in the OBJECT_PATH column are the valid object
types. (See "Metadata Filters" for an example of how to perform such a query.)
All object types for the given mode of export are included in the export except those
specified in an EXCLUDE statement. If an object is excluded, then all of its dependent
objects are also excluded. For example, excluding a table will also exclude all indexes
and triggers on the table.
The name_clause is optional. It allows selection of specific objects within an object type.
It is a SQL expression used as a filter on the type's object names. It consists of a SQL
operator and the values against which the object names of the specified type are to be
compared. The name_clause applies only to object types whose instances have names
(for example, it is applicable to TABLE, but not to GRANT). It must be separated from the
object type with a colon and enclosed in double quotation marks, because single
quotation marks are required to delimit the name strings. For example, you could set
EXCLUDE=INDEX:"LIKE 'EMP%'" to exclude all indexes whose names start with EMP.
The name that you supply for the name_clause must exactly match, including upper and
lower casing, an existing object in the database. For example, if the name_clause you
supply is for a table named EMPLOYEES, then there must be an existing table named
EMPLOYEES using all upper case. If the name_clause were supplied as Employees or
employees or any other variation, then the table would not be found.
If no name_clause is provided, then all objects of the specified type are excluded.
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
If the object_type you specify is CONSTRAINT, GRANT, or USER, then you should be aware of
the effects, as described in the following paragraphs.
Excluding Constraints
The following constraints cannot be explicitly excluded:
2-31
Chapter 2
Parameters Available in Export's Command-Line Mode
• Constraints needed for the table to be created and loaded successfully; for
example, primary key constraints for index-organized tables, or REF SCOPE and WITH
ROWID constraints for tables with REF columns
This means that the following EXCLUDE statements are interpreted as follows:
Note that in this situation, an export mode of FULL is specified. If no mode were
specified, then the default mode, SCHEMAS, would be used. This would cause an error
because the command would indicate that the schema should be both exported and
excluded at the same time.
If you try to exclude a user by using a statement such as EXCLUDE=USER:"='HR'", then
only the information used in CREATE USER hr DDL statements is excluded, and you may
not get the results you expect.
Restrictions
• The EXCLUDE and INCLUDE parameters are mutually exclusive.
Example
The following is an example of using the EXCLUDE statement.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_exclude.dmp EXCLUDE=VIEW,
PACKAGE, FUNCTION
This results in a schema-mode export (the default export mode) in which all of the hr
schema is exported except its views, packages, and functions.
See Also:
• "Filtering During Export Operations" for more information about the effects
of using the EXCLUDE parameter
• "INCLUDE" for an example of using a parameter file
• "Use of Quotation Marks On the Data Pump Command Line"
2-32
Chapter 2
Parameters Available in Export's Command-Line Mode
2.4.19 FILESIZE
Default: 0 (equivalent to the maximum size of 16 terabytes)
Purpose
Specifies the maximum size of each dump file. If the size is reached for any member
of the dump file set, then that file is closed and an attempt is made to create a new file,
if the file specification contains a substitution variable or if additional dump files have
been added to the job.
The integer can be immediately followed (do not insert a space) by B, KB, MB, GB, or TB
(indicating bytes, kilobytes, megabytes, gigabytes, and terabytes respectively). Bytes
is the default. The actual size of the resulting file may be rounded down slightly to
match the size of the internal blocks used in dump files.
Restrictions
• The minimum size for a file is ten times the default Data Pump block size, which is
4 kilobytes.
• The maximum size for a file is 16 terabytes.
Example
The following shows an example in which the size of the dump file is set to 3
megabytes:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_3m.dmp FILESIZE=3MB
If 3 megabytes had not been sufficient to hold all the exported data, then the following
error would have been displayed and the job would have stopped:
ORA-39095: Dump file space has been exhausted: Unable to allocate 217088 bytes
The actual number of bytes that could not be allocated may vary. Also, this number
does not represent the amount of space needed to complete the entire export
operation. It indicates only the size of the current object that was being exported when
the job ran out of dump file space.This situation can be corrected by first attaching to
the stopped job, adding one or more files using the ADD_FILE command, and then
restarting the operation.
2.4.20 FLASHBACK_SCN
Default: There is no default
Purpose
Specifies the system change number (SCN) that Export will use to enable the
Flashback Query utility.
2-33
Chapter 2
Parameters Available in Export's Command-Line Mode
The export operation is performed with data that is consistent up to the specified SCN.
If the NETWORK_LINK parameter is specified, then the SCN refers to the SCN of the
source database.
As of Oracle Database 12c release 2 (12.2), the SCN value can be a big SCN (8
bytes). You can also specify a big SCN when you create a dump file for an earlier
version that does not support big SCNs because actual SCN values are not moved.
See the following restrictions for more information about using big SCNs.
Restrictions
• FLASHBACK_SCN and FLASHBACK_TIME are mutually exclusive.
Example
The following example assumes that an existing SCN value of 384632 exists. It exports
the hr schema up to SCN 384632.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_scn.dmp FLASHBACK_SCN=384632
Note:
If you are on a logical standby system and using a network link to access the
logical standby primary, then the FLASHBACK_SCN parameter is ignored because
SCNs are selected by logical standby. See Oracle Data Guard Concepts and
Administration for information about logical standby databases.
2.4.21 FLASHBACK_TIME
Default: There is no default
Purpose
The SCN that most closely matches the specified time is found, and this SCN is used
to enable the Flashback utility. The export operation is performed with data that is
consistent up to this SCN.
Because the TO_TIMESTAMP value is enclosed in quotation marks, it would be best to put
this parameter in a parameter file. See "Use of Quotation Marks On the Data Pump
Command Line".
2-34
Chapter 2
Parameters Available in Export's Command-Line Mode
Alternatively, you could enter the following which would initiate a consistent export
based on current system time:
FLASHBACK_TIME=systimestamp
Restrictions
• FLASHBACK_TIME and FLASHBACK_SCN are mutually exclusive.
Example
You can specify the time in any format that the DBMS_FLASHBACK.ENABLE_AT_TIME
procedure accepts. For example, suppose you have a parameter file, flashback.par,
with the following contents:
DIRECTORY=dpump_dir1
DUMPFILE=hr_time.dmp
FLASHBACK_TIME="TO_TIMESTAMP('27-10-2012 13:16:00', 'DD-MM-YYYY HH24:MI:SS')"
The export operation will be performed with data that is consistent with the SCN that
most closely matches the specified time.
Note:
If you are on a logical standby system and using a network link to access the
logical standby primary, then the FLASHBACK_SCN parameter is ignored because
SCNs are selected by logical standby. See Oracle Data Guard Concepts and
Administration for information about logical standby databases.
See Also:
Oracle Database Development Guide for information about using Flashback
Query
2.4.22 FULL
Default: NO
Purpose
Specifies that you want to perform a full database mode export.
2-35
Chapter 2
Parameters Available in Export's Command-Line Mode
FULL=YES indicates that all data and metadata are to be exported. To perform a full
export, you must have the DATAPUMP_EXP_FULL_DATABASE role.
Filtering can restrict what is exported using this export mode. See "Filtering During
Export Operations".
You can perform a full mode export using the transportable option
(TRANSPORTABLE=ALWAYS). This is referred to as a full transportable export, which exports
all objects and data necessary to create a complete copy of the database. See "Using
the Transportable Option During Full Mode Exports".
Note:
Be aware that when you later import a dump file that was created by a full-
mode export, the import operation attempts to copy the password for the SYS
account from the source database. This sometimes fails (for example, if the
password is in a shared password file). If it does fail, then after the import
completes, you must set the password for the SYS account at the target
database to a password of your choice.
Restrictions
• To use the FULL parameter in conjunction with TRANSPORTABLE (a full transportable
export), either the Data Pump VERSION parameter must be set to at least 12.0. or
the COMPATIBLE database initialization parameter must be set to at least 12.0 or
later.
• A full export does not, by default, export system schemas that contain Oracle-
managed data and metadata. Examples of system schemas that are not exported
by default include SYS, ORDSYS, and MDSYS.
• Grants on objects owned by the SYS schema are never exported.
• A full export operation exports objects from only one database edition; by default it
exports the current edition but you can use the Export SOURCE_EDITION parameter to
specify a different edition.
• If you are exporting data that is protected by a realm, then you must have
authorization for that realm.
• The Automatic Workload Repository (AWR) is not moved in a full database export
and import operation. (See Oracle Database Performance Tuning Guide for
information about using Data Pump to move AWR snapshots.)
• The XDB repository is not moved in a full database export and import operation.
User created XML schemas are moved.
Example
The following is an example of using the FULL parameter. The dump file, expfull.dmp is
written to the dpump_dir2 directory.
> expdp hr DIRECTORY=dpump_dir2 DUMPFILE=expfull.dmp FULL=YES NOLOGFILE=YES
2-36
Chapter 2
Parameters Available in Export's Command-Line Mode
See Also:
2.4.23 HELP
Default: NO
Purpose
Displays online help for the Export utility.
Example
> expdp HELP = YES
This example will display a brief description of all Export parameters and commands.
2.4.24 INCLUDE
Default: There is no default
Purpose
Enables you to filter the metadata that is exported by specifying objects and object
types for the current export mode. The specified objects and all their dependent
objects are exported. Grants on these objects are also exported.
The object_type specifies the type of object to be included. To see a list of valid values
for object_type, query the following views: DATABASE_EXPORT_OBJECTS for full mode,
SCHEMA_EXPORT_OBJECTS for schema mode, and TABLE_EXPORT_OBJECTS for table and
tablespace mode. The values listed in the OBJECT_PATH column are the valid object
types. (See "Metadata Filters" for an example of how to perform such a query.)
Only object types explicitly specified in INCLUDE statements, and their dependent
objects, are exported. No other object types, including the schema definition
information that is normally part of a schema-mode export when you have the
DATAPUMP_EXP_FULL_DATABASE role, are exported.
2-37
Chapter 2
Parameters Available in Export's Command-Line Mode
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
See "Use of Quotation Marks On the Data Pump Command Line".
For example, suppose you have a parameter file named hr.par with the following
content:
SCHEMAS=HR
DUMPFILE=expinclude.dmp
DIRECTORY=dpump_dir1
LOGFILE=expinclude.log
INCLUDE=TABLE:"IN ('EMPLOYEES', 'DEPARTMENTS')"
INCLUDE=PROCEDURE
INCLUDE=INDEX:"LIKE 'EMP%'"
You could then use the hr.par file to start an export operation, without having to enter
any other parameters on the command line. The EMPLOYEES and DEPARTMENTS tables, all
procedures, and all index names with an EMP prefix will be included in the export.
> expdp hr PARFILE=hr.par
Including Constraints
If the object_type you specify is a CONSTRAINT, then you should be aware of the effects
this will have.
The following constraints cannot be explicitly included:
• NOT NULL constraints
• Constraints needed for the table to be created and loaded successfully; for
example, primary key constraints for index-organized tables, or REF SCOPE and WITH
ROWID constraints for tables with REF columns
This means that the following INCLUDE statements will be interpreted as follows:
• INCLUDE=CONSTRAINT will include all (nonreferential) constraints, except for NOT NULL
constraints and any constraints needed for successful table creation and loading
• INCLUDE=REF_CONSTRAINT will include referential integrity (foreign key) constraints
Restrictions
• The INCLUDE and EXCLUDE parameters are mutually exclusive.
2-38
Chapter 2
Parameters Available in Export's Command-Line Mode
Example
The following example performs an export of all tables (and their dependent objects) in
the hr schema:
> expdp hr INCLUDE=TABLE DUMPFILE=dpump_dir1:exp_inc.dmp NOLOGFILE=YES
2.4.25 JOB_NAME
Default: system-generated name of the form SYS_EXPORT_<mode>_NN
Purpose
Used to identify the export job in subsequent actions, such as when the ATTACH
parameter is used to attach to a job, or to identify the job using the DBA_DATAPUMP_JOBS
or USER_DATAPUMP_JOBS views.
The jobname_string specifies a name of up to 128 bytes for this export job. The bytes
must represent printable characters and spaces. If spaces are included, then the name
must be enclosed in single quotation marks (for example, 'Thursday Export'). The job
name is implicitly qualified by the schema of the user performing the export operation.
The job name is used as the name of the master table, which controls the export job.
The default job name is system-generated in the form SYS_EXPORT_<mode>_NN, where NN
expands to a 2-digit incrementing integer starting at 01. An example of a default name
is 'SYS_EXPORT_TABLESPACE_02'.
Example
The following example shows an export operation that is assigned a job name of
exp_job:
2.4.26 KEEP_MASTER
Default: NO
Purpose
Indicates whether the master table should be deleted or retained at the end of a Data
Pump job that completes successfully. The master table is automatically retained for
jobs that do not complete successfully.
2-39
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• None
Example
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr KEEP_MASTER=YES
2.4.27 LOGFILE
Default: export.log
Purpose
Specifies the name, and optionally, a directory, for the log file of the export job.
The file_name specifies a name for the log file. The default behavior is to create a file
named export.log in the directory referenced by the directory object specified in the
DIRECTORY parameter.
All messages regarding work in progress, work completed, and errors encountered are
written to the log file. (For a real-time status of the job, use the STATUS command in
interactive mode.)
A log file is always created for an export job unless the NOLOGFILE parameter is
specified. As with the dump file set, the log file is relative to the server and not the
client.
An existing file matching the file name will be overwritten.
Restrictions
• To perform a Data Pump Export using Oracle Automatic Storage Management
(Oracle ASM), you must specify a LOGFILE parameter that includes a directory
object that does not include the Oracle ASM + notation. That is, the log file must
be written to a disk file, and not written into the Oracle ASM storage. Alternatively,
you can specify NOLOGFILE=YES. However, this prevents the writing of the log file.
Example
The following example shows how to specify a log file name if you do not want to use
the default:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp LOGFILE=hr_export.log
2-40
Chapter 2
Parameters Available in Export's Command-Line Mode
Note:
Data Pump Export writes the log file using the database character set. If your
client NLS_LANG environment setting sets up a different client character set from
the database character set, then it is possible that table names may be different
in the log file than they are when displayed on the client output screen.
See Also:
• "STATUS"
• "Using Directory Objects When Oracle Automatic Storage Management Is
Enabled" for information about Oracle Automatic Storage Management and
directory objects
2.4.28 LOGTIME
Default: No timestamps are recorded
Purpose
Specifies that messages displayed during export operations be timestamped. You can
use the timestamps to figure out the elapsed time between different phases of a Data
Pump operation. Such information can be helpful in diagnosing performance problems
and estimating the timing of future similar operations.
Restrictions
• None
Example
The following example records timestamps for all status and log file messages that are
displayed during the export operation:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr LOGTIME=ALL
2-41
Chapter 2
Parameters Available in Export's Command-Line Mode
2.4.29 METRICS
Default: NO
Purpose
Indicates whether additional information about the job should be reported to the Data
Pump log file.
2-42
Chapter 2
Parameters Available in Export's Command-Line Mode
When METRICS=YES is used, the number of objects and the elapsed time are recorded in
the Data Pump log file.
Restrictions
• None
Example
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr METRICS=YES
2.4.30 NETWORK_LINK
Default: There is no default
Purpose
Enables an export from a (source) database identified by a valid database link. The
data from the source database instance is written to a dump file set on the connected
database instance.
The NETWORK_LINK parameter initiates an export using a database link. This means that
the system to which the expdp client is connected contacts the source database
referenced by the source_database_link, retrieves data from it, and writes the data to a
dump file set back on the connected system.
The source_database_link provided must be the name of a database link to an
available database. If the database on that instance does not already have a database
link, then you or your DBA must create one using the SQL CREATE DATABASE LINK
statement.
If the source database is read-only, then the user on the source database must have a
locally managed temporary tablespace assigned as the default temporary tablespace.
Otherwise, the job will fail.
The following types of database links are supported for use with Data Pump Export:
• Public fixed user
• Public connected user
• Public shared user (only when used by link owner)
• Private shared user (only when used by link owner)
• Private fixed user (only when used by link owner)
2-43
Chapter 2
Parameters Available in Export's Command-Line Mode
Caution:
If an export operation is performed over an unencrypted network link, then all
data is exported as clear text even if it is encrypted in the database. See Oracle
Database Security Guide for more information about network security.
Restrictions
• The following types of database links are not supported for use with Data Pump
Export:
– Private connected user
– Current user
• When operating across a network link, Data Pump requires that the source and
target databases differ by no more than two versions. For example, if one
database is Oracle Database 12c, then the other database must be 12c, 11g, or
10g. Note that Data Pump checks only the major version number (for example,
10g,11g, 12c), not specific release numbers (for example, 12.1, 12.2, 11.1, 11.2,
10.1 or 10.2).
Example
The following is an example of using the NETWORK_LINK parameter. The
source_database_link would be replaced with the name of a valid database link that
must already exist.
> expdp hr DIRECTORY=dpump_dir1 NETWORK_LINK=source_database_link
DUMPFILE=network_export.dmp LOGFILE=network_export.log
See Also:
2.4.31 NOLOGFILE
Default: NO
Purpose
Specifies whether to suppress creation of a log file.
2-44
Chapter 2
Parameters Available in Export's Command-Line Mode
Specify NOLOGFILE =YES to suppress the default behavior of creating a log file. Progress
and error information is still written to the standard output device of any attached
clients, including the client that started the original export operation. If there are no
clients attached to a running job and you specify NOLOGFILE=YES, then you run the risk of
losing important progress and error information.
Example
The following is an example of using the NOLOGFILE parameter:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp NOLOGFILE=YES
This command results in a schema-mode export (the default) in which no log file is
written.
2.4.32 PARALLEL
Default: 1
Purpose
Specifies the maximum number of processes of active execution operating on behalf
of the export job. This execution set consists of a combination of worker processes
and parallel I/O server processes. The master control process and worker processes
acting as query coordinators in parallel query operations do not count toward this total.
This parameter enables you to make trade-offs between resource consumption and
elapsed time.
The value you specify for integer should be less than, or equal to, the number of files
in the dump file set (or you should specify either the %U or %L substitution variables in
the dump file specifications). Because each active worker process or I/O server
process writes exclusively to one file at a time, an insufficient number of files can have
adverse effects. Some of the worker processes will be idle while waiting for files,
thereby degrading the overall performance of the job. More importantly, if any member
of a cooperating group of parallel I/O server processes cannot obtain a file for output,
then the export operation will be stopped with an ORA-39095 error. Both situations can
be corrected by attaching to the job using the Data Pump Export utility, adding more
files using the ADD_FILE command while in interactive mode, and in the case of a
stopped job, restarting the job.
To increase or decrease the value of PARALLEL during job execution, use interactive-
command mode. Decreasing parallelism does not result in fewer worker processes
associated with the job; it decreases the number of worker processes that will be
executing at any given time. Also, any ongoing work must reach an orderly completion
point before the decrease takes effect. Therefore, it may take a while to see any effect
from decreasing the value. Idle workers are not deleted until the job exits.
Increasing the parallelism takes effect immediately if there is work that can be
performed in parallel.
2-45
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
• To export a table or table partition in parallel (using PQ slaves), you must have the
DATAPUMP_EXP_FULL_DATABASE role.
Example
The following is an example of using the PARALLEL parameter:
> expdp hr DIRECTORY=dpump_dir1 LOGFILE=parallel_export.log
JOB_NAME=par4_job DUMPFILE=par_exp%u.dmp PARALLEL=4
See Also:
2.4.33 PARFILE
Default: There is no default
Purpose
Specifies the name of an export parameter file.
A parameter file allows you to specify Data Pump parameters within a file, and then
that file can be specified on the command line instead of entering all the individual
2-46
Chapter 2
Parameters Available in Export's Command-Line Mode
commands. This can be useful if you use the same parameter combination many
times. The use of parameter files is also highly recommended if you are using
parameters whose values require the use of quotation marks.
A directory object is not specified for the parameter file because unlike dump files, log
files, and SQL files which are created and written by the server, the parameter file is
opened and read by the expdp client. The default location of the parameter file is the
user's current directory.
Within a parameter file, a comma is implicit at every newline character so you do not
have to enter commas at the end of each line. If you have a long line that wraps, such
as a long table name, enter the backslash continuation character (\) at the end of the
current line to continue onto the next line.
The contents of the parameter file are written to the Data Pump log file.
Restrictions
• The PARFILE parameter cannot be specified within a parameter file.
Example
The content of an example parameter file, hr.par, might be as follows:
SCHEMAS=HR
DUMPFILE=exp.dmp
DIRECTORY=dpump_dir1
LOGFILE=exp.log
You could then issue the following Export command to specify the parameter file:
> expdp hr PARFILE=hr.par
See Also:
"Use of Quotation Marks On the Data Pump Command Line"
2.4.34 QUERY
Default: There is no default
Purpose
Allows you to specify a query clause that is used to filter the data that gets exported.
The query_clause is typically a SQL WHERE clause for fine-grained row selection, but
could be any SQL clause. For example, an ORDER BY clause could be used to speed up
a migration from a heap-organized table to an index-organized table. If a schema and
table name are not supplied, then the query is applied to (and must be valid for) all
tables in the export job. A table-specific query overrides a query applied to all tables.
2-47
Chapter 2
Parameters Available in Export's Command-Line Mode
When the query is to be applied to a specific table, a colon must separate the table
name from the query clause. More than one table-specific query can be specified, but
only one query can be specified per table.
If the NETWORK_LINK parameter is specified along with the QUERY parameter, then any
objects specified in the query_clause that are on the remote (source) node must be
explicitly qualified with the NETWORK_LINK value. Otherwise, Data Pump assumes that
the object is on the local (target) node; if it is not, then an error is returned and the
import of the table from the remote (source) system fails.
For example, if you specify NETWORK_LINK=dblink1, then the query_clause of the QUERY
parameter must specify that link, as shown in the following example:
QUERY=(hr.employees:"WHERE last_name IN(SELECT last_name
FROM hr.employees@dblink1)")
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
See "Use of Quotation Marks On the Data Pump Command Line".
To specify a schema other than your own in a table-specific query, you must be
granted access to that specific table.
Restrictions
• The QUERY parameter cannot be used with the following parameters:
– CONTENT=METADATA_ONLY
– ESTIMATE_ONLY
– TRANSPORT_TABLESPACES
• When the QUERY parameter is specified for a table, Data Pump uses external tables
to unload the target table. External tables uses a SQL CREATE TABLE AS SELECT
statement. The value of the QUERY parameter is the WHERE clause in the SELECT
portion of the CREATE TABLE statement. If the QUERY parameter includes references
to another table with columns whose names match the table being unloaded, and
if those columns are used in the query, then you will need to use a table alias to
distinguish between columns in the table being unloaded and columns in the
SELECT statement with the same name. The table alias used by Data Pump for the
table being unloaded is KU$.
For example, suppose you want to export a subset of the sh.sales table based on
the credit limit for a customer in the sh.customers table. In the following example,
KU$ is used to qualify the cust_id field in the QUERY parameter for unloading
sh.sales. As a result, Data Pump exports only rows for customers whose credit
limit is greater than $10,000.
QUERY='sales:"WHERE EXISTS (SELECT cust_id FROM customers c
WHERE cust_credit_limit > 10000 AND ku$.cust_id = c.cust_id)"'
If, as in the following query, KU$ is not used for a table alias, then the result will be
that all rows are unloaded:
QUERY='sales:"WHERE EXISTS (SELECT cust_id FROM customers c
WHERE cust_credit_limit > 10000 AND cust_id = c.cust_id)"'
2-48
Chapter 2
Parameters Available in Export's Command-Line Mode
• The maximum length allowed for a QUERY string is 4000 bytes including quotation
marks, which means that the actual maximum length allowed is 3998 bytes.
Example
The following is an example of using the QUERY parameter:
> expdp hr PARFILE=emp_query.par
This example unloads all tables in the hr schema, but only the rows that fit the query
expression. In this case, all rows in all tables (except employees) in the hr schema will
be unloaded. For the employees table, only rows that meet the query criteria are
unloaded.
2.4.35 REMAP_DATA
Default: There is no default
Purpose
The REMAP_DATA parameter allows you to specify a remap function that takes as a
source the original value of the designated column and returns a remapped value that
will replace the original value in the dump file. A common use for this option is to mask
data when moving from a production system to a test system. For example, a column
of sensitive customer data such as credit card numbers could be replaced with
numbers generated by a REMAP_DATA function. This would allow the data to retain its
essential formatting and processing characteristics without exposing private data to
unauthorized personnel.
The same function can be applied to multiple columns being dumped. This is useful
when you want to guarantee consistency in remapping both the child and parent
column in a referential constraint.
The description of each syntax element, in the order in which they appear in the
syntax, is as follows:
schema: the schema containing the table to be remapped. By default, this is the
schema of the user doing the export.
tablename : the table whose column will be remapped.
column_name: the column whose data is to be remapped.
schema : the schema containing the PL/SQL package you have created that contains
the remapping function. As a default, this is the schema of the user doing the export.
pkg: the name of the PL/SQL package you have created that contains the remapping
function.
2-49
Chapter 2
Parameters Available in Export's Command-Line Mode
function: the name of the function within the PL/SQL that will be called to remap the
column table in each row of the specified table.
Restrictions
• The data types of the source argument and the returned value should both match
the data type of the designated column in the table.
• Remapping functions should not perform commits or rollbacks except in
autonomous transactions.
• The use of synonyms as values for the REMAP_DATA parameter is not supported. For
example, if the regions table in the hr schema had a synonym of regn, an error
would be returned if you specified regn as part of the REMPA_DATA specification.
• Remapping LOB column data of a remote table is not supported.
• Columns of the following types are not supported byREMAP_DATA: User Defined
Types, attributes of User Defined Types, LONGs, REFs, VARRAYs, Nested
Tables, BFILEs, and XMLtype.
Example
The following example assumes a package named remap has been created that
contains functions named minus10 and plusx which change the values for employee_id
and first_name in the employees table.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=remap1.dmp TABLES=employees
REMAP_DATA=hr.employees.employee_id:hr.remap.minus10
REMAP_DATA=hr.employees.first_name:hr.remap.plusx
2.4.36 REUSE_DUMPFILES
Default: NO
Purpose
Specifies whether to overwrite a preexisting dump file.
Normally, Data Pump Export will return an error if you specify a dump file name that
already exists. The REUSE_DUMPFILES parameter allows you to override that behavior
and reuse a dump file name. For example, if you performed an export and specified
DUMPFILE=hr.dmp and REUSE_DUMPFILES=YES, then hr.dmp would be overwritten if it already
existed. Its previous contents would be lost and it would contain data for the current
export instead.
Example
The following export operation creates a dump file named enc1.dmp, even if a dump file
with that name already exists.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=enc1.dmp
TABLES=employees REUSE_DUMPFILES=YES
2-50
Chapter 2
Parameters Available in Export's Command-Line Mode
2.4.37 SAMPLE
Default: There is no default
Purpose
Allows you to specify a percentage of the data rows to be sampled and unloaded from
the source database.
This parameter allows you to export subsets of data by specifying the percentage of
data to be sampled and exported. The sample_percent indicates the probability that a
row will be selected as part of the sample. It does not mean that the database will
retrieve exactly that amount of rows from the table. The value you supply for
sample_percent can be anywhere from .000001 up to, but not including, 100.
The sample_percent can be applied to specific tables. In the following example, 50% of
the HR.EMPLOYEES table will be exported:
SAMPLE="HR"."EMPLOYEES":50
If you specify a schema, then you must also specify a table. However, you can specify
a table without specifying a schema; the current user will be assumed. If no table is
specified, then the sample_percent value applies to the entire export job.
You can use this parameter with the Data Pump Import PCTSPACE transform, so that the
size of storage allocations matches the sampled data subset. (See the Import
"TRANSFORM" parameter.)
Restrictions
• The SAMPLE parameter is not valid for network exports.
Example
In the following example, the value 70 for SAMPLE is applied to the entire export job
because no table name is specified.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=sample.dmp SAMPLE=70
2.4.38 SCHEMAS
Default: current user's schema
Purpose
Specifies that you want to perform a schema-mode export. This is the default mode for
Export.
2-51
Chapter 2
Parameters Available in Export's Command-Line Mode
If you have the DATAPUMP_EXP_FULL_DATABASE role, then you can specify a single schema
other than your own or a list of schema names. The DATAPUMP_EXP_FULL_DATABASE role
also allows you to export additional nonschema object information for each specified
schema so that the schemas can be re-created at import time. This additional
information includes the user definitions themselves and all associated system and
role grants, user password history, and so on. Filtering can further restrict what is
exported using schema mode (see "Filtering During Export Operations").
Restrictions
• If you do not have the DATAPUMP_EXP_FULL_DATABASE role, then you can specify only
your own schema.
• The SYS schema cannot be used as a source schema for export jobs.
Example
The following is an example of using the SCHEMAS parameter. Note that user hr is
allowed to specify more than one schema because the DATAPUMP_EXP_FULL_DATABASE
role was previously assigned to it for the purpose of these examples.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr,sh,oe
This results in a schema-mode export in which the schemas, hr, sh, and oe will be
written to the expdat.dmp dump file located in the dpump_dir1 directory.
2.4.39 SERVICE_NAME
Default: There is no default
Purpose
Used to specify a service name to be used in conjunction with the CLUSTER parameter.
The SERVICE_NAME parameter can be used with the CLUSTER=YES parameter to specify an
existing service associated with a resource group that defines a set of Oracle Real
Application Clusters (Oracle RAC) instances belonging to that resource group,
typically a subset of all the Oracle RAC instances.
The service name is only used to determine the resource group and instances defined
for that resource group. The instance where the job is started is always used,
regardless of whether it is part of the resource group.
The SERVICE_NAME parameter is ignored if CLUSTER=NO is also specified.
2-52
Chapter 2
Parameters Available in Export's Command-Line Mode
• If you start a Data Pump job on instance A and specify CLUSTER=YES and
SERVICE_NAME=my_service, then workers can be started on instances A, B, and C
only.
• If you start a Data Pump job on instance D and specify CLUSTER=YES and
SERVICE_NAME=my_service, then workers can be started on instances A, B, C, and D.
Even though instance D is not in my_service it is included because it is the instance
on which the job was started.
• If you start a Data Pump job on instance A and specify CLUSTER=NO, then any
SERVICE_NAME parameter you specify is ignored and all processes will start on
instance A.
Example
The following is an example of using the SERVICE_NAME parameter:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr_svname2.dmp SERVICE_NAME=sales
This example starts a schema-mode export (the default mode) of the hr schema. Even
though CLUSTER=YES is not specified on the command line, it is the default behavior, so
the job will use all instances in the resource group associated with the service name
sales. A dump file named hr_svname2.dmp will be written to the location specified by the
dpump_dir1 directory object.
See Also:
"CLUSTER"
2.4.40 SOURCE_EDITION
Default: the default database edition on the system
Purpose
Specifies the database edition from which objects will be exported.
Restrictions
• This parameter is only useful if there are two or more versions of the same
versionable objects in the database.
• The job version must be 11.2 or later. See "VERSION".
2-53
Chapter 2
Parameters Available in Export's Command-Line Mode
Example
The following is an example of using the SOURCE_EDITION parameter:
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=exp_dat.dmp SOURCE_EDITION=exp_edition
EXCLUDE=USER
This example assumes the existence of an edition named exp_edition on the system
from which objects are being exported. Because no export mode is specified, the
default of schema mode will be used. The EXCLUDE=user parameter excludes only the
definitions of users, not the objects contained within users' schemas.
See Also:
2.4.41 STATUS
Default: 0
Purpose
Specifies the frequency at which the job status display is updated.
If you supply a value for integer, it specifies how frequently, in seconds, job status
should be displayed in logging mode. If no value is entered or if the default value of 0
is used, then no additional information is displayed beyond information about the
completion of each object type, table, or partition.
This status information is written only to your standard output device, not to the log file
(if one is in effect).
Example
The following is an example of using the STATUS parameter.
> expdp hr DIRECTORY=dpump_dir1 SCHEMAS=hr,sh STATUS=300
This example will export the hr and sh schemas and display the status of the export
every 5 minutes (60 seconds x 5 = 300 seconds).
2.4.42 TABLES
Default: There is no default
2-54
Chapter 2
Parameters Available in Export's Command-Line Mode
Purpose
Specifies that you want to perform a table-mode export.
Filtering can restrict what is exported using this mode (see "Filtering During Export
Operations"). You can filter the data and metadata that is exported, by specifying a
comma-delimited list of tables and partitions or subpartitions. If a partition name is
specified, then it must be the name of a partition or subpartition in the associated
table. Only the specified set of tables, partitions, and their dependent objects are
unloaded.
If an entire partitioned table is exported, then it will be imported in its entirety, as a
partitioned table. The only case in which this is not true is if
PARTITION_OPTIONS=DEPARTITION is specified during import.
The table name that you specify can be preceded by a qualifying schema name. The
schema defaults to that of the current user. To specify a schema other than your own,
you must have the DATAPUMP_EXP_FULL_DATABASE role.
Use of the wildcard character, %, to specify table names and partition names is
supported.
The following restrictions apply to table names:
• By default, table names in a database are stored as uppercase. If you have a table
name in mixed-case or lowercase, and you want to preserve case-sensitivity for
the table name, then you must enclose the name in quotation marks. The name
must exactly match the table name stored in the database.
Some operating systems require that quotation marks on the command line be
preceded by an escape character. The following are examples of how case-
sensitivity can be preserved in the different Export modes.
– In command-line mode:
TABLES='\"Emp\"'
However, if the parameter file contains the following line, then the Export utility
exports all three tables because emp# is enclosed in quotation marks:
2-55
Chapter 2
Parameters Available in Export's Command-Line Mode
Note:
Some operating systems require single quotation marks rather than double
quotation marks, or the reverse. See your Oracle operating system-specific
documentation. Different operating systems also have other restrictions on
table naming.
For example, the UNIX C shell attaches a special meaning to a dollar sign
($) or pound sign (#) (or certain other special characters). You must use
escape characters to get such characters in the name past the shell and
into Export.
Restrictions
• Cross-schema references are not exported. For example, a trigger defined on a
table within one of the specified schemas, but that resides in a schema not
explicitly specified, is not exported.
• Types used by the table are not exported in table mode. This means that if you
subsequently import the dump file and the type does not already exist in the
destination database, then the table creation will fail.
• The use of synonyms as values for the TABLES parameter is not supported. For
example, if the regions table in the hr schema had a synonym of regn, then it
would not be valid to use TABLES=regn. An error would be returned.
• The export of tables that include a wildcard character, %, in the table name is not
supported if the table has partitions.
• The length of the table name list specified for the TABLES parameter is limited to a
maximum of 4 MB, unless you are using the NETWORK_LINK parameter to an Oracle
Database release 10.2.0.3 or earlier or to a read-only database. In such cases, the
limit is 4 KB.
• You can only specify partitions from one table if TRANSPORTABLE=ALWAYS is also set
on the export.
Examples
The following example shows a simple use of the TABLES parameter to export three
tables found in the hr schema: employees, jobs, and departments. Because user hr is
exporting tables found in the hr schema, the schema name is not needed before the
table names.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=tables.dmp
TABLES=employees,jobs,departments
2-56
Chapter 2
Parameters Available in Export's Command-Line Mode
The following example assumes that user hr has the DATAPUMP_EXP_FULL_DATABASE role.
It shows the use of the TABLES parameter to export partitions.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=tables_part.dmp
TABLES=sh.sales:sales_Q1_2012,sh.sales:sales_Q2_2012
This example exports the partitions, sales_Q1_2012 and sales_Q2_2012, from the table
sales in the schema sh.
See Also:
• "TRANSPORTABLE"
• The Import "REMAP_TABLE" command
• "Using Data File Copying to Move Data"
2.4.43 TABLESPACES
Default: There is no default
Purpose
Specifies a list of tablespace names to be exported in tablespace mode.
In tablespace mode, only the tables contained in a specified set of tablespaces are
unloaded. If a table is unloaded, then its dependent objects are also unloaded. Both
object metadata and data are unloaded. If any part of a table resides in the specified
set, then that table and all of its dependent objects are exported. Privileged users get
all tables. Unprivileged users get only the tables in their own schemas
Filtering can restrict what is exported using this mode (see "Filtering During Export
Operations").
Restrictions
• The length of the tablespace name list specified for the TABLESPACES parameter is
limited to a maximum of 4 MB, unless you are using the NETWORK_LINK to an Oracle
Database release 10.2.0.3 or earlier or to a read-only database. In such cases, the
limit is 4 KB.
Example
The following is an example of using the TABLESPACES parameter. The example
assumes that tablespaces tbs_4, tbs_5, and tbs_6 already exist.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=tbs.dmp
TABLESPACES=tbs_4, tbs_5, tbs_6
This results in a tablespace export in which tables (and their dependent objects) from
the specified tablespaces (tbs_4, tbs_5, and tbs_6) will be unloaded.
2-57
Chapter 2
Parameters Available in Export's Command-Line Mode
2.4.44 TRANSPORT_FULL_CHECK
Default: NO
Purpose
Specifies whether to check for dependencies between those objects inside the
transportable set and those outside the transportable set. This parameter is applicable
only to a transportable-tablespace mode export.
Example
The following is an example of using the TRANSPORT_FULL_CHECK parameter. It assumes
that tablespace tbs_1 exists.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=tts.dmp
TRANSPORT_TABLESPACES=tbs_1 TRANSPORT_FULL_CHECK=YES LOGFILE=tts.log
2.4.45 TRANSPORT_TABLESPACES
Default: There is no default
Purpose
Specifies that you want to perform an export in transportable-tablespace mode.
2-58
Chapter 2
Parameters Available in Export's Command-Line Mode
The log file for the export lists the data files that are used in the transportable set, the
dump files, and any containment violations.
The TRANSPORT_TABLESPACES parameter exports metadata for all objects within the
specified tablespaces. To perform a transportable export of only certain tables,
partitions, or subpartitions, then you must use the TABLES parameter with the
TRANSPORTABLE=ALWAYS parameter.
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
Restrictions
• Transportable tablespace jobs are not restartable.
• Transportable tablespace jobs are restricted to a degree of parallelism of 1.
• Transportable tablespace mode requires that you have the
DATAPUMP_EXP_FULL_DATABASE role.
• The default tablespace of the user performing the export must not be set to one of
the tablespaces being transported.
• The SYSTEM and SYSAUX tablespaces are not transportable in transportable
tablespace mode.
• All tablespaces in the transportable set must be set to read-only.
• If the Data Pump Export VERSION parameter is specified along with the
TRANSPORT_TABLESPACES parameter, then the version must be equal to or greater
than the Oracle Database COMPATIBLE initialization parameter.
• The TRANSPORT_TABLESPACES parameter cannot be used in conjunction with the QUERY
parameter.
Example
The following is an example of using the TRANSPORT_TABLESPACES parameter in a file-
based job (rather than network-based). The tablespace tbs_1 is the tablespace being
moved. This example assumes that tablespace tbs_1 exists and that it has been set to
read-only. This example also assumes that the default tablespace was changed before
this export command was issued.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=tts.dmp
TRANSPORT_TABLESPACES=tbs_1 TRANSPORT_FULL_CHECK=YES LOGFILE=tts.log
2-59
Chapter 2
Parameters Available in Export's Command-Line Mode
See Also:
2.4.46 TRANSPORTABLE
Default: NEVER
Purpose
Specifies whether the transportable option should be used during a table mode export
(specified with the TABLES parameter) or a full mode export (specified with the FULL
parameter).
Note:
To export an entire tablespace in transportable mode, use the
TRANSPORT_TABLESPACES parameter.
2-60
Chapter 2
Parameters Available in Export's Command-Line Mode
– If PARTITION_OPTIONS is not used, then the complete table is created. That is, all
the metadata for the complete table is present so that the table definition looks
the same on the target system as it did on the source. But only the data that
was exported for the specified partitions is inserted into the table.
Restrictions
• The TRANSPORTABLE parameter is only valid in table mode exports and full mode
exports.
• To use the TRANSPORTABLE parameter, the COMPATIBLE initialization parameter must
be set to at least 11.0.0.
• To use the FULL parameter in conjunction with TRANSPORTABLE (to perform a full
transportable export), the Data Pump VERSION parameter must be set to at least
12.0. If the VERSION parameter is not specified, then the COMPATIBLE database
initialization parameter must be set to at least 12.0 or later.
• The user performing a transportable export requires the
DATAPUMP_EXP_FULL_DATABASE privilege.
Example
The following example assumes that the sh user has the DATAPUMP_EXP_FULL_DATABASE
role and that table sales2 is partitioned and contained within tablespace tbs2. (The
tbs2 tablespace must be set to read-only in the source database.)
After the export completes successfully, you must copy the data files to the target
database area. You could then perform an import operation using the
PARTITION_OPTIONS and REMAP_SCHEMA parameters to make each of the partitions in
sales2 its own table.
2-61
Chapter 2
Parameters Available in Export's Command-Line Mode
See Also:
2.4.47 VERSION
Default: COMPATIBLE
Purpose
Specifies the version of database objects to be exported. Only database objects and
attributes that are compatible with the specified release will be exported. This can be
used to create a dump file set that is compatible with a previous release of Oracle
Database. Note that this does not mean that Data Pump Export can be used with
releases of Oracle Database prior to Oracle Database 10g release 1 (10.1). Data
Pump Export only works with Oracle Database 10g release 1 (10.1) or later. The
VERSION parameter simply allows you to identify the version of objects being exported.
On Oracle Database 11g release 2 (11.2.0.3) or later, the VERSION parameter can be
specified as VERSION=12 in conjunction with FULL=Y to generate a full export dump file
that is ready for import into Oracle Database 12c. The export will include information
from registered database options and components. (This dump file set can only be
imported into Oracle Database 12c Release 1 (12.1.0.1) and later.) If VERSION=12 is
used in conjunction with FULL=Y and also with TRANSPORTABLE=ALWAYS, then a full
transportable export dump file is generated that is ready for import into Oracle
Database 12c. (See "Using the Transportable Option During Full Mode Exports".)
• COMPATIBLE - This is the default value. The version of the metadata corresponds to
the database compatibility level as specified on the COMPATIBLE initialization
parameter. Database compatibility must be set to 9.2 or later.
• LATEST - The version of the metadata and resulting SQL DDL corresponds to the
database release regardless of its compatibility level.
• version_string - A specific database release (for example, 11.2.0). In Oracle
Database 11g, this value cannot be lower than 9.2.
Database objects or attributes that are incompatible with the release specified for
VERSION will not be exported. For example, tables containing new data types that are
not supported in the specified release will not be exported.
Restrictions
• Exporting a table with archived LOBs to a database release earlier than 11.2 is not
allowed.
2-62
Chapter 2
Parameters Available in Export's Command-Line Mode
• If the Data Pump Export VERSION parameter is specified along with the
TRANSPORT_TABLESPACES parameter, then the value must be equal to or greater than
the Oracle Database COMPATIBLE initialization parameter.
• If the Data Pump VERSION parameter is specified as any value earlier than 12.1,
then the Data Pump dump file excludes any tables that contain VARCHAR2 or
NVARCHAR2 columns longer than 4000 bytes and any RAW columns longer than 2000
bytes.
• Dump files created on Oracle Database 11g releases with the Data Pump
parameter VERSION=12 can only be imported on Oracle Database 12c Release 1
(12.1) and later.
Example
The following example shows an export for which the version of the metadata will
correspond to the database release:
> expdp hr TABLES=hr.employees VERSION=LATEST DIRECTORY=dpump_dir1
DUMPFILE=emp.dmp NOLOGFILE=YES
See Also:
"Exporting and Importing Between Different Database Releases"
2.4.48 VIEWS_AS_TABLES
Default: There is no default
Caution:
The VIEWS_AS_TABLES parameter unloads view data in unencrypted format and
creates an unencrypted table. If you are unloading sensitive data, then Oracle
strongly recommends that you enable encryption on the export operation and
that you ensure the table is created in an encrypted tablespace. You can use
the REMAP_TABLESPACE parameter to move the table to such a tablespace.
Purpose
Specifies that one or more views are to be exported as tables.
Data Pump exports a table with the same columns as the view and with row data
fetched from the view. Data Pump also exports objects dependent on the view, such
as grants and constraints. Dependent objects that do not apply to tables (for example,
grants of the UNDER object privilege) are not exported. The VIEWS_AS_TABLES parameter
can be used by itself or along with the TABLES parameter. If either is used, Data Pump
performs a table-mode export.
2-63
Chapter 2
Parameters Available in Export's Command-Line Mode
Restrictions
• The VIEWS_AS_TABLES parameter cannot be used with the TRANSPORTABLE=ALWAYS
parameter.
• Tables created using the VIEWS_AS_TABLES parameter do not contain any hidden
columns that were part of the specified view.
• The VIEWS_AS_TABLES parameter does not support tables that have columns with a
data type of LONG.
Example
The following example exports the contents of view scott.view1 to a dump file named
scott1.dmp.
The dump file will contain a table named view1 with rows fetched from the view.
2-64
Chapter 2
Commands Available in Export's Interactive-Command Mode
• ADD_FILE
• CONTINUE_CLIENT
• EXIT_CLIENT
• FILESIZE
• HELP
• KILL_JOB
• PARALLEL
• START_JOB
2-65
Chapter 2
Commands Available in Export's Interactive-Command Mode
• STATUS
• STOP_JOB
2.5.1 ADD_FILE
Purpose
Adds additional files or substitution variables to the export dump file set.
Each file name can have a different directory object. If no directory object is specified,
then the default is assumed.
The file_name must not contain any directory path information. However, it can include
a substitution variable, %U, which indicates that multiple files may be generated using
the specified file name as a template.
The size of the file being added is determined by the setting of the FILESIZE parameter.
Example
The following example adds two dump files to the dump file set. A directory object is
not specified for the dump file named hr2.dmp, so the default directory object for the job
is assumed. A different directory object, dpump_dir2, is specified for the dump file
named hr3.dmp.
Export> ADD_FILE=hr2.dmp, dpump_dir2:hr3.dmp
See Also:
"File Allocation" for information about the effects of using substitution variables
2.5.2 CONTINUE_CLIENT
Purpose
Changes the Export mode from interactive-command mode to logging mode.
In logging mode, status is continually output to the terminal. If the job is currently
stopped, then CONTINUE_CLIENT will also cause the client to attempt to start the job.
Example
Export> CONTINUE_CLIENT
2-66
Chapter 2
Commands Available in Export's Interactive-Command Mode
2.5.3 EXIT_CLIENT
Purpose
Stops the export client session, exits Export, and discontinues logging to the terminal,
but leaves the current job running.
Because EXIT_CLIENT leaves the job running, you can attach to the job at a later time.
To see the status of the job, you can monitor the log file for the job or you can query
the USER_DATAPUMP_JOBS view or the V$SESSION_LONGOPS view.
Example
Export> EXIT_CLIENT
2.5.4 FILESIZE
Purpose
Redefines the maximum size of subsequent dump files. If the size is reached for any
member of the dump file set, then that file is closed and an attempt is made to create a
new file, if the file specification contains a substitution variable or if additional dump
files have been added to the job.
The integer can be immediately followed (do not insert a space) by B, KB, MB, GB, or TB
(indicating bytes, kilobytes, megabytes, gigabytes, and terabytes respectively). Bytes
is the default. The actual size of the resulting file may be rounded down slightly to
match the size of the internal blocks used in dump files.
A file size of 0 is equivalent to the maximum file size of 16 TB.
Restrictions
• The minimum size for a file is ten times the default Data Pump block size, which is
4 kilobytes.
• The maximum size for a file is 16 terabytes.
Example
Export> FILESIZE=100MB
2.5.5 HELP
Purpose
Provides information about Data Pump Export commands available in interactive-
command mode.
2-67
Chapter 2
Commands Available in Export's Interactive-Command Mode
Example
Export> HELP
2.5.6 KILL_JOB
Purpose
Detaches all currently attached client sessions and then terminates the current job. It
exits Export and returns to the terminal prompt.
A job that is terminated using KILL_JOB cannot be restarted. All attached clients,
including the one issuing the KILL_JOB command, receive a warning that the job is
being terminated by the current user and are then detached. After all clients are
detached, the job's process structure is immediately run down and the master table
and dump files are deleted. Log files are not deleted.
Example
Export> KILL_JOB
2.5.7 PARALLEL
Purpose
Enables you to increase or decrease the number of active processes (worker and
parallel slaves) for the current job.
Restrictions
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
Example
Export> PARALLEL=10
2-68
Chapter 2
Commands Available in Export's Interactive-Command Mode
See Also:
"PARALLEL" for more information about parallelism
2.5.8 START_JOB
Purpose
Starts the current job to which you are attached.
The START_JOB command restarts the current job to which you are attached (the job
cannot be currently executing). The job is restarted with no data loss or corruption
after an unexpected failure or after you issued a STOP_JOB command, provided the
dump file set and master table have not been altered in any way.
Exports done in transportable-tablespace mode are not restartable.
Example
Export> START_JOB
2.5.9 STATUS
Purpose
Displays cumulative status of the job, a description of the current operation, and an
estimated completion percentage. It also allows you to reset the display interval for
logging mode status.
You have the option of specifying how frequently, in seconds, this status should be
displayed in logging mode. If no value is entered or if the default value of 0 is used,
then the periodic status display is turned off and status is displayed only once.
This status information is written only to your standard output device, not to the log file
(even if one is in effect).
Example
The following example will display the current job status and change the logging mode
display interval to five minutes (300 seconds):
Export> STATUS=300
2-69
Chapter 2
Examples of Using Data Pump Export
2.5.10 STOP_JOB
Purpose
Stops the current job either immediately or after an orderly shutdown, and exits Export.
If the master table and dump file set are not disturbed when or after the STOP_JOB
command is issued, then the job can be attached to and restarted at a later time with
the START_JOB command.
Example
Export> STOP_JOB=IMMEDIATE
2-70
Chapter 2
Examples of Using Data Pump Export
Example 2-1 shows the Data Pump export command to perform a table export of the
tables employees and jobs from the human resources (hr) schema.
Because user hr is exporting tables in his own schema, it is not necessary to specify
the schema name for the tables. The NOLOGFILE=YES parameter indicates that an Export
log file of the operation will not be generated.
Example 2-1 Performing a Table-Mode Export
expdp hr TABLES=employees,jobs DUMPFILE=dpump_dir1:table.dmp NOLOGFILE=YES
You can issue the following command to execute the exp.par parameter file:
> expdp hr PARFILE=exp.par
A schema-mode export (the default mode) is performed, but the CONTENT parameter
effectively limits the export to an unload of just the table's data. The DBA previously
created the directory object dpump_dir1 which points to the directory on the server
where user hr is authorized to read and write export dump files. The dump file
dataonly.dmp is created in dpump_dir1.
The estimate is printed in the log file and displayed on the client's standard output
device. The estimate is for table row data only; it does not include metadata.
2-71
Chapter 2
Examples of Using Data Pump Export
Because this is a full database export, all data and metadata in the database will be
exported. Dump files full101.dmp, full201.dmp, full102.dmp, and so on will be created in
a round-robin fashion in the directories pointed to by the dpump_dir1 and dpump_dir2
directory objects. For best performance, these should be on separate I/O channels.
Each file will be up to 2 gigabytes in size, as necessary. Initially, up to three files will
be created. More files will be created, if needed. The job and master table will have a
name of expfull. The log file will be written to expfull.log in the dpump_dir1 directory.
A message is displayed that the job has been reopened, and processing status is
output to the client.
2-72
Chapter 2
Syntax Diagrams for Data Pump Export
ExpInit
YES
HELP =
NO
expdp
@ connect_identifier AS SYSDBA
username / password ExpStart
ExpStart
ExpEncrypt
schema_name .
= job_name
ATTACH
2-73
Chapter 2
Syntax Diagrams for Data Pump Export
ExpModes
YES
FULL =
NO
SCHEMAS = schema_name
schema_name . : partition_name
TABLES = table_name
TABLESPACES = tablespace_name
YES
, TRANSPORT_FULL_CHECK =
NO
TRANSPORT_TABLESPACES = tablespace_name
2-74
Chapter 2
Syntax Diagrams for Data Pump Export
ExpOpts
ALL
CONTENT = DATA_ONLY
METADATA_ONLY
ExpCompression
XML_CLOBS
DATA_OPTIONS = GROUP_PARTITION_TABLE_DATA
VERIFY_STREAM_FORMAT
BLOCKS
ESTIMATE =
STATISTICS
YES
ESTIMATE_ONLY =
NO
ExpEncrypt
ExpFilter
FLASHBACK_SCN = scn_value
FLASHBACK_TIME = timestamp
JOB_NAME = jobname_string
2-75
Chapter 2
Syntax Diagrams for Data Pump Export
ExpOpts_Cont
ALL
CONTENT = DATA_ONLY
METADATA_ONLY
ExpCompression
XML_CLOBS
DATA_OPTIONS = GROUP_PARTITION_TABLE_DATA
VERIFY_STREAM_FORMAT
BLOCKS
ESTIMATE =
STATISTICS
YES
ESTIMATE_ONLY =
NO
ExpEncrypt
ExpFilter
FLASHBACK_SCN = scn_value
FLASHBACK_TIME = timestamp
JOB_NAME = jobname_string
ExpCompression
ALL
DATA_ONLY
COMPRESSION =
METADATA_ONLY
NONE
BASIC
LOW
COMPRESSION_ALGORITHM =
MEDIUM
HIGH
2-76
Chapter 2
Syntax Diagrams for Data Pump Export
ExpEncrypt
ALL
DATA_ONLY
ENCRYPTION = METADATA_ONLY
ENCRYPTED_COLUMNS_ONLY
NONE
AES128
ENCRYPTION_ALGORITHM = AES192
AES256
PASSWORD
ENCRYPTION_MODE = TRANSPARENT
DUAL
ENCRYPTION_PASSWORD = password
YES
ENCRYPTION_PWD_PROMPT =
NO
ExpFilter
: name_clause
EXCLUDE = object_type
: name_clause
INCLUDE = object_type
schema_name .
table_name :
QUERY = query_clause
schema_name .
table_name :
SAMPLE = sample_percent
ExpRacOpt
YES
CLUSTER =
NO
SERVICE_NAME = service_name
2-77
Chapter 2
Syntax Diagrams for Data Pump Export
ExpRemap
schema . schema .
REMAP_DATA = table . column : pkg . function
ExpVersion
COMPATIBLE
VERSION = LATEST
version_string
ExpFileOpts
DIRECTORY = directory_object
directory_object :
DUMPFILE = file_name
FILESIZE = number_of_bytes
directory_object :
LOGFILE = file_name
YES
NOLOGFILE =
NO
directory_path
PARFILE = file_name
YES
REUSE_DUMPFILES =
NO
2-78
Chapter 2
Syntax Diagrams for Data Pump Export
ExpDynOpts
directory_object :
ADD_FILE = file_name
CONTINUE_CLIENT
EXIT_CLIENT
FILESIZE = number_of_bytes
HELP
KILL_JOB
PARALLEL = integer
YES
= SKIP_CURRENT =
NO
START_JOB
= integer
STATUS
= IMMEDIATE
STOP_JOB
ExpDiagnostics
ABORT_STEP = integer
AUTOMATIC
EXTERNAL_TABLE
ACCESS_METHOD =
DIRECT_PATH
INSERT_AS_SELECT
YES
KEEP_MASTER =
NO
YES
METRICS =
NO
2-79
3
Data Pump Import
The Oracle Data Pump Import utility is used to load an export dump file set into a
target database. You can also use it to perform a network import to load a target
database directly from a source database with no intervening files.
3-1
Chapter 3
Invoking Data Pump Import
See Also:
• Filtering During Import Operations to learn more about data filters and
metadata filters.
• Examples of Using Data Pump Import to see some examples of the various
ways in which you can use Import.
The characteristics of the import operation are determined by the import parameters
you specify. These parameters can be specified either on the command line or in a
parameter file.
Note:
Do not start Import as SYSDBA, except at the request of Oracle technical support.
SYSDBA is used internally and has specialized functions; its behavior is not the
same as for general users.
Note:
Be aware that if you are performing a Data Pump Import into a table or
tablespace created with the NOLOGGING clause enabled, then a redo log file may
still be generated. The redo that is generated in such a case is generally for
maintenance of the master table or related to underlying recursive space
transactions, data dictionary changes, and index maintenance for indices on
the table that require logging.
3-2
Chapter 3
Invoking Data Pump Import
See Also:
When the source of the import operation is a dump file set, specifying a mode is
optional. If no mode is specified, then Import attempts to load the entire dump file set
in the mode in which the export operation was run.
The mode is specified on the command line, using the appropriate parameter. The
available modes are described in the following sections.
3-3
Chapter 3
Invoking Data Pump Import
Note:
When you import a dump file that was created by a full-mode export, the import
operation attempts to copy the password for the SYS account from the source
database. This sometimes fails (for example, if the password is in a shared
password file). If it does fail, then after the import completes, you must set the
password for the SYS account at the target database to a password of your
choice.
In full import mode, the entire content of the source (dump file set or another
database) is loaded into the target database. This is the default for file-based imports.
You must have the DATAPUMP_IMP_FULL_DATABASE role if the source is another database
containing schemas other than your own.
Cross-schema references are not imported for non-privileged users. For example, a
trigger defined on a table within the importing user's schema, but residing in another
user's schema, is not imported.
The DATAPUMP_IMP_FULL_DATABASE role is required on the target database and the
DATAPUMP_EXP_FULL_DATABASE role is required on the source database if the NETWORK_LINK
parameter is used for a full import.
3-4
Chapter 3
Invoking Data Pump Import
• Either the NETWORK_LINK parameter must also be specified or the dump file set
being imported must have been created using the transportable option during
export.
• If you are using a network link, then the database specified on the NETWORK_LINK
parameter must be Oracle Database 11g release 2 (11.2.0.3) or later, and the
Data Pump VERSION parameter must be set to at least 12. (In a non-network import,
VERSION=12 is implicitly determined from the dump file.)
• If the source platform and the target platform are of different endianness, then you
must convert the data being transported so that it is in the format of the target
platform. You can use the DBMS_FILE_TRANSFER package or the RMAN CONVERT
command to convert the data.
• A full transportable import of encrypted tablespaces is not supported in network
mode or dump file mode if the source and target platforms do not have the same
endianess.
Related Topics
• FULL
• TRANSPORTABLE
See Also:
Oracle Database Administrator's Guide for a detailed example of performing a
full transportable import
In a schema import, only objects owned by the specified schemas are loaded. The
source can be a full, table, tablespace, or schema-mode export dump file set or
another database. If you have the DATAPUMP_IMP_FULL_DATABASE role, then a list of
schemas can be specified and the schemas themselves (including system privilege
grants) are created in the database in addition to the objects contained within those
schemas.
Cross-schema references are not imported for non-privileged users unless the other
schema is remapped to the current schema. For example, a trigger defined on a table
within the importing user's schema, but residing in another user's schema, is not
imported.
Related Topics
• SCHEMAS
A table-mode import is specified using the TABLES parameter. In table mode, only the
specified set of tables, partitions, and their dependent objects are loaded. The source
can be a full, schema, tablespace, or table-mode export dump file set or another
3-5
Chapter 3
Invoking Data Pump Import
database. You must have the DATAPUMP_IMP_FULL_DATABASE role to specify tables that
are not in your own schema.
You can use the transportable option during a table-mode import by specifying the
TRANPORTABLE=ALWAYS parameter with the TABLES parameter. Note that this requires use
of the NETWORK_LINK parameter, as well.
To recover tables and table partitions, you can also use RMAN backups and the
RMAN RECOVER TABLE command. During this process, RMAN creates (and optionally
imports) a Data Pump export dump file that contains the recovered objects.
Related Topics
• TABLES
• TRANSPORTABLE
• Using Data File Copying to Move Data
The fastest method of moving data is to copy the database data files to the target
database without interpreting or altering the data. With this method, Data Pump
Export is used to unload only structural information (metadata) into the dump file.
See Also:
Oracle Database Backup and Recovery User's Guide
See Also:
TABLESPACES
3-6
Chapter 3
Invoking Data Pump Import
the TRANSPORT_DATAFILES parameter, must be made available from the source system
for use in the target database, typically by copying them over to the target system.
When transportable jobs are performed, it is best practice to keep a copy of the data
files on the source system until the import job has successfully completed on the target
system. If the import job should fail for some reason, you will still have uncorrupted
copies of the data files.
This mode requires the DATAPUMP_IMP_FULL_DATABASE role.
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
Related Topics
• How Does Data Pump Handle Timestamp Data?
This section describes factors that can affect successful completion of export and
import jobs that involve the timestamp data types TIMESTAMP WITH TIMEZONE and
TIMESTAMP WITH LOCAL TIMEZONE.
See Also:
• How Does Data Pump Handle Timestamp Data? for information about
special considerations concerning timestamp data when using
transportable tablespace mode
• Using Data File Copying to Move Data for information about moving data.
3-7
Chapter 3
Filtering During Import Operations
Password: password
The local Import client connects to the database instance identified by the connect
identifier inst1 (a net service name), and imports the data from the dump file hr.dmp to
inst1.
Specifying a connect identifier when you start the Import utility is different from
performing an import operation using the NETWORK_LINK parameter. When you start an
import operation and specify a connect identifier, the local Import client connects to the
database instance identified by the connect identifier and imports the data from the
dump file named on the command line to that database instance.
Whereas, when you perform an import using the NETWORK_LINK parameter, the import is
performed using a database link, and there is no dump file involved. (A database link
is a connection between two physical database servers that allows a client to access
them as one logical database.)
Related Topics
• NETWORK_LINK
See Also:
3-8
Chapter 3
Parameters Available in Import's Command-Line Mode
Data Pump Import provides much greater metadata filtering capability than was
provided by the original Import utility. The EXCLUDE and INCLUDE parameters are mutually
exclusive.
Metadata filters identify a set of objects to be included or excluded from a Data Pump
operation. For example, you could request a full import, but without Package
Specifications or Package Bodies.
To use filters correctly and to get the results you expect, remember that dependent
objects of an identified object are processed along with the identified object. For
example, if a filter specifies that a package is to be included in an operation, then
grants upon that package will also be included. Likewise, if a table is excluded by a
filter, then indexes, constraints, grants, and triggers upon the table will also be
excluded by the filter.
If multiple filters are specified for an object type, then an implicit AND operation is
applied to them. That is, objects participating in the job must pass all of the filters
applied to their object types.
The same filter name can be specified multiple times within a job.
To see a list of valid object types, query the following views: DATABASE_EXPORT_OBJECTS
for full mode, SCHEMA_EXPORT_OBJECTS for schema mode, and TABLE_EXPORT_OBJECTS for
table and tablespace mode. The values listed in the OBJECT_PATH column are the valid
object types. Note that full object path names are determined by the export mode, not
by the import mode.
Related Topics
• Metadata Filters
Metadata filtering is implemented through the EXCLUDE and INCLUDE parameters.
The EXCLUDE and INCLUDE parameters are mutually exclusive.
• EXCLUDE
• INCLUDE
See Also:
3-9
Chapter 3
Parameters Available in Import's Command-Line Mode
For every parameter you enter, you must enter an equal sign (=) and a value. Data
Pump has no other way of knowing that the previous parameter specification is
complete and a new parameter specification is beginning. For example, in the
following command line, even though NOLOGFILE is a valid parameter, it would be
interpreted as another dump file name for the DUMPFILE parameter:
impdp DIRECTORY=dpumpdir DUMPFILE=test.dmp NOLOGFILE TABLES=employees
This would result in two dump files being created, test.dmp and nologfile.dmp.
If you were to specify that on the command line, then some operating systems would
require that it be surrounded by single quotation marks, as follows:
TABLES = '\"MixedCaseTableName\"'
3-10
Chapter 3
Parameters Available in Import's Command-Line Mode
To avoid having to supply additional quotation marks on the command line, Oracle
recommends the use of parameter files. Also, note that if you use a parameter file and
the parameter value being specified does not have quotation marks as the first
character in the string (for example, TABLES=scott."EmP"), then the use of escape
characters may not be necessary on some systems.
• ABORT_STEP
• ACCESS_METHOD
• ATTACH
• CLUSTER
• CONTENT
• DATA_OPTIONS
• DIRECTORY
• DUMPFILE
• ENCRYPTION_PASSWORD
• ENCRYPTION_PWD_PROMPT
• ESTIMATE
• EXCLUDE
• FLASHBACK_SCN
• FLASHBACK_TIME
• FULL
3-11
Chapter 3
Parameters Available in Import's Command-Line Mode
• HELP
• INCLUDE
• JOB_NAME
• KEEP_MASTER
• LOGFILE
• LOGTIME
• MASTER_ONLY
• METRICS
• NETWORK_LINK
• NOLOGFILE
• PARALLEL
• PARFILE
• PARTITION_OPTIONS
• QUERY
• REMAP_DATA
• REMAP_DATAFILE
• REMAP_DIRECTORY
• REMAP_SCHEMA
• REMAP_TABLE
• REMAP_TABLESPACE
• REUSE_DATAFILES
• SCHEMAS
• SERVICE_NAME
• SKIP_UNUSABLE_INDEXES
• SOURCE_EDITION
• SQLFILE
• STATUS
• STREAMS_CONFIGURATION
• TABLE_EXISTS_ACTION
• TABLES
• TABLESPACES
• TARGET_EDITION
• TRANSFORM
• TRANSPORT_DATAFILES
• TRANSPORT_FULL_CHECK
• TRANSPORT_TABLESPACES
• TRANSPORTABLE
3-12
Chapter 3
Parameters Available in Import's Command-Line Mode
• VERSION
• VIEWS_AS_TABLES (Network Import)
• VIEWS_AS_TABLES (Non-Network Import)
Related Topics
• PARFILE
• Default Locations for Dump, Log, and SQL Files
Data Pump is server-based rather than client-based. Dump files, log files, and
SQL files are accessed relative to server-based directory paths.
• Examples of Using Data Pump Import
This section provides examples of the following ways in which you might use Data
Pump Import.
• Syntax Diagrams for Data Pump Import
This section provides syntax diagrams for Data Pump Import.
See Also:
Oracle Database Sample Schemas
Your Oracle operating system-specific documentation for information about
how special and reserved characters are handled on your system.
3.4.1 ABORT_STEP
Default: Null
Purpose
Used to stop the job after it is initialized. This allows the master table to be queried
before any data is imported.
The possible values correspond to a process order number in the master table. The
result of using each number is as follows:
• n: If the value is zero or greater, then the import operation is started and the job is
aborted at the object that is stored in the master table with the corresponding
process order number.
• -1 and the job is an import using a NETWORK_LINK: Abort the job after setting it up but
before importing any objects.
• -1 and the job is an import that does not use NETWORK_LINK: Abort the job after
loading the master table and applying filters.
Restrictions
• None
3-13
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
> impdp hr SCHEMAS=hr DIRECTORY=dpump_dir1 LOGFILE=schemas.log
DUMPFILE=expdat.dmp ABORT_STEP=-1
3.4.2 ACCESS_METHOD
Default: AUTOMATIC
Purpose
Instructs Import to use a particular method to load data.
The ACCESS_METHOD parameter is provided so that you can try an alternative method if
the default method does not work for some reason. If the data for a table cannot be
loaded with the specified access method, then the data displays an error for the table
and continues with the next work item.
The available options are:
• AUTOMATIC — This is the default. Data Pump determines the best way to load data
for each table. Oracle recommends that you use AUTOMATIC whenever possible
because it allows Data Pump to automatically select the most efficient method.
• DIRECT_PATH — Data Pump uses direct path load for every table.
• EXTERNAL_TABLE — Data Pump creates an external table over the data stored in the
dump file and uses a SQL INSERT AS SELECT statement to load the data into the
table. Data Pump applies the APPEND hint to the INSERT statement.
• CONVENTIONAL_PATH — Data Pump creates an external table over the data stored in
the dump file and reads rows from the external table one at a time. Every time it
reads a row Data Pump executes an insert statement to load that row into the
target table. This method takes a long time to load data, but it is the only way to
load data that cannot be loaded by direct path and external tables.
• INSERT_AS_SELECT — Data Pump loads tables by executing a SQL INSERT AS SELECT
statement that selects data from the remote database and inserts it into the target
table. This option is available only for network mode imports. It is used to disable
use of DIRECT_PATH when data is moved over the network.
Restrictions
• The valid options for network mode import are AUTOMATIC, DIRECT_PATH and
INSERT_AS_SELECT .
• The only valid options when importing from a dump file are AUTOMATIC, DIRECT_PATH,
EXTERNAL_TABLE and CONVENTIONAL_PATH
• To use the ACCESS_METHOD parameter with network imports, you must be using
Oracle Database 12c Release 2 (12.2.0.1) or later
3-14
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
The following example allows Data Pump to load data for multiple partitions of the pre-
existing table SALES at the same time.
impdp hr SCHEMAS=hr DIRECTORY=dpump_dir1 LOGFILE=schemas.log
DUMPFILE=expdat.dmp ACCESS_METHOD=CONVENTIONAL
3.4.3 ATTACH
Default: current job in user's schema, if there is only one running job.
Purpose
Attaches the client session to an existing import job and automatically places you in
interactive-command mode.
Specify a schema_name if the schema to which you are attaching is not your own. You
must have the DATAPUMP_IMP_FULL_DATABASE role to do this.
A job_name does not have to be specified if only one running job is associated with your
schema and the job is active. If the job you are attaching to is stopped, then you must
supply the job name. To see a list of Data Pump job names, you can query the
DBA_DATAPUMP_JOBS view or the USER_DATAPUMP_JOBS view.
When you are attached to the job, Import displays a description of the job and then
displays the Import prompt.
Restrictions
• When you specify the ATTACH parameter, the only other Data Pump parameter you
can specify on the command line is ENCRYPTION_PASSWORD.
• If the job you are attaching to was initially started using an encryption password,
then when you attach to the job you must again enter the ENCRYPTION_PASSWORD
parameter on the command line to re-specify that password.
• You cannot attach to a job in another schema unless it is already running.
• If the dump file set or master table for the job have been deleted, then the attach
operation fails.
• Altering the master table in any way can lead to unpredictable results.
Example
The following is an example of using the ATTACH parameter.
> impdp hr ATTACH=import_job
This example assumes that a job named import_job exists in the hr schema.
3-15
Chapter 3
Parameters Available in Import's Command-Line Mode
See Also:
"Commands Available in Import's Interactive-Command Mode"
3.4.4 CLUSTER
Default: YES
Purpose
Determines whether Data Pump can use Oracle Real Application Clusters (Oracle
RAC) resources and start workers on other Oracle RAC instances.
To force Data Pump Import to use only the instance where the job is started and to
replicate pre-Oracle Database 11g release 2 (11.2) behavior, specify CLUSTER=NO.
To specify a specific, existing service and constrain worker processes to run only on
instances defined for that service, use the SERVICE_NAME parameter with the CLUSTER=YES
parameter.
Use of the CLUSTER parameter may affect performance because there is some
additional overhead in distributing the import job across Oracle RAC instances. For
small jobs, it may be better to specify CLUSTER=NO to constrain the job to run on the
instance where it is started. Jobs whose performance benefits the most from using the
CLUSTER parameter are those involving large amounts of data.
Example
> impdp hr DIRECTORY=dpump_dir1 SCHEMAS=hr CLUSTER=NO PARALLEL=3 NETWORK_LINK=dbs1
See Also:
• "SERVICE_NAME"
• "Oracle RAC Considerations"
3-16
Chapter 3
Parameters Available in Import's Command-Line Mode
3.4.5 CONTENT
Default: ALL
Purpose
Enables you to filter what is loaded during the import operation.
• ALL loads any data and metadata contained in the source. This is the default.
• DATA_ONLY loads only table row data into existing tables; no database objects are
created.
• METADATA_ONLY loads only database object definitions; no table row data is loaded.
Be aware that if you specify CONTENT=METADATA_ONLY, then any index or table
statistics imported from the dump file are locked after the import operation is
complete.
Restrictions
• The CONTENT=METADATA_ONLY parameter and value cannot be used in conjunction
with the TRANSPORT_TABLESPACES (transportable-tablespace mode) parameter or the
QUERY parameter.
Example
The following is an example of using the CONTENT parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp CONTENT=METADATA_ONLY
This command will execute a full import that will load only the metadata in the
expfull.dmp dump file. It executes a full import because that is the default for file-based
imports in which no import mode is specified.
3.4.6 DATA_OPTIONS
Default: There is no default. If this parameter is not used, then the special data
handling options it provides simply do not take effect.
Purpose
The DATA_OPTIONS parameter designates how certain types of data should be handled
during import operations.
3-17
Chapter 3
Parameters Available in Import's Command-Line Mode
• DISABLE_APPEND_HINT — Specifies that you do not want the import operation to use
the APPEND hint while loading the data object. Disabling the APPEND hint can be
useful if there is a small set of data objects to load that already exist in the
database and some other application may be concurrently accessing one or more
of the data objects.
If DISABLE_APPEND_HINT is not set, then the default behavior is to use the APPEND hint
for loading data objects.
• SKIP_CONSTRAINT_ERRORS — Affects how non-deferred constraint violations are
handled while a data object (table, partition, or subpartition) is being loaded. It has
no effect on the load if deferred constraint violations are encountered. Deferred
constraint violations always cause the entire load to be rolled back.
The SKIP_CONSTRAINT_ERRORS option specifies that you want the import operation to
proceed even if non-deferred constraint violations are encountered. It logs any
rows that cause non-deferred constraint violations, but does not stop the load for
the data object experiencing the violation.
If SKIP_CONSTRAINT_ERRORS is not set, then the default behavior is to roll back the
entire load of the data object on which non-deferred constraint violations are
encountered.
• ENABLE_NETWORK_COMPRESSION — Used for network imports in which the Data Pump
ACCESS_METHOD parameter is set to DIRECT_PATH to load remote table data. When
ENABLE_NETWORK_COMPRESSION is specified, Data Pump compresses data on the
remote node before it is sent over the network to the target database, where it is
decompressed. This option is useful if the network connection between the remote
and local database is slow because it reduces the amount of data sent over the
network.
If ACCESS_METHOD=AUTOMATIC and Data Pump decides to use DIRECT_PATH for a
network import, then ENABLE_NETWORK_COMPRESSION would also apply.
The ENABLE_NETWORK_COMPRESSION option is ignored if Data Pump is importing data
from a dump file, if the remote data base is earlier than Oracle Database 12c
Release 2 (12.2), or if an INSERT_AS_SELECT statement is being used to load data
from the remote database.
• REJECT_ROWS_WITH_REPL_CHAR — specifies that you want the import operation to
reject any rows that experience data loss because the default replacement
character was used during character set conversion.
If REJECT_ROWS_WITH_REPL_CHAR is not set, then the default behavior is to load the
converted rows with replacement characters.
• TRUST_EXISTING_TABLE_PARTITIONS — tells Data Pump to load partition data in
parallel into existing tables. You should use this option when you are using Data
Pump to create the table from the definition in the export database before the table
data import is started. This is done as part of a migration when the metadata is
static and can be moved before the databases are taken off line in order to migrate
the data. Moving the metadata separately minimizes downtime. If you use this
option and if other attributes of the database are the same (for example, character
set), then the data from the export database goes to the same partitions in the
import database.
You can create the table outside of the data pump but the partition attributes and
partition names must be identical to the export database.
• VALIDATE_TABLE_DATA — directs Data Pump to validate the number and date data
types in table data columns. An ORA-39376 error is written to the .log file if invalid
3-18
Chapter 3
Parameters Available in Import's Command-Line Mode
data is encountered. The error text includes the column name. The default is to do
no validation. Use this option if the source of the Data Pump dump file is not
trusted.
Restrictions
• If DISABLE_APPEND_HINT is used, then it can take longer for data objects to load.
• If SKIP_CONSTRAINT_ERRORS is used and if a data object has unique indexes or
constraints defined on it at the time of the load, then the APPEND hint will not be
used for loading that data object. Therefore, loading such data objects will take
longer when the SKIP_CONSTRAINT_ERRORS option is used.
• Even if SKIP_CONSTRAINT_ERRORS is specified, it is not used unless a data object is
being loaded using the external table access method.
Example
This example shows a data-only table mode import with SKIP_CONSTRAINT_ERRORS
enabled:
> impdp hr TABLES=employees CONTENT=DATA_ONLY
DUMPFILE=dpump_dir1:table.dmp DATA_OPTIONS=skip_constraint_errors
If any non-deferred constraint violations are encountered during this import operation,
then they will be logged and the import will continue on to completion.
3.4.7 DIRECTORY
Default: DATA_PUMP_DIR
Purpose
Specifies the default location in which the import job can find the dump file set and
where it should create log and SQL files.
The directory_object is the name of a database directory object (not the file path of an
actual directory). Privileged users have access to a default directory object named
DATA_PUMP_DIR. The definition of the DATA_PUMP_DIR directory may be changed by Oracle
during upgrades or when patches are applied.
Users with access to the default DATA_PUMP_DIR directory object do not need to use the
DIRECTORY parameter.
Example
The following is an example of using the DIRECTORY parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
3-19
Chapter 3
Parameters Available in Import's Command-Line Mode
This command results in the import job looking for the expfull.dmp dump file in the
directory pointed to by the dpump_dir1 directory object. The dpump_dir2 directory object
specified on the LOGFILE parameter overrides the DIRECTORY parameter so that the log
file is written to dpump_dir2.
See Also:
• "Default Locations for Dump_ Log_ and SQL Files" for more information
about default directory objects and the order of precedence Data Pump
uses to determine a file's location
• "Oracle RAC Considerations"
• Oracle Database SQL Language Reference for more information about the
CREATE DIRECTORY command
3.4.8 DUMPFILE
Default: expdat.dmp
Purpose
Specifies the names and optionally, the directory objects of the dump file set that was
created by Export.
The directory_object is optional if one has already been established by the DIRECTORY
parameter. If you do supply a value here, then it must be a directory object that
already exists, and that you have access to. A database directory object that is
specified as part of the DUMPFILE parameter overrides a value specified by the
DIRECTORY parameter.
The file_name is the name of a file in the dump file set. The file names can also be
templates that contain substitution variables. Import examines each file that matches
the template (until no match is found) to locate all files that are part of the dump file
set. Sufficient information is contained within the files for Import to locate the entire set,
provided the file specifications in the DUMPFILE parameter encompass the entire set.
The files are not required to have the same names, locations, or order that they had at
export time.
The possible substitution variables are described in the following table.
Substitution Description
Variable
%U If %U is used, then the %U expands to a 2-digit incrementing integer starting
with 01.
3-20
Chapter 3
Parameters Available in Import's Command-Line Mode
Substitution Description
Variable
%l, %L Specifies a system-generated unique file name.
The file names can contain a substitution variable (%L), which implies that
multiple files may be generated. The substitution variable is expanded in the
resulting file names into a 2-digit, fixed-width, incrementing integer starting at
01 and ending at 99 which is the same as (%U). In addition, the substitution
variable is expanded in the resulting file names into a 3-digit to 10-digit,
variable-width, incrementing integers starting at 100 and ending at
2147483646. The width field is determined by the number of digits in the
integer.
For example if the current integer was 1, exp%Laa%L.dmp would resolve to
exp01aa01.dmp
exp02aa02.dmp
and so forth up until 99. Then, the next file name would have 3 digits
substituted:
exp100aa100.dmp
exp101aa101.dmp
and so forth up until 999 where the next file would have 4 digits substituted.
The substitution will continue up to the largest number substitution allowed,
which is 2147483646.
Restrictions
• Dump files created on Oracle Database 11g releases with the Data Pump
parameter VERSION=12 can only be imported on Oracle Database 12c Release 1
(12.1) and later.
Example
The following is an example of using the Import DUMPFILE parameter. You can create
the dump files used in this example by running the example provided for the Export
DUMPFILE parameter. See "DUMPFILE".
Because a directory object (dpump_dir2) is specified for the exp1.dmp dump file, the
import job looks there for the file. It also looks in dpump_dir1 for dump files of the form
exp2nn.dmp. The log file is written to dpump_dir1.
See Also:
• "File Allocation"
• "Performing a Data-Only Table-Mode Import"
3.4.9 ENCRYPTION_PASSWORD
Default: There is no default; the value is user-supplied.
3-21
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Specifies a password for accessing encrypted column data in the dump file set. This
prevents unauthorized access to an encrypted dump file set.
It is also required for the transport of keys associated with encrypted tablespaces and
tables with encrypted columns during a full transportable export or import operation.
The password that you enter is echoed to the screen. If you do not want the password
shown on the screen as you enter it, then use the ENCRYPTION_PWD_PROMPT parameter.
Restrictions
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
• Data Pump encryption features require that the Oracle Advanced Security option
be enabled. See Oracle Database Licensing Information for information about
licensing requirements for the Oracle Advanced Security option.
• The ENCRYPTION_PASSWORD parameter is not valid if the dump file set was created
using the transparent mode of encryption.
• The ENCRYPTION_PASSWORD parameter is required for network-based full transportable
imports where the source database has encrypted tablespaces or tables with
encrypted columns.
• Encryption attributes for all columns must match between the exported table
definition and the target table. For example, suppose you have a table, EMP, and
one of its columns is named EMPNO. Both of the following situations would result in
an error because the encryption attribute for the EMP column in the source table
would not match the encryption attribute for the EMP column in the target table:
– The EMP table is exported with the EMPNO column being encrypted, but before
importing the table you remove the encryption attribute from the EMPNO column.
– The EMP table is exported without the EMPNO column being encrypted, but before
importing the table you enable encryption on the EMPNO column.
Example
In the following example, the encryption password, 123456, must be specified because
it was specified when the dpcd2be1.dmp dump file was created (see
"ENCRYPTION_PASSWORD").
> impdp hr TABLES=employee_s_encrypt DIRECTORY=dpump_dir
DUMPFILE=dpcd2be1.dmp ENCRYPTION_PASSWORD=123456
During the import operation, any columns in the employee_s_encrypt table that were
encrypted during the export operation are decrypted before being imported.
3-22
Chapter 3
Parameters Available in Import's Command-Line Mode
3.4.10 ENCRYPTION_PWD_PROMPT
Default: NO
Purpose
Specifies whether Data Pump should prompt you for the encryption password.
If you specify an encryption password on the export operation, you must also supply it
on the import operation.
Restrictions
• Concurrent use of the ENCRYPTION_PWD_PROMPT and ENCRYPTION_PASSWORD parameters
is prohibited.
Example
The following example shows Data Pump first prompting for the user password and
then for the encryption password.
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp ENCRYPTION_PWD_PROMPT=YES
.
.
.
Copyright (c) 1982, 2016, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Production
Encryption Password:
3.4.11 ESTIMATE
Default: BLOCKS
3-23
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Instructs the source system in a network import operation to estimate how much data
will be generated.
Restrictions
• The Import ESTIMATE parameter is valid only if the NETWORK_LINK parameter is also
specified.
• When the import source is a dump file set, the amount of data to be loaded is
already known, so the percentage complete is automatically calculated.
• The estimate may be inaccurate if either the QUERY or REMAP_DATA parameter is
used.
Example
In the following example, source_database_link would be replaced with the name of a
valid link to the source database.
> impdp hr TABLES=job_history NETWORK_LINK=source_database_link
DIRECTORY=dpump_dir1 ESTIMATE=STATISTICS
The job_history table in the hr schema is imported from the source database. A log
file is created by default and written to the directory pointed to by the dpump_dir1
directory object. When the job begins, an estimate for the job is calculated based on
table statistics.
3.4.12 EXCLUDE
Default: There is no default
Purpose
Enables you to filter the metadata that is imported by specifying objects and object
types to exclude from the import job.
3-24
Chapter 3
Parameters Available in Import's Command-Line Mode
The object_type specifies the type of object to be excluded. To see a list of valid
values for object_type, query the following views: DATABASE_EXPORT_OBJECTS for full
mode, SCHEMA_EXPORT_OBJECTS for schema mode, and TABLE_EXPORT_OBJECTS for table
and tablespace mode. The values listed in the OBJECT_PATH column are the valid object
types. (See "Metadata Filters" for an example of how to perform such a query.)
For the given mode of import, all object types contained within the source (and their
dependents) are included, except those specified in an EXCLUDE statement. If an object
is excluded, then all of its dependent objects are also excluded. For example,
excluding a table will also exclude all indexes and triggers on the table.
The name_clause is optional. It allows fine-grained selection of specific objects within an
object type. It is a SQL expression used as a filter on the object names of the type. It
consists of a SQL operator and the values against which the object names of the
specified type are to be compared. The name_clause applies only to object types whose
instances have names (for example, it is applicable to TABLE and VIEW, but not to GRANT).
It must be separated from the object type with a colon and enclosed in double
quotation marks, because single quotation marks are required to delimit the name
strings. For example, you could set EXCLUDE=INDEX:"LIKE 'DEPT%'" to exclude all
indexes whose names start with dept.
The name that you supply for the name_clause must exactly match, including upper and
lower casing, an existing object in the database. For example, if the name_clause you
supply is for a table named EMPLOYEES, then there must be an existing table named
EMPLOYEES using all upper case. If the name_clause were supplied as Employees or
employees or any other variation, then the table would not be found.
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
As explained in the following sections, you should be aware of the effects of specifying
certain objects for exclusion, in particular, CONSTRAINT, GRANT, and USER.
Excluding Constraints
The following constraints cannot be excluded:
• Constraints needed for the table to be created and loaded successfully (for
example, primary key constraints for index-organized tables or REF SCOPE and WITH
ROWID constraints for tables with REF columns).
This means that the following EXCLUDE statements will be interpreted as follows:
3-25
Chapter 3
Parameters Available in Import's Command-Line Mode
To exclude a specific user and all objects of that user, specify a command such as the
following, where hr is the schema name of the user you want to exclude.
Note that in this situation, an import mode of FULL is specified. If no mode were
specified, then the default mode, SCHEMAS, would be used. This would cause an error
because the command would indicate that the schema should be both imported and
excluded at the same time.
If you try to exclude a user by using a statement such as EXCLUDE=USER:"= 'HR'", then
only CREATE USER hr DDL statements will be excluded, and you may not get the results
you expect.
Restrictions
• The EXCLUDE and INCLUDE parameters are mutually exclusive.
Example
Assume the following is in a parameter file, exclude.par, being used by a DBA or some
other user with the DATAPUMP_IMP_FULL_DATABASE role. (To run the example, you must
first create this file.)
EXCLUDE=FUNCTION
EXCLUDE=PROCEDURE
EXCLUDE=PACKAGE
EXCLUDE=INDEX:"LIKE 'EMP%' "
You could then issue the following command. You can create the expfull.dmp dump
file used in this command by running the example provided for the Export FULL
parameter. See "FULL".
> impdp system DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp PARFILE=exclude.par
All data from the expfull.dmp dump file will be loaded except for functions, procedures,
packages, and indexes whose names start with emp.
See Also:
"Filtering During Import Operations" for more information about the effects of
using the EXCLUDE parameter
3.4.13 FLASHBACK_SCN
Default: There is no default
Purpose
Specifies the system change number (SCN) that Import will use to enable the
Flashback utility.
3-26
Chapter 3
Parameters Available in Import's Command-Line Mode
The import operation is performed with data that is consistent up to the specified
scn_number.
As of Oracle Database 12c release 2 (12.2), the SCN value can be a big SCN (8
bytes). See the following restrictions for more information about using big SCNs.
Note:
If you are on a logical standby system, then the FLASHBACK_SCN parameter is
ignored because SCNs are selected by logical standby. See Oracle Data
Guard Concepts and Administration for information about logical standby
databases.
Restrictions
• The FLASHBACK_SCN parameter is valid only when the NETWORK_LINK parameter is also
specified.
• The FLASHBACK_SCN parameter pertains only to the Flashback Query capability of
Oracle Database. It is not applicable to Flashback Database, Flashback Drop, or
Flashback Data Archive.
• FLASHBACK_SCN and FLASHBACK_TIME are mutually exclusive.
• You cannot specify a big SCN for a network export or network import from a
version that does not support big SCNs.
Example
The following is an example of using the FLASHBACK_SCN parameter.
> impdp hr DIRECTORY=dpump_dir1 FLASHBACK_SCN=123456
NETWORK_LINK=source_database_link
The source_database_link in this example would be replaced with the name of a source
database from which you were importing data.
3.4.14 FLASHBACK_TIME
Default: There is no default
Purpose
Specifies the system change number (SCN) that Import will use to enable the
Flashback utility.
3-27
Chapter 3
Parameters Available in Import's Command-Line Mode
The SCN that most closely matches the specified time is found, and this SCN is used
to enable the Flashback utility. The import operation is performed with data that is
consistent up to this SCN. Because the TO_TIMESTAMP value is enclosed in quotation
marks, it would be best to put this parameter in a parameter file. See "Use of
Quotation Marks On the Data Pump Command Line".
Note:
If you are on a logical standby system, then the FLASHBACK_TIME parameter is
ignored because SCNs are selected by logical standby. See Oracle Data
Guard Concepts and Administration for information about logical standby
databases.
Restrictions
• This parameter is valid only when the NETWORK_LINK parameter is also specified.
• The FLASHBACK_TIME parameter pertains only to the flashback query capability of
Oracle Database. It is not applicable to Flashback Database, Flashback Drop, or
Flashback Data Archive.
• FLASHBACK_TIME and FLASHBACK_SCN are mutually exclusive.
Example
You can specify the time in any format that the DBMS_FLASHBACK.ENABLE_AT_TIME
procedure accepts,. For example, suppose you have a parameter file,
flashback_imp.par, that contains the following:
The import operation will be performed with data that is consistent with the SCN that
most closely matches the specified time.
See Also:
Oracle Database Development Guide for information about using flashback
3.4.15 FULL
Default: YES
Purpose
Specifies that you want to perform a full database import.
3-28
Chapter 3
Parameters Available in Import's Command-Line Mode
A value of FULL=YES indicates that all data and metadata from the source is imported.
The source can be a dump file set for a file-based import or it can be another
database, specified with the NETWORK_LINK parameter, for a network import.
If you are importing from a file and do not have the DATAPUMP_IMP_FULL_DATABASE role,
then only schemas that map to your own schema are imported.
If the NETWORK_LINK parameter is used and the user executing the import job has the
DATAPUMP_IMP_FULL_DATABASE role on the target database, then that user must also have
the DATAPUMP_EXP_FULL_DATABASE role on the source database.
Filtering can restrict what is imported using this import mode (see "Filtering During
Import Operations").
FULL is the default mode, and does not need to be specified on the command line when
you are performing a file-based import, but if you are performing a network-based full
import then you must specify FULL=Y on the command line.
You can use the transportable option during a full-mode import to perform a full
transportable import. See "Using the Transportable Option During Full Mode Imports".
Restrictions
• The Automatic Workload Repository (AWR) is not moved in a full database export
and import operation. (See Oracle Database Performance Tuning Guide for
information about using Data Pump to move AWR snapshots.)
• The XDB repository is not moved in a full database export and import operation.
User created XML schemas are moved.
• Full imports performed over a network link require that you set VERSION=12 if the
target is Oracle Database 12c Release 1 (12.1.0.1) or later and the source is
Oracle Database 11g Release 2 (11.2.0.3) or later.
Example
The following is an example of using the FULL parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
> impdp hr DUMPFILE=dpump_dir1:expfull.dmp FULL=YES
LOGFILE=dpump_dir2:full_imp.log
This example imports everything from the expfull.dmp dump file. In this example, a
DIRECTORY parameter is not provided. Therefore, a directory object must be provided on
both the DUMPFILE parameter and the LOGFILE parameter. The directory objects can be
different, as shown in this example.
3.4.16 HELP
Default: NO
3-29
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Displays online help for the Import utility.
Example
> impdp HELP = YES
This example will display a brief description of all Import parameters and commands.
3.4.17 INCLUDE
Default: There is no default
Purpose
Enables you to filter the metadata that is imported by specifying objects and object
types for the current import mode.
The object_type specifies the type of object to be included. To see a list of valid values
for object_type, query the following views: DATABASE_EXPORT_OBJECTS for full mode,
SCHEMA_EXPORT_OBJECTS for schema mode, and TABLE_EXPORT_OBJECTS for table and
tablespace mode. The values listed in the OBJECT_PATH column are the valid object
types. (See "Metadata Filters" for an example of how to perform such a query.)
Only object types in the source (and their dependents) that are explicitly specified in
the INCLUDE statement are imported.
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
3-30
Chapter 3
Parameters Available in Import's Command-Line Mode
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
See "Use of Quotation Marks On the Data Pump Command Line".
To see a list of valid paths for use with the INCLUDE parameter, you can query the
following views: DATABASE_EXPORT_OBJECTS for Full mode, SCHEMA_EXPORT_OBJECTS for
schema mode, and TABLE_EXPORT_OBJECTS for table and tablespace mode.
Restrictions
• The INCLUDE and EXCLUDE parameters are mutually exclusive.
Example
Assume the following is in a parameter file, imp_include.par, being used by a DBA or
some other user with the DATAPUMP_IMP_FULL_DATABASE role:
INCLUDE=FUNCTION
INCLUDE=PROCEDURE
INCLUDE=PACKAGE
INCLUDE=INDEX:"LIKE 'EMP%' "
You can create the expfull.dmp dump file used in this example by running the example
provided for the Export FULL parameter. See "FULL".
The Import operation will load only functions, procedures, and packages from the hr
schema and indexes whose names start with EMP. Although this is a privileged-mode
import (the user must have the DATAPUMP_IMP_FULL_DATABASE role), the schema definition
is not imported, because the USER object type was not specified in an INCLUDE
statement.
3.4.18 JOB_NAME
Default: system-generated name of the form SYS_<IMPORT or SQLFILE>_<mode>_NN
Purpose
The job name is used to identify the import job in subsequent actions, such as when
the ATTACH parameter is used to attach to a job, or to identify the job via the
DBA_DATAPUMP_JOBS or USER_DATAPUMP_JOBS views.
The jobname_string specifies a name of up to 128 bytes for this import job. The bytes
must represent printable characters and spaces. If spaces are included, then the name
must be enclosed in single quotation marks (for example, 'Thursday Import'). The job
name is implicitly qualified by the schema of the user performing the import operation.
The job name is used as the name of the master table, which controls the export job.
3-31
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
The following is an example of using the JOB_NAME parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp JOB_NAME=impjob01
3.4.19 KEEP_MASTER
Default: NO
Purpose
Indicates whether the master table should be deleted or retained at the end of a Data
Pump job that completes successfully. The master table is automatically retained for
jobs that do not complete successfully.
Restrictions
• None
Example
> impdp hr SCHEMAS=hr DIRECTORY=dpump_dir1 LOGFILE=schemas.log
DUMPFILE=expdat.dmp KEEP_MASTER=YES
3.4.20 LOGFILE
Default: import.log
Purpose
Specifies the name, and optionally, a directory object, for the log file of the import job.
If you specify a directory_object, then it must be one that was previously established
by the DBA and that you have access to. This overrides the directory object specified
with the DIRECTORY parameter. The default behavior is to create import.log in the
directory referenced by the directory object specified in the DIRECTORY parameter.
All messages regarding work in progress, work completed, and errors encountered are
written to the log file. (For a real-time status of the job, use the STATUS command in
interactive mode.)
3-32
Chapter 3
Parameters Available in Import's Command-Line Mode
A log file is always created unless the NOLOGFILE parameter is specified. As with the
dump file set, the log file is relative to the server and not the client.
Note:
Data Pump Import writes the log file using the database character set. If your
client NLS_LANG environment sets up a different client character set from the
database character set, then it is possible that table names may be different in
the log file than they are when displayed on the client output screen.
Restrictions
• To perform a Data Pump Import using Oracle Automatic Storage Management
(Oracle ASM), you must specify a LOGFILE parameter that includes a directory
object that does not include the Oracle ASM + notation. That is, the log file must
be written to a disk file, and not written into the Oracle ASM storage. Alternatively,
you can specify NOLOGFILE=YES. However, this prevents the writing of the log file.
Example
The following is an example of using the LOGFILE parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
> impdp hr SCHEMAS=HR DIRECTORY=dpump_dir2 LOGFILE=imp.log
DUMPFILE=dpump_dir1:expfull.dmp
Because no directory object is specified on the LOGFILE parameter, the log file is written
to the directory object specified on the DIRECTORY parameter.
See Also:
• "STATUS"
• "Using Directory Objects When Oracle Automatic Storage Management Is
Enabled" for information about Oracle Automatic Storage Management and
directory objects
3.4.21 LOGTIME
Default: No timestamps are recorded
Purpose
Specifies that messages displayed during import operations be timestamped. You can
use the timestamps to figure out the elapsed time between different phases of a Data
Pump operation. Such information can be helpful in diagnosing performance problems
and estimating the timing of future similar operations.
3-33
Chapter 3
Parameters Available in Import's Command-Line Mode
Restrictions
• None
Example
The following example records timestamps for all status and log file messages that are
displayed during the import operation:
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp SCHEMAS=hr LOGTIME=ALL
TABLE_EXISTS_ACTION=REPLACE
For an example of what the LOGTIME output looks like, see the Export LOGTIME
parameter.
3.4.22 MASTER_ONLY
Default: NO
Purpose
Indicates whether to import just the master table and then stop the job so that the
contents of the master table can be examined.
Restrictions
• If the NETWORK_LINK parameter is also specified, then MASTER_ONLY=YES is not
supported.
Example
> impdp hr SCHEMAS=hr DIRECTORY=dpump_dir1 LOGFILE=schemas.log
DUMPFILE=expdat.dmp MASTER_ONLY=YES
3.4.23 METRICS
Default: NO
3-34
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Indicates whether additional information about the job should be reported to the Data
Pump log file.
When METRICS=YES is used, the number of objects and the elapsed time are recorded in
the Data Pump log file.
Restrictions
• None
Example
> impdp hr SCHEMAS=hr DIRECTORY=dpump_dir1 LOGFILE=schemas.log
DUMPFILE=expdat.dmp METRICS=YES
3.4.24 NETWORK_LINK
Default: There is no default
Purpose
Enables an import from a (source) database identified by a valid database link. The
data from the source database instance is written directly back to the connected
database instance.
The NETWORK_LINK parameter initiates an import via a database link. This means that
the system to which the impdp client is connected contacts the source database
referenced by the source_database_link, retrieves data from it, and writes the data
directly to the database on the connected instance. There are no dump files involved.
The source_database_link provided must be the name of a database link to an
available database. If the database on that instance does not already have a database
link, then you or your DBA must create one using the SQL CREATE DATABASE LINK
statement.
When you perform a network import using the transportable method, you must copy
the source data files to the target database before you start the import.
If the source database is read-only, then the connected user must have a locally
managed tablespace assigned as the default temporary tablespace on the source
database. Otherwise, the job will fail.
This parameter is required when any of the following parameters are specified:
FLASHBACK_SCN, FLASHBACK_TIME, ESTIMATE, TRANSPORT_TABLESPACES, or TRANSPORTABLE.
The following types of database links are supported for use with Data Pump Import:
• Public fixed user
3-35
Chapter 3
Parameters Available in Import's Command-Line Mode
Caution:
If an import operation is performed over an unencrypted network link, then all
data is imported as clear text even if it is encrypted in the database. See Oracle
Database Security Guide for more information about network security.
Restrictions
• The following types of database links are not supported for use with Data Pump
Import:
– Private connected user
– Current user
• The Import NETWORK_LINK parameter is not supported for tables containing
SecureFiles that have ContentType set or that are currently stored outside of the
SecureFiles segment through Oracle Database File System Links.
• Network imports do not support the use of evolved types.
• When operating across a network link, Data Pump requires that the source and
target databases differ by no more than two versions. For example, if one
database is Oracle Database 12c, then the other database must be 12c, 11g, or
10g. Note that Data Pump checks only the major version number (for example,
10g,11g, 12c), not specific release numbers (for example, 12.1, 12.2, 11.1, 11.2,
10.1, or 10.2).
• If the USERID that is executing the import job has the DATAPUMP_IMP_FULL_DATABASE
role on the target database, then that user must also have the
DATAPUMP_EXP_FULL_DATABASE role on the source database.
• Network mode import does not use parallel query (PQ) slaves. See "Using
PARALLEL During a Network Mode Import".
Example
In the following example, the source_database_link would be replaced with the name of
a valid database link.
> impdp hr TABLES=employees DIRECTORY=dpump_dir1
NETWORK_LINK=source_database_link EXCLUDE=CONSTRAINT
This example results in an import of the employees table (excluding constraints) from
the source database. The log file is written to dpump_dir1, specified on the DIRECTORY
parameter.
3-36
Chapter 3
Parameters Available in Import's Command-Line Mode
See Also:
3.4.25 NOLOGFILE
Default: NO
Purpose
Specifies whether to suppress the default behavior of creating a log file.
If you specify NOLOGFILE=YES to suppress creation of a log file, then progress and error
information is still written to the standard output device of any attached clients,
including the client that started the original export operation. If there are no clients
attached to a running job and you specify NOLOGFILE=YES, then you run the risk of losing
important progress and error information.
Example
The following is an example of using the NOLOGFILE parameter.
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp NOLOGFILE=YES
This command results in a full mode import (the default for file-based imports) of the
expfull.dmp dump file. No log file is written because NOLOGFILE is set to YES.
3.4.26 PARALLEL
Default: 1
Purpose
Specifies the maximum number of processes of active execution operating on behalf
of the import job.
The value you specify for integer specifies the maximum number of processes of
active execution operating on behalf of the import job. This execution set consists of a
combination of worker processes and parallel I/O server processes. The master
control process, idle workers, and worker processes acting as parallel execution
3-37
Chapter 3
Parameters Available in Import's Command-Line Mode
coordinators in parallel I/O operations do not count toward this total. This parameter
enables you to make trade-offs between resource consumption and elapsed time.
If the source of the import is a dump file set consisting of files, then multiple processes
can read from the same file, but performance may be limited by I/O contention.
To increase or decrease the value of PARALLEL during job execution, use interactive-
command mode.
scott.part_table:p2
scott.sub_part_table:p1s2
scott.sub_part_table:p2s1
scott.sub_part_table:p2s2
During a network mode import, each table_data object is assigned its own worker
process, up to the value specified for the PARALLEL parameter. No parallel query (PQ)
slaves are assigned because network mode import does not use parallel query (PQ)
slaves. Multiple table_data objects can be unloaded at the same time, but each
table_data object is unloaded using a single process.
3-38
Chapter 3
Parameters Available in Import's Command-Line Mode
Restrictions
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
• To import a table or table partition in parallel (using PQ slaves), you must have the
DATAPUMP_IMP_FULL_DATABASE role.
Example
The following is an example of using the PARALLEL parameter.
> impdp hr DIRECTORY=dpump_dir1 LOGFILE=parallel_import.log
JOB_NAME=imp_par3 DUMPFILE=par_exp%U.dmp PARALLEL=3
This command imports the dump file set that is created when you run the example for
the Export PARALLEL parameter. (See "PARALLEL".) The names of the dump files are
par_exp01.dmp, par_exp02.dmp, and par_exp03.dmp.
See Also:
"Controlling Resource Consumption"
3.4.27 PARFILE
Default: There is no default
Purpose
Specifies the name of an import parameter file.
A parameter file allows you to specify Data Pump parameters within a file, and then
that file can be specified on the command line instead of entering all the individual
commands. This can be useful if you use the same parameter combination many
times. The use of parameter files is also highly recommended if you are using
parameters whose values require the use of quotation marks.
A directory object is not specified for the parameter file because unlike dump files, log
files, and SQL files which are created and written by the server, the parameter file is
opened and read by the impdp client. The default location of the parameter file is the
user's current directory.
Within a parameter file, a comma is implicit at every newline character so you do not
have to enter commas at the end of each line. If you have a long line that wraps, such
as a long table name, enter the backslash continuation character (\) at the end of the
current line to continue onto the next line.
The contents of the parameter file are written to the Data Pump log file.
3-39
Chapter 3
Parameters Available in Import's Command-Line Mode
Restrictions
• The PARFILE parameter cannot be specified within a parameter file.
Example
The content of an example parameter file, hr_imp.par, might be as follows:
TABLES= countries, locations, regions
DUMPFILE=dpump_dir2:exp1.dmp,exp2%U.dmp
DIRECTORY=dpump_dir1
PARALLEL=3
You could then issue the following command to execute the parameter file:
> impdp hr PARFILE=hr_imp.par
The tables named countries, locations, and regions will be imported from the dump
file set that is created when you run the example for the Export DUMPFILE parameter.
(See "DUMPFILE".) The import job looks for the exp1.dmp file in the location pointed to
by dpump_dir2. It looks for any dump files of the form exp2nn.dmp in the location pointed
to by dpump_dir1. The log file for the job will also be written to dpump_dir1.
See Also:
"Use of Quotation Marks On the Data Pump Command Line"
3.4.28 PARTITION_OPTIONS
Default: The default is departition when partition names are specified on the TABLES
parameter and TRANPORTABLE=ALWAYS is set (whether on the import operation or during
the export). Otherwise, the default is none.
Purpose
Specifies how table partitions should be created during an import operation.
A value of none creates tables as they existed on the system from which the export
operation was performed. You cannot use the none option or the merge option if the
export was performed with the transportable method, along with a partition or
subpartition filter. In such a case, you must use the departition option.
A value of departition promotes each partition or subpartition to a new individual
table. The default name of the new table will be the concatenation of the table and
partition name or the table and subpartition name, as appropriate.
A value of merge combines all partitions and subpartitions into one table.
3-40
Chapter 3
Parameters Available in Import's Command-Line Mode
• If a partitioned table is imported into an existing partitioned table, then Data Pump
only processes one partition or subpartition at a time, regardless of any value that
might be specified with the PARALLEL parameter.
• If the table into which you are importing does not already exist and Data Pump has
to create it, then the import runs in parallel up to the parallelism specified on the
PARALLEL parameter when the import is started.
Restrictions
• If the export operation that created the dump file was performed with the
transportable method and if a partition or subpartition was specified, then the
import operation must use the departition option.
• If the export operation that created the dump file was performed with the
transportable method, then the import operation cannot use
PARTITION_OPTIONS=MERGE.
• If there are any grants on objects being departitioned, then an error message is
generated and the objects are not loaded.
Example
The following example assumes that the sh.sales table has been exported into a dump
file named sales.dmp. It uses the merge option to merge all the partitions in sh.sales into
one non-partitioned table in scott schema.
> impdp system TABLES=sh.sales PARTITION_OPTIONS=MERGE
DIRECTORY=dpump_dir1 DUMPFILE=sales.dmp REMAP_SCHEMA=sh:scott
See Also:
"TRANSPORTABLE" for an example of performing an import operation using
PARTITION_OPTIONS=DEPARTITION
3.4.29 QUERY
Default: There is no default
Purpose
Allows you to specify a query clause that filters the data that gets imported.
The query_clause is typically a SQL WHERE clause for fine-grained row selection, but
could be any SQL clause. For example, an ORDER BY clause could be used to speed up
a migration from a heap-organized table to an index-organized table. If a schema and
table name are not supplied, then the query is applied to (and must be valid for) all
tables in the source dump file set or database. A table-specific query overrides a query
applied to all tables.
3-41
Chapter 3
Parameters Available in Import's Command-Line Mode
When the query is to be applied to a specific table, a colon (:) must separate the table
name from the query clause. More than one table-specific query can be specified, but
only one query can be specified per table.
If the NETWORK_LINK parameter is specified along with the QUERY parameter, then any
objects specified in the query_clause that are on the remote (source) node must be
explicitly qualified with the NETWORK_LINK value. Otherwise, Data Pump assumes that
the object is on the local (target) node; if it is not, then an error is returned and the
import of the table from the remote (source) system fails.
For example, if you specify NETWORK_LINK=dblink1, then the query_clause of the QUERY
parameter must specify that link, as shown in the following example:
QUERY=(hr.employees:"WHERE last_name IN(SELECT last_name
FROM hr.employees@dblink1)")
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
See "Use of Quotation Marks On the Data Pump Command Line".
When the QUERY parameter is used, the external tables method (rather than the direct
path method) is used for data access.
To specify a schema other than your own in a table-specific query, you must be
granted access to that specific table.
Restrictions
• The QUERY parameter cannot be used with the following parameters:
– CONTENT=METADATA_ONLY
– SQLFILE
– TRANSPORT_DATAFILES
• When the QUERY parameter is specified for a table, Data Pump uses external tables
to load the target table. External tables uses a SQL INSERT statement with a SELECT
clause. The value of the QUERY parameter is included in the WHERE clause of the
SELECT portion of the INSERT statement. If the QUERY parameter includes references
to another table with columns whose names match the table being loaded, and if
those columns are used in the query, then you will need to use a table alias to
distinguish between columns in the table being loaded and columns in the SELECT
statement with the same name. The table alias used by Data Pump for the table
being loaded is KU$.
For example, suppose you are importing a subset of the sh.sales table based on
the credit limit for a customer in the sh.customers table. In the following example,
KU$ is used to qualify the cust_id field in the QUERY parameter for loading sh.sales.
As a result, Data Pump imports only rows for customers whose credit limit is
greater than $10,000.
QUERY='sales:"WHERE EXISTS (SELECT cust_id FROM customers c
WHERE cust_credit_limit > 10000 AND ku$.cust_id = c.cust_id)"'
If KU$ is not used for a table alias, then all rows are loaded:
QUERY='sales:"WHERE EXISTS (SELECT cust_id FROM customers c
WHERE cust_credit_limit > 10000 AND cust_id = c.cust_id)"'
3-42
Chapter 3
Parameters Available in Import's Command-Line Mode
• The maximum length allowed for a QUERY string is 4000 bytes including quotation
marks, which means that the actual maximum length allowed is 3998 bytes.
Example
The following is an example of using the QUERY parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL". Because the QUERY value uses quotation marks,
Oracle recommends that you use a parameter file.
Suppose you have a parameter file, query_imp.par, that contains the following:
QUERY=departments:"WHERE department_id < 120"
All tables in expfull.dmp are imported, but for the departments table, only data that
meets the criteria specified in the QUERY parameter is imported.
3.4.30 REMAP_DATA
Default: There is no default
Purpose
The REMAP_DATA parameter allows you to remap data as it is being inserted into a new
database. A common use is to regenerate primary keys to avoid conflict when
importing a table into a preexisting table on the target database.
You can specify a remap function that takes as a source the value of the designated
column from either the dump file or a remote database. The remap function then
returns a remapped value that will replace the original value in the target database.
The same function can be applied to multiple columns being dumped. This is useful
when you want to guarantee consistency in remapping both the child and parent
column in a referential constraint.
The description of each syntax element, in the order in which they appear in the
syntax, is as follows:
schema: the schema containing the table to be remapped. By default, this is the
schema of the user doing the import.
tablename: the table whose column will be remapped.
column_name: the column whose data is to be remapped.
schema: the schema containing the PL/SQL package you created that contains the
remapping function. As a default, this is the schema of the user doing the import.
pkg: the name of the PL/SQL package you created that contains the remapping
function.
3-43
Chapter 3
Parameters Available in Import's Command-Line Mode
function: the name of the function within the PL/SQL that will be called to remap the
column table in each row of the specified table.
Restrictions
• The data types of the source argument and the returned value should both match
the data type of the designated column in the table.
• Remapping functions should not perform commits or rollbacks except in
autonomous transactions.
• The use of synonyms as values for the REMAP_DATA parameter is not supported. For
example, if the regions table in the hr schema had a synonym of regn, an error
would be returned if you specified regn as part of the REMPA_DATA specification.
• Remapping LOB column data of a remote table is not supported.
• Columns of the following types are not supported byREMAP_DATA: User Defined
Types, attributes of User Defined Types, LONGs, REFs, VARRAYs, Nested
Tables, BFILEs, and XMLtype.
Example
The following example assumes a package named remap has been created that
contains a function named plusx that changes the values for first_name in the
employees table.
3.4.31 REMAP_DATAFILE
Default: There is no default
Purpose
Changes the name of the source data file to the target data file name in all SQL
statements where the source data file is referenced: CREATE TABLESPACE, CREATE
LIBRARY, and CREATE DIRECTORY.
Remapping data files is useful when you move databases between platforms that have
different file naming conventions. The source_datafile and target_datafile names
should be exactly as you want them to appear in the SQL statements where they are
referenced. Oracle recommends that you enclose data file names in quotation marks
to eliminate ambiguity on platforms for which a colon is a valid file specification
character.
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
recommends that you place this parameter in a parameter file, which can reduce the
number of escape characters that might otherwise be needed on the command line.
You must have the DATAPUMP_IMP_FULL_DATABASE role to specify this parameter.
3-44
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
Suppose you had a parameter file, payroll.par, with the following content:
DIRECTORY=dpump_dir1
FULL=YES
DUMPFILE=db_full.dmp
REMAP_DATAFILE="'DB1$:[HRDATA.PAYROLL]tbs6.dbf':'/db1/hrdata/payroll/tbs6.dbf'"
See Also:
"Use of Quotation Marks On the Data Pump Command Line"
3.4.32 REMAP_DIRECTORY
The REMAP_DIRECTORY parameter lets you remap directories when you move databases
between platforms.
Default: There is no default.
Purpose
The REMAP_DIRECTORY parameter changes the source directory string to the target
directory string in all SQL statements where the source directory is the left-most
portion of a full file or directory specification: CREATE TABLESPACE, CREATE LIBRARY, and
CREATE DIRECTORY.
Remapping a directory is useful when you move databases between platforms that
have different directory file naming conventions. This provides an easy way to remap
multiple data files in a directory when you only want to change the directory file
specification while preserving the original data file names.
The source_directory_string and target_directory_string should be exactly as you want
them to appear in the SQL statements where they are referenced. In addition, it is
recommended that the directory be properly terminated with the directory file
terminator for the respective source and target platform. Oracle recommends that you
enclose the directory names in quotation marks to eliminate ambiguity on platforms for
which a colon is a valid directory file specification character.
Depending on your operating system, the use of quotation marks when you specify a
value for this parameter may also require that you use escape characters. Oracle
3-45
Chapter 3
Parameters Available in Import's Command-Line Mode
recommends that you place this parameter in a parameter file which can reduce the
number of escape characters that might otherwise be needed on the command line.
You must have the DATAPUMP_IMP_FULL_DATABASE role to specify this parameter.
Restrictions
• The REMAP_DIRECTORY and REMAP_DATAFILE parameters are mutually exclusive.
Example
Suppose you want to remap the following data files:
DB1$:[HRDATA.PAYROLL]tbs5.dbf
DB1$:[HRDATA.PAYROLL]tbs6.dbf
In addition, you have a parameter file, payroll.par, with the following content:
DIRECTORY=dpump_dir1
FULL=YES
DUMPFILE=db_full.dmp
REMAP_DIRECTORY="'DB1$:[HRDATA.PAYROLL]':'/db1/hrdata/payroll/'"
3.4.33 REMAP_SCHEMA
Default: There is no default
Purpose
Loads all objects from the source schema into a target schema.
Multiple REMAP_SCHEMA lines can be specified, but the source schema must be different
for each one. However, different source schemas can map to the same target schema.
Note that the mapping may not be 100 percent complete; see the Restrictions section
below.
If the schema you are remapping to does not already exist, then the import operation
creates it, provided that the dump file set contains the necessary CREATE USER metadata
for the source schema, and provided that you are importing with enough privileges.
For example, the following Export commands create dump file sets with the necessary
metadata to create a schema, because the user SYSTEM has the necessary privileges:
> expdp system SCHEMAS=hr
Password: password
3-46
Chapter 3
Parameters Available in Import's Command-Line Mode
If your dump file set does not contain the metadata necessary to create a schema, or if
you do not have privileges, then the target schema must be created before the import
operation is performed. This is because the unprivileged dump files do not contain the
necessary information for the import to create the schema automatically.
For Oracle databases earlier than Oracle Database 11g, if the import operation does
create the schema, then after the import is complete, you must assign it a valid
password to connect to it. The SQL statement to do this, which requires privileges, is:
SQL> ALTER USER schema_name IDENTIFIED BY new_password
Restrictions
• Unprivileged users can perform schema remaps only if their schema is the target
schema of the remap. (Privileged users can perform unrestricted schema remaps.)
For example, SCOTT can remap his BLAKE's objects to SCOTT, but SCOTT cannot remap
SCOTT's objects to BLAKE.
• The mapping may not be 100 percent complete because there are certain schema
references that Import is not capable of finding. For example, Import will not find
schema references embedded within the body of definitions of types, views,
procedures, and packages.
• For triggers, REMAP_SCHEMA affects only the trigger owner.
• If any table in the schema being remapped contains user-defined object types and
that table changes between the time it is exported and the time you attempt to
import it, then the import of that table will fail. However, the import operation itself
will continue.
• By default, if schema objects on the source database have object identifiers
(OIDs), then they are imported to the target database with those same OIDs. If an
object is imported back into the same database from which it was exported, but
into a different schema, then the OID of the new (imported) object would be the
same as that of the existing object and the import would fail. For the import to
succeed you must also specify the TRANSFORM=OID:N parameter on the import. The
transform OID:N causes a new OID to be created for the new object, allowing the
import to succeed.
Example
Suppose that, as user SYSTEM, you execute the following Export and Import commands
to remap the hr schema into the scott schema:
> expdp system SCHEMAS=hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp
In this example, if user scott already exists before the import, then the Import
REMAP_SCHEMA command will add objects from the hr schema into the existing scott
schema. You can connect to the scott schema after the import by using the existing
password (without resetting it).
If user scott does not exist before you execute the import operation, then Import
automatically creates it with an unusable password. This is possible because the
dump file, hr.dmp, was created by SYSTEM, which has the privileges necessary to create
a dump file that contains the metadata needed to create a schema. However, you
3-47
Chapter 3
Parameters Available in Import's Command-Line Mode
cannot connect to scott on completion of the import, unless you reset the password for
scott on the target database after the import completes.
3.4.34 REMAP_TABLE
Default: There is no default
Purpose
Allows you to rename tables during an import operation.
OR
REMAP_TABLE=[schema.]old_tablename[:partition]:new_tablename
You can use the REMAP_TABLE parameter to rename entire tables or to rename table
partitions if the table is being departitioned. (See "PARTITION_OPTIONS".)
You can also use it to override the automatic naming of table partitions that were
exported.
Usage Notes
Be aware that with the first syntax, if you specify REMAP_TABLE=A.B:C, then Import
assumes that A is a schema name, B is the old table name, and C is the new table
name. To use the first syntax to rename a partition that is being promoted to a
nonpartitioned table, you must specify a schema name.
To use the second syntax to rename a partition being promoted to a nonpartitioned
table, you only need to qualify it with the old table name. No schema name is required.
Restrictions
• Only objects created by the Import will be remapped. In particular, preexisting
tables will not be remapped.
• The REMAP_TABLE parameter will not work if the table being remapped has named
constraints in the same schema and the constraints need to be created when the
table is created.
Example
The following is an example of using the REMAP_TABLE parameter to rename the
employees table to a new name of emps:
3.4.35 REMAP_TABLESPACE
Default: There is no default
3-48
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Remaps all objects selected for import with persistent data in the source tablespace to
be created in the target tablespace.
Multiple REMAP_TABLESPACE parameters can be specified, but no two can have the same
source tablespace. The target schema must have sufficient quota in the target
tablespace.
Note that use of the REMAP_TABLESPACE parameter is the only way to remap a tablespace
in Data Pump Import. This is a simpler and cleaner method than the one provided in
the original Import utility. That method was subject to many restrictions (including the
number of tablespace subclauses) which sometimes resulted in the failure of some
DDL commands.
By contrast, the Data Pump Import method of using the REMAP_TABLESPACE parameter
works for all objects, including the user, and it works regardless of how many
tablespace subclauses are in the DDL statement.
Restrictions
• Data Pump Import can only remap tablespaces for transportable imports in
databases where the compatibility level is set to 10.1 or later.
• Only objects created by the Import will be remapped. In particular, the tablespaces
for preexisting tables will not be remapped if TABLE_EXISTS_ACTION is set to SKIP,
TRUNCATE, or APPEND.
Example
The following is an example of using the REMAP_TABLESPACE parameter.
> impdp hr REMAP_TABLESPACE=tbs_1:tbs_6 DIRECTORY=dpump_dir1
DUMPFILE=employees.dmp
3.4.36 REUSE_DATAFILES
Default: NO
Purpose
Specifies whether the import job should reuse existing data files for tablespace
creation.
If the default (n) is used and the data files specified in CREATE TABLESPACE statements
already exist, then an error message from the failing CREATE TABLESPACE statement is
issued, but the import job continues.
If this parameter is specified as y, then the existing data files are reinitialized.
3-49
Chapter 3
Parameters Available in Import's Command-Line Mode
Caution:
Specifying REUSE_DATAFILES=YES may result in a loss of data.
Example
The following is an example of using the REUSE_DATAFILES parameter. You can create
the expfull.dmp dump file used in this example by running the example provided for
the Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp LOGFILE=reuse.log
REUSE_DATAFILES=YES
This example reinitializes data files referenced by CREATE TABLESPACE statements in the
expfull.dmp file.
3.4.37 SCHEMAS
Default: There is no default
Purpose
Specifies that a schema-mode import is to be performed.
If you have the DATAPUMP_IMP_FULL_DATABASE role, then you can use this parameter to
perform a schema-mode import by specifying a list of schemas to import. First, the
user definitions are imported (if they do not already exist), including system and role
grants, password history, and so on. Then all objects contained within the schemas
are imported. Unprivileged users can specify only their own schemas or schemas
remapped to their own schemas. In that case, no information about the schema
definition is imported, only the objects contained within it.
The use of filtering can restrict what is imported using this import mode. See "Filtering
During Import Operations".
Schema mode is the default mode when you are performing a network-based import.
Example
The following is an example of using the SCHEMAS parameter. You can create the
expdat.dmp file used in this example by running the example provided for the Export
SCHEMAS parameter. See "SCHEMAS".
The hr schema is imported from the expdat.dmp file. The log file, schemas.log, is written
to dpump_dir1.
3-50
Chapter 3
Parameters Available in Import's Command-Line Mode
3.4.38 SERVICE_NAME
Default: There is no default
Purpose
Used to specify a service name to be used in conjunction with the CLUSTER parameter.
The SERVICE_NAME parameter can be used with the CLUSTER=YES parameter to specify an
existing service associated with a resource group that defines a set of Oracle Real
Application Clusters (Oracle RAC) instances belonging to that resource group,
typically a subset of all the Oracle RAC instances.
The service name is only used to determine the resource group and instances defined
for that resource group. The instance where the job is started is always used,
regardless of whether it is part of the resource group.
The SERVICE_NAME parameter is ignored if CLUSTER=NO is also specified.
Example
> impdp system DIRECTORY=dpump_dir1 SCHEMAS=hr
SERVICE_NAME=sales NETWORK_LINK=dbs1
This example starts a schema-mode network import of the hr schema. Even though
CLUSTER=YES is not specified on the command line, it is the default behavior, so the job
will use all instances in the resource group associated with the service name sales.
The NETWORK_LINK value of dbs1 would be replaced with the name of the source
database from which you were importing data. (Note that there is no dump file
generated because this is a network import.)
3-51
Chapter 3
Parameters Available in Import's Command-Line Mode
The NETWORK_LINK parameter is simply being used as part of the example. It is not
required when using the SERVICE_NAME parameter.
See Also:
"CLUSTER"
3.4.39 SKIP_UNUSABLE_INDEXES
Default: the value of the Oracle Database configuration parameter,
SKIP_UNUSABLE_INDEXES.
Purpose
Specifies whether Import skips loading tables that have indexes that were set to the
Index Unusable state (by either the system or the user).
Note:
This parameter is useful only when importing data into an existing table. It has
no practical effect when a table is created as part of an import because in that
case, the table and indexes are newly created and will not be marked
unusable.
Example
The following is an example of using the SKIP_UNUSABLE_INDEXES parameter. You can
create the expfull.dmp dump file used in this example by running the example provided
for the Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp LOGFILE=skip.log
SKIP_UNUSABLE_INDEXES=YES
3-52
Chapter 3
Parameters Available in Import's Command-Line Mode
3.4.40 SOURCE_EDITION
Default: the default database edition on the remote node from which objects will be
fetched
Purpose
Specifies the database edition on the remote node from which objects will be fetched.
Restrictions
• The SOURCE_EDITION parameter is valid on an import operation only when the
NETWORK_LINK parameter is also specified. See "NETWORK_LINK".
• This parameter is only useful if there are two or more versions of the same
versionable objects in the database.
• The job version must be set to 11.2 or later. See "VERSION".
Example
The following is an example of using the import SOURCE_EDITION parameter:
> impdp hr DIRECTORY=dpump_dir1 SOURCE_EDITION=exp_edition
NETWORK_LINK=source_database_link EXCLUDE=USER
This example assumes the existence of an edition named exp_edition on the system
from which objects are being imported. Because no import mode is specified, the
default of schema mode will be used. The source_database_link would be replaced
with the name of the source database from which you were importing data. The
EXCLUDE=USER parameter excludes only the definitions of users, not the objects
contained within users' schemas. (Note that there is no dump file generated because
this is a network import.)
See Also:
3-53
Chapter 3
Parameters Available in Import's Command-Line Mode
3.4.41 SQLFILE
Default: There is no default
Purpose
Specifies a file into which all of the SQL DDL that Import would have executed, based
on other parameters, is written.
The file_name specifies where the import job will write the DDL that would be executed
during the job. The SQL is not actually executed, and the target system remains
unchanged. The file is written to the directory object specified in the DIRECTORY
parameter, unless another directory_object is explicitly specified here. Any existing
file that has a name matching the one specified with this parameter is overwritten.
Note that passwords are not included in the SQL file. For example, if a CONNECT
statement is part of the DDL that was executed, then it will be replaced by a comment
with only the schema name shown. In the following example, the dashes (--) indicate
that a comment follows, and the hr schema name is shown, but not the password.
-- CONNECT hr
Therefore, before you can execute the SQL file, you must edit it by removing the
dashes indicating a comment and adding the password for the hr schema.
Data Pump places any ALTER SESSION statements at the top of the SQL file created by
Data Pump import. So if the import operation has different connection statements, you
must manually copy each of the ALTER SESSION statements and paste them after the
appropriate CONNECT statements.
For Streams and other Oracle database options, anonymous PL/SQL blocks may
appear within the SQLFILE output. They should not be executed directly.
Restrictions
• If SQLFILE is specified, then the CONTENT parameter is ignored if it is set to either ALL
or DATA_ONLY.
• To perform a Data Pump Import to a SQL file using Oracle Automatic Storage
Management (Oracle ASM), the SQLFILE parameter that you specify must include a
directory object that does not use the Oracle ASM + notation. That is, the SQL file
must be written to a disk file, not into the Oracle ASM storage.
• The SQLFILE parameter cannot be used in conjunction with the QUERY parameter.
Example
The following is an example of using the SQLFILE parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp
SQLFILE=dpump_dir2:expfull.sql
3-54
Chapter 3
Parameters Available in Import's Command-Line Mode
3.4.42 STATUS
Default: 0
Purpose
Specifies the frequency at which the job status will be displayed.
If you supply a value for integer, it specifies how frequently, in seconds, job status
should be displayed in logging mode. If no value is entered or if the default value of 0
is used, then no additional information is displayed beyond information about the
completion of each object type, table, or partition.
This status information is written only to your standard output device, not to the log file
(if one is in effect).
Example
The following is an example of using the STATUS parameter. You can create the
expfull.dmp dump file used in this example by running the example provided for the
Export FULL parameter. See "FULL".
> impdp hr NOLOGFILE=YES STATUS=120 DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp
In this example, the status is shown every two minutes (120 seconds).
3.4.43 STREAMS_CONFIGURATION
Default: YES
Purpose
Specifies whether to import any Streams metadata that may be present in the export
dump file.
Example
The following is an example of using the STREAMS_CONFIGURATION parameter. You can
create the expfull.dmp dump file used in this example by running the example provided
for the Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp STREAMS_CONFIGURATION=NO
3-55
Chapter 3
Parameters Available in Import's Command-Line Mode
See Also:
Oracle Streams Replication Administrator's Guide
3.4.44 TABLE_EXISTS_ACTION
Default: SKIP (Note that if CONTENT=DATA_ONLY is specified, then the default is APPEND, not
SKIP.)
Purpose
Tells Import what to do if the table it is trying to create already exists.
• TRUNCATE deletes existing rows and then loads rows from the source.
• REPLACE drops the existing table and then creates and loads it from the source.
This is not a valid option if the CONTENT parameter is set to DATA_ONLY.
The following considerations apply when you are using these options:
• When you use TRUNCATE or REPLACE, ensure that rows in the affected tables are not
targets of any referential constraints.
• When you use SKIP, APPEND, or TRUNCATE, existing table-dependent objects in the
source, such as indexes, grants, triggers, and constraints, are not modified. For
REPLACE, the dependent objects are dropped and re-created from the source, if they
were not explicitly or implicitly excluded (using EXCLUDE) and they exist in the
source dump file or system.
• When you use APPEND or TRUNCATE, checks are made to ensure that rows from the
source are compatible with the existing table before performing any action.
If the existing table has active constraints and triggers, then it is loaded using the
external tables access method. If any row violates an active constraint, then the
load fails and no data is loaded. You can override this behavior by specifying
DATA_OPTIONS=SKIP_CONSTRAINT_ERRORS on the Import command line.
If you have data that must be loaded, but may cause constraint violations, then
consider disabling the constraints, loading the data, and then deleting the problem
rows before reenabling the constraints.
• When you use APPEND, the data is always loaded into new space; existing space,
even if available, is not reused. For this reason, you may want to compress your
data after the load.
3-56
Chapter 3
Parameters Available in Import's Command-Line Mode
Note:
When Data Pump detects that the source table and target table do not match
(the two tables do not have the same number of columns or the target table has
a column name that is not present in the source table), it compares column
names between the two tables. If the tables have at least one column in
common, then the data for the common columns is imported into the table
(assuming the data types are compatible). The following restrictions apply:
• This behavior is not supported for network imports.
• The following types of columns cannot be dropped: object columns, object
attributes, nested table columns, and ref columns based on a primary key.
Restrictions
• TRUNCATE cannot be used on clustered tables.
Example
The following is an example of using the TABLE_EXISTS_ACTION parameter. You can
create the expfull.dmp dump file used in this example by running the example provided
for the Export FULL parameter. See "FULL".
> impdp hr TABLES=employees DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp
TABLE_EXISTS_ACTION=REPLACE
3.4.45 TABLES
Default: There is no default
Purpose
Specifies that you want to perform a table-mode import.
In a table-mode import, you can filter the data that is imported from the source by
specifying a comma-delimited list of tables and partitions or subpartitions.
If you do not supply a schema_name, then it defaults to that of the current user. To
specify a schema other than your own, you must either have the
DATAPUMP_IMP_FULL_DATABASE role or remap the schema to the current user.
The use of filtering can restrict what is imported using this import mode. See "Filtering
During Import Operations".
If a partition_name is specified, then it must be the name of a partition or subpartition
in the associated table.
3-57
Chapter 3
Parameters Available in Import's Command-Line Mode
Use of the wildcard character, %, to specify table names and partition names is
supported.
The following restrictions apply to table names:
• By default, table names in a database are stored as uppercase. If you have a table
name in mixed-case or lowercase, and you want to preserve case sensitivity for
the table name, then you must enclose the name in quotation marks. The name
must exactly match the table name stored in the database.
Some operating systems require that quotation marks on the command line be
preceded by an escape character. The following are examples of how case-
sensitivity can be preserved in the different Import modes.
– In command-line mode:
TABLES='\"Emp\"'
– In parameter file mode:
TABLES='"Emp"'
• Table names specified on the command line cannot include a pound sign (#),
unless the table name is enclosed in quotation marks. Similarly, in the parameter
file, if a table name includes a pound sign (#), then the Import utility interprets the
rest of the line as a comment, unless the table name is enclosed in quotation
marks.
For example, if the parameter file contains the following line, then Import interprets
everything on the line after emp# as a comment and does not import the tables dept
and mydata:
TABLES=(emp#, dept, mydata)
However, if the parameter file contains the following line, then the Import utility
imports all three tables because emp# is enclosed in quotation marks:
TABLES=('"emp#"', dept, mydata)
Note:
Some operating systems require single quotation marks rather than double
quotation marks, or the reverse; see your Oracle operating system-specific
documentation. Different operating systems also have other restrictions on
table naming.
For example, the UNIX C shell attaches a special meaning to a dollar sign
($) or pound sign (#) (or certain other special characters). You must use
escape characters to get such characters in the name past the shell and
into Import.
Restrictions
• The use of synonyms as values for the TABLES parameter is not supported. For
example, if the regions table in the hr schema had a synonym of regn, then it
would not be valid to use TABLES=regn. An error would be returned.
• You can only specify partitions from one table if PARTITION_OPTIONS=DEPARTITION is
also specified on the import.
3-58
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
The following example shows a simple use of the TABLES parameter to import only the
employees and jobs tables from the expfull.dmp file. You can create the expfull.dmp
dump file used in this example by running the example provided for the Export FULL
parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp TABLES=employees,jobs
The following example shows the use of the TABLES parameter to import partitions:
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp
TABLES=sh.sales:sales_Q1_2012,sh.sales:sales_Q2_2012
This example imports the partitions sales_Q1_2012 and sales_Q2_2012 for the table sales
in the schema sh.
3.4.46 TABLESPACES
Default: There is no default
Purpose
Specifies that you want to perform a tablespace-mode import.
Use TABLESPACES to specify a list of tablespace names whose tables and dependent
objects are to be imported from the source (full, schema, tablespace, or table-mode
export dump file set or another database).
During the following import situations, Data Pump automatically creates the
tablespaces into which the data will be imported:
• The import is being done in FULL or TRANSPORT_TABLESPACES mode
• The import is being done in table mode with TRANSPORTABLE=ALWAYS
In all other cases, the tablespaces for the selected objects must already exist on the
import database. You could also use the Import REMAP_TABLESPACE parameter to map
the tablespace name to an existing tablespace on the import database.
The use of filtering can restrict what is imported using this import mode. See "Filtering
During Import Operations".
Restrictions
• The length of the list of tablespace names specified for the TABLESPACES parameter
is limited to a maximum of 4 MB, unless you are using the NETWORK_LINK parameter
3-59
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
The following is an example of using the TABLESPACES parameter. It assumes that the
tablespaces already exist. You can create the expfull.dmp dump file used in this
example by running the example provided for the Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp
TABLESPACES=tbs_1,tbs_2,tbs_3,tbs_4
This example imports all tables that have data in tablespaces tbs_1, tbs_2, tbs_3, and
tbs_4.
3.4.47 TARGET_EDITION
Default: the default database edition on the system
Purpose
Specifies the database edition into which objects should be imported.
If TARGET_EDITION=name is specified, then Data Pump Import creates all of the objects
found in the dump file. Objects that are not editionable are created in all editions. For
example, tables are not editionable, so if there is a table in the dump file, then it will be
created, and all editions will see it. Objects in the dump file that are editionable, such
as procedures, are created only in the specified target edition.
If this parameter is not specified, then the default edition on the target database is
used, even if an edition was specified in the export job. If the specified edition does not
exist or is not usable, then an error message is returned.
Restrictions
• This parameter is only useful if there are two or more versions of the same
versionable objects in the database.
• The job version must be 11.2 or later. See "VERSION".
Example
The following is an example of using the TARGET_EDITION parameter:
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=exp_dat.dmp TARGET_EDITION=exp_edition
This example assumes the existence of an edition named exp_edition on the system
to which objects are being imported. Because no import mode is specified, the default
of schema mode will be used.
3-60
Chapter 3
Parameters Available in Import's Command-Line Mode
See Also:
3.4.48 TRANSFORM
Default: There is no default
Purpose
Enables you to alter object creation DDL for objects being imported.
This transform is valid for the following object types: INDEX and TABLE.
If set to Y, then the logging attributes for the specified object types (TABLE and/or
INDEX) are disabled before the data is imported. If set to N (the default), then
archive logging is not disabled during import. After the data has been loaded, the
logging attributes for the objects are restored to their original settings. If no object
type is specified, then the DISABLE_ARCHIVE_LOGGING behavior is applied to both
TABLE and INDEX object types. This transform works for both file mode imports
and network mode imports. It does not apply to transportable tablespace imports.
Note:
If the database is in FORCE LOGGING mode, then the DISABLE_ARCHIVE_LOGGING
option will not disable logging when indexes and tables are created.
• INMEMORY:[Y | N]
This transform is valid for the following object types: TABLE and TABLESPACE.
The INMEMORY transform is related to the In-Memory Column Store (IM column
store). The IM column store is an optional portion of the system global area (SGA)
that stores copies of tables, table partitions, and other database objects. In the IM
column store, data is populated by column rather than row as it is in other parts of
the SGA, and data is optimized for rapid scans. The IM column store does not
3-61
Chapter 3
Parameters Available in Import's Command-Line Mode
replace the buffer cache, but acts as a supplement so that both memory areas can
store the same data in different formats. The IM column store is included with the
Oracle Database In-Memory option.
If Y (the default value) is specified on import, then Data Pump keeps the IM column
store clause for all objects that have one. When those objects are recreated at
import time, Data Pump generates the IM column store clause that matches the
setting for those objects at export time.
If N is specified on import, then Data Pump drops the IM column store clause from
all objects that have one. If there is no IM column store clause for an object that is
stored in a tablespace, then the object inherits the IM column store clause from the
tablespace. So if you are migrating a database and want the new database to use
IM column store features, you could pre-create the tablespaces with the
appropriate IM column store clause and then use TRANSFORM=INMEMORY:N on the
import command. The object would then inherit the IM column store clause from
the new pre-created tablespace.
If you do not use the INMEMORY transform, then you must individually alter every
object to add the appropriate IM column store clause.
Note:
The INMEMORY transform is available only in Oracle Database 12c Release 1
(12.1.0.2) or later.
See Also:
This transform is valid for the following object types: TABLE and TABLESPACE.
The INMEMORY_CLAUSE transform is related to the In-Memory Column Store (IM
column store). The IM column store is an optional portion of the system global
area (SGA) that stores copies of tables, table partitions, and other database
objects. In the IM column store, data is populated by column rather than row as it
is in other parts of the SGA, and data is optimized for rapid scans. The IM column
store does not replace the buffer cache, but acts as a supplement so that both
memory areas can store the same data in different formats. The IM column store
is included with the Oracle Database In-Memory option.
When you specify this transform, Data Pump uses the contents of the string as the
INMEMORY_CLAUSE for all objects being imported that have an IM column store clause
in their DDL. This transform is useful when you want to override the IM column
store clause for an object in the dump file.
The string that you supply must be enclosed in double quotation marks. If you are
entering the command on the command line, be aware that some operating
systems may strip out the quotation marks during parsing of the command, which
will cause an error. You can avoid this by using backslash escape characters. For
example:
3-62
Chapter 3
Parameters Available in Import's Command-Line Mode
Alternatively you can put parameters in a parameter file, and the quotation marks
will be maintained during processing.
Note:
The INMEMORY_CLAUSE transform is available only in Oracle Database 12c
Release 1 (12.1.0.2) or later.
See Also:
This transform is valid for the following object types: INC_TYPE, TABLE, and
TYPE
If Y (the default value) is specified on import, then the exported OIDs are assigned
to new object tables and types. Data Pump also performs OID checking when
looking for an existing matching type on the target database.
If N is specified on import, then:
– The assignment of the exported OID during the creation of new object tables
and types is inhibited. Instead, a new OID is assigned. This can be useful for
cloning schemas, but does not affect referenced objects.
– Prior to loading data for a table associated with a type, Data Pump skips
normal type OID checking when looking for an existing matching type on the
target database. Other checks using a type's hash code, version number, and
type name are still performed.
• PCTSPACE:some_number_greater_than_zero
This transform is valid for the following object types: CLUSTER, CONSTRAINT,
INDEX, ROLLBACK_SEGMENT, TABLE, and TABLESPACE.
3-63
Chapter 3
Parameters Available in Import's Command-Line Mode
The value supplied for this transform must be a number greater than zero. It
represents the percentage multiplier used to alter extent allocations and the size of
data files.
Note that you can use the PCTSPACE transform with the Data Pump Export SAMPLE
parameter so that the size of storage allocations matches the sampled data
subset. (See "SAMPLE".)
• SEGMENT_ATTRIBUTES:[Y | N]
This transform is valid for the following object types: CLUSTER, CONSTRAINT,
INDEX, ROLLBACK_SEGMENT, TABLE, and TABLESPACE.
If the value is specified as Y, then segment attributes (physical attributes, storage
attributes, tablespaces, and logging) are included, with appropriate DDL. The
default is Y.
• SEGMENT_CREATION:[Y | N]
This transform is valid for the following object types: CLUSTER, CONSTRAINT,
INDEX, ROLLBACK_SEGMENT, and TABLE.
If the value is specified as Y, then the storage clauses are included, with
appropriate DDL. The default is Y. This parameter is ignored if
SEGMENT_ATTRIBUTES=N.
• TABLE_COMPRESSION_CLAUSE:[NONE | compression_clause]
Specifying this transform changes the type of compression for all tables in the job,
including tables that provide storage for materialized views.
Example
For the following example, assume that you have exported the employees table in the
hr schema. The SQL CREATE TABLE statement that results when you then import the
table is similar to the following:
3-64
Chapter 3
Parameters Available in Import's Command-Line Mode
If you do not want to retain the STORAGE clause or TABLESPACE clause, then you can
remove them from the CREATE STATEMENT by using the Import TRANSFORM parameter.
Specify the value of SEGMENT_ATTRIBUTES as N. This results in the exclusion of segment
attributes (both storage and tablespace) from the table.
> impdp hr TABLES=hr.employees DIRECTORY=dpump_dir1 DUMPFILE=hr_emp.dmp
TRANSFORM=SEGMENT_ATTRIBUTES:N:table
The resulting CREATE TABLE statement for the employees table would then look similar to
the following. It does not contain a STORAGE or TABLESPACE clause; the attributes for the
default tablespace for the HR schema will be used instead.
CREATE TABLE "HR"."EMPLOYEES"
( "EMPLOYEE_ID" NUMBER(6,0),
"FIRST_NAME" VARCHAR2(20),
"LAST_NAME" VARCHAR2(25) CONSTRAINT "EMP_LAST_NAME_NN" NOT NULL ENABLE,
"EMAIL" VARCHAR2(25) CONSTRAINT "EMP_EMAIL_NN" NOT NULL ENABLE,
"PHONE_NUMBER" VARCHAR2(20),
"HIRE_DATE" DATE CONSTRAINT "EMP_HIRE_DATE_NN" NOT NULL ENABLE,
"JOB_ID" VARCHAR2(10) CONSTRAINT "EMP_JOB_NN" NOT NULL ENABLE,
"SALARY" NUMBER(8,2),
"COMMISSION_PCT" NUMBER(2,2),
"MANAGER_ID" NUMBER(6,0),
"DEPARTMENT_ID" NUMBER(4,0)
);
The SEGMENT_ATTRIBUTES and STORAGE transforms can be applied to all applicable table
and index objects by not specifying the object type on the TRANSFORM parameter, as
shown in the following command:
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp SCHEMAS=hr
TRANSFORM=SEGMENT_ATTRIBUTES:N
3.4.49 TRANSPORT_DATAFILES
Default: There is no default
3-65
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Specifies a list of data files to be imported into the target database by a transportable-
tablespace mode import, or by a table-mode or full-mode import if
TRANSPORTABLE=ALWAYS was set during the export. The data files must already exist on
the target database system.
Restrictions
• The TRANSPORT_DATAFILES parameter cannot be used in conjunction with the QUERY
parameter.
• Transportable import jobs cannot be restarted.
• The TRANSPORT_DATAFILES directory portion of the absolute file path cannot contain
wildcards. However, the file name portion of the absolute file path can contain
wildcards
Example 1
The following is an example of using the TRANSPORT_DATAFILES parameter. Assume you
have a parameter file, trans_datafiles.par, with the following content:
DIRECTORY=dpump_dir1
DUMPFILE=tts.dmp
TRANSPORT_DATAFILES='/user01/data/tbs1.dbf'
3-66
Chapter 3
Parameters Available in Import's Command-Line Mode
Example 2
This example illustrates the renaming of data files as part of a transportable
tablespace export and import operation. Assume that you have a data file named
employees.dat on your source system.
1. Using a method supported by your operating system, manually copy the data file
named employees.dat from your source system to the system where your target
database resides. As part of the copy operation, rename it to workers.dat.
2. Perform a transportable tablespace export of tablespace tbs_1.
> expdp hr DIRECTORY=dpump_dir1 DUMPFILE=tts.dmp TRANSPORT_TABLESPACES=tbs_1
The metadata only (no data) for tbs_1 is exported to a dump file named tts.dmp.
The actual data was copied over to the target database in step 1.
3. Perform a transportable tablespace import, specifying an absolute directory path
for the data file named workers.dat:
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=tts.dmp
TRANSPORT_DATAFILES='/user01/data/workers.dat'
The metadata contained in tts.dmp is imported and Data Pump then assigns the
information in the workers.dat file to the correct place in the database.
See Also:
"Use of Quotation Marks On the Data Pump Command Line"
Example 3
This example illustrates use of the asterisk (*) wildcard character in the file name when
used with the TRANSPORT_DATAFILES parameter.
TRANSPORT_DATAFILES='/db1/hrdata/payroll/emp*.dbf'
This will result in Data Pump validating that all files in the directory /db1/hrdata/
payroll/ of type .dbf whose names begins with emp are part of the transport set.
Example 4
This example illustrates use of the question mark (?) wildcard character in the file
name when used with the TRANSPORT_DATAFILES parameter.
TRANSPORT_DATAFILES='/db1/hrdata/payroll/m?emp.dbf'
This will result in Data Pump validating that all files in the directory /db1/hrdata/
payroll/ of type .dbf whose name begins with m, followed by any other single
character, and ending in emp are part of the transport set. For example, a file named
myemp.dbf would be included but memp.dbf would not.
3.4.50 TRANSPORT_FULL_CHECK
Default: NO
3-67
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Specifies whether to verify that the specified transportable tablespace set is being
referenced by objects in other tablespaces.
Restrictions
• This parameter is valid for transportable mode (or table mode or full mode when
TRANSPORTABLE=ALWAYS was specified on the export) only when the NETWORK_LINK
parameter is specified.
Example
In the following example, source_database_link would be replaced with the name of a
valid database link. The example also assumes that a data file named tbs6.dbf
already exists.
Assume you have a parameter file, full_check.par, with the following content:
DIRECTORY=dpump_dir1
TRANSPORT_TABLESPACES=tbs_6
NETWORK_LINK=source_database_link
TRANSPORT_FULL_CHECK=YES
TRANSPORT_DATAFILES='/wkdir/data/tbs6.dbf'
3.4.51 TRANSPORT_TABLESPACES
Default: There is no default.
3-68
Chapter 3
Parameters Available in Import's Command-Line Mode
Purpose
Specifies that you want to perform an import in transportable-tablespace mode over a
database link (as specified with the NETWORK_LINK parameter.)
Note:
If you already have a dump file set generated by a transportable-tablespace
mode export, then you can perform a transportable-mode import of that dump
file, but in this case you do not specify TRANSPORT_TABLESPACES or NETWORK_LINK.
Doing so would result in an error. Rather, you specify the dump file (which
contains the metadata) and the TRANSPORT_DATAFILES parameter. The presence
of the TRANSPORT_DATAFILES parameter tells import that it's a transportable-mode
import and where to get the actual data.
When transportable jobs are performed, it is best practice to keep a copy of the data
files on the source system until the import job has successfully completed on the target
system. If the import job should fail for some reason, you will still have uncorrupted
copies of the data files.
Restrictions
• You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database into which you are
importing must be at the same or later release level as the source database.
• The TRANSPORT_TABLESPACES parameter is valid only when the NETWORK_LINK
parameter is also specified.
3-69
Chapter 3
Parameters Available in Import's Command-Line Mode
Example
In the following example, the source_database_link would be replaced with the name of
a valid database link. The example also assumes that a data file named tbs6.dbf has
already been copied from the source database to the local system. Suppose you have
a parameter file, tablespaces.par, with the following content:
DIRECTORY=dpump_dir1
NETWORK_LINK=source_database_link
TRANSPORT_TABLESPACES=tbs_6
TRANSPORT_FULL_CHECK=NO
TRANSPORT_DATAFILES='user01/data/tbs6.dbf'
See Also:
3.4.52 TRANSPORTABLE
Default: NEVER
Purpose
Specifies whether the transportable option should be used during a table mode import
(specified with the TABLES parameter) or a full mode import (specified with the FULL
parameter).
3-70
Chapter 3
Parameters Available in Import's Command-Line Mode
Restrictions
• The Import TRANSPORTABLE parameter is valid only if the NETWORK_LINK parameter is
also specified.
• The TRANSPORTABLE parameter is only valid in table mode imports and full mode
imports.
• The user performing a transportable import requires the
DATAPUMP_EXP_FULL_DATABASE role on the source database and the
DATAPUMP_IMP_FULL_DATABASE role on the target database.
• All objects with storage that are selected for network import must have all of their
storage segments on the source system either entirely within administrative, non-
transportable tablespaces (SYSTEM / SYSAUX) or entirely within user-defined,
transportable tablespaces. Storage for a single object cannot straddle the two
kinds of tablespaces.
• To use the TRANSPORTABLE parameter to perform a network-based full transportable
import, the Data Pump VERSION parameter must be set to at least 12.0 if the source
database is release 11.2.0.3. If the source database is release 12.1 or later, then
the VERSION parameter is not required, but the COMPATIBLE database initialization
parameter must be set to 12.0.0 or later.
Example 1
The following example shows the use of the TRANSPORTABLE parameter during a network
link import.
3-71
Chapter 3
Parameters Available in Import's Command-Line Mode
Example 2
The following example shows the use of the TRANSPORTABLE parameter when performing
a full transportable import where the NETWORK_LINK points to a an Oracle Database 11g
release 2 (11.2.0.3) system with encrypted tablespaces and tables with encrypted
columns.
> impdp import_admin FULL=Y TRANSPORTABLE=ALWAYS VERSION=12 NETWORK_LINK=dbs1
ENCRYPTION_PASSWORD=password TRANSPORT_DATAFILES=<datafile_name>
LOGFILE=dpump_dir1:fullnet.log
See Also:
3.4.53 VERSION
Default: You should rarely have to specify the VERSION parameter on an import
operation. Data Pump uses whichever of the following is earlier:
• the version associated with the dump file, or source database in the case of
network imports
• the version specified by the COMPATIBLE initialization parameter on the target
database
Purpose
Specifies the version of database objects to be imported (that is, only database objects
and attributes that are compatible with the specified release will be imported). Note
that this does not mean that Data Pump Import can be used with releases of Oracle
Database earlier than 10.1. Data Pump Import only works with Oracle Database 10g
release 1 (10.1) or later. The VERSION parameter simply allows you to identify the
version of the objects being imported.
This parameter can be used to load a target system whose Oracle database is at an
earlier compatibility release than that of the source system. Database objects or
attributes on the source system that are incompatible with the specified release will not
be moved to the target. For example, tables containing new data types that are not
supported in the specified release will not be imported. Legal values for this parameter
are as follows:
3-72
Chapter 3
Parameters Available in Import's Command-Line Mode
• COMPATIBLE - This is the default value. The version of the metadata corresponds to
the database compatibility level. Database compatibility must be set to 9.2.0 or
later.
• LATEST - The version of the metadata corresponds to the database release.
Specifying VERSION=LATEST on an import job has no effect when the target
database's actual version is later than the version specified in its COMPATIBLE
initialization parameter.
• version_string - A specific database release (for example, 11.2.0).
Restrictions
• If the Data Pump VERSION parameter is specified as any value earlier than 12.1,
then the Data Pump dump file excludes any tables that contain VARCHAR2 or
NVARCHAR2 columns longer than 4000 bytes and any RAW columns longer than 2000
bytes.
• Full imports performed over a network link require that you set VERSION=12 if the
target is Oracle Database 12c Release 1 (12.1.0.1) or later and the source is
Oracle Database 11g Release 2 (11.2.0.3) or later.
• Dump files created on Oracle Database 11g releases with the Data Pump
parameter VERSION=12 can only be imported on Oracle Database 12c Release 1
(12.1) and later.
• The value of the VERSION parameter affects the import differently depending on
whether data-bound collation (DBC) is enabled. See Oracle Data Pump Behavior
with Data-Bound Collation.
Example
In the following example, assume that the target is an Oracle Database 12c Release 1
(12.1.0.1) database and the source is an Oracle Database 11g Release 2 (11.2.0.3)
database. In that situation, you must set VERSION=12 for network-based imports. Also
note that even though full is the default import mode, you must specify it on the
command line when the NETWORK_LINK parameter is being used.
> impdp hr FULL=Y DIRECTORY=dpump_dir1
NETWORK_LINK=source_database_link VERSION=12
See Also:
"Exporting and Importing Between Different Database Releases"
3-73
Chapter 3
Parameters Available in Import's Command-Line Mode
Note:
This description of VIEWS_AS_TABLES is applicable during network imports,
meaning that you supply a value for the Data Pump Import NETWORK_LINK
parameter. If you are performing an import that is not a network import, then
see "VIEWS_AS_TABLES (Non-Network Import)".
Purpose
Specifies that one or more views are to be imported as tables.
Data Pump imports a table with the same columns as the view and with row data
fetched from the view. Data Pump also imports objects dependent on the view, such
as grants and constraints. Dependent objects that do not apply to tables (for example,
grants of the UNDER object privilege) are not imported. The VIEWS_AS_TABLES parameter
can be used by itself or along with the TABLES parameter. If either is used, Data Pump
performs a table-mode import.
The syntax elements are defined as follows:
schema_name: The name of the schema in which the view resides. If a schema name is
not supplied, it defaults to the user performing the import.
view_name: The name of the view to be imported as a table. The view must exist and it
must be a relational view with only scalar, non-LOB columns. If you specify an invalid
or non-existent view, the view is skipped and an error message is returned.
table_name: The name of a table to serve as the source of the metadata for the
imported view. By default Data Pump automatically creates a temporary "template
table" with the same columns and data types as the view, but no rows. If the database
is read-only, then this default creation of a template table will fail. In such a case, you
can specify a table name. The table must be in the same schema as the view. It must
be a non-partitioned relational table with heap organization. It cannot be a nested
table.
If the import job contains multiple views with explicitly specified template tables, the
template tables must all be different. For example, in the following job (in which two
views use the same template table) one of the views is skipped:
impdp hr DIRECTORY=dpump_dir NETWORK_LINK=dblink1
VIEWS_AS_TABLES=v1:employees,v2:employees
3-74
Chapter 3
Parameters Available in Import's Command-Line Mode
KU$VAT_63629 TABLE
Data Pump metadata template table for view HR.EMPLOYEESV
Restrictions
• The VIEWS_AS_TABLES parameter cannot be used with the TRANSPORTABLE=ALWAYS
parameter.
• Tables created using the VIEWS_AS_TABLES parameter do not contain any hidden
columns that were part of the specified view.
• The VIEWS_AS_TABLES parameter does not support tables that have columns with a
data type of LONG.
Example
The following example performs a network import to import the contents of the view
hr.v1 from a read-only database. The hr schema on the source database must contain
a template table with the same geometry as the view view1 (call this table view1_tab).
The VIEWS_AS_TABLES parameter lists the view name and the table name separated by a
colon:
> impdp hr VIEWS_AS_TABLES=view1:view1_tab NETWORK_LINK=dblink1
The view is imported as a table named view1 with rows fetched from the view. The
metadata for the table is copied from the template table view1_tab.
Purpose
Specifies that one or more tables in the dump file that were exported as views, should
be imported.
The VIEWS_AS_TABLES parameter can be used by itself or along with the TABLES
parameter. If either is used, Data Pump performs a table-mode import.
The syntax elements are defined as follows:
schema_name: The name of the schema in which the view resides. If a schema name is
not supplied, it defaults to the user performing the import.
view_name: The name of the view to be imported as a table.
Restrictions
• The VIEWS_AS_TABLES parameter cannot be used with the TRANSPORTABLE=ALWAYS
parameter.
• Tables created using the VIEWS_AS_TABLES parameter do not contain any hidden
columns that were part of the specified view.
• The VIEWS_AS_TABLES parameter does not support tables that have columns with a
data type of LONG.
3-75
Chapter 3
Commands Available in Import's Interactive-Command Mode
Example
The following example imports the table in the scott1.dmp dump file that was exported
as view1:
> impdp scott/tiger views_as_tables=view1 directory=data_pump_dir dumpfile=scott1.dmp
• CONTINUE_CLIENT
• EXIT_CLIENT
• HELP
• KILL_JOB
• PARALLEL
• START_JOB
• STATUS
3-76
Chapter 3
Commands Available in Import's Interactive-Command Mode
• STOP_JOB
3.5.1 CONTINUE_CLIENT
Purpose
Changes the mode from interactive-command mode to logging mode.
In logging mode, the job status is continually output to the terminal. If the job is
currently stopped, then CONTINUE_CLIENT will also cause the client to attempt to start the
job.
Example
Import> CONTINUE_CLIENT
3.5.2 EXIT_CLIENT
Purpose
Stops the import client session, exits Import, and discontinues logging to the terminal,
but leaves the current job running.
Because EXIT_CLIENT leaves the job running, you can attach to the job at a later time if
it is still executing or in a stopped state. To see the status of the job, you can monitor
the log file for the job or you can query the USER_DATAPUMP_JOBS view or the
V$SESSION_LONGOPS view.
Example
Import> EXIT_CLIENT
3.5.3 HELP
Purpose
Provides information about Data Pump Import commands available in interactive-
command mode.
Example
Import> HELP
3-77
Chapter 3
Commands Available in Import's Interactive-Command Mode
3.5.4 KILL_JOB
Purpose
Detaches all currently attached client sessions and then terminates the current job. It
exits Import and returns to the terminal prompt.
A job that is terminated using KILL_JOB cannot be restarted. All attached clients,
including the one issuing the KILL_JOB command, receive a warning that the job is
being terminated by the current user and are then detached. After all clients are
detached, the job's process structure is immediately run down and the master table is
deleted. Log files are not deleted.
Example
Import> KILL_JOB
3.5.5 PARALLEL
Purpose
Enables you to increase or decrease the number of active worker processes and/or
PQ slaves for the current job.
Restrictions
• This parameter is valid only in the Enterprise Edition of Oracle Database 11g or
later.
Example
Import> PARALLEL=10
See Also:
"PARALLEL" for more information about parallelism
3-78
Chapter 3
Commands Available in Import's Interactive-Command Mode
3.5.6 START_JOB
Purpose
Starts the current job to which you are attached.
The START_JOB command restarts the job to which you are currently attached (the job
cannot be currently executing). The job is restarted with no data loss or corruption
after an unexpected failure or after you issue a STOP_JOB command, provided the dump
file set and master table remain undisturbed.
The SKIP_CURRENT option allows you to restart a job that previously failed, or that is
hung or performing slowly on a particular object. The failing statement or current object
being processed is skipped and the job is restarted from the next work item. For
parallel jobs, this option causes each worker to skip whatever it is currently working on
and to move on to the next item at restart.
Neither SQLFILE jobs nor imports done in transportable-tablespace mode are
restartable.
Example
Import> START_JOB
3.5.7 STATUS
Purpose
Displays cumulative status of the job, a description of the current operation, and an
estimated completion percentage. It also allows you to reset the display interval for
logging mode status.
You have the option of specifying how frequently, in seconds, this status should be
displayed in logging mode. If no value is entered or if the default value of 0 is used,
then the periodic status display is turned off and status is displayed only once.
This status information is written only to your standard output device, not to the log file
(even if one is in effect).
Example
The following example will display the current job status and change the logging mode
display interval to two minutes (120 seconds).
Import> STATUS=120
3-79
Chapter 3
Examples of Using Data Pump Import
3.5.8 STOP_JOB
Purpose
Stops the current job either immediately or after an orderly shutdown, and exits Import.
If the master table and dump file set are not disturbed when or after the STOP_JOB
command is issued, then the job can be attached to and restarted at a later time with
the START_JOB command.
Example
Import> STOP_JOB=IMMEDIATE
3-80
Chapter 3
Syntax Diagrams for Data Pump Import
The EXCLUDE parameter filters the metadata that is imported. For the given mode of
import, all the objects contained within the source, and all their dependent objects, are
included except those specified in an EXCLUDE statement. If an object is excluded, then
all of its dependent objects are also excluded.The TABLE_EXISTS_ACTION=REPLACE
parameter tells Import to drop the table if it already exists and to then re-create and
load it using the dump file contents.
This example imports the employees table from the hr schema into the scott schema.
The dblink references a source database that is different than the target database.
To remap the schema, user hr must have the DATAPUMP_IMP_FULL_DATABASE role on the
local database and the DATAPUMP_EXP_FULL_DATABASE role on the source database.
REMAP_SCHEMA loads all the objects from the source schema into the target schema.
Related Topics
• NETWORK_LINK
3-81
Chapter 3
Syntax Diagrams for Data Pump Import
ImpInit
YES
HELP =
NO
impdp
@ connect_identifier AS SYSDBA
username / password ImpStart
ImpStart
ImpEncrypt
schema_name .
= job_name
ATTACH
ImpModes
YES
FULL =
NO
SCHEMAS = schema_name
schema_name . : partition_name
TABLES = table_name
TABLESPACES = tablespace_name
3-82
Chapter 3
Syntax Diagrams for Data Pump Import
ImpOpts
ImpContent
DISABLE_APPEND_HINT
SKIP_CONSTRAINT_ERRORS
REJECT_ROWS_WITH_REPL_CHAR
DATA_OPTIONS =
TRUST_EXISTING_TABLE_PARTITIONS
VALIDATE_TABLE_DATA
ENABLE_NETWORK_COMPRESSION
ImpEncrypt
ImpFilter
JOB_NAME = jobname_string
NONE
STATUS
LOGTIME =
LOGFILE
ALL
PARALLEL = integer
ImpRemap
YES
REUSE_DATAFILES =
NO
ImpPartitioning
ImpRacOpt
3-83
Chapter 3
Syntax Diagrams for Data Pump Import
ImpOpts_Cont
YES
SKIP_UNUSABLE_INDEXES =
NO
STATUS = integer
YES
STREAMS_CONFIGURATION =
NO
SKIP
APPEND
TABLE_EXISTS_ACTION =
TRUNCATE
REPLACE
TARGET_EDITION = target_edition_name
ImpTransforms
ImpVersion
schema_object. :table_name
view_name
,
VIEWS_AS_TABLES =
schema_object.
view_name
ImpDiagnostics
ImpContent
ALL
CONTENT = DATA_ONLY
METADATA_ONLY
ImpEncrypt
ENCRYPTION_PASSWORD = password
YES
ENCRYPTION_PWD_PROMPT =
NO
3-84
Chapter 3
Syntax Diagrams for Data Pump Import
ImpFilter
: name_clause
EXCLUDE = object_type
: name_clause
INCLUDE = object_type
schema_name .
table_name :
QUERY = query_clause
ImpPartitioning
NONE
DEPARTITION
PARTITION_OPTIONS =
EXCHANGE
MERGE
ImpRacOpt
YES
CLUSTER =
NO
SERVICE_NAME = service_name
ImpRemap
schema . schema .
REMAP_DATA = table . column : pkg . function
schema_name . : partition
REMAP_TABLE = old_table_name : new_tablename
3-85
Chapter 3
Syntax Diagrams for Data Pump Import
ImpFileOpts
DIRECTORY = directory_object
directory_object :
DUMPFILE = file_name
directory_object :
LOGFILE = file_name
YES
NOLOGFILE =
NO
directory_path
PARFILE = file_name
directory_object :
SQLFILE = file_name
ImpNetworkOpts
BLOCKS
ESTIMATE =
STATISTICS
FLASHBACK_SCN = SCN_number
FLASHBACK_TIME = timestamp
ALWAYS ,
TRANSPORTABLE =
NEVER TRANSPORT_DATAFILES = datafile_name
TRANSPORT_TABLESPACES = tablespace_name
YES
TRANSPORT_FULL_CHECK =
NO
3-86
Chapter 3
Syntax Diagrams for Data Pump Import
ImpDynOpts
CONTINUE_CLIENT
EXIT_CLIENT
HELP
KILL_JOB
PARALLEL = integer
YES
= SKIP_CURRENT =
NO
START_JOB
= integer
STATUS
= IMMEDIATE
STOP_JOB
ImpTransforms
SEGMENT_ATTRIBUTES
STORAGE
OID
PARTITION : object_type
TRANSFORM = : value
PCTSPACE
DISABLE_ARCHIVE_LOGGING
LOB_STORAGE
TABLE_COMPRESSION_CLAUSE
ImpVersion
COMPATIBLE
VERSION = LATEST
version_string
3-87
Chapter 3
Syntax Diagrams for Data Pump Import
ImpDiagnostics
ABORT_STEP = integer
AUTOMATIC
EXTERNAL_TABLE
ACCESS_METHOD = DIRECT_PATH
CONVENTIONAL
INSERT_AS_SELECT
YES
KEEP_MASTER =
NO
YES
MASTER_ONLY =
NO
YES
METRICS =
NO
3-88
4
Data Pump Legacy Mode
Data Pump legacy mode lets you use original Export and Import parameters on the
Data Pump Export and Data Pump Import command lines.
If you use original Export (exp) and Import (imp), then you may have scripts you have
been using for many years. Data Pump provides a legacy mode which allows you to
continue to use your existing scripts with Data Pump.
Data Pump enters legacy mode when it determines that a parameter unique to original
Export or Import is present, either on the command line or in a script. As Data Pump
processes the parameter, the analogous Data Pump Export or Data Pump Import
parameter is displayed. Oracle strongly recommends that you view the new syntax
and make script changes as time permits.
Note:
The Data Pump Export and Import utilities create and read dump files and log
files in Data Pump format only. They never create or read dump files
compatible with original Export or Import. If you have a dump file created with
original Export, then you must use original Import to import the data into the
database.
• Parameter Mappings
This section describes parameter mappings.
• Management of File Locations in Data Pump Legacy Mode
Original Export and Import and Data Pump Export and Import differ on where
dump files and log files can be written to and read from because the original
version is client-based and Data Pump is server-based.
• Adjusting Existing Scripts for Data Pump Log Files and Errors
This section describes how to adjust existing scripts for Data Pump log files and
errors.
4-1
Chapter 4
Parameter Mappings
See Also:
Table 4-1 How Data Pump Export Handles Original Export Parameters
4-2
Chapter 4
Parameter Mappings
Table 4-1 (Cont.) How Data Pump Export Handles Original Export Parameters
4-3
Chapter 4
Parameter Mappings
Table 4-1 (Cont.) How Data Pump Export Handles Original Export Parameters
4-4
Chapter 4
Parameter Mappings
Table 4-1 (Cont.) How Data Pump Export Handles Original Export Parameters
Table 4-2 How Data Pump Import Handles Original Import Parameters
4-5
Chapter 4
Parameter Mappings
Table 4-2 (Cont.) How Data Pump Import Handles Original Import Parameters
4-6
Chapter 4
Parameter Mappings
Table 4-2 (Cont.) How Data Pump Import Handles Original Import Parameters
4-7
Chapter 4
Parameter Mappings
Table 4-2 (Cont.) How Data Pump Import Handles Original Import Parameters
4-8
Chapter 4
Management of File Locations in Data Pump Legacy Mode
Table 4-2 (Cont.) How Data Pump Import Handles Original Import Parameters
4-9
Chapter 4
Management of File Locations in Data Pump Legacy Mode
If Data Pump legacy mode is enabled and the original Export FILE=filespec parameter
and/or LOG=filespec parameter are present on the command line, then the following
rules of precedence are used to determine a file's location:
Note:
If the FILE parameter and LOG parameter are both present on the command line,
then the rules of precedence are applied separately to each parameter.
Also, when a mix of original Export/Import and Data Pump Export/Import
parameters are used, separate rules apply to them. For example, suppose you
have the following command:
expdp system FILE=/user/disk/foo.dmp LOGFILE=foo.log DIRECTORY=dpump_dir
The Data Pump legacy mode file management rules, as explained in this
section, would apply to the FILE parameter. The normal (that is, non-legacy
mode) Data Pump file management rules, as described in Default Locations for
Dump_ Log_ and SQL Files, would apply to the LOGFILE parameter.
1. If a path location is specified as part of the file specification, then Data Pump
attempts to look for a directory object accessible to the schema executing the
export job whose path location matches the path location of the file specification. If
such a directory object cannot be found, then an error is returned. For example,
assume that a server-based directory object named USER_DUMP_FILES has been
defined with a path value of '/disk1/user1/dumpfiles/' and that read and write
access to this directory object has been granted to the hr schema. The following
command causes Data Pump to look for a server-based directory object whose
path value contains '/disk1/user1/dumpfiles/' and to which the hr schema has
been granted read and write access:
expdp hr FILE=/disk1/user1/dumpfiles/hrdata.dmp
In this case, Data Pump uses the directory object USER_DUMP_FILES. The path value,
in this example '/disk1/user1/dumpfiles/', must refer to a path on the server
system that is accessible to the Oracle Database.
If a path location is specified as part of the file specification, then any directory
object provided using the DIRECTORY parameter is ignored. For example, if the
following command is issued, then Data Pump does not use the DPUMP_DIR
directory object for the file parameter, but instead looks for a server-based
directory object whose path value contains '/disk1/user1/dumpfiles/' and to
which the hr schema has been granted read and write access:
expdp hr FILE=/disk1/user1/dumpfiles/hrdata.dmp DIRECTORY=dpump_dir
2. If no path location is specified as part of the file specification, then the directory
object named by the DIRECTORY parameter is used. For example, if the following
command is issued, then Data Pump applies the path location defined for the
DPUMP_DIR directory object to the hrdata.dmp file:
4-10
Chapter 4
Adjusting Existing Scripts for Data Pump Log Files and Errors
a. Data Pump looks for the existence of a directory object of the form
DATA_PUMP_DIR_schema_name, where schema_name is the schema that is executing
the Data Pump job. For example, the following command would cause Data
Pump to look for the existence of a server-based directory object named
DATA_PUMP_DIR_HR:
expdp hr FILE=hrdata.dmp
The hr schema also must have been granted read and write access to this
directory object. If such a directory object does not exist, then the process
moves to step b.
b. Data Pump looks for the existence of the client-based environment variable
DATA_PUMP_DIR. For instance, assume that a server-based directory object
named DUMP_FILES1 has been defined and the hr schema has been granted
read and write access to it. Then on the client system, the environment
variable DATA_PUMP_DIR can be set to point to DUMP_FILES1 as follows:
setenv DATA_PUMP_DIR DUMP_FILES1
expdp hr FILE=hrdata.dmp
Data Pump then uses the served-based directory object DUMP_FILES1 for the
hrdata.dmp file.
See Also:
Default Locations for Dump_ Log_ and SQL Files for information about Data
Pump file management rules of precedence under normal Data Pump
conditions (that is, non-legacy mode)
4.3 Adjusting Existing Scripts for Data Pump Log Files and
Errors
This section describes how to adjust existing scripts for Data Pump log files and
errors.
Data Pump legacy mode requires that you review and update your existing scripts
written for original Export and Import because of differences in file format and error
reporting.
• Log Files
Data Pump Export and Import do not generate log files in the same format as
those created by original Export and Import.
4-11
Chapter 4
Adjusting Existing Scripts for Data Pump Log Files and Errors
• Error Cases
Data Pump Export and Import may not produce the same errors as those
generated by original Export and Import.
• Exit Status
Data Pump Export and Import have enhanced exit status values to allow scripts to
better determine the success of failure of export and import jobs.
4-12
5
Data Pump Performance
Reasons why the performance of Data Pump Export and Import is better than that of
original Export and Import, and specific steps you can take to enhance performance of
export and import operations.
The Data Pump Export and Import utilities are designed especially for very large
databases. If you have large quantities of data versus metadata, then you should
experience increased data performance compared to the original Export and Import
utilities. (Performance of metadata extraction and database object creation in Data
Pump Export and Import remains essentially equivalent to that of the original Export
and Import utilities.)
• Data Performance Improvements for Data Pump Export and Import
This section describes data performance improvements for Data Pump Export and
Import.
• Tuning Performance
Data Pump is designed to fully use all available resources to maximize throughput
and minimize elapsed job time.
• Initialization Parameters That Affect Data Pump Performance
The settings for certain Oracle Database initialization parameters can affect the
performance of Data Pump Export and Import.
5-1
Chapter 5
Tuning Performance
• The supported data access methods, direct path and external tables, are faster
than conventional SQL. The direct path API provides the fastest single-stream
performance. The external tables feature makes efficient use of the parallel
queries and parallel DML capabilities of the Oracle database.
• Metadata and data extraction can be overlapped during export.
5-2
Chapter 5
Initialization Parameters That Affect Data Pump Performance
and fast disks, the path between the CPU and the disk may be the constraining factor
in the degree of parallelism that can be sustained.
The Data Pump PARALLEL parameter is valid only in the Enterprise Edition of Oracle
Database 11g or later.
See Also:
• Oracle Database SQL Tuning Guide for information about manual statistics
collection using the DBMS_STATS PL/SQL package
• Oracle Database PL/SQL Packages and Types Reference for more
information about the DBMS_STATS PL/SQL package
• The Data Pump Export EXCLUDE parameter
• The Data Pump Import EXCLUDE parameter
5-3
Chapter 5
Initialization Parameters That Affect Data Pump Performance
• DISK_ASYNCH_IO=TRUE
• DB_BLOCK_CHECKING=FALSE
• DB_BLOCK_CHECKSUM=FALSE
The following initialization parameters must have values set high enough to allow for
maximum parallelism:
• PROCESSES
• SESSIONS
• PARALLEL_MAX_SERVERS
See Also:
Oracle Streams Concepts and Administration
5-4
6
The Data Pump API
The Data Pump API, DBMS_DATAPUMP.
The Data Pump API, DBMS_DATAPUMP, provides a high-speed mechanism to move all or
part of the data and metadata for a site from one database to another. The Data Pump
Export and Data Pump Import utilities are based on the Data Pump API.
• How Does the Client Interface to the Data Pump API Work?
The main structure used in the client interface is a job handle, which appears to
the caller as an integer.
• What Are the Basic Steps in Using the Data Pump API?
To use the Data Pump API, you use the procedures provided in the DBMS_DATAPUMP
package.
• Examples of Using the Data Pump API
Using the Data Pump API.
See Also:
6.1 How Does the Client Interface to the Data Pump API
Work?
The main structure used in the client interface is a job handle, which appears to the
caller as an integer.
Handles are created using the DBMS_DATAPUMP.OPEN or DBMS_DATAPUMP.ATTACH function.
Other sessions can attach to a job to monitor and control its progress. This allows a
DBA to start up a job before departing from work and then watch the progress of the
job from home. Handles are session specific. The same job can create different
handles in different sessions.
• Job States
This section describes job states.
6-1
Chapter 6
How Does the Client Interface to the Data Pump API Work?
The Not Running state indicates that a master table exists outside the context of an
executing job. This will occur if a job has been stopped (probably to be restarted later)
or if a job has abnormally terminated. This state can also be seen momentarily during
job state transitions at the beginning of a job, and at the end of a job before the master
table is dropped. Note that the Not Running state is shown only in the
DBA_DATAPUMP_JOBS view and the USER_DATAPUMP_JOBS view. It is never returned by the
GET_STATUS procedure.
6-2
Chapter 6
How Does the Client Interface to the Data Pump API Work?
Table 6-1 shows the valid job states in which DBMS_DATAPUMP procedures can be
executed. The states listed are valid for both export and import jobs, unless otherwise
noted.
6-3
Chapter 6
What Are the Basic Steps in Using the Data Pump API?
1 The ENCRYPTION_PASSWORD parameter can be entered during the Idling state, as well as during the
Defining state.
6.2 What Are the Basic Steps in Using the Data Pump API?
To use the Data Pump API, you use the procedures provided in the DBMS_DATAPUMP
package.
The following steps list the basic activities involved in using the Data Pump API. The
steps are presented in the order in which the activities would generally be performed:
1. Execute the DBMS_DATAPUMP.OPEN procedure to create a Data Pump job and its
infrastructure.
2. Define any parameters for the job.
3. Start the job.
4. Optionally, monitor the job until it completes.
5. Optionally, detach from the job and reattach at a later time.
6. Optionally, stop the job.
7. Optionally, restart the job, if desired.
These concepts are illustrated in the examples provided in the next section.
See Also:
Oracle Database PL/SQL Packages and Types Reference for a complete
description of the DBMS_DATAPUMP package
6-4
Chapter 6
Examples of Using the Data Pump API
The examples are in the form of PL/SQL scripts. If you choose to copy these scripts
and run them, then you must first do the following, using SQL*Plus:
• Create a directory object and grant READ and WRITE access to it. For example, to
create a directory object named dmpdir to which you have access, do the following.
Replace user with your username.
SQL> CREATE DIRECTORY dmpdir AS '/rdbms/work';
SQL> GRANT READ, WRITE ON DIRECTORY dmpdir TO user;
• Ensure that you have the EXP_FULL_DATABASE and IMP_FULL_DATABASE roles. To see a
list of all roles assigned to you within your security domain, do the following:
SQL> SELECT * FROM SESSION_ROLES;
If you do not have the necessary roles assigned to you, then contact your system
administrator for help.
• Turn on server output if it is not already on. This is done as follows:
SQL> SET SERVEROUTPUT ON
If you do not do this, then you will not see any output to your screen. You must do
this in the same session in which you run the example. If you exit SQL*Plus, then
this setting is lost and must be reset when you begin a new session. (It must also
be reset if you connect to a different user name.)
Example 6-1 Performing a Simple Schema Export
The PL/SQL script in this example shows how to use the Data Pump API to perform a
simple schema export of the HR schema. It shows how to create a job, start it, and
monitor it. Additional information about the example is contained in the comments
within the script. To keep the example simple, exceptions from any of the API calls will
not be trapped. However, in a production environment, Oracle recommends that you
define exception handlers and call GET_STATUS to retrieve more detailed error
information when a failure occurs.
Connect as user SYSTEM to use this script.
DECLARE
ind NUMBER; -- Loop index
h1 NUMBER; -- Data Pump job handle
percent_done NUMBER; -- Percentage of job complete
job_state VARCHAR2(30); -- To keep track of job state
le ku$_LogEntry; -- For WIP and error messages
js ku$_JobStatus; -- The job status from get_status
jd ku$_JobDesc; -- The job description from get_status
sts ku$_Status; -- The status object returned by get_status
BEGIN
h1 := DBMS_DATAPUMP.OPEN('EXPORT','SCHEMA',NULL,'EXAMPLE1','LATEST');
-- Specify a single dump file for the job (using the handle just returned)
-- and a directory object, which must already be defined and accessible
-- to the user running this procedure.
DBMS_DATAPUMP.ADD_FILE(h1,'example1.dmp','DMPDIR');
6-5
Chapter 6
Examples of Using the Data Pump API
DBMS_DATAPUMP.METADATA_FILTER(h1,'SCHEMA_EXPR','IN (''HR'')');
DBMS_DATAPUMP.START_JOB(h1);
-- The export job should now be running. In the following loop, the job
-- is monitored until it completes. In the meantime, progress information is
-- displayed.
percent_done := 0;
job_state := 'UNDEFINED';
while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop
dbms_datapump.get_status(h1,
dbms_datapump.ku$_status_job_error +
dbms_datapump.ku$_status_job_status +
dbms_datapump.ku$_status_wip,-1,job_state,sts);
js := sts.job_status;
if js.percent_done != percent_done
then
dbms_output.put_line('*** Job percent done = ' ||
to_char(js.percent_done));
percent_done := js.percent_done;
end if;
-- If any work-in-progress (WIP) or error messages were received for the job,
-- display them.
if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0)
then
le := sts.wip;
else
if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
then
le := sts.error;
else
le := null;
end if;
end if;
if le is not null
then
ind := le.FIRST;
while ind is not null loop
dbms_output.put_line(le(ind).LogText);
ind := le.NEXT(ind);
end loop;
end if;
end loop;
6-6
Chapter 6
Examples of Using the Data Pump API
Example 6-2 Importing a Dump File and Remapping All Schema Objects
The script in this example imports the dump file created in Example 6-1 (an export of
the hr schema). All schema objects are remapped from the hr schema to the blake
schema. To keep the example simple, exceptions from any of the API calls will not be
trapped. However, in a production environment, Oracle recommends that you define
exception handlers and call GET_STATUS to retrieve more detailed error information when
a failure occurs.
Connect as user SYSTEM to use this script.
DECLARE
ind NUMBER; -- Loop index
h1 NUMBER; -- Data Pump job handle
percent_done NUMBER; -- Percentage of job complete
job_state VARCHAR2(30); -- To keep track of job state
le ku$_LogEntry; -- For WIP and error messages
js ku$_JobStatus; -- The job status from get_status
jd ku$_JobDesc; -- The job description from get_status
sts ku$_Status; -- The status object returned by get_status
BEGIN
h1 := DBMS_DATAPUMP.OPEN('IMPORT','FULL',NULL,'EXAMPLE2');
-- Specify the single dump file for the job (using the handle just returned)
-- and directory object, which must already be defined and accessible
-- to the user running this procedure. This is the dump file created by
-- the export operation in the first example.
DBMS_DATAPUMP.ADD_FILE(h1,'example1.dmp','DMPDIR');
DBMS_DATAPUMP.METADATA_REMAP(h1,'REMAP_SCHEMA','HR','BLAKE');
DBMS_DATAPUMP.SET_PARAMETER(h1,'TABLE_EXISTS_ACTION','SKIP');
DBMS_DATAPUMP.START_JOB(h1);
-- The import job should now be running. In the following loop, the job is
-- monitored until it completes. In the meantime, progress information is
-- displayed. Note: this is identical to the export example.
percent_done := 0;
job_state := 'UNDEFINED';
while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop
dbms_datapump.get_status(h1,
dbms_datapump.ku$_status_job_error +
dbms_datapump.ku$_status_job_status +
dbms_datapump.ku$_status_wip,-1,job_state,sts);
js := sts.job_status;
6-7
Chapter 6
Examples of Using the Data Pump API
if js.percent_done != percent_done
then
dbms_output.put_line('*** Job percent done = ' ||
to_char(js.percent_done));
percent_done := js.percent_done;
end if;
-- If any work-in-progress (WIP) or Error messages were received for the job,
-- display them.
if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0)
then
le := sts.wip;
else
if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
then
le := sts.error;
else
le := null;
end if;
end if;
if le is not null
then
ind := le.FIRST;
while ind is not null loop
dbms_output.put_line(le(ind).LogText);
ind := le.NEXT(ind);
end loop;
end if;
end loop;
-- Indicate that the job finished and gracefully detach from it.
6-8
Chapter 6
Examples of Using the Data Pump API
h1 := dbms_datapump.open('EXPORT','SCHEMA',NULL,'EXAMPLE3','LATEST');
-- Specify a single dump file for the job (using the handle just returned)
-- and a directory object, which must already be defined and accessible
-- to the user running this procedure.
dbms_datapump.add_file(h1,'example3.dmp','DMPDIR');
dbms_datapump.metadata_filter(h1,'SCHEMA_EXPR','IN (''HR'')');
begin
dbms_datapump.start_job(h1);
dbms_output.put_line('Data Pump job started successfully');
exception
when others then
if sqlcode = dbms_datapump.success_with_info_num
then
dbms_output.put_line('Data Pump job started with info available:');
dbms_datapump.get_status(h1,
dbms_datapump.ku$_status_job_error,0,
job_state,sts);
if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
then
le := sts.error;
if le is not null
then
ind := le.FIRST;
while ind is not null loop
dbms_output.put_line(le(ind).LogText);
ind := le.NEXT(ind);
end loop;
end if;
end if;
else
raise;
end if;
end;
percent_done := 0;
job_state := 'UNDEFINED';
while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop
dbms_datapump.get_status(h1,
6-9
Chapter 6
Examples of Using the Data Pump API
dbms_datapump.ku$_status_job_error +
dbms_datapump.ku$_status_job_status +
dbms_datapump.ku$_status_wip,-1,job_state,sts);
js := sts.job_status;
if js.percent_done != percent_done
then
dbms_output.put_line('*** Job percent done = ' ||
to_char(js.percent_done));
percent_done := js.percent_done;
end if;
-- Display any work-in-progress (WIP) or error messages that were received for
-- the job.
if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0)
then
le := sts.wip;
else
if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
then
le := sts.error;
else
le := null;
end if;
end if;
if le is not null
then
ind := le.FIRST;
while ind is not null loop
dbms_output.put_line(le(ind).LogText);
ind := le.NEXT(ind);
end loop;
end if;
end loop;
exception
when others then
dbms_output.put_line('Exception in Data Pump job');
dbms_datapump.get_status(h1,dbms_datapump.ku$_status_job_error,0,
job_state,sts);
if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
then
le := sts.error;
if le is not null
then
ind := le.FIRST;
while ind is not null loop
spos := 1;
slen := length(le(ind).LogText);
6-10
Chapter 6
Examples of Using the Data Pump API
DECLARE
ind NUMBER;
fileType NUMBER;
value VARCHAR2(2048);
infoTab KU$_DUMPFILE_INFO := KU$_DUMPFILE_INFO();
BEGIN
--
-- Get the information about the dump file into the infoTab.
--
BEGIN
DBMS_DATAPUMP.GET_DUMPFILE_INFO('example1.dmp','DMPDIR',infoTab,fileType);
DBMS_OUTPUT.PUT_LINE('---------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Information for file: example1.dmp');
--
-- Determine what type of file is being looked at.
--
CASE fileType
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('example1.dmp is a Data Pump dump file');
WHEN 2 THEN
DBMS_OUTPUT.PUT_LINE('example1.dmp is an Original Export dump file');
WHEN 3 THEN
DBMS_OUTPUT.PUT_LINE('example1.dmp is an External Table dump file');
ELSE
DBMS_OUTPUT.PUT_LINE('example1.dmp is not a dump file');
DBMS_OUTPUT.PUT_LINE('---------------------------------------------');
6-11
Chapter 6
Examples of Using the Data Pump API
END CASE;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('---------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Error retrieving information for file: ' ||
'example1.dmp');
DBMS_OUTPUT.PUT_LINE(SQLERRM);
DBMS_OUTPUT.PUT_LINE('---------------------------------------------');
fileType := 0;
END;
--
-- If a valid file type was returned, then loop through the infoTab and
-- display each item code and value returned.
--
IF fileType > 0
THEN
DBMS_OUTPUT.PUT_LINE('The information table has ' ||
TO_CHAR(infoTab.COUNT) || ' entries');
DBMS_OUTPUT.PUT_LINE('---------------------------------------------');
ind := infoTab.FIRST;
WHILE ind IS NOT NULL
LOOP
--
-- The following item codes return boolean values in the form
-- of a '1' or a '0'. Display them as 'Yes' or 'No'.
--
value := NVL(infoTab(ind).value, 'NULL');
IF infoTab(ind).item_code IN
(DBMS_DATAPUMP.KU$_DFHDR_MASTER_PRESENT,
DBMS_DATAPUMP.KU$_DFHDR_DIRPATH,
DBMS_DATAPUMP.KU$_DFHDR_METADATA_COMPRESSED,
DBMS_DATAPUMP.KU$_DFHDR_DATA_COMPRESSED,
DBMS_DATAPUMP.KU$_DFHDR_METADATA_ENCRYPTED,
DBMS_DATAPUMP.KU$_DFHDR_DATA_ENCRYPTED,
DBMS_DATAPUMP.KU$_DFHDR_COLUMNS_ENCRYPTED)
THEN
CASE value
WHEN '1' THEN value := 'Yes';
WHEN '0' THEN value := 'No';
END CASE;
END IF;
--
-- Display each item code with an appropriate name followed by
-- its value.
--
CASE infoTab(ind).item_code
--
-- The following item codes have been available since Oracle
-- Database 10g, Release 10.2.
--
WHEN DBMS_DATAPUMP.KU$_DFHDR_FILE_VERSION THEN
DBMS_OUTPUT.PUT_LINE('Dump File Version: ' || value);
WHEN DBMS_DATAPUMP.KU$_DFHDR_MASTER_PRESENT THEN
DBMS_OUTPUT.PUT_LINE('Master Table Present: ' || value);
WHEN DBMS_DATAPUMP.KU$_DFHDR_GUID THEN
DBMS_OUTPUT.PUT_LINE('Job Guid: ' || value);
WHEN DBMS_DATAPUMP.KU$_DFHDR_FILE_NUMBER THEN
6-12
Chapter 6
Examples of Using the Data Pump API
--
-- The following item codes were introduced in Oracle Database 11g
-- Release 11.1
--
--
-- For the DBMS_DATAPUMP.KU$_DFHDR_ENCRYPTION_MODE item code a
-- numeric value is returned. So examine that numeric value
-- and display an appropriate name value for it.
--
WHEN DBMS_DATAPUMP.KU$_DFHDR_ENCRYPTION_MODE THEN
CASE TO_NUMBER(value)
WHEN DBMS_DATAPUMP.KU$_DFHDR_ENCMODE_NONE THEN
DBMS_OUTPUT.PUT_LINE('Encryption Mode: None');
WHEN DBMS_DATAPUMP.KU$_DFHDR_ENCMODE_PASSWORD THEN
DBMS_OUTPUT.PUT_LINE('Encryption Mode: Password');
WHEN DBMS_DATAPUMP.KU$_DFHDR_ENCMODE_DUAL THEN
DBMS_OUTPUT.PUT_LINE('Encryption Mode: Dual');
WHEN DBMS_DATAPUMP.KU$_DFHDR_ENCMODE_TRANS THEN
DBMS_OUTPUT.PUT_LINE('Encryption Mode: Transparent');
END CASE;
--
-- The following item codes were introduced in Oracle Database 12c
6-13
Chapter 6
Examples of Using the Data Pump API
-- Release 12.1
--
--
-- For the DBMS_DATAPUMP.KU$_DFHDR_COMPRESSION_ALG item code a
-- numeric value is returned. So examine that numeric value and
-- display an appropriate name value for it.
--
WHEN DBMS_DATAPUMP.KU$_DFHDR_COMPRESSION_ALG THEN
CASE TO_NUMBER(value)
WHEN DBMS_DATAPUMP.KU$_DFHDR_CMPALG_NONE THEN
DBMS_OUTPUT.PUT_LINE('Compression Algorithm: None');
WHEN DBMS_DATAPUMP.KU$_DFHDR_CMPALG_BASIC THEN
DBMS_OUTPUT.PUT_LINE('Compression Algorithm: Basic');
WHEN DBMS_DATAPUMP.KU$_DFHDR_CMPALG_LOW THEN
DBMS_OUTPUT.PUT_LINE('Compression Algorithm: Low');
WHEN DBMS_DATAPUMP.KU$_DFHDR_CMPALG_MEDIUM THEN
DBMS_OUTPUT.PUT_LINE('Compression Algorithm: Medium');
WHEN DBMS_DATAPUMP.KU$_DFHDR_CMPALG_HIGH THEN
DBMS_OUTPUT.PUT_LINE('Compression Algorithm: High');
END CASE;
ELSE NULL; -- Ignore other, unrecognized dump file attributes.
END CASE;
ind := infoTab.NEXT(ind);
END LOOP;
END IF;
END;
/
6-14
Part II
SQL*Loader
Following are topics about the SQL*Loader utility.
SQL*Loader Concepts
Describes SQL*Loader and its features, as well as data loading concepts (including
object support). It discusses input to SQL*Loader, database preparation, and output
from SQL*Loader.
SQL*Loader Command-Line Reference
Describes the command-line syntax used by SQL*Loader. It discusses command-line
arguments, suppressing SQL*Loader messages, sizing the bind array, and more.
SQL*Loader Control File Reference
Describes the control file syntax you use to configure SQL*Loader and to describe to
SQL*Loader how to map your data to Oracle format. It provides detailed syntax
diagrams and information about specifying data files, tables and columns, the location
of data, the type and format of data to be loaded, and more.
SQL*Loader Field List Reference
Describes the field list section of a SQL*Loader control file. The field list provides
information about fields being loaded, such as position, data type, conditions, and
delimiters.
Loading Objects, LOBs, and Collections
Describes how to load column objects in various formats. It also discusses how to load
object tables, REF columns, LOBs, and collections.
7-1
Chapter 7
SQL*Loader Features
• Load data across a network if your data files are on a different system than the
database.
• Load data from multiple data files during the same load session.
• Load data into multiple tables during the same load session.
• Specify the character set of the data.
• Selectively load data (you can load records based on the records' values).
• Manipulate the data before loading it, using SQL functions.
• Generate unique sequential key values in specified columns.
• Use the operating system's file system to access the data files.
• Load data from disk, tape, or named pipe.
• Generate sophisticated error reports, which greatly aid troubleshooting.
• Load arbitrarily complex object-relational data.
• Use secondary data files for loading LOBs and collections.
• Use conventional, direct path, or external table loads. See Conventional Path
Loads_ Direct Path Loads_ and External Table Loads.
You can use SQL*Loader in two ways: with or without a control file. A control file
controls the behavior of SQL*Loader and one or more data files used in the load.
Using a control file gives you more control over the load operation, which might be
desirable for more complicated load situations. But for simple loads, you can use
SQL*Loader without specifying a control file; this is referred to as SQL*Loader express
mode. See SQL*Loader Express .
The output of SQL*Loader is an Oracle database (where the data is loaded), a log file,
a bad file if there are rejected records, and potentially, a discard file.
The following figure shows an example of the flow of a typical SQL*Loader session
that uses a control file.
Bad Loader
Input
Files Control
Datafiles File
Bad
Log SQL*Loader Bad
Files
File Files
Discard
Discard
Files
Database Files
Table
Table
Indexes
Table
Table
Tables
7-2
Chapter 7
SQL*Loader Parameters
See Also:
7-3
Chapter 7
Input Data and Data Files
• The keywords CONSTANT and ZONE have special meaning to SQL*Loader and are
therefore reserved. To avoid potential conflicts, Oracle recommends that you do
not use either CONSTANT or ZONE as a name for any tables or columns.
See Also:
SQL*Loader Control File Reference for details about control file syntax and
semantics
Note:
If data is specified inside the control file (that is, INFILE * was specified in the
control file), then the data is interpreted in the stream record format with the
default record terminator.
7-4
Chapter 7
Input Data and Data Files
This example specifies that SQL*Loader should interpret the particular data file as
being in fixed record format where every record is n bytes long.
Example 7-1 shows a control file that specifies a data file (example1.dat) to be
interpreted in the fixed record format. The data file in the example contains five
physical records; each record has fields that contain the number and name of an
employee. Each of the five records is 11 bytes long, including spaces. For the
purposes of explaining this example, periods are used to represent spaces in the
records, but in the actual records there would be no periods. With that in mind, the first
physical record is 396,...ty,. which is exactly eleven bytes (assuming a single-byte
character set). The second record is 4922,beth, followed by the newline character (\n)
which is the eleventh byte, and so on. (Newline characters are not required with the
fixed record format; it is simply used here to illustrate that if used, it counts as a byte in
the record length.)
Note that the length is always interpreted in bytes, even if character-length semantics
are in effect for the file. This is necessary because the file could contain a mix of fields,
some of which are processed with character-length semantics and others which are
processed with byte-length semantics. See Character-Length Semantics.
Example 7-1 Loading Data in Fixed Record Format
load data
infile 'example1.dat' "fix 11"
into table example
fields terminated by ',' optionally enclosed by '"'
(col1, col2)
example1.dat:
396,...ty,.4922,beth,\n
68773,ben,.
1,.."dave",
5455,mike,.
In this example, n specifies the number of bytes in the record length field. If n is not
specified, then SQL*Loader assumes a length of 5 bytes. Specifying n larger than 40
results in an error.
Example 7-2 shows a control file specification that tells SQL*Loader to look for data in
the data file example2.dat and to expect variable record format where the record's first
three bytes indicate the length of the field. The example2.dat data file consists of three
physical records. The first is specified to be 009 (9) bytes long, the second is 010 (10)
bytes long (plus a 1-byte newline), and the third is 012 (12) bytes long (plus a 1-byte
newline). Note that newline characters are not required with the variable record format.
This example also assumes a single-byte character set for the data file. For the
7-5
Chapter 7
Input Data and Data Files
purposes of this example, periods in example2.dat represent spaces; the fields do not
contain actual periods.
The lengths are always interpreted in bytes, even if character-length semantics are in
effect for the file. This is necessary because the file could contain a mix of fields, some
processed with character-length semantics and others processed with byte-length
semantics. See Character-Length Semantics.
Example 7-2 Loading Data in Variable Record Format
load data
infile 'example2.dat' "var 3"
into table example
fields terminated by ',' optionally enclosed by '"'
(col1 char(5),
col2 char(7))
example2.dat:
009.396,.ty,0104922,beth,
012..68773,ben,
The str indicates the file is in stream record format. The terminator_string is specified
as either 'char_string' or X'hex_string' where:
If the character set specified with the NLS_LANG initialization parameter for your session
is different from the character set of the data file, then character strings are converted
to the character set of the data file. This is done before SQL*Loader checks for the
default record terminator.
Hexadecimal strings are assumed to be in the character set of the data file, so no
conversion is performed.
7-6
Chapter 7
Input Data and Data Files
See Also:
example3.dat:
396,ty,|
4922,beth,|
See Also:
7-7
Chapter 7
LOBFILEs and Secondary Data Files (SDFs)
See Also:
7-8
Chapter 7
Data Conversion and Data Type Specification
Secondary data files (SDFs) are similar in concept to primary data files. Like primary
data files, SDFs are a collection of records, and each record is made up of fields. The
SDFs are specified on a per control-file-field basis. Only a collection_fld_spec can
name an SDF as its data source.
SDFs are specified using the SDF parameter. The SDF parameter can be followed by
either the file specification string, or a FILLER field that is mapped to a data field
containing one or more file specification strings.
See Also:
2. The database accepts the data and executes the INSERT statement to store the
data in the database.
Oracle Database uses the data type of the column to convert the data into its final,
stored form. Keep in mind the distinction between a field in a data file and a column in
the database. Remember also that the field data types defined in a SQL*Loader
control file are not the same as the column data types.
See Also:
• "BINDSIZE"
• "READSIZE"
7-9
Chapter 7
Discarded and Rejected Records
See Also:
7-10
Chapter 7
Log File and Logging Information
This file is created only when it is needed, and only if you have specified that a discard
file should be enabled. The discard file contains records that were filtered out of the
load because they did not match any record-selection criteria specified in the control
file.
The discard file therefore contains records that were not inserted into any table in the
database. You can specify the maximum number of such records that the discard file
can accept. Data written to any database table is not written to the discard file.
See Also:
7-11
Chapter 7
Conventional Path Loads, Direct Path Loads, and External Table Loads
See Also:
7-12
Chapter 7
Conventional Path Loads, Direct Path Loads, and External Table Loads
See Also:
Parallel Data Loading Models
Direct Path Load
Note:
An external table load is not supported using a named pipe on Windows
operating systems.
See Also:
7-13
Chapter 7
Conventional Path Loads, Direct Path Loads, and External Table Loads
to the different architecture of external tables and SQL*Loader, there are situations in
which one method may be more appropriate than the other.
Use external tables for the best load performance in the following situations:
• You want to transform the data as it is being loaded into the database
• You want to use transparent parallel processing without having to split the external
data first
Use SQL*Loader for the best load performance in the following situations:
• You want to load data remotely
• Transformations are not required on the data, and the data does not need to be
loaded in parallel
• You want to load data, and additional indexing of the staging table is required
7-14
Chapter 7
Loading Objects, Collections, and LOBs
• Use of the following database column types: LONG, nested table, VARRAY, REF,
primary key REF, and SID
In external tables, the use of the backslash escape character within a string raises an
error. The workaround is to use double quotation marks to identify a single quotation
mark as the enclosure character, as follows:
TERMINATED BY ',' ENCLOSED BY "'"
7-15
Chapter 7
Loading Objects, Collections, and LOBs
See Also:
• Nested Tables
A nested table is a table that appears as a column in another table.
• VARRAYs
A VARRAY is a variable sized arrays.
7-16
Chapter 7
Partitioned Object Support
7.10.2.2 VARRAYs
A VARRAY is a variable sized arrays.
An array is an ordered set of built-in types or objects, called elements. Each array
element is of the same type and has an index, which is a number corresponding to the
element's position in the VARRAY.
When you create a VARRAY type, you must specify the maximum size. Once you have
declared a VARRAY type, it can be used as the data type of a column of a relational
table, as an object type attribute, or as a PL/SQL variable.
See Also:
Loading Collections (Nested Tables and VARRAYs) for details on using
SQL*Loader control file data definition language to load these collection types
See Also:
Loading LOBs for details on using SQL*Loader control file data definition
language to load these LOB types
7-17
Chapter 7
Application Development: Direct Path Load API
Note:
Files for use in the case studies are located in the $ORACLE_HOME/rdbms/demo
directory. These files are installed when you install the Oracle Database 12c
Examples (formerly Companion) media. See Table 7-1 for the names of the
files.
7-18
Chapter 7
SQL*Loader Case Studies
• Case Study 7: Extracting Data from a Formatted Report - Extracts data from a
formatted report.
• Case Study 8: Loading Partitioned Tables - Loads partitioned tables.
• Case Study 9: Loading LOBFILEs (CLOBs) - Adds a CLOB column called resume to
the table emp, uses a FILLER field (res_file), and loads multiple LOBFILEs into the
emp table.
• Case Study 10: REF Fields and VARRAYs - Loads a customer table that has a
primary key as its OID and stores order items in a VARRAY. Loads an order table
that has a reference to the customer table and the order items in a VARRAY.
• Case Study 11: Loading Data in the Unicode Character Set - Loads data in the
Unicode character set, UTF16, in little-endian byte order. This case study uses
character-length semantics.
• Case Study Files
This section describes case study files.
• Running the Case Studies
This section describes running the case studies.
• Case Study Log Files
Log files for the case studies are not provided in the $ORACLE_HOME/rdbms/demo
directory.
• Checking the Results of a Case Study
To check the results of running a case study, start SQL*Plus and perform a select
operation from the table that was loaded in the case study.
If the sample data for the case study is contained within the control file, then there will
be no .dat file for that case.
Case study 2 does not require any special set up, so there is no .sql script for that
case. Case study 7 requires that you run both a starting (setup) script and an ending
(cleanup) script.
Table 7-1 lists the files associated with each case.
7-19
Chapter 7
SQL*Loader Case Studies
1. At the system prompt, type sqlplus and press Enter to start SQL*Plus. At the user-
name prompt, enter scott. At the password prompt, enter tiger.
The SQL prompt is displayed.
2. At the SQL prompt, execute the SQL script for the case study. For example, to
execute the SQL script for case study 1, enter the following:
SQL> @ulcase1
This prepares and populates tables for the case study and then returns you to the
system prompt.
3. At the system prompt, start SQL*Loader and run the case study, as follows:
sqlldr USERID=scott CONTROL=ulcase1.ctl LOG=ulcase1.log
Substitute the appropriate control file name and log file name for the CONTROL and
LOG parameters and press Enter. When you are prompted for a password, type
tiger and then press Enter.
Be sure to read the control file for each case study before you run it. The beginning of
the control file contains information about what is being demonstrated in the case
study and any other special information you need to know. For example, case study 6
requires that you add DIRECT=TRUE to the SQL*Loader command line.
7-20
Chapter 7
SQL*Loader Case Studies
This is because the log file for each case study is produced when you execute the
case study, provided that you use the LOG parameter. If you do not want to produce a
log file, then omit the LOG parameter from the command line.
7-21
8
SQL*Loader Command-Line Reference
You can use command-line parameters to start SQL*Loader.
Note:
Regular SQL*Loader and SQL*Loader express mode share some of the same
parameters, but the behavior may be different. The parameter descriptions in
this chapter are for regular SQL*Loader. The parameters for SQL*Loader
express mode are described in SQL*Loader Express .
• Invoking SQL*Loader
This section describes how to start SQL*Loader and specify parameters.
• Command-Line Parameters for SQL*Loader
This section describes each SQL*Loader command-line parameter.
• Exit Codes for Inspection and Display
Oracle SQL*Loader provides the results of a SQL*Loader run immediately upon
completion.
8-1
Chapter 8
Invoking SQL*Loader
Specifying by position means that you enter a value, but not the parameter name. In
the following example, the username scott is provided and then the name of the
control file, ulcase1.ctl. You are prompted for the password:
> sqlldr scott ulcase1.ctl
Password: password
Once a parameter name is used, parameter names must be supplied for all
subsequent specifications. No further positional specification is allowed. For example,
in the following command, the CONTROL parameter is used to specify the control file
name, but then the log file name is supplied without the LOG parameter. This would
result in an error even though the position of ulcase1.log is correct:
> sqlldr scott CONTROL=ulcase1.ctl ulcase1.log
See Also:
"Command-Line Parameters for SQL*Loader" for descriptions of all the
command-line parameters
These alternative ways of specifying parameters are useful when you often use the
same parameters with the same values.
Parameter values specified on the command line override parameter values specified
in either a parameter file or in the OPTIONS clause.
See Also:
• OPTIONS Clause
• PARFILE
8-2
Chapter 8
Command-Line Parameters for SQL*Loader
The local SQL*Loader client connects to the database instance defined by the connect
identifier inst1 (a net service name), and loads the data, as specified in the
ulcase1.ctl control file.
Note:
To load data into a pluggable database (PDB), simply specify its connect
identifier on the connect string when you start SQL*Loader.
See Also:
8-3
Chapter 8
Command-Line Parameters for SQL*Loader
• DEFAULTS
• DEGREE_OF_PARALLELISM
• DIRECT
• DIRECT_PATH_LOCK_WAIT
• DISCARD
• DISCARDMAX
• DNFS_ENABLE
• DNFS_READBUFFERS
• EMPTY_LOBS_ARE_NULL
• ERRORS
• EXTERNAL_TABLE
• FILE
• HELP
• LOAD
• LOG
• MULTITHREADING
• NO_INDEX_ERRORS
• PARALLEL
• PARFILE
• PARTITION_MEMORY
• READSIZE
• RESUMABLE
• RESUMABLE_NAME
• RESUMABLE_TIMEOUT
• ROWS
• SDF_PREFIX
• SILENT
• SKIP
• SKIP_INDEX_MAINTENANCE
• SKIP_UNUSABLE_INDEXES
• STREAMSIZE
• TRIM
• USERID
8.2.1 BAD
Default: The name of the data file, with an extension of .bad
8-4
Chapter 8
Command-Line Parameters for SQL*Loader
Purpose
Specifies the name or location, or both, of the bad file associated with the first data file
specification.
The bad file stores records that cause errors during insert or that are improperly
formatted. If you specify the BAD parameter, you must supply either a directory or file
name, or both. If there are rejected records, and you have not specified a name for the
bad file, then the name defaults to the name of the data file with an extension or file
type of .bad.
The directory parameter specifies a directory to which the bad file is written. The
specification can include the name of a device or network node. The value of directory
is determined as follows:
• If the BAD parameter is not specified at all and a bad file is needed, then the default
directory is the one in which the SQL*Loader control file resides.
• If the BAD parameter is specified with a file name but no directory, then the
directory defaults to the current directory.
• If the BAD parameter is specified with a directory but no file name, then the
specified directory is used and the default is used for the bad file name and
extension.
The filename parameter specifies a file name recognized as valid on your platform.
You must specify only a name (and extension, if one other than .bad is desired). Any
spaces or punctuation marks in the file name must be enclosed in single quotation
marks.
A bad file specified on the command line becomes the bad file associated with the first
INFILE statement (if there is one) in the control file. The name of the bad file can also
be specified in the SQL*Loader control file, using the BADFILE clause. If the bad file is
specified in the control file, as well as on the command line, then the command-line
value is used. If a bad file with that name already exists, then it is either overwritten or
a new version is created, depending on your operating system
See Also:
"Specifying the Bad File" for information about the format of bad files
Example
The following specification creates a bad file named emp1.bad in the current directory:
BAD=emp1
8.2.2 BINDSIZE
Default: 256000
8-5
Chapter 8
Command-Line Parameters for SQL*Loader
Purpose
The BINDSIZE parameter specifies the maximum size (in bytes) of the bind array.
A bind array is an area in memory where SQL*Loader stores data that is to be loaded.
When the bind array is full, the data is transmitted to the database. The bind array size
is controlled by the BINDSIZE and READSIZE parameters.
The size of the bind array given by BINDSIZE overrides the default size (which is system
dependent) and any size determined by ROWS.
See Also:
Restrictions
• The BINDSIZE parameter is used only for conventional path loads.
Example
The following BINDSIZE specification limits the maximum size of the bind array to
356,000 bytes.
BINDSIZE=356000
8.2.3 COLUMNARRAYROWS
Default: 5000
Purpose
The COLUMNARRAYROWS parameter specifies the number of rows to allocate for direct path
column arrays.
See Also:
8-6
Chapter 8
Command-Line Parameters for SQL*Loader
The value for this parameter is not calculated by SQL*Loader. You must either specify
it or accept the default.
Example
The following example specifies that 1000 rows are to be allocated for direct path
column arrays.
COLUMNARRAYROWS=1000
8.2.4 CONTROL
Default: There is no default.
Purpose
The CONTROL parameter specifies the name of the SQL*Loader control file that
describes how to load the data.
If a file extension or file type is not specified, then it defaults to .ctl. If the CONTROL
parameter is not specified, then SQL*Loader prompts you for it.
If the name of your SQL*Loader control file contains special characters, then your
operating system may require that they be preceded by an escape character. Also, if
your operating system uses backslashes in its file system paths, then you may need to
use multiple escape characters or to enclose the path in quotation marks. See your
Oracle operating system-specific documentation for more information.
See Also:
SQL*Loader Control File Reference for a detailed description of the
SQL*Loader control file
Example
The following example specifies a control file named emp1. It is automatically given the
default extension of .ctl.
CONTROL=emp1
8.2.5 DATA
Default: The same name as the control file, but with an extension of .dat.
Purpose
The DATA parameter specifies the name(s) of the data file(s) containing the data to be
loaded.
8-7
Chapter 8
Command-Line Parameters for SQL*Loader
The file specification can contain wildcards (only in the file name and file extension,
not in a device or directory name). An asterisk (*) represents multiple characters and a
question mark (?) represents a single character. For example:
DATA='emp*.dat'
DATA='m?emp.dat'
To list multiple data file specifications (each of which can contain wild cards), the file
names must be separated by commas.
If the file name contains any special characters (for example, spaces, *, ?, ), then the
entire name must be enclosed within single quotation marks.
The following are three examples of possible valid uses of the DATA parameter (the
single quotation marks would only be necessary if the file name contained special
characters):
DATA='file1','file2','file3','file4','file5','file6'
DATA='file1','file2'
DATA='file3,'file4','file5'
DATA='file6'
DATA='file1'
DATA='file2'
DATA='file3'
DATA='file4'
DATA='file5'
DATA='file6'
Caution:
If multiple data files are being loaded and you are also specifying the BAD
parameter, it is recommended that you specify only a directory for the bad file,
not a file name. If you specify a file name, and a file with that name already
exists, then it is either overwritten or a new version is created, depending on
your operating system.
If you specify data files on the command line with the DATA parameter and also specify
data files in the control file with the INFILE clause, then the first INFILE specification in
the control file is ignored. All other data files specified on the command line and in the
control file are processed.
If you specify a file processing option along with the DATA parameter when loading data
from the control file, then a warning message is issued.
8-8
Chapter 8
Command-Line Parameters for SQL*Loader
Example
The following example specifies that a data file named employees.dat is to be loaded.
The .dat extension is assumed as the default because no extension is provided.
DATA=employees
8.2.6 DATE_CACHE
Default: Enabled (for 1000 elements). To completely disable the date cache feature, set
it to 0 (zero).
Purpose
The DATE_CACHE parameter specifies the date cache size (in entries). The date cache is
used to store the results of conversions from text strings to internal date format. The
cache is useful because the cost of looking up dates is much less than converting from
text format to date format. If the same dates occur repeatedly in the data file, then
using the date cache can improve the speed of a direct path load.
Every table has its own date cache, if one is needed. A date cache is created only if at
least one date or timestamp value is loaded that requires data type conversion in order
to be stored in the table.
The date cache feature is enabled by default. The default date cache size is 1000
elements. If the default size is used and the number of unique input values loaded
exceeds 1000, then the date cache feature is automatically disabled for that table.
However, if you override the default and specify a nonzero date cache size and that
size is exceeded, then the cache is not disabled.
You can use the date cache statistics (entries, hits, and misses) contained in the log
file to tune the size of the cache for future similar loads.
See Also:
"Specifying a Value for the Date Cache"
Restrictions
• The date cache feature is only available for direct path and external tables loads.
Example
The following specification completely disables the date cache feature.
DATE_CACHE=0
8-9
Chapter 8
Command-Line Parameters for SQL*Loader
8.2.7 DEFAULTS
Use the SQL*Loader DEFAULTS command to control evaluation and loading of default
expressions.
Default: EVALUATE_ONCE, unless a sequence is involved, then the default is
EVALUATE_EVERY_ROW.
Purpose
The DEFAULTS parameter is only applicable to direct path loads.
Example Usage
Suppose you create a table named test and a SQL*Loader control file named
test.ctl, as follows:
test.ctl:
load data
infile *
truncate
into table test
fields terminated by ','
trailing nullcols
8-10
Chapter 8
Command-Line Parameters for SQL*Loader
(
c0 char
)
begindata
1,
To load the default value of 100 into c1, issue the following statement:
sqlldr scott/tiger t.ctl direct=true
8.2.8 DEGREE_OF_PARALLELISM
Default: NONE
Purpose
The DEGREE_OF_PARALLELISM parameter specifies the degree of parallelism to use during
the load operation.
If DEFAULT is specified, then the default parallelism of the database (not the default
parameter value of AUTO) is used.
If AUTO is used, then the Oracle database automatically sets the degree of parallelism
for the load.
If NONE is specified, then the load is not performed in parallel.
See Also:
• Oracle Database VLDB and Partitioning Guide for more information about
parallel execution
Restrictions
• The DEGREE_OF_PARALLELISM parameter is valid only when the external table load
method is used.
Example
The following example sets the degree of parallelism for the load to 3.
DEGREE_OF_PARALLELISM=3
8-11
Chapter 8
Command-Line Parameters for SQL*Loader
8.2.9 DIRECT
Default: FALSE
Purpose
The DIRECT parameter specifies the load method to use, either conventional path or
direct path.
A value of TRUE specifies a direct path load. A value of FALSE specifies a conventional
path load.
See Also:
Conventional and Direct Path Loads
Example
The following example specifies that the load be performed using conventional path
mode.
DIRECT=FALSE
8.2.10 DIRECT_PATH_LOCK_WAIT
Use the SQL*Loader command DIRECT_PATH_LOCK_WAIT to control direct path load
behavior when waiting for table locks.
Default: FALSE
Purpose
Direct path loads must lock the table before the load can proceed. The
DIRECT_PATH_LOCK_WAIT command controls the direct path API’s behavior while waiting
for a lock.
• TRUE — Direct path waits until it can get a lock on the table before proceeding with
the load.
• FALSE — This is the default. The direct path API tries to lock the table multiple
times and waits one second between attempts. The maximum number of attempts
made is 30. If the table cannot be locked after 30 attempts, then the direct path
API returns the error that was generated when trying to lock the table.
8-12
Chapter 8
Command-Line Parameters for SQL*Loader
8.2.11 DISCARD
Default: The same file name as the data file, but with an extension of .dsc.
Purpose
The DISCARD parameter lets you optionally specify a discard file to store records that
are neither inserted into a table nor rejected. They are not bad records, they simply did
not match any record-selection criteria specified in the control file, such as a WHEN
clause for example.
If you specify the DISCARD parameter, then you must supply either a directory or file
name, or both.
The directory parameter specifies a directory to which the discard file will be written.
The specification can include the name of a device or network node. The value of
directory is determined as follows:
• If the DISCARD parameter is not specified at all, but the DISCARDMAX parameter is,
then the default directory is the one in which the SQL*Loader control file resides.
• If the DISCARD parameter is specified with a file name but no directory, then the
directory defaults to the current directory.
• If the DISCARD parameter is specified with a directory but no file name, then the
specified directory is used and the default is used for the name and the extension.
The filename parameter specifies a file name recognized as valid on your platform.
You must specify only a name (and extension, if one other than .dsc is desired). Any
spaces or punctuation marks in the file name must be enclosed in single quotation
marks.
If neither the DISCARD parameter nor the DISCARDMAX parameter is specified, then a
discard file is not created even if there are discarded records.
If the DISCARD parameter is not specified, but the DISCARDMAX parameter is, and there are
discarded records, then the discard file is created using the default name and the file is
written to the same directory in which the SQL*Loader control file resides.
Caution:
If multiple data files are being loaded and you are also specifying the DISCARD
parameter, it is recommended that you specify only a directory for the discard
file, not a file name. If you specify a file name, and a file with that name already
exists, then it is either overwritten or a new version is created, depending on
your operating system.
A discard file specified on the command line becomes the discard file associated with
the first INFILE statement (if there is one) in the control file. If the discard file is also
specified in the control file, then the command-line value overrides it. If a discard file
8-13
Chapter 8
Command-Line Parameters for SQL*Loader
with that name already exists, then it is either overwritten or a new version is created,
depending on your operating system.
See Also:
"Discarded and Rejected Records" for information about the format of discard
files
Example
Assume that you are loading a data file named employees.dat. The following example
supplies only a directory name so the name of the discard file will be employees.dsc
and it will be created in the mydir directory.
DISCARD=mydir/
8.2.12 DISCARDMAX
Default: ALL
Purpose
The DISCARDMAX parameter specifies the number of discard records to allow before data
loading is terminated.
Example
The following example allows 25 records to be discarded during the load before it is
terminated.
DISCARDMAX=25
8.2.13 DNFS_ENABLE
Default: TRUE
Purpose
The DNFS_ENABLE parameter lets you enable and disable use of the Direct NFS Client
on input data files during a SQL*Loader operation.
8-14
Chapter 8
Command-Line Parameters for SQL*Loader
The Direct NFS Client is an API that can be implemented by file servers to allow
improved performance when an Oracle database accesses files on those servers.
SQL*Loader uses the Direct NFS Client interfaces by default when it reads data files
over 1 GB. For smaller files, the operating system's I/O interfaces are used. To use the
Direct NFS Client on all input data files, use DNFS_ENABLE=TRUE.
To disable use of the Direct NFS Client for all data files, specify DNFS_ENABLE=FALSE.
The DNFS_READBUFFERS parameter can be used to specify the number of read buffers
used by the Direct NFS Client; the default is 4.
See Also:
• Oracle Grid Infrastructure Installation Guide for your platform for more
information about enabling the Direct NFS Client
Example
The following example disables use of the Direct NFS Client on input data files during
the load.
DNFS_ENABLE=FALSE
8.2.14 DNFS_READBUFFERS
Default: 4
Purpose
The DNFS_READBUFFERS parameter lets you control the number of read buffers used by
the Direct NFS Client. The Direct NFS Client is an API that can be implemented by file
servers to allow improved performance when an Oracle database accesses files on
those servers.
Using larger values might compensate for inconsistent I/O from the Direct NFS Client
file server, but it may result in increased memory usage.
See Also:
• Oracle Grid Infrastructure Installation Guide for your platform for more
information about enabling the Direct NFS Client
Restrictions
• To use this parameter without also specifying the DNFS_ENABLE parameter, the input
file must be larger than 1 GB.
8-15
Chapter 8
Command-Line Parameters for SQL*Loader
Example
The following example specifies 10 read buffers for use by the Direct NFS Client.
DNFS_READBUFFERS=10
8.2.15 EMPTY_LOBS_ARE_NULL
If the SQL*Loader EMPTY_LOBS_ARE_NULL parameter is specified, then any LOB column
for which there is no data available is set to NULL rather than to an empty LOB.
Default: FALSE
Purpose
Setting LOB columns for which there is no data available to NULL negates the need to
do this through post-processing after the data is loaded.
Restrictions
None.
Example
In the following example, c1 will be NULL instead of an empty lob.
create table t
(
c0 varchar2(10),
c1 clob
)
;
options (empty_lobs_are_null=true)
load data
infile *
truncate
into table t
fields terminated by ','
trailing nullcols
(
c0 char,
c1 char
)
begindata
1,,
8-16
Chapter 8
Command-Line Parameters for SQL*Loader
8.2.16 ERRORS
Default: 50
Purpose
The ERRORS parameter specifies the maximum number of insert errors to allow.
If the number of errors exceeds the value specified for ERRORS, then SQL*Loader
terminates the load. Any data inserted up to that point is committed.
To permit no errors at all, set ERRORS=0. To specify that all errors be allowed, use a
very high number.
SQL*Loader maintains the consistency of records across all tables. Therefore,
multitable loads do not terminate immediately if errors exceed the error limit. When
SQL*Loader encounters the maximum number of errors for a multitable load, it
continues to load rows to ensure that valid rows previously loaded into tables are
loaded into all tables and rejected rows are filtered out of all tables.
In all cases, SQL*Loader writes erroneous records to the bad file.
Example
The following example specifies a maximum of 25 insert errors for the load. After that,
the load is terminated.
ERRORS=25
8.2.17 EXTERNAL_TABLE
Default: NOT_USED
Purpose
The EXTERNAL_TABLE parameter instructs SQL*Loader whether to load data using the
external tables option.
8-17
Chapter 8
Command-Line Parameters for SQL*Loader
the attempt to load stops. Statements are placed in the log file as they are
executed. This means that if a SQL statement returns an error, then the remaining
SQL statements required for the load will not be placed in the log file.
If you use EXTERNAL_TABLE=EXECUTE and also use the SEQUENCE parameter in your
SQL*Loader control file, then SQL*Loader creates a database sequence, loads
the table using that sequence, and then deletes the sequence. The results of
doing the load this way will be different than if the load were done with
conventional or direct path. (For more information about creating sequences, see
CREATE SEQUENCE in Oracle Database SQL Language Reference.)
Note:
When the EXTERNAL_TABLE parameter is specified, any datetime data types (for
example, TIMESTAMP) in a SQL*Loader control file are automatically converted to
a CHAR data type and use the external tables date_format_spec clause. See
"date_format_spec".
Note that the external table option uses directory objects in the database to indicate
where all input data files are stored and to indicate where output files, such as bad
files and discard files, are created. You must have READ access to the directory objects
containing the data files, and you must have WRITE access to the directory objects
where the output files are created. If there are no existing directory objects for the
location of a data file or output file, then SQL*Loader will generate the SQL statement
to create one. Therefore, when the EXECUTE option is specified, you must have the
CREATE ANY DIRECTORY privilege. If you want the directory object to be deleted at the end
of the load, then you must also have the DROP ANY DIRECTORY privilege.
Note:
The EXTERNAL_TABLE=EXECUTE qualifier tells SQL*Loader to create an external
table that can be used to load data and then executes the INSERT statement to
load the data. All files in the external table must be identified as being in a
directory object. SQL*Loader attempts to use directory objects that already
exist and that you have privileges to access. However, if SQL*Loader does not
find the matching directory object, then it attempts to create a temporary
directory object. If you do not have privileges to create new directory objects,
then the operation fails.
To work around this, use EXTERNAL_TABLE=GENERATE_ONLY to create the SQL
statements that SQL*Loader would try to execute. Extract those SQL
statements and change references to directory objects to be the directory
object that you have privileges to access. Then, execute those SQL
statements.
8-18
Chapter 8
Command-Line Parameters for SQL*Loader
2. Creates an INSERT statement to load this table from an external table description of
the data.
3. Executes one INSERT statement for every table in the control file.
To see an example of this, run case study 5, but add the EXTERNAL_TABLE=GENERATE_ONLY
parameter. To guarantee unique names in the external table, SQL*Loader uses
generated names for all fields. This is because the field names may not be unique
across the different tables in the control file.
See Also:
Restrictions
• Julian dates cannot be used when you insert data into a database table from an
external table through SQL*Loader. To work around this, use TO_DATE and TO_CHAR
to convert the Julian date format, as shown in the following example:
TO_CHAR(TO_DATE(:COL1, 'MM-DD-YYYY'), 'J')
• Built-in functions and SQL strings cannot be used for object elements when you
insert data into a database table from an external table.
Example
EXTERNAL_TABLE=EXECUTE
8.2.18 FILE
Default: There is no default.
Purpose
The FILE parameter specifies the database file from which to allocate extents.
See Also:
"Parallel Data Loading Models"
By varying the value of the FILE parameter for different SQL*Loader processes, data
can be loaded onto a system with minimal disk contention.
8-19
Chapter 8
Command-Line Parameters for SQL*Loader
Restrictions
• The FILE parameter is used only for direct path parallel loads.
8.2.19 HELP
The SQL*Loader HELP command displays online help for the SQL*Loader utility.
Default: FALSE
8.2.20 LOAD
Default: All records are loaded.
Purpose
The LOAD parameter specifies the maximum number of records to load.
To test that all parameters you have specified for the load are set correctly, use the
LOAD parameter to specify a limited number of records rather than loading all records.
No error occurs if fewer than the maximum number of records are found.
Example
The following example specifies that a maximum of 10 records be loaded.
LOAD=10
For external tables method loads, only successfully loaded records are counted toward
the total. So if there are 15 records in the input data file and records 2 and 4 are bad,
then the following records are loaded into the table, for a total of 10 records - 1, 3, 5, 6,
7, 8, 9, 10, 11, and 12.
For conventional and direct path loads, both successful and unsuccessful load
attempts are counted toward the total. So if there are 15 records in the input data file
and records 2 and 4 are bad, then only the following 8 records are actually loaded into
the table - 1, 3, 5, 6, 7, 8, 9, and 10.
8.2.21 LOG
Default: The name of the control file, with an extension of .log.
8-20
Chapter 8
Command-Line Parameters for SQL*Loader
Purpose
The LOG parameter specifies a directory path, or file name, or both for the log file that
SQL*Loader uses to store logging information about the loading process.
If you specify the LOG parameter, then you must supply a directory name, or a file
name, or both.
If no directory name is specified, it defaults to the current directory.
If a directory name is specified without a file name, then the default log file name is
used.
Example
The following example creates a log file named emp1.log in the current directory. The
extension .log is used even though it is not specified, because it is the default.
LOG=emp1
8.2.22 MULTITHREADING
Default: TRUE on multiple-CPU systems, FALSE on single-CPU systems
Purpose
Allows stream building on the client system to be done in parallel with stream loading
on the server system.
See Also:
"Optimizing Direct Path Loads on Multiple-CPU Systems"
Restrictions
• The MULTITHREADING parameter is available only for direct path loads.
• Multithreading functionality is operating system-dependent. Not all operating
systems support multithreading.
8-21
Chapter 8
Command-Line Parameters for SQL*Loader
Example
The following example enables multithreading on a single-CPU system. On a multiple-
CPU system it is enabled by default.
MULTITHREADING=TRUE
8.2.23 NO_INDEX_ERRORS
Default: FALSE
Purpose
The NO_INDEX_ERRORS parameter determines whether indexing errors are tolerated
during a direct path load.
Restrictions
• The NO_INDEX_ERRORS parameter is valid only for direct path loads. If it is specified
for conventional path loads, then it is ignored.
Example
NO_INDEX_ERRORS=TRUE
8.2.24 PARALLEL
Default: FALSE
Purpose
The PARALLEL parameter specifies whether loads that use direct path or external tables
can operate in multiple concurrent sessions to load data into the same table.
See Also:
"Parallel Data Loading Models"
8-22
Chapter 8
Command-Line Parameters for SQL*Loader
Restrictions
• The PARALLEL parameter is not valid in conventional path loads.
Example
The following example specifies that the load will be performed in parallel.
PARALLEL=TRUE
8.2.25 PARFILE
Default: There is no default.
Purpose
The PARFILE parameter specifies the name of a file that contains commonly used
command-line parameters.
Instead of specifying each parameter on the command line, you can simply specify the
name of the parameter file. For example, a parameter file named daily_report.par
might have the following contents:
USERID=scott
CONTROL=daily_report.ctl
ERRORS=9999
LOG=daily_report.log
For security reasons, you should not include your USERID password in a parameter file.
SQL*Loader will prompt you for the password after you specify the parameter file at
the command line, for example:
sqlldr PARFILE=daily_report.par
Password: password
Restrictions
• Although it is not usually important, on some systems it may be necessary to have
no spaces around the equal sign (=) in the parameter specifications.
Example
See the example in the Syntax and Description section.
8.2.26 PARTITION_MEMORY
Default: The default value is 0 (zero), which limits memory use based on the value of
the PGA_AGGREGATE_TARGET initialization parameter. When memory use approaches that
value, loading of some partitions is delayed.
Purpose
The PARTITION_MEMORY parameter lets you limit the amount of memory used when you
are loading many partitions. This parameter is helpful in situations in which the number
8-23
Chapter 8
Command-Line Parameters for SQL*Loader
of partitions you are loading use up large amounts of memory, perhaps even
exceeding available memory (this can happen especially when the data is
compressed).
Once the specified limit is reached, loading of some partition rows is delayed until
memory use falls below the limit.
If n is set to 0 (the default), then SQL*Loader uses a value that is a function of the
PGA_AGGREGATE_TARGET initialization parameter.
If n is set to -1 (minus 1), then SQL*Loader makes no attempt use less memory when
loading many partitions.
Restrictions
• This parameter is only valid for direct path loads.
• This parameter is available only in Oracle Database 12c Release 1 (12.1.0.2) and
later.
Example
The following example limits memory use to 1 GB.
> sqlldr hr CONTROL=t.ctl DIRECT=true PARTITION_MEMORY=1000000
8.2.27 READSIZE
Default: 1048576
Purpose
The READSIZE parameter lets you specify (in bytes) the size of the read buffer, if you
choose not to use the default.
In the conventional path method, the bind array is limited by the size of the read buffer.
Therefore, the advantage of a larger read buffer is that more data can be read before a
commit operation is required.
For example, setting READSIZE to 1000000 enables SQL*Loader to perform reads from
the data file in chunks of 1,000,000 bytes before a commit is required.
Note:
If the READSIZE value specified is smaller than the BINDSIZE value, then the
READSIZE value will be increased.
8-24
Chapter 8
Command-Line Parameters for SQL*Loader
See "BINDSIZE".
Restrictions
• The READSIZE parameter is used only when reading data from data files. When
reading records from a control file, a value of 64 kilobytes (KB) is always used as
the READSIZE.
• The READSIZE parameter has no effect on LOBs. The size of the LOB read buffer is
fixed at 64 kilobytes (KB).
• The maximum size allowed is platform dependent.
Example
The following example sets the size of the read buffer to 500,000 bytes which means
that commit operations will be required more often than if the default or a value larger
than the default were used.
READSIZE=500000
8.2.28 RESUMABLE
Default: FALSE
Purpose
The RESUMABLE parameter is used to enable and disable resumable space allocation.
See Also:
Restrictions
• Because this parameter is disabled by default, you must set RESUMABLE=TRUE to use
its associated parameters, RESUMABLE_NAME and RESUMABLE_TIMEOUT.
Example
The following example enables resumable space allocation:
RESUMABLE=TRUE
8.2.29 RESUMABLE_NAME
Default: 'User USERNAME(USERID), Session SESSIONID, Instance INSTANCEID'
8-25
Chapter 8
Command-Line Parameters for SQL*Loader
Purpose
The RESUMABLE_NAME parameter identifies a statement that is resumable.
This value is a user-defined text string that is inserted in either the USER_RESUMABLE or
DBA_RESUMABLE view to help you identify a specific resumable statement that has been
suspended.
Restrictions
• This parameter is ignored unless the RESUMABLE parameter is set to TRUE to enable
resumable space allocation.
Example
RESUMABLE_NAME='my resumable sql'
8.2.30 RESUMABLE_TIMEOUT
Default: 7200 seconds (2 hours)
Purpose
The RESUMABLE_TIMEOUT parameter specifies the time period, in seconds, during which
an error must be fixed.
If the error is not fixed within the timeout period, then execution of the statement is
terminated, without finishing.
Restrictions
• This parameter is ignored unless the RESUMABLE parameter is set to TRUE to enable
resumable space allocation.
Example
The following example specifies that errors must be fixed within ten minutes (600
seconds).
RESUMABLE_TIMEOUT=600
8.2.31 ROWS
Default: Conventional path default is 64. Direct path default is all rows.
8-26
Chapter 8
Command-Line Parameters for SQL*Loader
Purpose
For conventional path loads, the ROWS parameter specifies the number of rows in the
bind array. For direct path loads, the ROWS parameter specifies the number of rows to
read from the data file(s) before a data save.
Conventional path loads only: The ROWS parameter specifies the number of rows in
the bind array. The maximum number of rows is 65534. See "Bind Arrays and
Conventional Path Loads".
Direct path loads only: The ROWS parameter identifies the number of rows you want to
read from the data file before a data save. The default is to read all rows and save
data once at the end of the load. See "Using Data Saves to Protect Against Data
Loss". The actual number of rows loaded into a table on a save is approximately the
value of ROWS minus the number of discarded and rejected records since the last save.
Note:
If you specify a low value for ROWS and then attempt to compress data using
table compression, the compression ratio will probably be degraded. Oracle
recommends that you either specify a high value or accept the default value
when compressing data.
Restrictions
• The ROWS parameter is ignored for direct path loads when data is loaded into an
Index Organized Table (IOT) or into a table containing VARRAYs, XML columns,
or LOBs. This means that the load still takes place, but no save points are done.
Example
In a conventional path load, the following example would result in an error because the
specified value exceeds the allowable maximum of 65534 rows.
ROWS=65900
8.2.32 SDF_PREFIX
The SDF_PREFIX parameter lets you specify a directory prefix which will be added to file
names of LOBFILEs and secondary data files (SDFs) that are opened as part of a load
operation.
Default: There is no default.
Purpose
If SDF_PREFIX is specified, then the string value must be specified as well. There is no
validation or verification of the string. The value of SDF_PREFIX is prepended to the
filenames used for all LOBFILEs and SDFs opened during the load. If the resulting
8-27
Chapter 8
Command-Line Parameters for SQL*Loader
string is not the name of as valid file, then the attempt to open that file fails and an
error is reported.
If SDF_PREFIX is not specified, then file names for LOBFILEs and SDFs are assumed to
be relative to the current working directory. Using SDF_PREFIX allows those files names
to be relative to a different directory.
Note:
The SDF_PREFIX parameter can also be specified in the OPTIONS clause in the
SQL Loader control file.
Syntax
SDF_PREFIX=string
Quotation marks are only required around the string if it contains characters that would
confuse the command line parser (for example, a space).
The file names that are built by prepending SDF_PREFIX to the file names found in the
record are passed to the operating system to open the file. The prefix can be relative
to the current working directory from which SQL*Loader is being executed or it can be
the start of an absolute path.
Restrictions
• The SDF_PREFIX parameter should not be used if the file specifications for the
LOBFILEs or SDFs contain full file names.
Example
The following SQL*Loader command looks for LOB files in the lobdir subdirectory of
the current directory
sqlldr control=picts.ctl log=picts.log sdf_prefix=lobdir/
8.2.33 SILENT
Default: There is no default.
Purpose
The SILENT parameter suppresses some of the content that is written to the screen
during a SQL*Loader operation.
Use the appropriate values to suppress one or more of the following (if more than one
option is specified, they must be separated by commas):
• HEADER - Suppresses the SQL*Loader header messages that normally appear on
the screen. Header messages still appear in the log file.
• FEEDBACK - Suppresses the "commit point reached" messages and the status
messages for the load that normally appear on the screen.
8-28
Chapter 8
Command-Line Parameters for SQL*Loader
• ERRORS - Suppresses the data error messages in the log file that occur when a
record generates an Oracle error that causes it to be written to the bad file. A
count of rejected records still appears.
• DISCARDS - Suppresses the messages in the log file for each record written to the
discard file.
• PARTITIONS - Disables writing the per-partition statistics to the log file during a direct
load of a partitioned table.
• ALL - Implements all of the suppression values: HEADER, FEEDBACK, ERRORS, DISCARDS,
and PARTITIONS.
Example
For example, you can suppress the header and feedback messages that normally
appear on the screen with the following command-line argument:
SILENT=HEADER, FEEDBACK
8.2.34 SKIP
Default: 0 (No records are skipped.)
Purpose
The SKIP parameter specifies the number of logical records from the beginning of the
file that should not be loaded. This allows you to continue loads that have been
interrupted for some reason, without loading records that have already been
processed.
The SKIP parameter can be used for all conventional loads, for single-table direct path
loads, and for multiple-table direct path loads when the same number of records was
loaded into each table. It cannot be used for multiple-table direct path loads when a
different number of records was loaded into each table.
If a WHEN clause is also present and the load involves secondary data, then the
secondary data is skipped only if the WHEN clause succeeds for the record in the
primary data file.
See Also:
"Interrupted Loads"
Restrictions
• The SKIP parameter cannot be used for external table loads.
Example
The following example skips the first 500 logical records in the data file(s) before
proceeding with the load:
8-29
Chapter 8
Command-Line Parameters for SQL*Loader
SKIP=500
8.2.35 SKIP_INDEX_MAINTENANCE
Default: FALSE
Purpose
The SKIP_INDEX_MAINTENANCE parameter specifies whether to stop index maintenance
for direct path loads.
If set to TRUE, this parameter causes the index partitions that would have had index
keys added to them to instead be marked Index Unusable because the index segment
is inconsistent with respect to the data it indexes. Index segments that are unaffected
by the load retain the state they had before the load.
The SKIP_INDEX_MAINTENANCE parameter:
Restrictions
• The SKIP_INDEX_MAINTENANCE parameter does not apply to conventional path loads.
• Indexes that are unique and marked Unusable are not allowed to skip index
maintenance. This rule is enforced by DML operations, and enforced by the direct
path load to be consistent with DML.
Example
The following example stops index maintenance from taking place during a direct path
load operation:
SKIP_INDEX_MAINTENANCE=TRUE
8.2.36 SKIP_UNUSABLE_INDEXES
Default: The value of the Oracle Database configuration parameter,
SKIP_UNUSABLE_INDEXES, as specified in the initialization parameter file. The default
database setting is TRUE.
Purpose
The SKIP_UNUSABLE_INDEXES parameter specifies whether to skip an index encountered
in an Index Unusable state and continue the load operation.
8-30
Chapter 8
Command-Line Parameters for SQL*Loader
Restrictions
• Indexes that are unique and marked Unusable are not allowed to skip index
maintenance. This rule is enforced by DML operations, and enforced by the direct
path load to be consistent with DML.
Example
If the Oracle Database initialization parameter had a value of
SKIP_UNUSABLE_INDEXES=FALSE, then the following parameter on the SQL*Loader
command line would override it. Therefore, if an index in an Index Unusable state is
encountered, it is skipped and the load operation continues.
SKIP_UNUSABLE_INDEXES=TRUE
8.2.37 STREAMSIZE
Default: 256000
Purpose
The STREAMSIZE parameter specifies the size (in bytes) of the data stream sent from the
client to the server.
8-31
Chapter 8
Command-Line Parameters for SQL*Loader
The STREAMSIZE parameter specifies the size of the direct path stream buffer. The
number of column array rows (specified with the COLUMNARRAYROWS parameter)
determines the number of rows loaded before the stream buffer is built. The optimal
values for these parameters vary, depending on the system, input data types, and
Oracle column data types used. When you are using optimal values for your particular
configuration, the elapsed time in the SQL*Loader log file should go down.
See Also:
"Specifying the Number of Column Array Rows and Size of Stream Buffers"
Restrictions
• The STREAMSIZE parameter applies only to direct path loads.
• The minimum value for STREAMSIZE is 65536. If a value lower than 65536 is
specified, then 65536 is used instead.
Example
The following example specifies a direct path stream buffer size of 300,000 bytes.
STREAMSIZE=300000
8.2.38 TRIM
Default: LDRTRIM
Purpose
The TRIM parameter specifies that spaces should be trimmed from the beginning of a
text field, the end of a text field, or both. Spaces include blanks and other nonprinting
characters such as tabs, line feeds, and carriage returns.
NOTRIM indicates that no characters will be trimmed from the field. This setting generally
yields that fastest performance.
LRTRIM, LTRIM, and RTRIM are used to indicate that characters should be trimmed from
the field. LRTRIM means that both leading and trailing spaces are trimmed. LTRIM means
that leading spaces will be trimmed. RTRIM means trailing spaces are trimmed.
• If the field is not a delimited field, then spaces will be trimmed from the right.
• If the field is a delimited field with OPTIONALLY ENCLOSED BY specified, and the
optional enclosures are missing for a particular instance, then spaces will be
trimmed from the left.
If trimming is specified for a field that is all spaces, then the field is set to NULL.
8-32
Chapter 8
Command-Line Parameters for SQL*Loader
Restrictions
• The TRIM parameter is valid only when the external table load method is used.
Example
The following example would result in a load operation for which no characters are
trimmed from any fields:
TRIM=NOTRIM
8.2.39 USERID
Default: If it is omitted, then you are prompted for it. If only a slash is used, then USERID
defaults to your operating system login
Purpose
The USERID parameter is used to provide your Oracle username and password.
Specify a user name. For security reasons, Oracle recommends that you specify only
the user name on the command line. SQL*Loader then prompts you for a password.
If you do not specify the USERID parameter, then you are prompted for it. If only a slash
is used, then USERID defaults to your operating system login.
If you connect as user SYS, then you must also specify AS SYSDBA in the connect string.
Restrictions
• Because the string, AS SYSDBA, contains a blank, some operating systems may
require that the entire connect string be placed in quotation marks or marked as a
literal by some method. Some operating systems also require that quotation marks
on the command line be preceded by an escape character, such as backslashes.
See your Oracle operating system-specific documentation for information about
special and reserved characters on your system.
Example
The following example specifies a user name of hr. SQL*Loader then prompts for a
password. Because it is the first and only parameter specified, you do not need to
include the parameter name USERID:
> sqlldr hr
Password:
See Also:
8-33
Chapter 8
Exit Codes for Inspection and Display
For Linux and UNIX operating systems, the exit codes are as follows:
EX_SUCC 0
EX_FAIL 1
EX_WARN 2
EX_FTL 3
If SQL*Loader returns any exit code other than zero, then you should consult your
system log files and SQL*Loader log files for more detailed diagnostic information.
In UNIX, you can check the exit code from the shell to determine the outcome of a
load.
8-34
9
SQL*Loader Control File Reference
The SQL*Loader control file is a text file that contains data definition language (DDL)
instructions for a SQL*Loader job.
Successfully using a SQL*Loader control file requires an understanding of the
following topics:
Note:
You can also use SQL*Loader without a control file; this is known as
SQL*Loader express mode. See SQL*Loader Express for more information.
9-1
Chapter 9
Control File Contents
9-2
Chapter 9
Control File Contents
In this sample control file, the numbers that appear to the left would not appear in a
real control file. They are keyed in this sample to the explanatory notes in the following
list:
1. This is how comments are entered in a control file. See "Comments in the Control
File".
2. The LOAD DATA statement tells SQL*Loader that this is the beginning of a new data
load. See SQL*Loader Syntax Diagrams for syntax information.
3. The INFILE clause specifies the name of a data file containing the data you want to
load. See "Specifying Data Files".
4. The BADFILE clause specifies the name of a file into which rejected records are
placed. See "Specifying the Bad File".
5. The DISCARDFILE clause specifies the name of a file into which discarded records
are placed. See "Specifying the Discard File".
6. The APPEND clause is one of the options you can use when loading data into a table
that is not empty. See "Loading Data into Nonempty Tables".
To load data into a table that is empty, you would use the INSERT clause. See
"Loading Data into Empty Tables".
7. The INTO TABLE clause enables you to identify tables, fields, and data types. It
defines the relationship between records in the data file and tables in the
database. See "Specifying Table Names".
8. The WHEN clause specifies one or more field conditions. SQL*Loader decides
whether to load the data based on these field conditions. See "Loading Records
Based on a Condition".
9-3
Chapter 9
Specifying Command-Line Parameters in the Control File
9. The TRAILING NULLCOLS clause tells SQL*Loader to treat any relatively positioned
columns that are not present in the record as null columns. See "Handling Short
Records with Missing Data".
10. The remainder of the control file contains the field list, which provides information
about column formats in the table being loaded. See SQL*Loader Field List
Reference for information about that section of the control file.
• Comments in the Control File
Comments can appear anywhere in the parameter section of the file, but they
should not appear within the data.
All text to the right of the double hyphen is ignored, until the end of the line.
This can be useful if you often use a control file with the same set of options. The
OPTIONS clause precedes the LOAD DATA statement.
• OPTIONS Clause
The following command-line parameters can be specified using the OPTIONS
clause.
• Specifying the Number of Default Expressions to Be Evaluated At One Time
Use the SQL*Loader DEFAULT EXPRESSION CACHE n clause to specify how many
default expressions are evaluated at a time by the direct path load. The default
value is 100.
9-4
Chapter 9
Specifying File Names and Object Names
LOAD = n
MULTITHREADING = {TRUE | FALSE}
PARALLEL = {TRUE | FALSE}
READSIZE = n
RESUMABLE = {TRUE | FALSE}
RESUMABLE_NAME = 'text string'
RESUMABLE_TIMEOUT = n
ROWS = n
SDF_PREFIX = string
SILENT = {HEADER | FEEDBACK | ERRORS | DISCARDS | PARTITIONS | ALL}
SKIP = n
SKIP_INDEX_MAINTENANCE = {TRUE | FALSE}
SKIP_UNUSABLE_INDEXES = {TRUE | FALSE}
STREAMSIZE = n
TRIM= {LRTRIM|NOTRIM|LTRIM|RTRIM|LDRTRIM}
The following is an example use of the OPTIONS clause that you could use in a
SQL*Loader control file:
OPTIONS (BINDSIZE=100000, SILENT=(ERRORS, FEEDBACK) )
Note:
Parameter values specified on the command line override parameter values
specified in the control file OPTIONS clause.
9-5
Chapter 9
Specifying File Names and Object Names
9.3.1 File Names That Conflict with SQL and SQL*Loader Reserved
Words
SQL and SQL*Loader reserved words must be specified within double quotation
marks.
The only SQL*Loader reserved word is CONSTANT.
You must use double quotation marks if the object name contains special characters
other than those recognized by SQL ($, #, _), or if the name is case sensitive.
See Also:
Oracle Database SQL Language Reference
See Also:
Applying SQL Operators to Fields
9-6
Chapter 9
Specifying File Names and Object Names
You can also put the escape character itself into a string by entering it twice.
For example:
"so'\"far" or 'so\'"far' is parsed as so'"far
"'so\\far'" or '\'so\\far\'' is parsed as 'so\far'
"so\\\\far" or 'so\\\\far' is parsed as so\\far
Note:
A double quotation mark in the initial position cannot be preceded by an escape
character. Therefore, you should avoid creating strings with an initial quotation
mark.
9-7
Chapter 9
Identifying XMLType Tables
strings, then you must specify double backslashes in your path names and use single
quotation marks.
As of Oracle Database 10g, the XMLTYPE clause is available for use in a SQL*Loader
control file. This clause is of the format XMLTYPE(field name). It is used to identify
XMLType tables so that the correct SQL statement can be constructed. Example 9-2
shows how the XMLTYPE clause can be used in a SQL*Loader control file to load data
into a schema-based XMLType table.
See Also:
Oracle XML DB Developer's Guide for more information about loading XML
data using SQL*Loader
9-8
Chapter 9
Specifying Field Order
</xs:complexType>
</xs:element>
</xs:schema>',
TRUE, TRUE, FALSE); end;
/
The control file used to load data into the table, xdb_tab5, looks as follows. It loads
XMLType data using the registered XML schema, xdb_user.xsd. The XMLTYPE clause is
used to identify this table as an XMLType table. Either direct path or conventional mode
can be used to load the data into the table.
LOAD DATA
INFILE *
INTO TABLE xdb_tab5 TRUNCATE
xmltype(xmldata)
(
xmldata char(4000)
)
BEGINDATA
<Employee> <EmployeeId>111</EmployeeId> <Name>Ravi</Name> <Salary>100000</Sal
ary> <DeptId>12</DeptId></Employee>
<Employee> <EmployeeId>112</EmployeeId> <Name>John</Name> <Salary>150000</Sal
ary> <DeptId>12</DeptId></Employee>
<Employee> <EmployeeId>113</EmployeeId> <Name>Michael</Name> <Salary>75000</S
alary> <DeptId>12</DeptId></Employee>
<Employee> <EmployeeId>114</EmployeeId> <Name>Mark</Name> <Salary>125000</Sal
ary> <DeptId>16</DeptId></Employee>
<Employee> <EmployeeId>115</EmployeeId> <Name>Aaron</Name> <Salary>600000</Sa
lary> <DeptId>16</DeptId></Employee>
• FIRST FILE: Indicates that the first data file contains a list of field names for the data
in the first record. This list uses the same delimiter as the data in the data file. The
record is read for setting up the mapping between the fields in the data file and the
columns in the target table. The record is skipped when the data is processed.
This can be useful if the order of the fields in the data file is different from the order
of the columns in the table, or if the number of fields in the data file is different
from the number of columns in the target table
• FIRST FILE IGNORE: Indicates that the first data file contains a list of field names for
the data in the first record, but that the information should be ignored. The record
will be skipped when the data is processed, but it will not be used for setting up the
fields.
• ALL FILES: Indicates that all data files contain a list of field names for the data in the
first record. The first record is skipped in each data file when the data is
9-9
Chapter 9
Specifying Data Files
processed. The fields can be in a different order in each data file. SQL*Loader
sets up the load based on the order of the fields in each data file.
• ALL FILES IGNORE: Indicates that all data files contain a list of field names for the
data in the first record, but that the information should be ignored. The record is
skipped when the data is processed in every data file, but it will not be used for
setting up the fields.
• NONE: Indicates that the data file contains normal data in the first record. This is the
default.
The FIELD NAMES clause cannot be used for complex column types such as column
objects, nested tables, or VARRAYs.
Note:
You can also specify the data file from the command line, using the DATA
parameter described in "Command-Line Parameters for SQL*Loader". A file
name specified on the command line overrides the first INFILE clause in the
control file.
If no file name is specified, then the file name defaults to the control file name with an
extension or file type of .dat.
If the control file itself contains the data to be loaded, then specify an asterisk (*). This
specification is described in "Identifying Data in the Control File with BEGINDATA" .
Note:
The information in this section applies only to primary data files. It does not
apply to LOBFILEs or SDFs.
For information about LOBFILES, see "Loading LOB Data from LOBFILEs".
For information about SDFs, see "Secondary Data Files (SDFs)".
* os_file_proc_clause
INFILE
input_filename
9-10
Chapter 9
Specifying Data Files
Parameter Description
INFILE Specifies that a data file specification follows.
input_filename Name of the file containing the data. The file name can contain
wildcards. An asterisk (*) represents multiple characters and a
question mark (?) represents a single character. For example:
INFILE 'emp*.dat'
INFILE 'm?emp.dat'
Note:
File names that include spaces or punctuation marks must be enclosed in
single quotation marks.
• Data contained in any file of type .dat whose name begins with emp:
INFILE 'emp*.dat'
9-11
Chapter 9
Specifying CSV Format Files
• Data contained in any file of type .dat whose name begins with m, followed by any
other single character, and ending in emp. For example, a file named myemp.dat
would be included in the following:
INFILE 'm?emp.dat'
• For mydat1.dat, both a bad file and discard file are explicitly specified. Therefore
both files are created, as needed.
• For mydat2.dat, neither a bad file nor a discard file is specified. Therefore, only the
bad file is created, as needed. If created, the bad file has the default file name and
extension mydat2.bad. The discard file is not created, even if rows are discarded.
• For mydat3.dat, the default bad file is created, if needed. A discard file with the
specified name (mydat3.dis) is created, as needed.
• For mydat4.dat, the default bad file is created, if needed. Because the DISCARDMAX
option is used, SQL*Loader assumes that a discard file is required and creates it
with the default name mydat4.dsc.
This assumes that the file is a stream record format file with the normal carriage return
string (for example, \n on UNIX or Linux operating systems and either \n or \r\n on
Windows operating systems). Record terminators can be included (embedded) in data
values. The syntax for the CSV clause is as follows:
FIELDS CSV [WITH EMBEDDED|WITHOUT EMBEDDED] [FIELDS TERMINATED BY ','] [OPTIONALLY
ENCLOSED BY '"']
The following are key points regarding the FIELDS CSV clause:
9-12
Chapter 9
Identifying Data in the Control File with BEGINDATA
• If WITH EMBEDDED is used, then embedded record terminators must be enclosed, and
intra-datafile parallelism is disabled for external table loads.
• The TERMINATED BY ',' and OPTIONALLY ENCLOSED BY '"' options are the defaults
and do not have to be specified. You can override them with different termination
and enclosure characters.
• When the CSV clause is used, only delimitable data types are allowed as control file
fields. Delimitable data types include CHAR, datetime, interval, and numeric
EXTERNAL.
• The TERMINATED BY and ENCLOSED BY clauses cannot be used at the field level when
the CSV clause is specified.
• When the CSV clause is specified, normal SQL*Loader blank trimming is done by
default. You can specify PRESERVE BLANKS to avoid trimming of spaces. Or, you can
use the SQL functions LTRIM and RTRIM in the field specification to remove left
and/or right spaces.
• When the CSV clause is specified, the INFILE * clause in not allowed. This means
that there cannot be any data included in the SQL*Loader control file.
The following sample SQL*Loader control file uses the FIELDS CSV clause with the
default delimiters:
LOAD DATA
INFILE "mydata.dat"
TRUNCATE
INTO TABLE mytable
FIELDS CSV WITH EMBEDDED
TRAILING NULLCOLS
(
c0 char,
c1 char,
c2 char,
)
If the data is included in the control file itself, then the INFILE clause is followed by an
asterisk rather than a file name. The actual data is placed in the control file after the
load configuration specifications.
The syntax is:
BEGINDATA
first_data_record
Keep the following points in mind when using the BEGINDATA statement:
• If you omit the BEGINDATA statement but include data in the control file, then
SQL*Loader tries to interpret your data as control information and issues an error
message. If your data is in a separate file, then do not use the BEGINDATA
statement.
• Do not use spaces or other characters on the same line as the BEGINDATA
statement, or the line containing BEGINDATA will be interpreted as the first line of
data.
9-13
Chapter 9
Specifying Data File Format and Buffering
• Do not put comments after BEGINDATA, or they will also be interpreted as data.
See Also:
In this syntax, RECSIZE is the size of a fixed-length record, and BUFFERS is the number of
buffers to use for asynchronous I/O.
To declare a file named mydata.dat as a file that contains 80-byte records and instruct
SQL*Loader to use 8 I/O buffers, you would use the following control file entry:
INFILE 'mydata.dat' "RECSIZE 80 BUFFERS 8"
Note:
This example uses the recommended convention of single quotation marks for
file names and double quotation marks for everything else.
See Also:
Oracle Database Platform Guide for Microsoft Windows for information about
using the os_file_proc_clause on Windows systems.
9-14
Chapter 9
Specifying the Bad File
• If one or more records are rejected, then the bad file is created and the rejected
records are logged.
• If no records are rejected, then the bad file is not created.
• If the bad file is created, then it overwrites any existing file with the same name;
ensure that you do not overwrite a file you want to retain.
Note:
On some systems, a new version of the file may be created if a file with the
same name already exists.
To specify the name of the bad file, use the BADFILE clause. You can also specify the
bad file from the command line with the BAD parameter described in "Command-Line
Parameters for SQL*Loader".
A file name specified on the command line is associated with the first INFILE clause in
the control file, overriding any bad file that may have been specified as part of that
clause.
The bad file is created in the same record and file format as the data file so that you
can reload the data after you correct it. For data files in stream record format, the
record terminator that is found in the data file is also used in the bad file.
The syntax for the BADFILE clause is as follows:
directory_path filename
BADFILE
The BADFILE clause specifies that a directory path or file name, or both, for the bad file
follows. If you specify BADFILE, then you must supply either a directory path or a file
name, or both.
The directory parameter specifies a directory path to which the bad file will be written.
The filename parameter specifies a valid file name specification for your platform. Any
spaces or punctuation marks in the file name must be enclosed in single quotation
marks. If you do not specify a name for the bad file, then the name defaults to the
name of the data file with an extension or file type of .bad.
9-15
Chapter 9
Specifying the Bad File
To specify a bad file with file name sample and default file extension or file type of .bad,
enter the following in the control file:
BADFILE sample
To specify only a directory name, enter the following in the control file:
BADFILE '/mydisk/bad_dir/'
To specify a bad file with file name bad0001 and file extension or file type of .rej, enter
either of the following lines in the control file:
BADFILE bad0001.rej
BADFILE '/REJECT_DIR/bad0001.rej'
9.10.2 How Bad Files Are Handled with LOBFILEs and SDFs
Data from LOBFILEs and SDFs is not written to a bad file when there are rejected
rows.
If there is an error loading a LOB, then the row is not rejected. Rather, the LOB column
is left empty (not null with a length of zero (0) bytes). However, when the LOBFILE is
being used to load an XML column and there is an error loading this LOB data, then the
XML column is left as null.
9-16
Chapter 9
Specifying the Discard File
• DISCARDS
• DISCARDMAX
The discard file is created in the same record and file format as the data file. For data
files in stream record format, the same record terminator that is found in the data file is
also used in the discard file.
You can also create a discard file from the command line by specifying either the
DISCARD or DISCARDMAX parameter. See SQL*Loader Command-Line Reference.
If no discard clauses are included in the control file or on the command line, then a
discard file is not created even if there are discarded records (that is, records that fail
to satisfy all of the WHEN clauses specified in the control file).
9-17
Chapter 9
Specifying the Discard File
DISCARDS
directory_path filename integer
DISCARDFILE DISCARDMAX
The DISCARDFILE clause specifies that a discard directory path and/or file name follows.
Neither the directory_path nor the filename is required. However, you must specify at
least one.
The directory parameter specifies a directory to which the discard file will be written.
The filename parameter specifies a valid file name specification for your platform. Any
spaces or punctuation marks in the file name must be enclosed in single quotation
marks.
The default file name is the name of the data file, and the default file extension or file
type is .dsc. A discard file name specified on the command line overrides one specified
in the control file. If a discard file with that name already exists, then it is either
overwritten or a new version is created, depending on your operating system.
• Limiting the Number of Discard Records
You can limit the number of records to be discarded for each data file by
specifying an integer for either the DISCARDS or DISCARDMAX keyword.
You can specify a different number of discards for each data file. Or, if you specify the
number of discards only once, then the maximum number of discards specified applies
to all files.
When the discard limit is reached, processing of the data file terminates and continues
with the next data file, if one exists.
If you specify a maximum number of discards, but no discard file name, then
SQL*Loader creates a discard file with the default file name and file extension or file
type.
9-18
Chapter 9
Specifying a NULLIF Clause At the Table Level
• To specify a discard file named notappl with the file extension or file type of .may:
DISCARDFILE notappl.may
• To specify a full path to the discard file forget.me:
DISCARDFILE '/discard_dir/forget.me'
This situation occurs when every INTO TABLE clause in the SQL*Loader control file has
a WHEN clause and, either the record fails to match any of them, or all fields are null.
No records are discarded if an INTO TABLE clause is specified without a WHEN clause. An
attempt is made to insert every record into such a table. Therefore, records may be
rejected, but none are discarded.
Case study 7, Extracting Data from a Formatted Report, provides an example of using
a discard file. (See SQL*Loader Case Studies for information on how to access case
studies.)
9.11.4 How Discard Files Are Handled with LOBFILEs and SDFs
Data from LOBFILEs and SDFs is not written to a discard file when there are
discarded rows.
The char_string and hex_string values must be enclosed in either single quotation
marks or double quotation marks.
This specification is used for each mapped character field unless a NULLIF clause is
specified at the field level. A NULLIF clause specified at the field level overrides a NULLIF
clause specified at the table level.
SQL*Loader checks the specified value against the value of the field in the record. If
there is a match using the equal or not equal specification, then the field is set to NULL
for that row. Any field that has a length of 0 after blank trimming is also set to NULL.
9-19
Chapter 9
Specifying Datetime Formats At the Table Level
If you do not want the default NULLIF or any other NULLIF clause applied to a field, you
can specify NO NULLIF at the field level.
See Also:
This specification is used for every date or timestamp field unless a different mask is
specified at the field level. A mask specified at the field level overrides a mask
specified at the table level.
The following is an example of using the DATE FORMAT clause in a SQL*Loader control
file. The DATE FORMAT clause is overridden by DATE at the field level for the hiredate and
entrydate fields:
LOAD DATA
INFILE myfile.dat
APPEND
INTO TABLE EMP
FIELDS TERMINATED BY ","
DATE FORMAT "DD-Month-YYYY"
(empno,
ename,
job,
mgr,
hiredate DATE,
sal,
comm,
deptno,
entrydate DATE)
See Also:
9-20
Chapter 9
Handling Different Character Encoding Schemes
See Also:
Oracle Database Globalization Support Guide
The following sections provide a brief introduction to some of the supported character
encoding schemes.
• Multibyte (Asian) Character Sets
Multibyte character sets support Asian languages.
• Unicode Character Sets
SQL*Loader supports loading data that is in a Unicode character set.
• Database Character Sets
The Oracle database uses the database character set for data stored in SQL CHAR
data types (CHAR, VARCHAR2, CLOB, and LONG), for identifiers such as table names,
and for SQL statements and PL/SQL source code.
• Data File Character Sets
By default, the data file is in the character set defined by the NLS_LANG parameter.
• Input Character Conversion
The default character set for all data files, if the CHARACTERSET parameter is not
specified, is the session character set defined by the NLS_LANG parameter.
• Shift-sensitive Character Data
In general, loading shift-sensitive character data can be much slower than loading
simple ASCII or EBCDIC data.
Unicode is a universal encoded character set that supports storage of information from
most languages in a single character set. Unicode provides a unique code value for
every character, regardless of the platform, program, or language. There are two
different encodings for Unicode, UTF-16 and UTF-8.
9-21
Chapter 9
Handling Different Character Encoding Schemes
Note:
In this manual, you will see the terms UTF-16 and UTF16 both used. The term
UTF-16 is a general reference to UTF-16 encoding for Unicode. The term
UTF16 (no hyphen) is the specific name of the character set and is what you
should specify for the CHARACTERSET parameter when you want to use UTF-16
encoding. This also applies to UTF-8 and UTF8.
See Also:
• Case study 11, Loading Data in the Unicode Character Set (see
"SQL*Loader Case Studies" for information on how to access case studies)
• Oracle Database Globalization Support Guide for more information about
Unicode encoding
The data file character sets supported with NLS_LANG are the same as those supported
as database character sets. SQL*Loader supports all Oracle-supported character sets
in the data file (even those not supported as database character sets).
For example, SQL*Loader supports multibyte fixed-width character sets (such as
AL16UTF16 and JA16EUCFIXED) in the data file. SQL*Loader also supports UTF-16
encoding with little-endian byte ordering. However, the Oracle database supports only
9-22
Chapter 9
Handling Different Character Encoding Schemes
UTF-16 encoding with big-endian byte ordering (AL16UTF16) and only as a database
national character set, not as a database character set.
The character set of the data file can be set up by using the NLS_LANG parameter or by
specifying a SQL*Loader CHARACTERSET parameter.
The character set used in input data files can be specified with the CHARACTERSET
parameter.
SQL*Loader can automatically convert data from the data file character set to the
database character set or the database national character set, when they differ.
When data character set conversion is required, the target character set should be a
superset of the source data file character set. Otherwise, characters that have no
equivalent in the target character set are converted to replacement characters, often a
default character such as a question mark (?). This causes loss of data.
The sizes of the database character types CHAR and VARCHAR2 can be specified in bytes
(byte-length semantics) or in characters (character-length semantics). If they are
specified in bytes, and data character set conversion is required, then the converted
values may take more bytes than the source values if the target character set uses
more bytes than the source character set for any character that is converted. This will
result in the following error message being reported if the larger target value exceeds
the size of the database column:
ORA-01401: inserted value too large for column
You can avoid this problem by specifying the database column size in characters and
also by using character sizes in the control file to describe the data. Another way to
avoid this problem is to ensure that the maximum column size is large enough, in
bytes, to hold the converted value.
9-23
Chapter 9
Handling Different Character Encoding Schemes
See Also:
• "Character-Length Semantics"
• Oracle Database Globalization Support Guide
If you use SQL*Loader conventional path or the Oracle Call Interface (OCI) to load
data into VARRAYs or into primary-key-based REFs, and the data being loaded is in a
different character set than the database character set, then problems such as the
following might occur:
• Rows might be rejected because a field is too large for the database column, but
in reality the field is not too large.
• A load might be abnormally terminated without any rows being loaded, when only
the field that really was too large should have been rejected.
• Rows might be reported as loaded correctly, but the primary-key-based REF
columns are returned as blank when they are selected with SQL*Plus.
To avoid these problems, set the client character set (using the NLS_LANG environment
variable) to the database character set before you load the data.
The char_set_name variable specifies the character set name. Normally, the specified
name must be the name of an Oracle-supported character set.
For UTF-16 Unicode encoding, use the name UTF16 rather than AL16UTF16.
AL16UTF16, which is the supported Oracle character set name for UTF-16 encoded
data, is only for UTF-16 data that is in big-endian byte order. However, because you
are allowed to set up data using the byte order of the system where you create the
data file, the data in the data file can be either big-endian or little-endian. Therefore, a
different character set name (UTF16) is used. The character set name AL16UTF16 is
also supported. But if you specify AL16UTF16 for a data file that has little-endian byte
9-24
Chapter 9
Handling Different Character Encoding Schemes
order, then SQL*Loader issues a warning message and processes the data file as
little-endian.
The CHARACTERSET parameter can be specified for primary data files and also for
LOBFILEs and SDFs. All primary data files are assumed to be in the same character
set. A CHARACTERSET parameter specified before the INFILE parameter applies to the
entire list of primary data files. If the CHARACTERSET parameter is specified for primary
data files, then the specified value will also be used as the default for LOBFILEs and
SDFs. This default setting can be overridden by specifying the CHARACTERSET parameter
with the LOBFILE or SDF specification.
The character set specified with the CHARACTERSET parameter does not apply to data
specified with the INFILE clause in the control file. The control file is always processed
using the character set specified for your session by the NLS_LANG parameter.
Therefore, to load data in a character set other than the one specified for your session
by the NLS_LANG parameter, you must place the data in a separate data file.
See Also:
• "Byte Ordering"
• Oracle Database Globalization Support Guide for more information about
the names of the supported character sets
• "Control File Character Set"
• Case study 11, Loading Data in the Unicode Character Set, for an example
of loading a data file that contains little-endian UTF-16 encoded data. (See
"SQL*Loader Case Studies" for information on how to access case
studies.)
If the control file character set is different from the data file character set, then keep
the following issue in mind. Delimiters and comparison clause values specified in the
SQL*Loader control file as character strings are converted from the control file
character set to the data file character set before any comparisons are made. To
ensure that the specifications are correct, you may prefer to specify hexadecimal
strings, rather than character string values.
If hexadecimal strings are used with a data file in the UTF-16 Unicode encoding, then
the byte order is different on a big-endian versus a little-endian system. For example,
"," (comma) in UTF-16 on a big-endian system is X'002c'. On a little-endian system it is
X'2c00'. SQL*Loader requires that you always specify hexadecimal strings in big-
endian format. If necessary, SQL*Loader swaps the bytes before making
comparisons. This allows the same syntax to be used in the control file on both a big-
endian and a little-endian system.
Record terminators for data files that are in stream format in the UTF-16 Unicode
encoding default to "\n" in UTF-16 (that is, 0x000A on a big-endian system and
0x0A00 on a little-endian system). You can override these default settings by using the
"STR 'char_str'" or the "STR x'hex_str'" specification on the INFILE line. For example,
9-25
Chapter 9
Handling Different Character Encoding Schemes
you could use either of the following to specify that 'ab' is to be used as the record
terminator, instead of '\n'.
INFILE myfile.dat "STR 'ab'"
Any data included after the BEGINDATA statement is also assumed to be in the character
set specified for your session by the NLS_LANG parameter.
For the SQL*Loader data types (CHAR, VARCHAR, VARCHARC, DATE, and EXTERNAL
numerics), SQL*Loader supports lengths of character fields that are specified in either
bytes (byte-length semantics) or characters (character-length semantics). For
example, the specification CHAR(10) in the control file can mean 10 bytes or 10
characters. These are equivalent if the data file uses a single-byte character set.
However, they are often different if the data file uses a multibyte character set.
To avoid insertion errors caused by expansion of character strings during character set
conversion, use character-length semantics in both the data file and the target
database columns.
BYTE
SEMANTICS
LENGTH CHAR
CHARACTER
The LENGTH parameter is placed after the CHARACTERSET parameter in the SQL*Loader
control file. The LENGTH parameter applies to the syntax specification for primary data
files and also to LOBFILEs and secondary data files (SDFs). A LENGTH specification
before the INFILE parameters applies to the entire list of primary data files. The LENGTH
specification specified for the primary data file is used as the default for LOBFILEs and
SDFs. You can override that default by specifying LENGTH with the LOBFILE or SDF
specification. Unlike the CHARACTERSET parameter, the LENGTH parameter can also apply
to data contained within the control file itself (that is, INFILE * syntax).
You can specify CHARACTER instead of CHAR for the LENGTH parameter.
If character-length semantics are being used for a SQL*Loader data file, then the
following SQL*Loader data types will use character-length semantics:
• CHAR
• VARCHAR
• VARCHARC
• DATE
9-26
Chapter 9
Handling Different Character Encoding Schemes
For the VARCHAR data type, the length subfield is still a binary SMALLINT length subfield,
but its value indicates the length of the character string in characters.
The following data types use byte-length semantics even if character-length semantics
are being used for the data file, because the data is binary, or is in a special binary-
encoded form in the case of ZONED and DECIMAL:
• INTEGER
• SMALLINT
• FLOAT
• DOUBLE
• BYTEINT
• ZONED
• DECIMAL
• RAW
• VARRAW
• VARRAWC
• GRAPHIC
• GRAPHIC EXTERNAL
• VARGRAPHIC
The start and end arguments to the POSITION parameter are interpreted in bytes, even
if character-length semantics are in use in a data file. This is necessary to handle data
files that have a mix of data of different data types, some of which use character-
length semantics, and some of which use byte-length semantics. It is also needed to
handle position with the VARCHAR data type, which has a SMALLINT length field and then
the character data. The SMALLINT length field takes up a certain number of bytes
depending on the system (usually 2 bytes), but its value indicates the length of the
character string in characters.
Character-length semantics in the data file can be used independent of whether
character-length semantics are used for the database columns. Therefore, the data file
and the database columns can use either the same or different length semantics.
9-27
Chapter 9
Interrupted Loads
See Also:
SKIP
9-28
Chapter 9
Interrupted Loads
9-29
Chapter 9
Interrupted Loads
In that case, all data that was previously committed is saved. SQL*Loader reports the
value for the SKIP parameter only if it is the same for all tables.
9-30
Chapter 9
Assembling Logical Records from Physical Records
load is discontinued, the value for SKIP is written to the log file in a message similar to
the following:
Specify SKIP=1001 when continuing the load.
This message specifying the value of the SKIP parameter is preceded by a message
indicating why the load was discontinued.
Note that for multiple-table loads, the value of the SKIP parameter is displayed only if it
is the same for all tables.
See Also:
SKIP
• CONTINUEIF
The integer value specified for CONCATENATE determines the number of physical record
structures that SQL*Loader allocates for each row in the column array. In direct path
loads, the default value for COLUMNARRAYROWS is large, so if you also specify a large value
for CONCATENATE, then excessive memory allocation can occur. If this happens, you can
improve performance by reducing the value of the COLUMNARRAYROWS parameter to lower
the number of rows in a column array.
9-31
Chapter 9
Assembling Logical Records from Physical Records
See Also:
• COLUMNARRAYROWS
• Specifying the Number of Column Array Rows and Size of Stream Buffers
The CONTINUEIF clause is followed by a condition that is evaluated for each physical
record, as it is read. For example, two records might be combined if a pound sign (#)
were in byte position 80 of the first record. If any other character were there, then the
second record would not be added to the first.
The full syntax for CONTINUEIF adds even more flexibility:
THIS
NEXT PRESERVE (
pos_spec )
str
CONTINUEIF PRESERVE ( operator
X’hex_str’
LAST
Parameter Description
THIS If the condition is true in the current record, then the next physical
record is read and concatenated to the current physical record,
continuing until the condition is false. If the condition is false, then
the current physical record becomes the last physical record of the
current logical record. THIS is the default.
NEXT If the condition is true in the next record, then the current physical
record is concatenated to the current logical record, continuing until
the condition is false.
operator The supported operators are equal (=) and not equal (!= or <>).
For the equal operator, the field and comparison string must match
exactly for the condition to be true. For the not equal operator, they
can differ in any character.
9-32
Chapter 9
Assembling Logical Records from Physical Records
Parameter Description
LAST This test is similar to THIS, but the test is always against the last
nonblank character. If the last nonblank character in the current
physical record meets the test, then the next physical record is read
and concatenated to the current physical record, continuing until the
condition is false. If the condition is false in the current record, then
the current physical record is the last physical record of the current
logical record.
LAST allows only a single character-continuation field (as opposed
to THIS and NEXT, which allow multiple character-continuation
fields).
pos_spec Specifies the starting and ending column numbers in the physical
record.
Column numbers start with 1. Either a hyphen or a colon is
acceptable (start-end or start:end).
If you omit end, then the length of the continuation field is the length
of the byte string or character string. If you use end, and the length
of the resulting continuation field is not the same as that of the byte
string or the character string, then the shorter one is padded.
Character strings are padded with blanks, hexadecimal strings with
zeros.
str A string of characters to be compared to the continuation field
defined by start and end, according to the operator. The string must
be enclosed in double or single quotation marks. The comparison is
made character by character, blank padding on the right if
necessary.
X'hex-str' A string of bytes in hexadecimal format used in the same way as
str.X'1FB033' would represent the three bytes with values 1F, B0,
and 33 (hexadecimal).
PRESERVE Includes 'char_string' or X'hex_string' in the logical record. The
default is to exclude them.
The positions in the CONTINUEIF clause refer to positions in each physical record. This is
the only time you refer to positions in physical records. All other references are to
logical records.
For CONTINUEIF THIS and CONTINUEIF LAST, if the PRESERVE parameter is not specified,
then the continuation field is removed from all physical records when the logical record
is assembled. That is, data values are allowed to span the records with no extra
characters (continuation characters) in the middle. For example, if CONTINUEIF
THIS(3:5)='***' is specified, then positions 3 through 5 are removed from all records.
This means that the continuation characters are removed if they are in positions 3
through 5 of the record. It also means that the characters in positions 3 through 5 are
removed from the record even if the continuation characters are not in positions 3
through 5.
For CONTINUEIF THIS and CONTINUEIF LAST, if the PRESERVE parameter is used, then the
continuation field is kept in all physical records when the logical record is assembled.
CONTINUEIF LAST differs from CONTINUEIF THIS and CONTINUEIF NEXT. For CONTINUEIF LAST,
where the positions of the continuation field vary from record to record, the
continuation field is never removed, even if PRESERVE is not specified.
9-33
Chapter 9
Assembling Logical Records from Physical Records
Example 9-3 through Example 9-6 show the use of CONTINUEIF THIS and CONTINUEIF
NEXT, with and without the PRESERVE parameter.
In this example, the CONTINUEIF THIS clause does not use the PRESERVE parameter:
CONTINUEIF THIS (1:2) = '%%'
Note that columns 1 and 2 (for example, %% in physical record 1) are removed from
the physical records when the logical records are assembled.
Example 9-4 CONTINUEIF THIS with the PRESERVE Parameter
Assume that you have the same physical records as in Example 9-3.
In this example, the CONTINUEIF THIS clause uses the PRESERVE parameter:
CONTINUEIF THIS PRESERVE (1:2) = '%%'
Note that columns 1 and 2 are not removed from the physical records when the logical
records are assembled.
Example 9-5 CONTINUEIF NEXT Without the PRESERVE Parameter
Assume that you have physical records 14 bytes long and that a period represents a
space:
..aaaaaaaa....
%%bbbbbbbb....
%%cccccccc....
..dddddddddd..
%%eeeeeeeeee..
%%ffffffffff..
In this example, the CONTINUEIF NEXT clause does not use the PRESERVE parameter:
CONTINUEIF NEXT (1:2) = '%%'
Therefore, the logical records are assembled as follows (the same results as for
Example 9-3).
9-34
Chapter 9
Loading Logical Records into Tables
aaaaaaaa....bbbbbbbb....cccccccc....
dddddddddd..eeeeeeeeee..ffffffffff..
See Also:
Case study 4, Loading Combined Physical Records, for an example of the
CONTINUEIF clause. (See "SQL*Loader Case Studies" for information on how to
access case studies.)
9-35
Chapter 9
Loading Logical Records into Tables
The table must already exist. The table name should be enclosed in double quotation
marks if it is the same as any SQL or SQL*Loader reserved keyword, if it contains any
special characters, or if it is case sensitive.
INTO TABLE scott."CONSTANT"
INTO TABLE scott."Constant"
INTO TABLE scott."-CONSTANT"
The user must have INSERT privileges for the table being loaded. If the table is not in
the user's schema, then the user must either use a synonym to reference the table or
include the schema name as part of the table name (for example, scott.emp refers to
the table emp in the scott schema).
9-36
Chapter 9
Loading Logical Records into Tables
Note:
SQL*Loader considers the default schema to be whatever schema is current
after your connect to the database finishes executing. This means that the
default schema will not necessarily be the one you specified in the connect
string, if there are logon triggers present that get executed during connection to
a database.
If you have a logon trigger that changes your current schema to a different one
when you connect to a certain database, then SQL*Loader uses that new
schema as the default.
• INSERT
9.17.2.1.1 INSERT
This 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. Case study 1, Loading
Variable-Length Data, provides an example. (See "SQL*Loader Case Studies" for
information on how to access case studies.)
• REPLACE
• TRUNCATE
9-37
Chapter 9
Loading Logical Records into Tables
Note:
When REPLACE or TRUNCATE is specified, the entire table is replaced, not just
individual rows. After the rows are successfully deleted, a COMMIT statement
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
• REPLACE
• Updating Existing Rows
• TRUNCATE
9.17.2.2.1 APPEND
If data already exists in the table, then SQL*Loader appends the new rows to it. If data
does not already exist, then the new rows are simply loaded. You must have SELECT
privilege to use the APPEND option. Case study 3, Loading a Delimited Free-Format File,
provides an example. (See "SQL*Loader Case Studies" for information on how to
access case studies.)
9.17.2.2.2 REPLACE
The REPLACE option executes a SQL DELETE FROM TABLE statement. 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. Case study 4, Loading Combined Physical
Records, provides an example. (See "SQL*Loader Case Studies" for information on
how to access case studies.)
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. For more
information about cascaded deletes, see Oracle Database Concepts.
9.17.2.2.4 TRUNCATE
The TRUNCATE option executes a SQL TRUNCATE TABLE table_name REUSE STORAGE
statement, which means that the table's extents will be reused. The TRUNCATE option
quickly and efficiently deletes all rows from a table or cluster, to achieve the best
possible performance. For the TRUNCATE statement to operate, the table's referential
integrity constraints must first be disabled. If they have not been disabled, then
SQL*Loader returns an error.
9-38
Chapter 9
Loading Logical Records into Tables
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 DROP ANY TABLE privilege.
OPTIONS ( FILE=database_filename )
See Also:
Parameters for Parallel Direct Path Loads
AND
’char_string’
( full_fieldname )
operator X’hex_string’
pos_spec
BLANKS
For example, the following clause indicates that any record with the value "q" in the
fifth column position should be loaded:
WHEN (5) = 'q'
A WHEN clause can contain several comparisons, provided each is preceded by AND.
Parentheses are optional, but should be used for clarity with multiple comparisons
joined by AND. For example:
WHEN (deptno = '10') AND (job = 'SALES')
9-39
Chapter 9
Loading Logical Records into Tables
See Also:
• Case study 5, Loading Data into Multiple Tables, for an example of using
the WHEN clause (see "SQL*Loader Case Studies" for information on how to
access case studies)
9.17.5.1 fields_spec
enclosure_spec
csv_clause
FIELDS OPTIONALLY
enclosure_spec
termination_spec
See Also:
9-40
Chapter 9
Loading Logical Records into Tables
9.17.5.2 termination_spec
WHITESPACE
BY X’hexstr’
TERMINATED
’string’
EOF
Note:
Terminator strings can contain one or more characters. Also, TERMINATED BY EOF
applies only to loading LOBs from a LOBFILE.
9.17.5.3 enclosure_spec
’string’ ’string’
AND
BY X’hexstr’ X’hexstr’
ENCLOSED
Note:
Enclosure strings can contain one or more characters.
You can override the delimiter for any given column by specifying it after the column
name. Case study 3, Loading a Delimited Free-Format File, provides an example.
(See "SQL*Loader Case Studies" for information on how to access case studies.)
See Also:
9-41
Chapter 9
Index Options
If the control file definition explicitly states that a field's starting position is beyond the
end of the logical record, then SQL*Loader always defines the field as null. If a field is
defined with a relative position (such as dname and loc in the following example), and
the record ends before the field is found, then SQL*Loader could either treat the field
as null or generate an error. SQL*Loader uses the presence or absence of the
TRAILING NULLCOLS clause (shown in the following syntax diagram) to determine the
course of action.
OID_spec
delim_spec NULLCOLS
SID_spec FIELDS TRAILING
TREAT AS typename
Assume that the preceding data is read with the following control file and the record
ends after dname:
INTO TABLE dept
TRAILING NULLCOLS
( deptno CHAR TERMINATED BY " ",
dname CHAR TERMINATED BY WHITESPACE,
loc CHAR TERMINATED BY WHITESPACE
)
In this case, the remaining loc field is set to null. Without the TRAILING NULLCOLS clause,
an error would be generated due to missing data.
See Also:
Case study 7, Extracting Data from a Formatted Report, for an example of
using TRAILING NULLCOLS (see "SQL*Loader Case Studies" for information on
how to access case studies)
9-42
Chapter 9
Benefits of Using Multiple INTO TABLE Clauses
This section describes the following SQL*Loader options that control how index entries
are created:
• SORTED INDEXES
• SINGLEROW
See Also:
"SORTED INDEXES Clause"
9-43
Chapter 9
Benefits of Using Multiple INTO TABLE Clauses
Note:
A key point when using multiple INTO TABLE clauses is that field scanning
continues from where it left off when a new INTO TABLE clause is processed. The
remainder of this section details important ways to make use of that behavior. It
also describes alternative ways of using fixed field locations or the POSITION
parameter.
9-44
Chapter 9
Benefits of Using Multiple INTO TABLE Clauses
The important point in this example is that the second empno field is found immediately
after the first ename, although it is in a separate INTO TABLE clause. Field scanning does
not start over from the beginning of the record for a new INTO TABLE clause. Instead,
scanning continues where it left off.
To force record scanning to start in a specific location, you use the POSITION
parameter. That mechanism is described in "Distinguishing Different Input Record
Formats" and in "Loading Data into Multiple Tables".
A record ID field distinguishes between the two formats. Department records have a 1
in the first column, while employee records have a 2. The following control file uses
exact positioning to load this data:
INTO TABLE dept
WHEN recid = 1
(recid FILLER POSITION(1:1) INTEGER EXTERNAL,
deptno POSITION(3:4) INTEGER EXTERNAL,
dname POSITION(8:21) CHAR)
INTO TABLE emp
WHEN recid <> 1
(recid FILLER POSITION(1:1) INTEGER EXTERNAL,
empno POSITION(3:6) INTEGER EXTERNAL,
ename POSITION(8:17) CHAR,
deptno POSITION(19:20) INTEGER EXTERNAL)
9-45
Chapter 9
Benefits of Using Multiple INTO TABLE Clauses
The POSITION parameter in the second INTO TABLE clause is necessary to load this data
correctly. It causes field scanning to start over at column 1 when checking for data that
matches the second format. Without it, SQL*Loader would look for the recid field after
dname.
The following input data file contains a mixture of these row objects subtypes. A type
ID field distinguishes between the three subtypes. person_t objects have a P in the first
column, employee_t objects have an E, and student_t objects have an S.
P,James,31,
P,Thomas,22,
E,Pat,38,93645,1122,Engineering,
P,Bill,19,
P,Scott,55,
9-46
Chapter 9
Benefits of Using Multiple INTO TABLE Clauses
S,Judy,45,27316,English,
S,Karen,34,80356,History,
E,Karen,61,90056,1323,Manufacturing,
S,Pat,29,98625,Spanish,
S,Cody,22,99743,Math,
P,Ted,43,
E,Judy,44,87616,1544,Accounting,
E,Bob,50,63421,1314,Shipping,
S,Bob,32,67420,Psychology,
E,Cody,33,25143,1002,Human Resources,
The following control file uses relative positioning based on the POSITION parameter to
load this data. Note the use of the TREAT AS clause with a specific object type name.
This informs SQL*Loader that all input row objects for the object table will conform to
the definition of the named object type.
Note:
Multiple subtypes cannot be loaded with the same INTO TABLE statement.
Instead, you must use multiple INTO TABLE statements and have each one load a
different subtype.
See Also:
"Loading Column Objects" for more information about loading object types
9-47
Chapter 9
Bind Arrays and Conventional Path Loads
9-48
Chapter 9
Bind Arrays and Conventional Path Loads
See Also:
Oracle Call Interface Programmer's Guide for more information about the
concepts of direct path loading
Although the entire bind array need not be in contiguous memory, the buffer for each
field in the bind array must occupy contiguous memory. If the operating system cannot
supply enough contiguous memory to store a field, then SQL*Loader generates an
error.
See Also:
• BINDSIZE
• ROWS
9-49
Chapter 9
Bind Arrays and Conventional Path Loads
As part of its initialization, SQL*Loader determines the size in bytes required to load a
single row. If that size is too large to fit within the specified maximum, then the load
terminates with an error.
SQL*Loader then multiplies that size by the number of rows for the load, whether that
value was specified with the command-line parameter ROWS or the OPTIONS clause in the
control file.
If that size fits within the bind array maximum, then the load continues—SQL*Loader
does not try to expand the number of rows to reach the maximum bind array size. If
the number of rows and the maximum bind array size are both specified, then
SQL*Loader always uses the smaller value for the bind array.
If the maximum bind array size is too small to accommodate the initial number of rows,
then SQL*Loader uses a smaller number of rows that fits within the maximum.
Many fields do not vary in size. These fixed-length fields are the same for each loaded
row. For these fields, the maximum length of the field is the field size, in bytes, as
described in SQL*Loader Data Types. There is no overhead for these fields.
The fields that can vary in size from row to row are:
• CHAR
• DATE
• LONG VARRAW
• numeric EXTERNAL
• TIME
• TIMESTAMP
• VARCHAR
• VARCHARC
• VARGRAPHIC
• VARRAW
9-50
Chapter 9
Bind Arrays and Conventional Path Loads
• VARRAWC
The maximum length of these data types is described in "SQL*Loader Data Types".
The maximum lengths describe the number of bytes that the fields can occupy in the
input data record. That length also describes the amount of storage that each field
occupies in the bind array, but the bind array includes additional overhead for fields
that can vary in size.
When the character data types (CHAR, DATE, and numeric EXTERNAL) are specified with
delimiters, any lengths specified for these fields are maximum lengths. When specified
without delimiters, the size in the record is fixed, but the size of the inserted field may
still vary, due to whitespace trimming. So internally, these data types are always
treated as varying-length fields—even when they are fixed-length fields.
A length indicator is included for each of these fields in the bind array. The space
reserved for the field in the bind array is large enough to hold the longest possible
value of the field. The length indicator gives the actual length of the field for each row.
Note:
In conventional path loads, LOBFILEs are not included when allocating the size
of a bind array.
This control file loads a 1-byte CHAR using a 1-row bind array. In this example, no data
is actually loaded because a conversion error occurs when the character a is loaded
into a numeric column (deptno). The bind array size shown in the log file, minus one
(the length of the character field) is the value of the length indicator.
9-51
Chapter 9
Bind Arrays and Conventional Path Loads
Note:
A similar technique can determine bind array size without doing any
calculations. Run your control file without any data and with ROWS=1 to determine
the memory requirements for a single row of data. Multiply by the number of
rows you want in the bind array to determine the bind array size.
9-52
Chapter 9
Bind Arrays and Conventional Path Loads
Data Type Default Size Length Specified with Length Specified with
POSITION DATA TYPE
GRAPHIC None L 2*L
GRAPHIC EXTERNAL None L-2 2*(L-2)
VARGRAPHIC 4KB*2 L+S (2*L)+S
With byte-length semantics, this example uses (10 + 2) * 64 = 768 bytes in the bind
array, assuming that the length indicator is 2 bytes long and that 64 rows are loaded at
a time.
With character-length semantics, the same example uses ((10 * s) + 2) * 64 bytes in
the bind array, where "s" is the maximum size in bytes of a character in the data file
character set.
Now consider the following example:
CHAR TERMINATED BY ","
9.20.6 Calculating Bind Array Size for Multiple INTO TABLE Clauses
When calculating a bind array size for a control file that has multiple INTO TABLE
clauses, calculate as if the INTO TABLE clauses were not present.
9-53
Chapter 9
Bind Arrays and Conventional Path Loads
Imagine all of the fields listed in the control file as one, long data structure—that is, the
format of a single row in the bind array.
If the same field in the data record is mentioned in multiple INTO TABLE clauses, then
additional space in the bind array is required each time it is mentioned. It is especially
important to minimize the buffer allocations for such fields.
Note:
Generated data is produced by the SQL*Loader functions CONSTANT, EXPRESSION,
RECNUM, SYSDATE, and SEQUENCE. Such generated data does not require any space
in the bind array.
9-54
10
SQL*Loader Field List Reference
The field-list portion of a SQL*Loader control file provides information about fields
being loaded, such as position, data type, conditions, and delimiters.
More information about these aspects of SQL*Loader control files is provided in the
following topics:
• Field List Contents
The field-list portion of a SQL*Loader control file provides information about fields
being loaded.
• Specifying the Position of a Data Field
To load data from the data file, SQL*Loader must know the length and location of
the field.
• Specifying Columns and Fields
You may load any number of a table's columns.
• SQL*Loader Data Types
SQL*Loader data types can be grouped into portable and nonportable data types.
• Specifying Field Conditions
A field condition is a statement about a field in a logical record that evaluates as
true or false.
• Using the WHEN, NULLIF, and DEFAULTIF Clauses
This section describes using the WHEN, NULLIF, andDEFAULTIF clauses.
• Examples of Using the WHEN, NULLIF, and DEFAULTIF Clauses
These examples explain results for different situations in which you can use the
WHEN, NULLIF, and DEFAULTIF clauses.
10-1
Chapter 10
Field List Contents
In this sample control file, the numbers that appear to the left would not appear in a
real control file. They are keyed in this sample to the explanatory notes in the following
list:
1. SYSDATE sets the column to the current system date. See Setting a Column to the
Current Date .
2. POSITION specifies the position of a data field. See Specifying the Position of a
Data Field.
INTEGER EXTERNAL is the data type for the field. See Specifying the Data Type of a
Data Field and Numeric EXTERNAL.
The NULLIF clause is one of the clauses that can be used to specify field
conditions. See Using the WHEN_ NULLIF_ and DEFAULTIF Clauses.
In this sample, the field is being compared to blanks, using the BLANKS parameter.
See Comparing Fields to BLANKS.
3. The TERMINATED BY WHITESPACE clause is one of the delimiters it is possible to specify
for a field. See Specifying Delimiters.
10-2
Chapter 10
Specifying the Position of a Data Field
:
end
start –
( +integer )
*
The following table describes the parameters for the position specification clause.
Parameter Description
start The starting column of the data field in the logical record. The first
byte position in a logical record is 1.
end The ending position of the data field in the logical record. Either
start-end or start:end is acceptable. If you omit end, then the
length of the field is derived from the data type in the data file.
Note that CHAR data specified without start or end, and without a
length specification (CHAR(n)), is assumed to have a length of 1.
If it is impossible to derive a length from the data type, then an
error message is issued.
* Specifies that the data field follows immediately after the previous
field. If you use * for the first data field in the control file, then that
field is assumed to be at the beginning of the logical record.
When you use * to specify position, the length of the field is
derived from the data type.
+integer You can use an offset, specified as +integer, to offset the current
field from the next position after the end of the previous field. A
number of bytes, as specified by +integer, are skipped before
reading the value for the current field.
You may omit POSITION entirely. If you do, then the position specification for the data
field is the same as if POSITION(*) had been used.
10-3
Chapter 10
Specifying the Position of a Data Field
To fix the problem, inspect the data file for tabs and adjust the POSITION specifications,
or else use delimited fields.
See Also:
Specifying Delimiters
10-4
Chapter 10
Specifying Columns and Fields
If these were the first two column specifications, then siteid would begin in column 1,
and siteloc would begin in the column immediately following.
ename POSITION (1:20) CHAR
empno POSITION (22-26) INTEGER EXTERNAL
allow POSITION (*+2) INTEGER EXTERNAL TERMINATED BY "/"
Column ename is character data in positions 1 through 20, followed by column empno,
which is presumably numeric data in columns 22 through 26. Column allow is offset
from the next position (27) after the end of empno by +2, so it starts in column 29 and
continues until a slash is encountered.
Each column name (unless it is marked FILLER) must correspond to a column of the
table named in the INTO TABLE clause. A column name must be enclosed in quotation
marks if it is a SQL or SQL*Loader reserved word, contains special characters, or is
case sensitive.
If the value is to be generated by SQL*Loader, then the specification includes the
RECNUM, SEQUENCE, or CONSTANT parameter. See Using SQL*Loader to Generate Data for
Input.
If the column's value is read from the data file, then the data field that contains the
column's value is specified. In this case, the column specification includes a column
name that identifies a column in the database table, and a field specification that
describes a field in a data record. The field specification includes position, data type,
null restrictions, and defaults.
It is not necessary to specify all attributes when loading column objects. Any missing
attributes will be set to NULL.
10-5
Chapter 10
Specifying Columns and Fields
• Filler fields can be used as arguments to directives (for example, SID, OID, REF, and
BFILE).
Note:
The information in this section also applies to specifying bound fillers by
using BOUNDFILLER. The only exception is that with bound fillers, SQL strings
can be specified as part of the field, because space is allocated for them in
the bind array.
10-6
Chapter 10
SQL*Loader Data Types
(
filler_field1 char(2),
field_1 column object
(
attr1 char(2),
filler_field2 char(2),
attr2 char(2),
)
filler_field3 char(3),
)
filler_field4 char(6)
SQL*Loader Data Types describes how SQL*Loader data types are converted into
Oracle data types and gives detailed information about each SQL*Loader data type.
Before you specify the data type, you must specify the position of the field.
10-7
Chapter 10
SQL*Loader Data Types
Note:
As of Oracle Database 12c Release 1 (12.1), the maximum size of the Oracle
Database VARCHAR2, NVARCHAR2, and RAW data types has been increased to 32 KB
when the COMPATIBLE initialization parameter is set to 12.0 or later and the
MAX_STRING_SIZE initialization parameter is set to EXTENDED. SQL*Loader supports
this new maximum size.
The nonportable length-value data types are VARGRAPHIC, VARCHAR, VARRAW, and LONG
VARRAW.
The syntax for the nonportable data types is shown in the syntax diagram for
datatype_spec.
• INTEGER(n)
• SMALLINT
• FLOAT
• DOUBLE
• BYTEINT
• ZONED
• DECIMAL
10-8
Chapter 10
SQL*Loader Data Types
• VARGRAPHIC
• VARCHAR
• VARRAW
• LONG VARRAW
10.4.1.1 INTEGER(n)
The data is a full-word binary integer, where n is an optionally supplied length of 1, 2,
4, or 8. If no length specification is given, then the length, in bytes, is based on the size
of a LONG INT in the C programming language on your particular platform.
INTEGERs are not portable because their byte size, their byte order, and the
representation of signed values may be different between systems. However, if the
representation of signed values is the same between systems, then SQL*Loader may
be able to access INTEGER data with correct results. If INTEGER is specified with a length
specification (n), and the appropriate technique is used (if necessary) to indicate the
byte order of the data, then SQL*Loader can access the data with correct results
between systems. If INTEGER is specified without a length specification, then
SQL*Loader can access the data with correct results only if the size of a LONG INT in the
C programming language is the same length in bytes on both systems. In that case,
the appropriate technique must still be used (if necessary) to indicate the byte order of
the data.
Specifying an explicit length for binary integers is useful in situations where the input
data was created on a platform whose word length differs from that on which
SQL*Loader is running. For instance, input data containing binary integers might be
created on a 64-bit platform and loaded into a database using SQL*Loader on a 32-bit
platform. In this case, use INTEGER(8) to instruct SQL*Loader to process the integers
as 8-byte quantities, not as 4-byte quantities.
By default, INTEGER is treated as a SIGNED quantity. If you want SQL*Loader to treat it as
an unsigned quantity, then specify UNSIGNED. To return to the default behavior, specify
SIGNED.
See Also:
"Loading Data Across Different Platforms"
10.4.1.2 SMALLINT
The data is a half-word binary integer. The length of the field is the length of a half-
word integer on your system. By default, it is treated as a SIGNED quantity. If you want
SQL*Loader to treat it as an unsigned quantity, then specify UNSIGNED. To return to the
default behavior, specify SIGNED.
SMALLINT can be loaded with correct results only between systems where a SHORT INT
has the same length in bytes. If the byte order is different between the systems, then
use the appropriate technique to indicate the byte order of the data. See "Byte
Ordering".
10-9
Chapter 10
SQL*Loader Data Types
Note:
This is the SHORT INT data type in the C programming language. One way to
determine its length is to make a small control file with no data and look at the
resulting log file. This length cannot be overridden in the control file.
10.4.1.3 FLOAT
The data is a single-precision, floating-point, binary number. If you specify end in the
POSITION clause, then end is ignored. The length of the field is the length of a single-
precision, floating-point binary number on your system. (The data type is FLOAT in C.)
This length cannot be overridden in the control file.
FLOAT can be loaded with correct results only between systems where the
representation of FLOAT is compatible and of the same length. If the byte order is
different between the two systems, then use the appropriate technique to indicate the
byte order of the data. See "Byte Ordering".
10.4.1.4 DOUBLE
The data is a double-precision, floating-point binary number. If you specify end in the
POSITION clause, then end is ignored. The length of the field is the length of a double-
precision, floating-point binary number on your system. (The data type is DOUBLE or LONG
FLOAT in C.) This length cannot be overridden in the control file.
DOUBLE can be loaded with correct results only between systems where the
representation of DOUBLE is compatible and of the same length. If the byte order is
different between the two systems, then use the appropriate technique to indicate the
byte order of the data. See "Byte Ordering".
10.4.1.5 BYTEINT
The decimal value of the binary representation of the byte is loaded. For example, the
input character x"1C" is loaded as 28. The length of a BYTEINT field is always 1 byte. If
POSITION(start:end) is specified, then end is ignored. (The data type is UNSIGNED CHAR in
C.)
An example of the syntax for this data type is:
(column1 position(1) BYTEINT,
column2 BYTEINT,
...
)
10.4.1.6 ZONED
ZONED data is in zoned decimal format: a string of decimal digits, one per byte, with the
sign included in the last byte. (In COBOL, this is a SIGN TRAILING field.) The length of
this field equals the precision (number of digits) that you specify.
The syntax for the ZONED data type is as follows:
10-10
Chapter 10
SQL*Loader Data Types
, scale
ZONED ( precision )
In this syntax, precision is the number of digits in the number, and scale (if given) is
the number of digits to the right of the (implied) decimal point. The following example
specifies an 8-digit integer starting at position 32:
sal POSITION(32) ZONED(8),
The Oracle database uses the VAX/VMS zoned decimal format when the zoned data
is generated on an ASCII-based platform. It is also possible to load zoned decimal
data that is generated on an EBCDIC-based platform. In this case, Oracle uses the
IBM format as specified in the ESA/390 Principles of Operations, version 8.1 manual.
The format that is used depends on the character set encoding of the input data file.
See "CHARACTERSET Parameter" for more information.
10.4.1.7 DECIMAL
DECIMAL data is in packed decimal format: two digits per byte, except for the last byte,
which contains a digit and sign. DECIMAL fields allow the specification of an implied
decimal point, so fractional values can be represented.
The syntax for the DECIMAL data type is as follows:
, scale
DECIMAL ( precision )
The precision parameter is the number of digits in a value. The length of the field in
bytes, as computed from digits, is (N+1)/2 rounded up.
The scale parameter is the scaling factor, or number of digits to the right of the decimal
point. The default is zero (indicating an integer). The scaling factor can be greater than
the number of digits but cannot be negative.
An example is:
sal DECIMAL (7,2)
This example would load a number equivalent to +12345.67. In the data record, this
field would take up 4 bytes. (The byte length of a DECIMAL field is equivalent to (N+1)/2,
rounded up, where N is the number of digits in the value, and 1 is added for the sign.)
10.4.1.8 VARGRAPHIC
The data is a varying-length, double-byte character set (DBCS). It consists of a length
subfield followed by a string of double-byte characters. The Oracle database does not
support double-byte character sets; however, SQL*Loader reads them as single bytes
and loads them as RAW data. Like RAW data, VARGRAPHIC fields are stored without
modification in whichever column you specify.
10-11
Chapter 10
SQL*Loader Data Types
Note:
The size of the length subfield is the size of the SQL*Loader SMALLINT data type
on your system (C type SHORT INT). See "SMALLINT" for more information.
VARGRAPHIC data can be loaded with correct results only between systems where a
SHORT INT has the same length in bytes. If the byte order is different between the
systems, then use the appropriate technique to indicate the byte order of the length
subfield. See "Byte Ordering".
The syntax for the VARGRAPHIC data type is:
( max_length )
VARGRAPHIC
The length of the current field is given in the first 2 bytes. A maximum length specified
for the VARGRAPHIC data type does not include the size of the length subfield. The
maximum length specifies the number of graphic (double-byte) characters. It is
multiplied by 2 to determine the maximum length of the field in bytes.
The default maximum field length is 2 KB graphic characters, or 4 KB (2 times 2KB).
To minimize memory requirements, specify a maximum length for such fields
whenever possible.
If a position specification is specified (using pos_spec) before the VARGRAPHIC statement,
then it provides the location of the length subfield, not of the first graphic character. If
you specify pos_spec(start:end), then the end location determines a maximum length
for the field. Both start and end identify single-character (byte) positions in the file.
Start is subtracted from (end + 1) to give the length of the field in bytes. If a maximum
length is specified, then it overrides any maximum length calculated from the position
specification.
If a VARGRAPHIC field is truncated by the end of the logical record before its full length is
read, then a warning is issued. Because the length of a VARGRAPHIC field is embedded
in every occurrence of the input data for that field, it is assumed to be accurate.
VARGRAPHIC data cannot be delimited.
10.4.1.9 VARCHAR
A VARCHAR field is a length-value data type. It consists of a binary length subfield
followed by a character string of the specified length. The length is in bytes unless
character-length semantics are used for the data file. In that case, the length is in
characters. See "Character-Length Semantics".
VARCHAR fields can be loaded with correct results only between systems where a SHORT
data field INT has the same length in bytes. If the byte order is different between the
systems, or if the VARCHAR field contains data in the UTF16 character set, then use the
appropriate technique to indicate the byte order of the length subfield and of the data.
The byte order of the data is only an issue for the UTF16 character set. See "Byte
Ordering".
10-12
Chapter 10
SQL*Loader Data Types
Note:
The size of the length subfield is the size of the SQL*Loader SMALLINT data type
on your system (C type SHORT INT). See "SMALLINT" for more information.
( max_length )
VARCHAR
A maximum length specified in the control file does not include the size of the length
subfield. If you specify the optional maximum length for a VARCHAR data type, then a
buffer of that size, in bytes, is allocated for these fields. However, if character-length
semantics are used for the data file, then the buffer size in bytes is the max_length
times the size in bytes of the largest possible character in the character set. See
"Character-Length Semantics".
The default maximum size is 4 KB. Specifying the smallest maximum length that is
needed to load your data can minimize SQL*Loader's memory requirements,
especially if you have many VARCHAR fields.
The POSITION clause, if used, gives the location, in bytes, of the length subfield, not of
the first text character. If you specify POSITION(start:end), then the end location
determines a maximum length for the field. Start is subtracted from (end + 1) to give
the length of the field in bytes. If a maximum length is specified, then it overrides any
length calculated from POSITION.
If a VARCHAR field is truncated by the end of the logical record before its full length is
read, then a warning is issued. Because the length of a VARCHAR field is embedded in
every occurrence of the input data for that field, it is assumed to be accurate.
VARCHAR data cannot be delimited.
10.4.1.10 VARRAW
VARRAW is made up of a 2-byte binary length subfield followed by a RAW string value
subfield.
VARRAW results in a VARRAW with a 2-byte length subfield and a maximum size of 4 KB
(that is, the default). VARRAW(65000) results in a VARRAW with a length subfield of 2 bytes
and a maximum size of 65000 bytes.
VARRAW fields can be loaded between systems with different byte orders if the
appropriate technique is used to indicate the byte order of the length subfield. See
"Byte Ordering".
10-13
Chapter 10
SQL*Loader Data Types
LONG VARRAW results in a VARRAW with 4-byte length subfield and a maximum size of 4 KB
(that is, the default). LONG VARRAW(300000) results in a VARRAW with a length subfield of 4
bytes and a maximum size of 300000 bytes.
LONG VARRAW fields can be loaded between systems with different byte orders if the
appropriate technique is used to indicate the byte order of the length subfield. See
"Byte Ordering".
The syntax for these data types is shown in the diagram for datatype_spec.
The character data types are CHAR, DATE, and the numeric EXTERNAL data types. These
fields can be delimited and can have lengths (or maximum lengths) specified in the
control file.
• CHAR
• Datetime and Interval Data Types
• GRAPHIC
• GRAPHIC EXTERNAL
• Numeric EXTERNAL
• RAW
• VARCHARC
• VARRAWC
• Conflicting Native Data Type Field Lengths
• Field Lengths for Length-Value Data Types
10.4.2.1 CHAR
The data field contains character data. The length, which is optional, is a maximum
length. Note the following regarding length:
• If a length is not specified, then it is derived from the POSITION specification.
• If a length is specified, then it overrides the length in the POSITION specification.
• If no length is given and there is no POSITION specification, then CHAR data is
assumed to have a length of 1, unless the field is delimited:
– For a delimited CHAR field, if a length is specified, then that length is used as a
maximum.
– For a delimited CHAR field for which no length is specified, the default is 255
bytes.
10-14
Chapter 10
SQL*Loader Data Types
– For a delimited CHAR field that is greater than 255 bytes, you must specify a
maximum length. Otherwise you will receive an error stating that the field in
the data file exceeds maximum length.
The syntax for the CHAR data type is:
(length) delim_spec
CHAR
See Also:
"Specifying Delimiters"
• TIME
• TIMESTAMP
Values of datetime data types are sometimes called datetimes. In the following
descriptions of the datetime data types you will see that, except for DATE, you are
allowed to optionally specify a value for fractional_second_precision. The
fractional_second_precision specifies the number of digits stored in the fractional part
of the SECOND datetime field. When you create a column of this data type, the value can
be a number in the range 0 to 9. The default is 6.
The interval data types are:
• INTERVAL YEAR TO MONTH
Values of interval data types are sometimes called intervals. The INTERVAL YEAR TO
MONTH data type lets you optionally specify a value for year_precision. The
year_precision value is the number of digits in the YEAR datetime field. The default
value is 2.
The INTERVAL DAY TO SECOND data type lets you optionally specify values for
day_precision and fractional_second_precision. The day_precision is the number of
digits in the DAY datetime field. Accepted values are 0 to 9. The default is 2. The
fractional_second_precision specifies the number of digits stored in the fractional part
of the SECOND datetime field. When you create a column of this data type, the value can
be a number in the range 0 to 9. The default is 6.
10-15
Chapter 10
SQL*Loader Data Types
• DATE
• TIME
• TIME WITH TIME ZONE
• TIMESTAMP
• TIMESTAMP WITH TIME ZONE
• TIMESTAMP WITH LOCAL TIME ZONE
• INTERVAL YEAR TO MONTH
• INTERVAL DAY TO SECOND
See Also:
10.4.2.2.1 DATE
The DATE field contains character data that should be converted to an Oracle date
using the specified date mask. The syntax for the DATE field is:
For example:
LOAD DATA
INTO TABLE dates (col_a POSITION (1:15) DATE "DD-Mon-YYYY")
BEGINDATA
1-Jan-2012
1-Apr-2012 28-Feb-2012
Whitespace is ignored and dates are parsed from left to right unless delimiters are
present. (A DATE field that consists entirely of whitespace is loaded as a NULL field.)
10-16
Chapter 10
SQL*Loader Data Types
In this case, the date mask contains 14 bytes. If a value with a length longer than 14
bytes is specified, such as "September 30, 2012", then a length must be specified.
Similarly, a length is required for any Julian dates (date mask "J"). A field length is
required any time the length of the date string could exceed the length of the mask
(that is, the count of bytes in the mask).
If an explicit length is not specified, then it can be derived from the POSITION clause. It
is a good idea to specify the length whenever you use a mask, unless you are
absolutely sure that the length of the data is less than, or equal to, the length of the
mask.
An explicit length specification, if present, overrides the length in the POSITION clause.
Either of these overrides the length derived from the mask. The mask may be any
valid Oracle date mask. If you omit the mask, then the default Oracle date mask of
"dd-mon-yy" is used.
The length must be enclosed in parentheses and the mask in quotation marks.
A field of data type DATE may also be specified with delimiters. For more information,
see "Specifying Delimiters".
10.4.2.2.2 TIME
The TIME data type stores hour, minute, and second values. It is specified as follows:
TIME [(fractional_second_precision)]
If the LOCAL option is specified, then data stored in the database is normalized to the
database time zone, and time zone displacement is not stored as part of the column
data. When the data is retrieved, it is returned in the user's local session time zone.
10.4.2.2.4 TIMESTAMP
The TIMESTAMP data type is an extension of the DATE data type. It stores the year,
month, and day of the DATE data type, plus the hour, minute, and second values of the
TIME data type. It is specified as follows:
TIMESTAMP [(fractional_second_precision)]
If you specify a date value without a time component, then the default time is 12:00:00
a.m. (midnight).
10-17
Chapter 10
SQL*Loader Data Types
10.4.2.3 GRAPHIC
The data is in the form of a double-byte character set (DBCS). The Oracle database
does not support double-byte character sets; however, SQL*Loader reads them as
single bytes. Like RAW data, GRAPHIC fields are stored without modification in whichever
column you specify.
The syntax for the GRAPHIC data type is:
(graphic_char_length)
GRAPHIC
For GRAPHIC and GRAPHIC EXTERNAL, specifying POSITION(start:end) gives the exact
location of the field in the logical record.
If you specify a length for the GRAPHIC (EXTERNAL) data type, however, then you give the
number of double-byte graphic characters. That value is multiplied by 2 to find the
length of the field in bytes. If the number of graphic characters is specified, then any
length derived from POSITION is ignored. No delimited data field specification is allowed
with GRAPHIC data type specification.
10-18
Chapter 10
SQL*Loader Data Types
(graphic_char_length)
GRAPHIC_EXTERNAL
GRAPHIC indicates that the data is double-byte characters. EXTERNAL indicates that the
first and last characters are ignored. The graphic_char_length value specifies the
length in DBCS (see "GRAPHIC").
For example, let [ ] represent shift-in and shift-out characters, and let # represent any
double-byte character.
To describe ####, use POSITION(1:4) GRAPHIC or POSITION(1) GRAPHIC(2).
The syntax for the numeric EXTERNAL data types is shown as part of "datatype_spec".
Note:
The data is a number in character form, not binary representation. Therefore,
these data types are identical to CHAR and are treated identically, except for the
use of DEFAULTIF. If you want the default to be null, then use CHAR; if you want
it to be zero, then use EXTERNAL. See "Using the WHEN_ NULLIF_ and
DEFAULTIF Clauses".
FLOAT EXTERNAL data can be given in either scientific or regular notation. Both "5.33"
and "533E-2" are valid representations of the same value.
10.4.2.6 RAW
When raw, binary data is loaded "as is" into a RAW database column, it is not converted
by the Oracle database. If it is loaded into a CHAR column, then the Oracle database
converts it to hexadecimal. It cannot be loaded into a DATE or number column.
(length)
RAW
10-19
Chapter 10
SQL*Loader Data Types
The length of this field is the number of bytes specified in the control file. This length is
limited only by the length of the target column in the database and by memory
resources. The length is always in bytes, even if character-length semantics are used
for the data file. RAW data fields cannot be delimited.
10.4.2.7 VARCHARC
The data type VARCHARC consists of a character length subfield followed by a character
string value-subfield.
The declaration for VARCHARC specifies the length of the length subfield, optionally
followed by the maximum size of any string. If byte-length semantics are in use for the
data file, then the length and the maximum size are both in bytes. If character-length
semantics are in use for the data file, then the length and maximum size are in
characters. If a maximum size is not specified, then 4 KB is the default regardless of
whether byte-length semantics or character-length semantics are in use.
For example:
• VARCHARC results in an error because you must at least specify a value for the
length subfield.
• VARCHARC(7) results in a VARCHARC whose length subfield is 7 bytes long and whose
maximum size is 4 KB (the default) if byte-length semantics are used for the data
file. If character-length semantics are used, then it results in a VARCHARC with a
length subfield that is 7 characters long and a maximum size of 4 KB (the default).
Remember that when a maximum size is not specified, the default of 4 KB is
always used, regardless of whether byte-length or character-length semantics are
in use.
• VARCHARC(3,500) results in a VARCHARC whose length subfield is 3 bytes long and
whose maximum size is 500 bytes if byte-length semantics are used for the data
file. If character-length semantics are used, then it results in a VARCHARC with a
length subfield that is 3 characters long and a maximum size of 500 characters.
See "Character-Length Semantics".
10.4.2.8 VARRAWC
The data type VARRAWC consists of a RAW string value subfield.
For example:
• VARRAWC results in an error.
• VARRAWC(7) results in a VARRAWC whose length subfield is 7 bytes long and whose
maximum size is 4 KB (that is, the default).
• VARRAWC(3,500) results in a VARRAWC whose length subfield is 3 bytes long and
whose maximum size is 500 bytes.
10-20
Chapter 10
SQL*Loader Data Types
2. If the length (or precision) specified for a DECIMAL, INTEGER, ZONED, GRAPHIC, GRAPHIC
EXTERNAL, or RAW field conflicts with the size calculated from a POSITION(start:end)
specification, then the specified length (or precision) is used.
3. If the maximum size specified for a character or VARGRAPHIC field conflicts with the
size calculated from a POSITION(start:end) specification, then the specified
maximum is used.
For example, assume that the native data type INTEGER is 4 bytes long and the
following field specification is given:
column1 POSITION(1:6) INTEGER
In this case, a warning is issued, and the proper length (4) is used. The log file shows
the actual length used under the heading "Len" in the column table:
Column Name Position Len Term Encl Data Type
----------------------- --------- ----- ---- ---- ---------
COLUMN1 1:6 4 INTEGER
Note:
When you use SQL*Loader conventional path to load character data from the
data file into a LONG RAW column, the character data is interpreted has a HEX
string. SQL converts the HEX string into its binary representation. Be aware
that any string longer than 4000 bytes exceeds the byte limit for the SQL
HEXTORAW conversion operator. An error will be returned. SQL*Loader will reject
that row and continue loading.
10-21
Chapter 10
SQL*Loader Data Types
The data type of the data in the file does not need to be the same as the data type of
the column in the Oracle table. The Oracle database automatically performs
conversions, but you need to ensure that the conversion makes sense and does not
generate errors. For instance, when a data file field with data type CHAR is loaded into a
database column with data type NUMBER, you must ensure that the contents of the
character field represent a valid number.
Note:
SQL*Loader does not contain data type specifications for Oracle internal data
types such as NUMBER or VARCHAR2. The SQL*Loader data types describe data
that can be produced with text editors (character data types) and with standard
programming languages (native data types). However, although SQL*Loader
does not recognize data types like NUMBER and VARCHAR2, any data that the
Oracle database can convert can be loaded into these or other database
columns.
10.4.4 Data Type Conversions for Datetime and Interval Data Types
This section describes data type conversions for datetime and interval data types.
Table 10-2 shows which conversions between Oracle database data types and
SQL*Loader control file datetime and interval data types are supported and which are
not.
In the table, the abbreviations for the Oracle Database data types are as follows:
N = NUMBER
C = CHAR or VARCHAR2
D = DATE
For the SQL*Loader data types, the definitions for the abbreviations in the table are
the same for D, T, TS, YM, and DS. However, as noted in the previous section,
SQL*Loader does not contain data type specifications for Oracle internal data types
such as NUMBER,CHAR, and VARCHAR2. However, any data that the Oracle database can
convert can be loaded into these or other database columns.
For an example of how to read this table, look at the row for the SQL*Loader data type
DATE (abbreviated as D). Reading across the row, you can see that data type
conversion is supported for the Oracle database data types of CHAR, VARCHAR2, DATE,
TIMESTAMP, and TIMESTAMP WITH TIME ZONE data types. However, conversion is not
supported for the Oracle database data types NUMBER, TIME, TIME WITH TIME ZONE,
INTERVAL YEAR TO MONTH, or INTERVAL DAY TO SECOND data types.
10-22
Chapter 10
SQL*Loader Data Types
Table 10-2 Data Type Conversions for Datetime and Interval Data Types
Note:
The RAW data type can also be marked by delimiters, but only if it is in an input
LOBFILE, and only if the delimiter is TERMINATED BY EOF (end of file).
10-23
Chapter 10
SQL*Loader Data Types
WHITESPACE
BY X’hexstr’
TERMINATED
’string’
EOF
’string’ ’string’
AND
BY X’hexstr’ X’hexstr’
ENCLOSED
Table 10-3 describes the syntax for the termination and enclosure specifications used
to specify delimiters.
Parameter Description
TERMINATED Data is read until the first occurrence of a delimiter.
BY An optional word to increase readability.
WHITESPACE Delimiter is any whitespace character including spaces, tabs,
blanks, line feeds, form feeds, or carriage returns. (Only used
with TERMINATED, not with ENCLOSED.)
OPTIONALLY Data can be enclosed by the specified character. If SQL*Loader
finds a first occurrence of the character, then it reads the data
value until it finds the second occurrence. If the data is not
enclosed, then the data is read as a terminated field. If you
specify an optional enclosure, then you must specify a
TERMINATED BY clause (either locally in the field definition or
globally in the FIELDS clause).
ENCLOSED The data will be found between two delimiters.
string The delimiter is a string.
X'hexstr' The delimiter is a string that has the value specified by X'hexstr'
in the character encoding scheme, such as X'1F' (equivalent to
31 decimal). "X" can be either lowercase or uppercase.
AND Specifies a trailing enclosure delimiter that may be different from
the initial enclosure delimiter. If AND is not present, then the initial
and trailing delimiters are assumed to be the same.
EOF Indicates that the entire file has been loaded into the LOB. This is
valid only when data is loaded from a LOB file. Fields terminated
by EOF cannot be enclosed.
Here are some examples, with samples of the data they describe:
TERMINATED BY ',' a data string,
ENCLOSED BY '"' "a data string"
TERMINATED BY ',' ENCLOSED BY '"' "a data string",
ENCLOSED BY '(' AND ')' (a data string)
10-24
Chapter 10
SQL*Loader Data Types
For this reason, problems can arise when adjacent fields use the same delimiters. For
example, with the following specification:
field1 TERMINATED BY "/"
field2 ENCLOSED by "/"
But if field1 and field2 were adjacent, then the results would be incorrect, because
This is the first string//This is the second string/
would be interpreted as a single character string with a "/" in the middle, and that string
would belong to field1.
For example, if you have a string literal that is longer than 255 bytes, then in addition
to using SUBSTR(), use CHAR() to specify the longest string in any record for the field. An
example of how this would look is as follows, assuming that 600 bytes is the longest
string in any record for field1:
field1 CHAR(600) SUBSTR(:field, 1, 240)
10-25
Chapter 10
SQL*Loader Data Types
If a data field is 9 characters long and contains the value DANIELbbb, where bbb is three
blanks, then it is loaded into the Oracle database as "DANIEL" if declared as CHAR(9).
To include the trailing blanks, declare it as CHAR(9) TERMINATED BY ':', and add a colon
to the data file so that the field is DANIELbbb:. The field is loaded as "DANIEL ", with the
trailing blanks included. The same results are possible if you specify PRESERVE BLANKS
without the TERMINATED BY clause..
See Also:
• "Trimming Whitespace"
• "How the PRESERVE BLANKS Option Affects Whitespace Trimming"
The following topics describe the processing that takes place in each case.
• Fields Using Only TERMINATED BY
This section describes fields that use only TERMINATED BY.
• Fields Using ENCLOSED BY Without TERMINATED BY
This section describes fields using ENCLOSED BY without TERMINATED BY.
• Fields Using ENCLOSED BY With TERMINATED BY
This section describes fields that use ENCLOSED BY with TERMINATED BY.
• Fields Using OPTIONALLY ENCLOSED BY With TERMINATED BY
This section describes fields that use OPTIONALLY ENCLOSED BY with TERMINATED BY.
If TERMINATED BY is specified for a field without ENCLOSED BY, then the data for the field is
read from the starting position of the field up to, but not including, the first occurrence
of the TERMINATED BY delimiter. If the terminator delimiter is found in the first column
position of a field, then the field is null. If the end of the record is found before the
TERMINATED BY delimiter, then all data up to the end of the record is considered part of
the field.
If TERMINATED BY WHITESPACE is specified, then data is read until the first occurrence of a
whitespace character (spaces, tabs, blanks, line feeds, form feeds, or carriage
returns). Then the current position is advanced until no more adjacent whitespace
characters are found. This allows field values to be delimited by varying amounts of
whitespace. However, unlike non-whitespace terminators, if the first column position of
a field is known and a whitespace terminator is found there, then the field is not treated
as null and can result in record rejection or fields loaded into incorrect columns.
10-26
Chapter 10
SQL*Loader Data Types
The following steps take place when a field uses an ENCLOSED BY clause without also
using a TERMINATED BY clause.
4. If two of the second ENCLOSED BY delimiters are found adjacent to each other, then
they are interpreted as a single occurrence of the delimiter and included as part of
the data for the field. The search then continues for another instance of the second
ENCLOSED BY delimiter.
5. If the end of the record is found before the second ENCLOSED BY delimiter is found,
then the row is rejected.
The following steps take place when a field uses an ENCLOSED BY clause and also uses
a TERMINATED BY clause.
4. If two of the second ENCLOSED BY delimiters are found adjacent to each other, then
they are interpreted as a single occurrence of the delimiter and included as part of
the data for the field. The search then continues for the second instance of the
ENCLOSED BY delimiter.
5. If the end of the record is found before the second ENCLOSED BY delimiter is found,
then the row is rejected.
6. If the second ENCLOSED BY delimiter is found, then the parser looks for the
TERMINATED BY delimiter. If the TERMINATED BY delimiter is anything other than
WHITESPACE, then whitespace found between the end of the second ENCLOSED BY
delimiter and the TERMINATED BY delimiter is skipped over.
Note:
Only WHITESPACE is allowed between the second ENCLOSED BY delimiter and
the TERMINATED BY delimiter. Any other characters will cause an error.
7. The row is not rejected if the end of the record is found before the TERMINATED BY
delimiter is found.
10-27
Chapter 10
SQL*Loader Data Types
The following steps take place when a field uses an OPTIONALLY ENCLOSED BY clause
and a TERMINATED BY clause.
4. If two of the second OPTIONALLY ENCLOSED BY delimiters are found adjacent to each
other, then they are interpreted as a single occurrence of the delimiter and
included as part of the data for the field. The search then continues for the second
OPTIONALLY ENCLOSED BY delimiter.
5. If the end of the record is found before the second OPTIONALLY ENCLOSED BY
delimiter is found, then the row is rejected.
6. If the OPTIONALLY ENCLOSED BY delimiter is present in the data, then the parser looks
for the TERMINATED BY delimiter. If the TERMINATED BY delimiter is anything other than
WHITESPACE, then whitespace found between the end of the second OPTIONALLY
ENCLOSED BY delimiter and the TERMINATED BY delimiter is skipped over.
7. The row is not rejected if the end of record is found before the TERMINATED BY
delimiter is found.
Caution:
Be careful when you specify whitespace characters as the TERMINATED BY
delimiter and are also using OPTIONALLY ENCLOSED BY. SQL*Loader strips off
leading whitespace when looking for an OPTIONALLY ENCLOSED BY delimiter. If the
data contains two adjacent TERMINATED BY delimiters in the middle of a record
(usually done to set a field in the record to NULL), then the whitespace for the
first TERMINATED BY delimiter will be used to terminate a field, but the remaining
whitespace will be considered as leading whitespace for the next field rather
than the TERMINATED BY delimiter for the next field. To load a NULL value, you
must include the ENCLOSED BY delimiters in the data.
If conflicting lengths are specified, then one of the lengths takes precedence. A
warning is also issued when a conflict exists. This section explains which length is
used.
• Predetermined Size Fields
This section describes predetermined field size.
10-28
Chapter 10
SQL*Loader Data Types
• Delimited Fields
This section describes delimited fields.
• Date Field Masks
The length of a date field depends on the mask, if a mask is specified.
Then "May 3, 2012" would occupy 11 bytes in the record (with byte-length semantics),
while "January 31, 2012" would occupy 16.
If starting and ending positions are specified, however, then the length calculated from
the position specification overrides a length derived from the mask. A specified length
such as DATE(12) overrides either of those. If the date field is also specified with
10-29
Chapter 10
Specifying Field Conditions
terminating or enclosing delimiters, then the length specified in the control file is
interpreted as a maximum length for the field.
See Also:
Datetime and Interval Data Types for more information about the DATE field
Note:
If a field used in a clause evaluation has a NULL value, then that clause will
always evaluate to FALSE. This feature is illustrated in Examples of Using the
WHEN, NULLIF, and DEFAULTIF Clauses.
A field condition is similar to the condition in the CONTINUEIF clause, with two important
differences. First, positions in the field condition refer to the logical record, not to the
physical record. Second, you can specify either a position in the logical record or the
name of a field in the data file (including filler fields).
Note:
A field condition cannot be based on fields in a secondary data file (SDF).
AND
’char_string’
( full_fieldname )
operator X’hex_string’
pos_spec
BLANKS
:
end
start –
( +integer )
*
10-30
Chapter 10
Specifying Field Conditions
The following table describes the parameters used for the field condition clause. For a
full description of the position specification parameters, see Specifying the Position of
a Data Field.
Parameter Description
pos_spec Specifies the starting and ending position of the comparison field
in the logical record. It must be surrounded by parentheses.
Either start-end or start:end is acceptable.
The starting location can be specified as a column number, or as
* (next column), or as *+n (next column plus an offset).
If you omit an ending position, then the length of the field is
determined by the length of the comparison string. If the lengths
are different, then the shorter field is padded. Character strings
are padded with blanks, hexadecimal strings with zeros.
start Specifies the starting position of the comparison field in the
logical record.
end Specifies the ending position of the comparison field in the logical
record.
full_fieldname full_fieldname is the full name of a field specified using dot
notation. If the field col2 is an attribute of a column object col1,
then when referring to col2 in one of the directives, you must use
the notation col1.col2. The column name and the field name
referencing or naming the same entity can be different, because
the column name never includes the full name of the entity (no
dot notation).
operator A comparison operator for either equal or not equal.
char_string A string of characters enclosed in single or double quotation
marks that is compared to the comparison field. If the comparison
is true, then the current record is inserted into the table.
X'hex_string' A string of hexadecimal digits, where each pair of digits
corresponds to one byte in the field. It is enclosed in single or
double quotation marks. If the comparison is true, then the
current record is inserted into the table.
BLANKS Enables you to test a field to see if it consists entirely of blanks.
BLANKS is required when you are loading delimited data and you
cannot predict the length of the field, or when you use a multibyte
character set that has multiple blanks.
10-31
Chapter 10
Using the WHEN, NULLIF, and DEFAULTIF Clauses
The BLANKS parameter recognizes only blanks, not tabs. It can be used in place of a
literal string in any field comparison. The condition is true whenever the column is
entirely blank.
The BLANKS parameter also works for fixed-length fields. Using it is the same as
specifying an appropriately sized literal string of blanks. For example, the following
specifications are equivalent:
fixed_field CHAR(2) NULLIF fixed_field=BLANKS
fixed_field CHAR(2) NULLIF fixed_field=" "
There can be more than one blank in a multibyte character set. It is a good idea to use
the BLANKS parameter with these character sets instead of specifying a string of blank
characters.
The character string will match only a specific sequence of blank characters, while the
BLANKS parameter will match combinations of different blank characters. For more
information about multibyte character sets, see "Multibyte (Asian) Character Sets".
This example compares the data in position 1:4 with 4 blanks. If position 1:4 contains 4
blanks, then the clause evaluates as true.
Hexadecimal strings are padded with hexadecimal zeros, as in the following clause:
NULLIF (1:4)=X'FF'
The following information applies to scalar fields. For nonscalar fields (column objects,
LOBs, and collections), the WHEN, NULLIF, and DEFAULTIF clauses are processed
differently because nonscalar fields are more complex.
The results of a WHEN, NULLIF, or DEFAULTIF clause can be different depending on
whether the clause specifies a field name or a position.
• If the WHEN, NULLIF, or DEFAULTIF clause specifies a field name, then SQL*Loader
compares the clause to the evaluated value of the field. The evaluated value takes
trimmed whitespace into consideration. See Trimming Whitespace for information
about trimming blanks and tabs.
• If the WHEN, NULLIF, or DEFAULTIF clause specifies a position, then SQL*Loader
compares the clause to the original logical record in the data file. No whitespace
trimming is done on the logical record in that case.
10-32
Chapter 10
Using the WHEN, NULLIF, and DEFAULTIF Clauses
Different results are more likely if the field has whitespace that is trimmed, or if the
WHEN, NULLIF, or DEFAULTIF clause contains blanks or tabs or uses the BLANKS parameter.
If you require the same results for a field specified by name and for the same field
specified by position, then use the PRESERVE BLANKS option. The PRESERVE BLANKS option
instructs SQL*Loader not to trim whitespace when it evaluates the values of the fields.
The results of a WHEN, NULLIF, or DEFAULTIF clause are also affected by the order in
which SQL*Loader operates, as described in the following steps. SQL*Loader
performs these steps in order, but it does not always perform all of them. Once a field
is set, any remaining steps in the process are ignored. For example, if the field is set in
Step 5, then SQL*Loader does not move on to Step 6.
1. SQL*Loader evaluates the value of each field for the input record and trims any
whitespace that should be trimmed (according to existing guidelines for trimming
blanks and tabs).
2. For each record, SQL*Loader evaluates any WHEN clauses for the table.
3. If the record satisfies the WHEN clauses for the table, or no WHEN clauses are
specified, then SQL*Loader checks each field for a NULLIF clause.
4. If a NULLIF clause exists, then SQL*Loader evaluates it.
5. If the NULLIF clause is satisfied, then SQL*Loader sets the field to NULL.
6. If the NULLIF clause is not satisfied, or if there is no NULLIF clause, then
SQL*Loader checks the length of the field from field evaluation. If the field has a
length of 0 from field evaluation (for example, it was a null field, or whitespace
trimming resulted in a null field), then SQL*Loader sets the field to NULL. In this
case, any DEFAULTIF clause specified for the field is not evaluated.
7. If any specified NULLIF clause is false or there is no NULLIF clause, and if the field
does not have a length of 0 from field evaluation, then SQL*Loader checks the
field for a DEFAULTIF clause.
8. If a DEFAULTIF clause exists, then SQL*Loader evaluates it.
9. If the DEFAULTIF clause is satisfied, then the field is set to 0 if the field in the data
file is a numeric field. It is set to NULL if the field is not a numeric field. The following
fields are numeric fields and will be set to 0 if they satisfy the DEFAULTIF clause:
• BYTEINT
• SMALLINT
• INTEGER
• FLOAT
• DOUBLE
• ZONED
• (packed) DECIMAL
• Numeric EXTERNAL (INTEGER, FLOAT, DECIMAL, and ZONED)
10. If the DEFAULTIF clause is not satisfied, or if there is no DEFAULTIF clause, then
SQL*Loader sets the field with the evaluated value from Step 1.
The order in which SQL*Loader operates could cause results that you do not expect.
For example, the DEFAULTIF clause may look like it is setting a numeric field to NULL
rather than to 0.
10-33
Chapter 10
Examples of Using the WHEN, NULLIF, and DEFAULTIF Clauses
Note:
As demonstrated in these steps, the presence of NULLIF and DEFAULTIF clauses
results in extra processing that SQL*Loader must perform. This can affect
performance. Note that during Step 1, SQL*Loader will set a field to NULL if its
evaluated length is zero. To improve performance, consider whether it might be
possible for you to change your data to take advantage of this. The detection of
NULLs as part of Step 1 occurs much more quickly than the processing of a
NULLIF or DEFAULTIF clause.
For example, a CHAR(5) will have zero length if it falls off the end of the logical
record or if it contains all blanks and blank trimming is in effect. A delimited field
will have zero length if there are no characters between the start of the field
and the terminator.
Also, for character fields, NULLIF is usually faster to process than DEFAULTIF (the
default for character fields is NULL).
See Also:
In the examples, a blank or space is indicated with a period (.). Assume that col1 and
col2 are VARCHAR2(5) columns in the database.
In this example, col1 for the row evaluates to aname. col2 evaluates to NULL with a
length of 0 (it is ... but the trailing blanks are trimmed for a positional field).
When SQL*Loader determines the final loaded value for col2, it finds no WHEN clause
and no NULLIF clause. It then checks the length of the field, which is 0 from field
evaluation. Therefore, SQL*Loader sets the final value for col2 to NULL. The DEFAULTIF
clause is not evaluated, and the row is loaded as aname for col1 and NULL for col2.
10-34
Chapter 10
Examples of Using the WHEN, NULLIF, and DEFAULTIF Clauses
In this example, col1 for the row again evaluates to aname. col2 evaluates to '...'
because trailing blanks are not trimmed when PRESERVE BLANKS is specified.
When SQL*Loader determines the final loaded value for col2, it finds no WHEN clause
and no NULLIF clause. It then checks the length of the field from field evaluation, which
is 3, not 0.
Then SQL*Loader evaluates the DEFAULTIF clause, which evaluates to true because
col1 is aname, which is the same as aname.
Because col2 is a numeric field, SQL*Loader sets the final value for col2 to 0. The row
is loaded as aname for col1 and as 0 for col2.
In this example, col1 for the row evaluates to NULL with a length of 0 (it is ..... but the
trailing blanks are trimmed). col2 evaluates to 123.
When SQL*Loader sets the final loaded value for col2, it finds no WHEN clause and no
NULLIF clause. It then checks the length of the field from field evaluation, which is 3, not
0.
Then SQL*Loader evaluates the DEFAULTIF clause. It compares (1:5) which is ..... to
BLANKS, which evaluates to true. Therefore, because col2 is a numeric field (integer
EXTERNAL is numeric), SQL*Loader sets the final value for col2 to 0. The row is loaded
as NULL for col1 and 0 for col2.
10-35
Chapter 10
Loading Data Across Different Platforms
.....123
In this example, col1 for the row evaluates to NULL with a length of 0 (it is ..... but the
trailing blanks are trimmed). col2 evaluates to 123.
When SQL*Loader determines the final value for col2, it finds no WHEN clause and no
NULLIF clause. It then checks the length of the field from field evaluation, which is 3, not
0.
Then SQL*Loader evaluates the DEFAULTIF clause. As part of the evaluation, it checks
to see that col1 is NULL from field evaluation. It is NULL, so the DEFAULTIF clause
evaluates to false. Therefore, SQL*Loader sets the final value for col2 to 123, its
original value from field evaluation. The row is loaded as NULL for col1 and 123 for col2.
10-36
Chapter 10
Byte Ordering
Note:
The information in this section is only applicable if you are planning to create
input data on a system that has a different byte-ordering scheme than the
system on which SQL*Loader will be run. Otherwise, you can skip this section.
By default, SQL*Loader uses the byte order of the system where it is running as the
byte order for all data files. For example, on a Sun Solaris system, SQL*Loader uses
big-endian byte order. On an Intel or an Intel-compatible PC, SQL*Loader uses little-
endian byte order.
Byte order affects the results when data is written and read an even number of bytes
at a time (typically 2 bytes, 4 bytes, or 8 bytes). The following are some examples of
this:
• The 2-byte integer value 1 is written as 0x0001 on a big-endian system and as
0x0100 on a little-endian system.
• The 4-byte integer 66051 is written as 0x00010203 on a big-endian system and as
0x03020100 on a little-endian system.
Byte order also affects character data in the UTF16 character set if it is written and
read as 2-byte entities. For example, the character 'a' (0x61 in ASCII) is written as
0x0061 in UTF16 on a big-endian system, but as 0x6100 on a little-endian system.
All Oracle-supported character sets, except UTF16, are written one byte at a time. So,
even for multibyte character sets such as UTF8, the characters are written and read
the same way on all systems, regardless of the byte order of the system. Therefore,
data in the UTF16 character set is nonportable because it is byte-order dependent.
Data in all other Oracle-supported character sets is portable.
Byte order in a data file is only an issue if the data file that contains the byte-order-
dependent data is created on a system that has a different byte order from the system
on which SQL*Loader is running. If SQL*Loader knows the byte order of the data, then
it swaps the bytes as necessary to ensure that the data is loaded correctly in the target
database. Byte swapping means that data in big-endian format is converted to little-
endian format, or the reverse.
To indicate byte order of the data to SQL*Loader, you can use the BYTEORDER
parameter, or you can place a byte-order mark (BOM) in the file. If you do not use one
of these techniques, then SQL*Loader will not correctly load the data into the data file.
See Also:
Case study 11, Loading Data in the Unicode Character Set, for an example of
how SQL*Loader handles byte swapping. (See "SQL*Loader Case Studies" for
information on how to access case studies.)
10-37
Chapter 10
Byte Ordering
BIG ENDIAN
BYTEORDER
LITTLE
• BYTEORDER is placed after the LENGTH parameter in the SQL*Loader control file.
• It is possible to specify a different byte order for different data files. However, the
BYTEORDER specification before the INFILE parameters applies to the entire list of
primary data files.
• The BYTEORDER specification for the primary data files is also used as the default for
LOBFILEs and SDFs. To override this default, specify BYTEORDER with the LOBFILE
or SDF specification.
• The BYTEORDER parameter is not applicable to data contained within the control file
itself.
• The BYTEORDER parameter applies to the following:
– Binary INTEGER and SMALLINT data
– Binary lengths in varying-length fields (that is, for the VARCHAR, VARGRAPHIC,
VARRAW, and LONG VARRAW data types)
10-38
Chapter 10
Byte Ordering
If the first primary data file uses the UTF16 character set and it also begins with a
BOM, then that mark is read and interpreted to determine the byte order for all primary
data files. SQL*Loader reads and interprets the BOM, skips it, and begins processing
data with the byte immediately after the BOM. The BOM setting overrides any
BYTEORDER specification for the first primary data file. BOMs in data files other than the
first primary data file are read and used for checking for byte-order conflicts only. They
do not change the byte-order setting that SQL*Loader uses in processing the data file.
In summary, the precedence of the byte-order indicators for the first primary data file is
as follows:
• BOM in the first primary data file, if the data file uses a Unicode character set that
is byte-order dependent (UTF16) and a BOM is present
• BYTEORDER parameter value, if specified before the INFILE parameters
• The byte-order setting established for the first primary data file
10-39
Chapter 10
Byte Ordering
Note:
If the character set of your data file is a unicode character set and there is a
byte-order mark in the first few bytes of the file, then do not use the SKIP
parameter. If you do, then the byte-order mark will not be read and
interpreted as a byte-order mark.
CHECK
BYTEORDERMARK
NOCHECK
BYTEORDERMARK NOCHECK indicates that SQL*Loader should not check for a BOM and
should read all the data in the data file as data.
BYTEORDERMARK CHECK tells SQL*Loader to check for a BOM. This is the default behavior
for a data file in a Unicode character set. But this specification may be used in the
control file for clarification. It is an error to specify BYTEORDERMARK CHECK for a data file
that uses a non-Unicode character set.
The BYTEORDERMARK parameter has the following characteristics:
• It is placed after the optional BYTEORDER parameter in the SQL*Loader control file.
• It applies to the syntax specification for primary data files, and also to LOBFILEs
and secondary data files (SDFs).
• It is possible to specify a different BYTEORDERMARK value for different data files;
however, the BYTEORDERMARK specification before the INFILE parameters applies to
the entire list of primary data files.
• The BYTEORDERMARK specification for the primary data files is also used as the
default for LOBFILEs and SDFs, except that the value CHECK is ignored in this case
if the LOBFILE or SDF uses a non-Unicode character set. This default setting for
LOBFILEs and secondary data files can be overridden by specifying BYTEORDERMARK
with the LOBFILE or SDF specification.
10-40
Chapter 10
Loading All-Blank Fields
If an all-blank CHAR field is surrounded by enclosure delimiters, then the blanks within
the enclosures are loaded. Otherwise, the field is loaded as NULL.
A DATE or numeric field that consists entirely of blanks is loaded as a NULL field.
See Also:
• Case study 6, Loading Data Using the Direct Path Load Method, for an
example of how to load all-blank fields as NULL with the NULLIF clause. (See
SQL*Loader Case Studies for information on how to access case studies.)
• Trimming Whitespace
• "How the PRESERVE BLANKS Option Affects Whitespace Trimming"
The field specifications are contained in the control file. The control file CHAR
specification is not the same as the database CHAR specification. A data field defined as
CHAR in the control file simply tells SQL*Loader how to create the row insert. The data
could then be inserted into a CHAR, VARCHAR2, NCHAR, NVARCHAR2, or even a NUMBER or DATE
column in the database, with the Oracle database handling any necessary
conversions.
By default, SQL*Loader removes trailing spaces from CHAR data before passing it to the
database. So, in the figure "Example of Field Conversion,” both Field 1 and Field 2 are
passed to the database as 3-byte fields. However, when the data is inserted into the
table, there is a difference.
10-41
Chapter 10
Trimming Whitespace
Field 1 Field 2
DATAFILE
a a a b b b
ROW
aaa bbb
INSERT
DATABASE Table
SERVER
Column 1 Column 2
a a a _ _ b b b
CHAR (5) Column Datatypes VARCHAR (5)
10-42
Chapter 10
Trimming Whitespace
The rest of this section discusses the following topics with regard to trimming
whitespace:
• Data Types for Which Whitespace Can Be Trimmed
The information in this section applies only to fields specified with one of the
character-data data types.
• Specifying Field Length for Data Types for Which Whitespace Can Be Trimmed
This section describes specifying field length.
• Relative Positioning of Fields
This section describes the relative positioning of fields.
• Leading Whitespace
This section describes leading whitespace.
• Trimming Trailing Whitespace
Trailing whitespace is always trimmed from character-data fields that have a
predetermined size.
• Trimming Enclosed Fields
This section describes trimming enclosed fields.
– FLOAT EXTERNAL
10-43
Chapter 10
Trimming Whitespace
Note:
Although VARCHAR and VARCHARC fields also contain character data, these
fields are never trimmed. These fields include all whitespace that is
part of the field in the data file.
10.11.2 Specifying Field Length for Data Types for Which Whitespace
Can Be Trimmed
This section describes specifying field length.
There are two ways to specify field length. If a field has a constant length that is
defined in the control file with a position specification or the data type and length, then
it has a predetermined size. If a field's length is not known in advance, but depends on
indicators in the record, then the field is delimited, using either enclosure or
termination delimiters.
If a position specification with start and end values is defined for a field that also has
enclosure or termination delimiters defined, then only the position specification has
any effect. The enclosure and termination delimiters are ignored.
• Predetermined Size Fields
Fields that have a predetermined size are specified with a starting position and
ending position, or with a length.
• Delimited Fields
Delimiters are characters that demarcate field boundaries.
In the second case, even though the exact position of the field is not specified, the
length of the field is predetermined.
Termination delimiters signal the end of a field, like the comma in the following
example:
10-44
Chapter 10
Trimming Whitespace
__aa__,
Delimiters are specified with the control clauses TERMINATED BY and ENCLOSED BY, as
shown in the following example:
loc TERMINATED BY "." OPTIONALLY ENCLOSED BY '|'
a a a a b b b b ,
a a a a , b b b b ,
10-45
Chapter 10
Trimming Whitespace
" a a a a " , b b b b ,
a a a a b b b b
10-46
Chapter 10
Trimming Whitespace
This situation occurs when the previous field is explicitly specified with the TERMINATED
BY WHITESPACE clause, as shown in the example. It also occurs when you use the global
FIELDS TERMINATED BY WHITESPACE clause.
" a a a a " , b b b b ,
Unlike the case when the previous field is TERMINATED BY WHITESPACE, this specification
removes leading whitespace even when a starting position is specified for the current
field.
Note:
If enclosure delimiters are present, then leading whitespace after the initial
enclosure delimiter is kept, but whitespace before this delimiter is discarded.
See the first quotation mark in Field 1, Figure 10-6.
10-47
Chapter 10
How the PRESERVE BLANKS Option Affects Whitespace Trimming
However, there may be times when you do not want to preserve blanks for all CHAR,
DATE, and numeric EXTERNAL fields. Therefore, SQL*Loader also enables you to specify
PRESERVE BLANKS as part of the data type specification for individual fields, rather than
specifying it globally as part of the LOAD statement.
In the following example, assume that PRESERVE BLANKS has not been specified as part
of the LOAD statement, but you want the c1 field to default to zero when blanks are
present. You can achieve this by specifying PRESERVE BLANKS on the individual field.
Only that field is affected; blanks will still be removed on other fields.
c1 INTEGER EXTERNAL(10) PRESERVE BLANKS DEFAULTIF c1=BLANKS
In this example, if PRESERVE BLANKS were not specified for the field, then it would result in
the field being improperly loaded as NULL (instead of as 0).
There may be times when you want to specify PRESERVE BLANKS as an option to the LOAD
statement and have it apply to most CHAR, DATE, and numeric EXTERNAL fields. You can
override it for an individual field by specifying NO PRESERVE BLANKS as part of the data
type specification for that field, as follows:
c1 INTEGER EXTERNAL(10) NO PRESERVE BLANKS
• Leading whitespace is left intact when optional enclosure delimiters are not
present
• Trailing whitespace is left intact when fields are specified with a predetermined
size
For example, consider the following field, where underscores represent blanks:
__aa__,
In such a case, if PRESERVE BLANKS is specified, then both the leading whitespace and
the trailing whitespace are retained. If PRESERVE BLANKS is not specified, then the leading
whitespace is trimmed.
Now suppose the field is loaded with the following clause:
TERMINATED BY WHITESPACE
10-48
Chapter 10
Applying SQL Operators to Fields
In such a case, if PRESERVE BLANKS is specified, then it does not retain the space at the
beginning of the next field, unless that field is specified with a POSITION clause that
includes some of the whitespace. Otherwise, SQL*Loader scans past all whitespace at
the end of the previous field until it finds a nonblank, nontab character.
Related Topics
• Trimming Whitespace
Blanks, tabs, and other nonprinting characters (such as carriage returns and line
feeds) constitute whitespace.
10-49
Chapter 10
Applying SQL Operators to Fields
2. Any NULLIF or DEFAULTIF clauses are applied (and that may change the field
setting results for the fields that have such clauses). When NULLIF and
DEFAULTIF clauses are used with a SQL expression, they affect the field setting
results, not the final column results.
3. Any SQL expressions are evaluated using the field results obtained after
completion of Steps 1 and 2. The results are assigned to the corresponding
columns that have the SQL expressions. (If there is no SQL expression
present, then the result obtained from Steps 1 and 2 is assigned to the
column.)
• If your control file specifies character input that has an associated SQL string, then
SQL*Loader makes no attempt to modify the data. This is because SQL*Loader
assumes that character input data that is modified using a SQL operator will yield
results that are correct for database insertion.
• The SQL string must appear after any other specifications for a given column.
• The SQL string must be enclosed in double quotation marks.
• To enclose a column name in quotation marks within a SQL string, you must use
escape characters.
In the preceding example, Last is enclosed in double quotation marks to preserve
the mixed case, and the double quotation marks necessitate the use of the
backslash (escape) character.
• If a SQL string contains a column name that references a column object attribute,
then the full object attribute name must be used in the bind variable. Each attribute
name in the full name is an individual identifier. Each identifier is subject to the
SQL identifier quoting rules, independent of the other identifiers in the full name.
For example, suppose you have a column object named CHILD with an attribute
name of "HEIGHT_%TILE". (Note that the attribute name is in double quotation
marks.) To use the full object attribute name in a bind variable, any one of the
following formats would work:
– :CHILD.\"HEIGHT_%TILE\"
– :child.\"HEIGHT_%TILE\"
10-50
Chapter 10
Applying SQL Operators to Fields
• In direct path mode, a SQL string cannot reference a VARRAY, nested table, or LOB
column. This also includes a VARRAY, nested table, or LOB column that is an
attribute of a column object.
• The SQL string cannot be used on RECNUM, SEQUENCE, CONSTANT, or SYSDATE fields.
• The SQL string cannot be used on LOBs, BFILEs, XML columns, or a file that is an
element of a collection.
• In direct path mode, the final result that is returned after evaluation of the
expression in the SQL string must be a scalar data type. That is, the expression
may not return an object or collection data type when performing a direct path
load.
• Referencing Fields
To refer to fields in the record, precede the field name with a colon (:).
• Common Uses of SQL Operators in Field Specifications
This section describes the common uses of SQL operators in field specifications.
• Combinations of SQL Operators
This section describes combining SQL operators.
• Using SQL Strings with a Date Mask
When a SQL string is used with a date mask, the date mask is evaluated after the
SQL string.
• Interpreting Formatted Fields
It is possible to use the TO_CHAR operator to store formatted dates and numbers.
• Using SQL Strings to Load the ANYDATA Database Type
The ANYDATA database type can contain data of different types.
10-51
Chapter 10
Applying SQL Operators to Fields
• In the following line, :field1 is not enclosed in single quotation marks and is
therefore interpreted as a bind variable:
field1 POSITION(1:6) CHAR "LOWER(:field1)"
• In the following line, ':field1' and ':1' are enclosed in single quotation marks
and are therefore treated as text literals and passed unchanged to the TRANSLATE
function:
field3 CHAR(7) "TRANSLATE(:field3, ':field1', ':1')"
For more information about the use of quotation marks inside quoted strings, see
Specifying File Names and Object Names.
• For each input record read, the value of the field referenced by the bind variable
will be substituted for the bind variable. For example, the value ABCDEF in the first
record is mapped to the first field :field1. This value is then passed as an
argument to the LOWER function.
• A bind variable in a SQL string need not reference the current field. In the
preceding example, the bind variable in the SQL string for the field4.attr1 field
references the field4.attr3 field. The field4.attr1 field is still mapped to the
values 500 and NULL (because the NULLIF field4.attr2='ZZ' clause is TRUE for the
second record) in the input records, but the final values stored in its corresponding
columns are ABC and GHL.
The field4.attr3 field is mapped to the values ABC and GHL in the input records,
but the final values stored in its corresponding columns are 500 + 1 = 501 and
NULL because the SQL expression references field4.attr1. (Adding 1 to a NULL
field still results in a NULL field.)
• The field5 field is not mapped to any field in the input record. The value that is
stored in the target column is the result of executing the MYFUNC PL/SQL function,
which takes two arguments. The use of the EXPRESSION parameter requires that a
SQL string be used to compute the final value of the column because no input
data is mapped to the field.
10-52
Chapter 10
Applying SQL Operators to Fields
Note that when using the DATE field data type with a SQL string, a date mask is
required. This is because SQL*Loader assumes that the first quoted string it finds after
the DATE parameter is a date mask. For instance, the following field specification would
result in an error (ORA-01821: date format not recognized):
field1 DATE "RTRIM(TO_DATE(:field1, 'dd-mon-yyyy'))"
For example:
field1 ... "TO_CHAR(:field1, '$09999.99')"
This example could store numeric input data in formatted form, where field1 is a
character column in the database. This field would be stored with the formatting
characters (dollar sign, period, and so on) already in place.
You have even more flexibility, however, if you store such values as numeric quantities
or dates. You can then apply arithmetic functions to the values in the database, and
still select formatted values for your reports.
An example of using the SQL string to load data from a formatted report is shown in
case study 7, Extracting Data from a Formatted Report. (See SQL*Loader Case
Studies for information on how to access case studies.)
10-53
Chapter 10
Using SQL*Loader to Generate Data for Input
To load the ANYDATA type using SQL*loader, it must be explicitly constructed by using a
function call. The function is called using support for SQL strings as has been
described in this section.
For example, suppose you have a table with a column named miscellaneous which is
of type ANYDATA. You could load the column by doing the following, which would create
an ANYDATA type containing a number.
LOAD DATA
INFILE *
APPEND INTO TABLE ORDERS
(
miscellaneous CHAR "SYS.ANYDATA.CONVERTNUMBER(:miscellaneous)"
)
BEGINDATA
4
There can also be more complex situations in which you create an ANYDATA type that
contains a different type depending upon the values in the record. To do this, you
could write your own PL/SQL function that would determine what type should be in the
ANYDATA type, based on the value in the record, and then call the appropriate
ANYDATA.Convert*() function to create it.
See Also:
• Oracle Database SQL Language Reference for more information about the
ANYDATA database type
10-54
Chapter 10
Using SQL*Loader to Generate Data for Input
10-55
Chapter 10
Using SQL*Loader to Generate Data for Input
Note:
Do not use the CONSTANT parameter to set a column to null. To set a column to
null, do not specify that column at all. Oracle automatically sets that column to
null when loading the record. The combination of CONSTANT and a value is a
complete column specification.
In both conventional path mode and direct path mode, the EXPRESSION parameter can
be used to load the default value into column_name:
column_name EXPRESSION "DEFAULT"
Note that if DEFAULT is used and the mode is direct path, then use of a sequence as a
default will not work.
• RECNUM Parameter
10-56
Chapter 10
Using SQL*Loader to Generate Data for Input
column_name RECNUM
See the section on the DATE data type in Oracle Database SQL Language Reference.
• SYSDATE Parameter
The database column must be of type CHAR or DATE. If the column is of type CHAR, then
the date is loaded in the form 'dd-mon-yy.' After the load, it can be loaded only in that
form. If the system date is loaded into a DATE column, then it can be loaded in a variety
of forms that include the time and the date.
A new system date/time is used for each array of records inserted in a conventional
path load and for each block of records loaded during a direct path load.
COUNT
, incr
column_name SEQUENCE ( MAX )
integer
Parameter Description
column_name The name of the column in the database to which to assign the
sequence.
10-57
Chapter 10
Using SQL*Loader to Generate Data for Input
Parameter Description
SEQUENCE Use the SEQUENCE parameter to specify the value for a column.
COUNT The sequence starts with the number of records already in the
table plus the increment.
MAX The sequence starts with the current maximum value for the
column plus the increment.
integer Specifies the specific sequence number to begin with.
incr The value that the sequence number is to increment after a
record is loaded or rejected. This is optional. The default is 1.
If a record is rejected (that is, it has a format error or causes an Oracle error), then the
generated sequence numbers are not reshuffled to mask this. If four rows are
assigned sequence numbers 10, 12, 14, and 16 in a particular column, and the row
with 12 is rejected, then the three rows inserted are numbered 10, 14, and 16, not 10,
12, and 14. This allows the sequence of inserts to be preserved despite data errors.
When you correct the rejected data and reinsert it, you can manually set the columns
to agree with the sequence.
Case study 3, Loading a Delimited Free-Format File, provides an example of using the
SEQUENCE parameter. (See "SQL*Loader Case Studies" for information on how to
access case studies.)
10-58
Chapter 10
Using SQL*Loader to Generate Data for Input
You could use the following control file entries to generate unique department
numbers:
INTO TABLE dept
(deptno SEQUENCE(1, 3),
dname POSITION(1:14) CHAR)
INTO TABLE dept
(deptno SEQUENCE(2, 3),
dname POSITION(16:29) CHAR)
INTO TABLE dept
(deptno SEQUENCE(3, 3),
dname POSITION(31:44) CHAR)
The first INTO TABLE clause generates department number 1, the second number 2, and
the third number 3. They all use 3 as the sequence increment (the number of
department names in each record). This control file loads Accounting as department
number 1, Personnel as 2, and Manufacturing as 3.
The sequence numbers are then incremented for the next record, so Shipping loads
as 4, Purchasing as 5, and so on.
10-59
11
Loading Objects, LOBs, and Collections
You can use SQL*Loader to load column objects in various formats and to load object
tables, REF columns, LOBs, and collections.
Note:
With SQL*Loader support for complex data types such as column objects, the
possibility arises that two identical field names could exist in the control file, one
corresponding to a column, the other corresponding to a column object's
attribute. Certain clauses can refer to fields (for example, WHEN, NULLIF,
DEFAULTIF, SID, OID, REF, BFILE, and so on), causing a naming conflict if
identically named fields exist in the control file.
Therefore, if you use clauses that refer to fields, then you must specify the full
name. For example, if field fld1 is specified to be a COLUMN OBJECT and it
contains field fld2, then when you specify fld2 in a clause such as NULLIF, you
must use the full field name fld1.fld2.
11-1
Chapter 11
Loading Column Objects
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. This type of column object specification can be applied recursively to
describe nested column objects.
11-2
Chapter 11
Loading Column Objects
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The "var" string includes the number of bytes in the length field at the
beginning of each record (in this example, the number is 6). If no value is
specified, then the default is 5 bytes. The maximum size of a variable
record is 2^32-1. Specifying larger values will result in an error.
2. Although no positional specifications are given, the general syntax remains
the same (the column object's name followed by the list of its attributes
enclosed in parentheses). Also note that an omitted type specification
defaults to CHAR of length 255.
3. The first 6 bytes (italicized) specify the length of the forthcoming record.
These length specifications include the newline characters, which are
ignored thanks to the terminators after the emp_id field.
11-3
Chapter 11
Loading Column Objects
LOAD DATA
INFILE `sample.dat'
INTO TABLE departments_v2
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(dept_no CHAR(5),
dept_name CHAR(30),
dept_mgr COLUMN OBJECT
(name CHAR(30),
age INTEGER EXTERNAL(3),
emp_id INTEGER EXTERNAL(7),
1 em_contact COLUMN OBJECT
(name CHAR(30),
phone_num CHAR(20))))
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. This entry specifies a column object nested within a column object.
11-4
Chapter 11
Loading Column Objects
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The TREAT AS clause indicates that SQL*Loader should treat the column
object person as if it were declared to be of the derived type employee_type,
instead of its actual declared type, person_type.
2. The empid attribute is allowed here because it is an attribute of the
employee_type. If the TREAT AS clause had not been specified, then this
attribute would have resulted in an error, because it is not an attribute of
the column's declared type.
11-5
Chapter 11
Loading Column Objects
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The NULLIF clause corresponding to each attribute states the condition
under which the attribute value should be NULL
2. The age attribute of the dept_mgr value is null. The dept_name value is also
null.
11-6
Chapter 11
Loading Column Objects
NULLIF dept_mgr.em_contact.name=BLANKS,
phone_num CHAR(20)
NULLIF dept_mgr.em_contact.phone_num=BLANKS)),
1 is_null2 FILLER CHAR)
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The filler field (data file mapped; no corresponding column) is of type CHAR
(because it is a delimited field, the CHAR defaults to CHAR(255)). Note that the
NULLIF clause is not applicable to the filler field itself
2. Gets the value of null (atomic null) if the is_null field is blank.
11-7
Chapter 11
Loading Column Objects
BEGINDATA
1 101,Mathematics,Johny Q.,301189453,10249,
237,Physics,"Albert Einstein",128606590,10030,
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. When this control file is run in conventional path mode, the name fields,
Johny Q. and Albert Einstein, are both loaded in uppercase. This is
because the user-defined constructor is called in this mode. In contrast,
when this control file is run in direct path mode, the name fields are loaded
exactly as they appear in the input data. This is because the attribute-value
constructor is called in this mode.
It is possible to create a user-defined constructor whose argument list does not
match that of the attribute-value constructor. In this case, both conventional
and direct path modes will result in a call to the attribute-value constructor.
Consider the definitions in Example 11-8.
Example 11-8 Loading a Column Object with Constructors That Do Not Match
11-8
Chapter 11
Loading Column Objects
SELF.name := LOWER(name);
SELF.ssn := ssn;
SELF.empid := nextid;
RETURN;
END;
If the control file described in Example 11-7 is used with these definitions, then the
name fields are loaded exactly as they appear in the input data (that is, in mixed case).
This is because the attribute-value constructor is called in both conventional and direct
path modes.
It is still possible to load this table using conventional path mode by explicitly making
reference to the user-defined constructor in a SQL expression. Example 11-9 shows
how this can be done.
Example 11-9 Using SQL to Load Column Objects When Constructors Do Not
Match
11-9
Chapter 11
Loading Object Tables
BEGINDATA
1 101,Mathematics,Johny Q.,301189453,
237,Physics,"Albert Einstein",128606590,
Note:
The callouts, in bold, to the left of the example correspond to the following note:
1. When this control file is run in conventional path mode, the name fields,
Johny Q. and Albert Einstein, are both loaded in uppercase. This is
because the user-defined constructor is called in this mode. In contrast,
when this control file is run in direct path mode, the name fields are loaded
exactly as they appear in the input data. This is because the attribute-value
constructor is called in this mode.
If the control file in Example 11-9 is used in direct path mode, then the following error
is reported:
SQL*Loader-951: Error calling once/load initialization
ORA-26052: Unsupported type 121 for SQL expression on column EMPLOYEE.
By looking only at the preceding control file you might not be able to determine if the
table being loaded was an object table with system-generated OIDs, an object table
with primary-key-based OIDs, or a relational table.
11-10
Chapter 11
Loading Object Tables
You may want to load data that already contains system-generated OIDs and to
specify that instead of generating new OIDs, the existing OIDs in the data file should
be used. To do this, you would follow the INTO TABLE clause with the OID clause:
OID (fieldname)
In this clause, fieldname is the name of one of the fields (typically a filler field) from the
field specification list that is mapped to a data field that contains the system-generated
OIDs. SQL*Loader assumes that the OIDs provided are in the correct format and that
they preserve OID global uniqueness. Therefore, to ensure uniqueness, you should
use the Oracle OID generator to generate the OIDs to be loaded.
The OID clause can only be used for system-generated OIDs, not primary-key-based
OIDs.
Example 11-11 demonstrates loading system-generated OIDs with the row objects.
Example 11-11 Loading OIDs
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The OID clause specifies that the s_oid loader field contains the OID. The
parentheses are required
2. If s_oid does not contain a valid hexadecimal number, then the particular
record is rejected.
3. The OID in the data file is a character string and is interpreted as a 32-digit
hexadecimal number. The 32-digit hexadecimal number is later converted
into a 16-byte RAW and stored in the object table.
11-11
Chapter 11
Loading Object Tables
INFILE 'sample.dat'
INTO TABLE employees_v3
1 TREAT AS hourly_emps_type
FIELDS TERMINATED BY ','
(name CHAR(30),
age INTEGER EXTERNAL(3),
emp_id INTEGER EXTERNAL(5),
2 hours INTEGER EXTERNAL(2))
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The TREAT AS clause indicates that SQL*Loader should treat the object table
as if it were declared to be of type hourly_emps_type, instead of its actual
declared type, employee_type
2. The hours attribute is allowed here because it is an attribute of the
hourly_emps_type. If the TREAT AS clause had not been specified, then this
attribute would have resulted in an error, because it is not an attribute of
the object table's declared type.
11-12
Chapter 11
Loading REF Columns
For each of these, the way in which table names are specified is important, as
described in the following section.
• Specifying Table Names in a REF Clause
You can specify table names in a REF clause.
• System-Generated OID REF Columns
SQL*Loader assumes, when loading system-generated REF columns, that the
actual OIDs from which the REF columns are to be constructed are in the data file
with the rest of the data.
• Primary Key REF Columns
To load a primary key REF column, the SQL*Loader control-file field description
must provide the column name followed by a REF clause.
• Unscoped REF Columns That Allow Primary Keys
An unscoped REF column that allows primary keys can reference both system-
generated and primary key REFs.
Note:
The information in this section applies only to environments in which the
release of both SQL*Loader and Oracle Database are 11g release 1 (11.1) or
later. It does not apply to environments in which either SQL*Loader, Oracle
Database, or both are at an earlier release.
In the SQL*Loader control file, the description of the field corresponding to a REF
column consists of the column name followed by a REF clause. The REF clause takes
as arguments the table name and any attributes applicable to the type of REF column
being loaded. The table names can either be specified dynamically (using filler fields)
or as constants. The table name can also be specified with or without the schema
name.
Whether the table name specified in the REF clause is specified as a constant or by
using a filler field, it is interpreted as case-sensitive. This could result in the following
situations:
• If user SCOTT creates a table named table2 in lowercase without quotation marks
around the table name, then it can be used in a REF clause in any of the following
ways:
– REF(constant 'TABLE2', ...)
11-13
Chapter 11
Loading REF Columns
• If user SCOTT creates a table named "Table2" using quotation marks around a
mixed-case name, then it can be used in a REF clause in any of the following
ways:
– REF(constant 'Table2', ...)
In both of those situations, if constant is replaced with a filler field, then the same
values as shown in the examples will also work if they are placed in the data section.
The REF clause takes as arguments the table name and an OID. Note that the
arguments can be specified either as constants or dynamically (using filler fields). See
"ref_spec" for the appropriate syntax. Example 11-13 demonstrates loading system-
generated OID REF columns.
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. If the specified table does not exist, then the record is rejected. The
dept_mgr field itself does not map to any field in the data file.
11-14
Chapter 11
Loading REF Columns
The REF clause takes for arguments a comma-delimited list of field names and
constant values. The first argument is the table name, followed by arguments that
specify the primary key OID on which the REF column to be loaded is based. See
"ref_spec" for the appropriate syntax.
SQL*Loader assumes that the ordering of the arguments matches the relative ordering
of the columns making up the primary key OID in the referenced table. Example 11-14
demonstrates loading primary key REF columns.
The syntax for loading into such a REF column is the same as if you were loading into a
system-generated OID REF column or into a primary-key-based REF column. See
Example 11-13 and Example 11-14.
The following restrictions apply when loading into an unscoped REF column that allows
primary keys:
• Only one type of REF can be referenced by this column during a single-table load,
either system-generated or primary key, but not both. If you try to reference both
types, then the data row will be rejected with an error message indicating that the
referenced table name is invalid.
• If you are loading unscoped primary key REFs to this column, then only one object
table can be referenced during a single-table load. That is, to load unscoped
primary key REFs, some pointing to object table X and some pointing to object table
Y, you would have to do one of the following:
– Perform two single-table loads.
– Perform a single load using multiple INTO TABLE clauses for which the WHEN
clause keys off some aspect of the data, such as the object table name for the
unscoped primary key REF. For example:
11-15
Chapter 11
Loading LOBs
LOAD DATA
INFILE 'data.dat'
Note:
For an unscoped REF column that allows primary keys, SQL*Loader takes
the first valid object table parsed (either from the REF directive or from the
data rows) and uses that object table's OID type to determine the REF type
that can be referenced in that single-table load.
11-16
Chapter 11
Loading LOBs
LOBs can be column data types, and except for NCLOB, they can be an object's attribute
data types. LOBs can have actual values, they can be null, or they can be empty.
SQL*Loader creates an empty LOB when there is a 0-length field to store in the LOB.
(Note that this is different than other data types where SQL*Loader sets the column to
NULL for any 0-length string.) This means that the only way to load NULL values into a
LOB column is to use the NULLIF clause.
XML columns are columns declared to be of type SYS.XMLTYPE. SQL*Loader treats XML
columns as if they were CLOBs. All of the methods described in the following sections
for loading LOB data from the primary data file or from LOBFILEs are applicable to
loading XML columns.
Note:
You cannot specify a SQL string for LOB fields. This is true even if you specify
LOBFILE_spec.
Because LOBs can be quite large, SQL*Loader can load LOB data from either a
primary data file (in line with the rest of the data) or from LOBFILEs, as described in
the following sections:
See Also:
Oracle Database SQL Language Reference for more information about large
object (LOB) data types
11-17
Chapter 11
Loading LOBs
Note:
Because the LOBs you are loading may not be of equal size, you can use
whitespace to pad the LOB data to make the LOBs all of equal length within a
particular data field.
To load LOBs using this format, you should use either CHAR or RAW as the loading data
type.
Example 11-15 Loading LOB Data in Predetermined Size Fields
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. Because the DEFAULTIF clause is used, if the data field containing the
resume is empty, then the result is an empty LOB rather than a null LOB.
However, if a NULLIF clause had been used instead of DEFAULTIF, then the
empty data field would be null.
You can use SQL*Loader data types other than CHAR to load LOBs. For
example, when loading BLOBs, you would probably want to use the RAW data
type.
11-18
Chapter 11
Loading LOBs
notation (that is, X'hexadecimal string'). If the delimiters are specified in hexadecimal
notation, then the specification must consist of characters that are valid in the
character set of the input data file. In contrast, if hexadecimal notation is not used,
then the delimiter specification is considered to be in the client's (that is, the control
file's) character set. In this case, the delimiter is converted into the data file's character
set before SQL*Loader searches for the delimiter in the data file.
Note the following:
• Stutter syntax is supported with string delimiters (that is, the closing enclosure
delimiter can be stuttered).
• Leading whitespaces in the initial multicharacter enclosure delimiter are not
allowed.
• If a field is terminated by WHITESPACE, then the leading whitespaces are trimmed.
Note:
SQL*Loader defaults to 255 bytes when moving CLOB data, but a value of
up to 2 gigabytes can be specified. For a delimited field, if a length is
specified, then that length is used as a maximum. If no maximum is
specified, then it defaults to 255 bytes. For a CHAR field that is delimited and
is also greater than 255 bytes, you must specify a maximum length. See
"CHAR" for more information about the CHAR data type.
11-19
Chapter 11
Loading LOBs
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. <startlob> and <endlob> are the enclosure strings. With the default byte-
length semantics, the maximum length for a LOB that can be read using
CHAR(507) is 507 bytes. If character-length semantics were used, then the
maximum would be 507 characters. See "Character-Length Semantics"
2. If the record separator '|' had been placed right after <endlob> and
followed with the newline character, then the newline would have been
interpreted as part of the next record. An alternative would be to make the
newline part of the record separator (for example, '|\n' or, in hexadecimal
notation, X'7C0A').
11-20
Chapter 11
Loading LOBs
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. If the backslash escape character is not supported, then the string used as
a record separator in the example could be expressed in hexadecimal
notation.
2. "RESUME" is a field that corresponds to a CLOB column. In the control file, it is
a VARCHARC, whose length field is 3 bytes long and whose maximum size is
500 bytes (with byte-length semantics). If character-length semantics were
used, then the length would be 3 characters and the maximum size would
be 500 characters. See "Character-Length Semantics".
3. The length subfield of the VARCHARC is 0 (the value subfield is empty).
Consequently, the LOB instance is initialized to empty.
11-21
Chapter 11
Loading LOBs
11-22
Chapter 11
Loading LOBs
Speed Racer
400 Oracle Parkway
...
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The filler field is mapped to the 40-byte data field, which is read using the
SQL*Loader CHAR data type. This assumes the use of default byte-length
semantics. If character-length semantics were used, then the field would be
mapped to a 40-character data field
2. SQL*Loader gets the LOBFILE name from the ext_fname filler field. It then
loads the data from the LOBFILE (using the CHAR data type) from the first
byte to the EOF character. If no existing LOBFILE is specified, then the
"RESUME" field is initialized to empty.
11-23
Chapter 11
Loading LOBs
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. This entry specifies that SQL*Loader load 2000 bytes of data from the
jqresume.txt LOBFILE, using the CHAR data type, starting with the byte
following the byte loaded last during the current loading session. This
assumes the use of the default byte-length semantics. If character-length
semantics were used, then SQL*Loader would load 2000 characters of
data, starting from the first character after the last-loaded character. See
"Character-Length Semantics".
11-24
Chapter 11
Loading LOBs
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. Because a maximum length of 2000 is specified for CHAR, SQL*Loader
knows what to expect as the maximum length of the field, which can result
in memory usage optimization. If you choose to specify a maximum length,
then you should be sure not to underestimate its value. The TERMINATED BY
clause specifies the string that terminates the LOBs. Alternatively, you
could use the ENCLOSED BY clause. The ENCLOSED BY clause allows a bit more
flexibility as to the relative positioning of the LOBs in the LOBFILE (the
LOBs in the LOBFILE need not be sequential).
This method of loading can provide better performance over delimited LOBs, but at the
expense of some flexibility (for example, you must know the LOB length for each LOB
before loading).
Example 11-21 Loading LOB Data Using Length-Value Pair Specified LOBs
11-25
Chapter 11
Loading LOBs
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The entry VARCHARC(4,2000) tells SQL*Loader that the LOBs in the LOBFILE
are in length-value pair format and that the first 4 bytes should be
interpreted as the length. The value of 2000 tells SQL*Loader that the
maximum size of the field is 2000 bytes. This assumes the use of the
default byte-length semantics. If character-length semantics were used,
then the first 4 characters would be interpreted as the length in characters.
The maximum size of the field would be 2000 characters. See "Character-
Length Semantics".
2. The entry 0501 preceding Johny Quest tells SQL*Loader that the LOB
consists of the next 501 characters.
3. This entry specifies an empty (not null) LOB.
11-26
Chapter 11
Loading LOBs
An LLS field contains the file name, offset, and length of the LOB data in the data file.
SQL*Loader uses this information to read data for the LOB column.
The syntax for the LLS clause is as follows:
The LOB can be loaded in part or in whole and it can start from an arbitrary position
and for an arbitrary length. SQL Loader expects the expects the contents of the LLS
field to be filename.ext.nnn.mmm/ where each element is defined as follows:
• mmm is the length of the LOB in bytes. A value of -1 means the LOB is NULL. A
value of 0 means the LOB exists, but is empty.
• The forward slash (/) terminates the field
If the SQL*Loader parameter, SDF_PREFIX, is specified, then SQL*Loader looks for the
files in the directory specified by SDF_PREFIX. Otherwise, SQL*Loader looks in the same
directory as the data file.
An error is reported and the row is rejected if any of the following are true:
• The file name contains a relative or absolute path specification.
• The file is not found, the offset is invalid, or the length extends beyond the end of
the file.
• The contents of the field do not match the expected format.
• The data type for the column associated with an LLS field is not a CLOB, BLOB, or
NCLOB.
Usage Notes
• If an LLS field is referenced by a clause for any other field (for example a NULLIF
clause) in the control file, then the value used for evaluating the clause is the string
in the data file, not the data in the file pointed to by that string.
• The character set for the data in the file pointed to by the LLS clause is assumed to
be the same character set as the data file.
• The user running SQL*Loader must have read access to the data files.
Example 11-22 Example Specification of an LLS Clause
The following is an example of a SQL*Loader control file that contains an LLS clause.
Note that a data type is not needed on the column specification because the column
must be of type LOB.
LOAD DATA
INFILE *
TRUNCATE
INTO TABLE tklglls
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(col1 , col2 NULLIF col1 = '1' LLS)
11-27
Chapter 11
Loading BFILE Columns
BEGINDATA
1,"tklglls1.dat.1.11/"
Example 11-24 Loading Data Using BFILEs: File Name and Directory Specified
Dynamically
The following are the control file contents. Note that dname is mapped to the data file
field containing the directory name that corresponds to the file being loaded.
LOAD DATA
INFILE sample.dat
INTO TABLE planets
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(pl_id NUMBER(4),
pl_name CHAR(20),
fname FILLER CHAR(30),
dname FILLER CHAR(20),
pl_pict BFILE(dname, fname) )
11-28
Chapter 11
Loading Collections (Nested Tables and VARRAYs)
11-29
Chapter 11
Loading Collections (Nested Tables and VARRAYs)
• The column_name specified as part of the field_list must be the same as the
column_name preceding the VARRAY parameter.
Also, be aware that if you are loading into a table containing nested tables, then
SQL*Loader will not automatically split the load into multiple loads and generate a set
ID.
Example 11-25 demonstrates loading a VARRAY and a nested table.
11-30
Chapter 11
Loading Collections (Nested Tables and VARRAYs)
Note:
The callouts, in bold, to the left of the example correspond to the following
notes:
1. The TERMINATED BY clause specifies the VARRAY instance terminator (note that
no COUNT clause is used).
2. Full name field references (using dot notation) resolve the field name
conflict created by the presence of this filler field.
3. proj_cnt is a filler field used as an argument to the COUNT clause.
Note:
Only a collection_fld_spec can name an SDF as its data source.
SDFs are specified using the SDF parameter. The SDF parameter can be followed by
either the file specification string, or a FILLER field that is mapped to a data field
containing one or more file specification strings.
As for a primary data file, the following can be specified for each SDF:
• The record format (fixed, stream, or variable). Also, if stream record format is
used, then you can specify the record separator.
• The record size.
• The character set for an SDF can be specified using the CHARACTERSET clause (see
"Handling Different Character Encoding Schemes").
• A default delimiter (using the delimiter specification) for the fields that inherit a
particular SDF specification (all member fields or attributes of the collection that
contain the SDF specification, with exception of the fields containing their own
LOBFILE specification).
Also note the following regarding SDFs:
11-31
Chapter 11
Dynamic Versus Static SDF Specifications
• If a nonexistent SDF is specified as a data source for a particular field, then that
field is initialized to empty. If the concept of empty does not apply to the particular
field type, then the field is initialized to null.
• Table-level delimiters are not inherited by fields that are read from an SDF.
• To load SDFs larger than 64 KB, you must use the READSIZE parameter to specify a
larger physical record size. You can specify the READSIZE parameter either from the
command line or as part of an OPTIONS clause.
See Also:
– "READSIZE"
– "OPTIONS Clause"
– "sdf_spec"
11-32
Chapter 11
Loading a Parent Table Separately from Its Child Table
( dept_no CHAR(3),
dname CHAR(20) NULLIF dname=BLANKS ,
mysid FILLER CHAR(32),
1 projects SID(mysid))
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. mysid is a filler field that is mapped to a data file field containing the actual
set IDs and is supplied as an argument to the SID clause.
Note:
The callout, in bold, to the left of the example corresponds to the following note:
1. The table-level SID clause tells SQL*Loader that it is loading the storage
table for nested tables. sidsrc is the filler field name that is the source of
the real set IDs.
11-33
Chapter 11
Loading a Parent Table Separately from Its Child Table
elements, you will require at least 4000 bytes of client memory for each VARRAY
instance before you can load the VARRAYs into the database. In many cases,
SQL*Loader requires two to three times that amount of memory to successfully
construct and load a VARRAY.
• The BINDSIZE parameter specifies the amount of memory allocated by SQL*Loader
for loading records. Given the value specified for BINDSIZE, SQL*Loader takes into
consideration the size of each field being loaded, and determines the number of
rows it can load in one transaction. The larger the number of rows, the fewer
transactions, resulting in better performance. But if the amount of memory on your
system is limited, then at the expense of performance, you can specify a lower
value for ROWS than SQL*Loader calculated.
• Loading very large VARRAYs or a large number of smaller VARRAYs could cause you
to run out of memory during the load. If this happens, then specify a smaller value
for BINDSIZE or ROWS and retry the load.
11-34
12
Conventional and Direct Path Loads
SQL*Loader provides a conventional path load method and a direct path load method.
Further information about each method is provided in the following topics:
For an example of using the direct path load method, see case study 6, Loading Data
Using the Direct Path Load Method. The other cases use the conventional path load
method. (See "SQL*Loader Case Studies" for information on how to access case
studies.)
• Data Loading Methods
• Conventional Path Load
• Direct Path Load
• Using Direct Path Load
• Optimizing Performance of Direct Path Loads
• Optimizing Direct Path Loads on Multiple-CPU Systems
• Avoiding Index Maintenance
• Direct Path Loads, Integrity Constraints, and Triggers
• Parallel Data Loading Models
• General Performance Improvement Hints
12-1
Chapter 12
Conventional Path Load
See Also:
"Discontinued Conventional Path Loads"
The SQL layer of the Oracle kernel determines if the row being inserted maps to the
specified partition. If the row does not map to the partition, then the row is rejected,
and the SQL*Loader log file records an appropriate error message.
12-2
Chapter 12
Direct Path Load
To use a direct path load (except for parallel loads), SQL*Loader must have
exclusive write access to the table and exclusive read/write access to any indexes.
• When loading data into a clustered table
A direct path load does not support loading of clustered tables.
• When loading a relatively small number of rows into a large indexed table
During a direct path load, the existing index is copied when it is merged with the
new index keys. If the existing index is very large and the number of new keys is
very small, then the index copy time can offset the time saved by a direct path
load.
• When loading a relatively small number of rows into a large table with referential
and column-check integrity constraints
Because these constraints cannot be applied to rows loaded on the direct path,
they are disabled for the duration of the load. Then they are applied to the whole
table when the load completes. The costs could outweigh the savings for a very
large table and a small number of new rows.
• When loading records and you want to ensure that a record is rejected under any
of the following circumstances:
– If the record, upon insertion, causes an Oracle error
– If the record is formatted incorrectly, so that SQL*Loader cannot find field
boundaries
– If the record violates a constraint or tries to make a unique index non-unique
12-3
Chapter 12
Direct Path Load
See Also:
"Discontinued Direct Path Loads"
Example 12-1 Setting the Date Format in the SQL*Loader Control File
LOAD DATA
INFILE 'data.dat'
INSERT INTO TABLE emp
FIELDS TERMINATED BY "|"
(
EMPNO NUMBER(4) NOT NULL,
ENAME CHAR(10),
JOB CHAR(9),
MGR NUMBER(4),
HIREDATE DATE 'YYYYMMDD',
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2)
)
On UNIX csh:
%setenv NLS_DATE_FORMAT='YYYYMMDD'
12-4
Chapter 12
Direct Path Load
Note:
If you are performing a direct path load into multiple partitions and a space
error occurs, then the load is rolled back to the last commit point. If there was
no commit point, then the entire load is rolled back. This ensures that no data
encountered after the space error is written out to a different partition.
You can use the ROWS parameter to specify the frequency of the commit points.
If the ROWS parameter is not specified, then the entire load is rolled back.
While you are loading a partition of a partitioned or subpartitioned table, you are also
allowed to perform DML operations on, and direct path loads of, other partitions in the
table.
Although a direct path load minimizes database processing, several calls to the Oracle
database are required at the beginning and end of the load to initialize and finish the
load, respectively. Also, certain DML locks are required during load initialization and
are released when the load completes. The following operations occur during the load:
index keys are built and put into a sort, and space management routines are used to
get new extents when needed and to adjust the upper boundary (high-water mark) for
a data savepoint. See "Using Data Saves to Protect Against Data Loss" for information
about adjusting the upper boundary.
12-5
Chapter 12
Direct Path Load
• During a direct path load, processes perform their own write I/O, instead of using
Oracle's buffer cache. This minimizes contention with other Oracle users.
• The sorted indexes option available during direct path loads enables you to presort
data using high-performance sort routines that are native to your system or
installation.
• When a table to be loaded is empty, the presorting option eliminates the sort and
merge phases of index-building. The index is filled in as data arrives.
• Protection against instance failure does not require redo log file entries during
direct path loads. Therefore, no time is required to log the load when:
– The Oracle database has the SQL NOARCHIVELOG parameter enabled
– The SQL*Loader UNRECOVERABLE clause is enabled
– The object being loaded has the SQL NOLOGGING parameter set
See "Instance Recovery and Direct Path Loads".
• For releases of the database earlier than Oracle9i, you can perform a SQL*Loader
direct path load only when the client and server are the same release. This also
means that you cannot perform a direct path load of Oracle9i data into a database
of an earlier release. For example, you cannot use direct path load to load data
from a release 9.0.1 database into a release 8.1.7 database.
Beginning with Oracle9i, you can perform a SQL*Loader direct path load when the
client and server are different releases. However, both releases must be at least
release 9.0.1 and the client release must be the same as or lower than the server
release. For example, you can perform a direct path load from a release 9.0.1
database into a release 9.2 database. However, you cannot use direct path load to
load data from a release 10.0.0 database into a release 9.2 database.
The following features are not available with direct path load:
• Loading BFILE columns
• Use of CREATE SEQUENCE during the load. This is because in direct path loads there
is no SQL being generated to fetch the next value since direct path does not
generate INSERT statements.
12-6
Chapter 12
Direct Path Load
• The table that the partition is a member of cannot have any global indexes defined
on it.
• Enabled referential and check constraints on the table that the partition is a
member of are not allowed.
• Enabled triggers are not allowed.
12-7
Chapter 12
Using Direct Path Load
See Also:
12-8
Chapter 12
Using Direct Path Load
During a conventional path load, every time a row is inserted the index is updated.
This method does not require temporary storage space, but it does add processing
time.
• Improving Performance
• Temporary Segment Storage Requirements
Note:
If, during a direct load, you have specified that the data is to be presorted and
the existing index is empty, then a temporary segment is not required, and no
merge occurs—the keys are put directly into the index. See "Optimizing
Performance of Direct Path Loads" for more information.
When multiple indexes are built, the temporary segments corresponding to each index
exist simultaneously, in addition to the old indexes. The new keys are then merged
with the old indexes, one index at a time. As each new index is created, the old index
and the corresponding temporary segment are removed.
See Also:
Oracle Database Administrator's Guide for information about how to estimate
index size and set storage parameters
The columns included in this formula are the columns in the index. There is one length
byte per column, and 10 bytes per row are used for a ROWID and additional overhead.
The constant 1.3 reflects the average amount of extra space needed for sorting. This
value is appropriate for most randomly ordered data. If the data arrives in exactly
opposite order, then twice the key-storage space is required for sorting, and the value
of this constant would be 2.0. That is the worst case.
12-9
Chapter 12
Using Direct Path Load
If the data is fully sorted, then only enough space to store the index entries is required,
and the value of this constant would be 1.0. See "Presorting Data for Faster Indexing"
for more information.
If you are not the owner of the table, then search ALL_INDEXES or DBA_INDEXES instead of
USER_INDEXES.
If you are not the owner of the table, then search ALL_IND_PARTITIONS and
DBA_IND_PARTITIONS instead of USER_IND_PARTITIONS.
12-10
Chapter 12
Using Direct Path Load
Note:
Indexes are not protected by a data save, because SQL*Loader does not build
indexes until after data loading completes. (The only time indexes are built
during the load is when presorted data is loaded into an empty table, but these
indexes are also unprotected.)
• Instance - recovery from a system failure in which in-memory data was changed
but lost due to the failure before it was written to disk. The Oracle database can
always recover from instance failures, even when redo logs are not archived.
• Media Recovery and Direct Path Loads
• Instance Recovery and Direct Path Loads
12-11
Chapter 12
Using Direct Path Load
See Also:
Oracle Database Backup and Recovery User's Guide for more information
about using RMAN to recover a tablespace
See Also:
• "Loading LOBs"
• "Specifying the Number of Column Array Rows and Size of Stream Buffers"
You could also load data that is longer than the maximum buffer size by using the
PIECED parameter, as described in the next section, but Oracle highly recommends that
you use LOBs instead.
• Loading Data As PIECED
12-12
Chapter 12
Using Direct Path Load
For example, a PIECED field could span three records. SQL*Loader loads the piece
from the first record and then reuses the buffer for the second buffer. After loading
the second piece, the buffer is reused for the third record. If an error is discovered,
then only the third record is placed in the bad file because the first two records no
longer exist in the buffer. As a result, the record in the bad file would not be valid.
After creating the audit policy, use the AUDIT and NOAUDIT SQL statements to,
respectively, enable and disable the policy.
12-13
Chapter 12
Optimizing Performance of Direct Path Loads
See Also:
• Oracle Database SQL Language Reference for more information about the
SQL CREATE AUDIT POLICY, ALTER AUDIT POLICY,AUDIT, and NOAUDIT
statements
• Oracle Database Security Guide for more information about using auditing
in an Oracle database
12-14
Chapter 12
Optimizing Performance of Direct Path Loads
To calculate the space required by a table, see the information about managing
database files in the Oracle Database Administrator's Guide. Then use the INITIAL or
MINEXTENTS clause in the SQL CREATE TABLE statement to allocate the required space.
12-15
Chapter 12
Optimizing Performance of Direct Path Loads
12-16
Chapter 12
Optimizing Performance of Direct Path Loads
good idea to determine the average time to load a row by loading a few thousand
rows. Then you can use that value to select a good value for ROWS.
For example, if you can load 20,000 rows per minute, and you do not want to repeat
more than 10 minutes of work after an interruption, then set ROWS to be 200,000
(20,000 rows/minute * 10 minutes).
Note:
Because the data load is not logged, you may want to make a backup of the
data after loading.
If media recovery becomes necessary on data that was loaded with the UNRECOVERABLE
clause, then the data blocks that were loaded are marked as logically corrupted.
To recover the data, drop and re-create the data. It is a good idea to do backups
immediately after the load to preserve the otherwise unrecoverable data.
By default, a direct path load is RECOVERABLE.
The following is an example of specifying the UNRECOVERABLE clause in the control file:
UNRECOVERABLE
LOAD DATA
INFILE 'sample.dat'
12-17
Chapter 12
Optimizing Performance of Direct Path Loads
The optimal values for these parameters vary, depending on the system, input data
types, and Oracle column data types used. When you are using optimal values for
your particular configuration, the elapsed time in the SQL*Loader log file should go
down.
Note:
You should monitor process paging activity, because if paging becomes
excessive, then performance can be significantly degraded. You may need to
lower the values for READSIZE, STREAMSIZE, and COLUMNARRAYROWS to avoid
excessive paging.
It can be particularly useful to specify the number of column array rows and size of the
stream buffer when you perform direct path loads on multiple-CPU systems.
See Also:
12-18
Chapter 12
Optimizing Performance of Direct Path Loads
Note:
Date cache statistics are not written to the SQL*Loader log file if the cache
was active by default and disabled because the maximum was exceeded.
If increasing the cache size does not improve performance, then revert to the default
behavior or set the cache size to 0. The overall performance improvement also
depends on the data types of the other columns being loaded. Improvement will be
12-19
Chapter 12
Optimizing Direct Path Loads on Multiple-CPU Systems
greater for cases in which the total number of date columns loaded is large compared
to other types of data loaded.
See Also:
"DATE_CACHE"
In this example, the SQL*Loader load thread has offloaded the SQL*Loader main
thread, allowing the main thread to build the next stream buffer while the load thread
loads the current stream on the server.
The goal is to have the load thread perform as many stream buffer loads as possible.
This can be accomplished by increasing the number of column array rows, decreasing
the stream buffer size, or both. You can monitor the elapsed time in the SQL*Loader
log file to determine whether your changes are having the desired effect. See
"Specifying the Number of Column Array Rows and Size of Stream Buffers" for more
information.
On single-CPU systems, optimization is turned off by default. When the server is on
another system, performance may improve if you manually turn on multithreading.
To turn the multithreading option on or off, use the MULTITHREADING parameter at the
SQL*Loader command line or specify it in your SQL*Loader control file.
12-20
Chapter 12
Avoiding Index Maintenance
See Also:
Oracle Call Interface Programmer's Guide for more information about the
concepts of direct path loading
12-21
Chapter 12
Direct Path Loads, Integrity Constraints, and Triggers
• UNIQUE
NOT NULL constraints are checked at column array build time. Any row that violates the
NOT NULL constraint is rejected.
Even though UNIQUE constraints remain enabled during direct path loads, any rows that
violate those constraints are loaded anyway (this is different than in conventional path
in which such rows would be rejected). When indexes are rebuilt at the end of the
direct path load, UNIQUE constraints are verified and if a violation is detected, then the
index will be left in an Index Unusable state. See "Indexes Left in an Unusable State".
12-22
Chapter 12
Direct Path Loads, Integrity Constraints, and Triggers
Note:
Normally, when a table constraint is left in an ENABLE NOVALIDATE state, new data
can be inserted into the table but no new invalid data may be inserted.
However, SQL*Loader direct path load does not enforce this rule. Thus, if
subsequent direct path loads are performed with invalid data, then the invalid
data will be inserted but the same error reporting and exception table
processing as described previously will take place. In this scenario the
exception table may contain duplicate entries if it is not cleared out before each
load. Duplicate entries can easily be filtered out by performing a query such as
the following:
SELECT UNIQUE * FROM exceptions_table;
12-23
Chapter 12
Direct Path Loads, Integrity Constraints, and Triggers
Note:
Because referential integrity must be reverified for the entire table, performance
may be improved by using the conventional path, instead of the direct path,
when a small number of rows are to be loaded into a very large table.
12.8.2.3 Preparation
Before either method can be used, the table must be prepared. Use the following
general guidelines to prepare the table:
1. Before the load, add a 1-byte or 1-character column to the table that marks rows
as "old data" or "new data."
2. Let the value of null for this column signify "old data" because null columns do not
take up space.
12-24
Chapter 12
Direct Path Loads, Integrity Constraints, and Triggers
3. When loading, flag all loaded rows as "new data" with SQL*Loader's CONSTANT
parameter.
After following this procedure, all newly loaded rows are identified, making it possible
to operate on the new data without affecting the old rows.
2. Replace the current update trigger, if it exists, with the new one.
3. Update the table, changing the "new data" flag to null, thereby firing the update
trigger.
4. Restore the original update trigger, if there was one.
Depending on the behavior of the trigger, it may be necessary to have exclusive
update access to the table during this operation, so that other users do not
inadvertently apply the trigger to rows they modify.
12-25
Chapter 12
Parallel Data Loading Models
b. Open the cursor and fetch rows, one at a time, in a processing loop.
c. Perform the operations contained in the insert trigger.
d. If the operations succeed, then change the "new data" flag to null.
e. If the operations fail, then change the "new data" flag to "bad data."
2. Execute the stored procedure using an administration tool such as SQL*Plus.
3. After running the procedure, check the table for any rows marked "bad data."
4. Update or remove the bad rows.
5. Reenable the insert trigger.
12-26
Chapter 12
Parallel Data Loading Models
12-27
Chapter 12
Parallel Data Loading Models
TRUE
PARALLEL =
FALSE
PARALLEL can be specified on the command line or in a parameter file. It can also be
specified in the control file with the OPTIONS clause.
For example, to start three SQL*Loader direct path load sessions on the same table,
you would execute each of the following commands at the operating system prompt.
After entering each command, you will be prompted for a password.
sqlldr USERID=scott CONTROL=load1.ctl DIRECT=TRUE PARALLEL=TRUE
sqlldr USERID=scott CONTROL=load2.ctl DIRECT=TRUE PARALLEL=TRUE
sqlldr USERID=scott CONTROL=load3.ctl DIRECT=TRUE PARALLEL=TRUE
12-28
Chapter 12
Parallel Data Loading Models
Note:
Indexes are not maintained during a parallel load. Any indexes must be created
or re-created manually after the load completes. You can use the parallel index
creation or parallel index rebuild feature to speed the building of large indexes
after a parallel load.
When you perform a parallel load, SQL*Loader creates temporary segments for each
concurrent session and then merges the segments upon completion. The segment
created from the merge is then added to the existing segment in the database above
the segment's high-water mark. The last extent used of each segment for each loader
session is trimmed of any free space before being combined with the other extents of
the SQL*Loader session.
You could also specify the FILE parameter on the command line of each concurrent
SQL*Loader session, but then it would apply globally to all objects being loaded with
that session.
• Using the FILE Parameter
• Using the STORAGE Parameter
12-29
Chapter 12
General Performance Improvement Hints
• For partitioned tables, single-partition load: The specified file must be in the
tablespace of the partition being loaded.
• For partitioned tables, full-table load: The specified file must be in the
tablespace of all partitions being loaded; that is, all partitions must be in the same
tablespace.
For example, the following OPTIONS clause could be used to specify STORAGE
parameters:
OPTIONS (STORAGE=(INITIAL 100M NEXT 100M PCTINCREASE 0))
You can use the STORAGE parameter only in the SQL*Loader control file, and not on the
command line. Use of the STORAGE parameter to specify anything other than
PCTINCREASE of 0, and INITIAL or NEXT values is strongly discouraged and may be
silently ignored.
12-30
Chapter 12
General Performance Improvement Hints
– Make it easy for the software to identify physical record boundaries. Use the
file processing option string "FIX nnn" or "VAR". If you use the default (stream
mode), then on most platforms (for example, UNIX and NT) the loader must
scan each physical record for the record terminator (newline character).
• Make field setting efficient. Field setting is the process of mapping fields in the
data file to their corresponding columns in the table being loaded. The mapping
function is controlled by the description of the fields in the control file. Field setting
(along with data conversion) is the biggest consumer of CPU cycles for most
loads.
– Avoid delimited fields; use positional fields. If you use delimited fields, then the
loader must scan the input data to find the delimiters. If you use positional
fields, then field setting becomes simple pointer arithmetic (very fast).
– Do not trim whitespace if you do not need to (use PRESERVE BLANKS).
• Make conversions efficient. SQL*Loader performs character set conversion and
data type conversion for you. Of course, the quickest conversion is no conversion.
– Use single-byte character sets if you can.
– Avoid character set conversions if you can. SQL*Loader supports four
character sets:
* Client character set (NLS_LANG of the client sqlldr process)
* Data file character set (usually the same as the client character set)
* Database character set
* Database national character set
Performance is optimized if all character sets are the same. For direct path
loads, it is best if the data file character set and the database character set are
the same. If the character sets are the same, then character set conversion
buffers are not allocated.
• Use direct path loads.
• Use the SORTED INDEXES clause.
• Avoid unnecessary NULLIF and DEFAULTIF clauses. Each clause must be evaluated
on each column that has a clause associated with it for every row loaded.
• Use parallel direct path loads and parallel index creation when you can.
• Be aware of the effect on performance when you have large values for both the
CONCATENATE clause and the COLUMNARRAYROWS clause. See "Using CONCATENATE
to Assemble Logical Records".
12-31
13
SQL*Loader Express
SQL*Loader express mode allows you to quickly and easily use SQL*Loader to load
simple data types.
Topics:
• What is SQL*Loader Express Mode?
• Using SQL*Loader Express Mode
• SQL*Loader Express Mode Parameter Reference
• SQL*Loader Express Mode Syntax Diagrams
Note:
The only valid parameters for use with SQL*Loader express mode are those
described in this chapter. Any other parameters will be ignored or may result in
an error.
Copyright (c) 1982, 2016, Oracle and/or its affiliates. All rights reserved.
13-1
Chapter 13
Using SQL*Loader Express Mode
.
.
If you activate SQL*Loader express mode by specifying only the TABLE parameter, then
SQL*Loader uses default settings for a number of other parameters. You can override
most of the default values by specifying additional parameters on the command line.
SQL*Loader express mode generates a log file that includes a SQL*Loader control
file. The log file also contains SQL scripts for creating the external table and
performing the load using a SQL INSERT AS SELECT statement. Neither the control file
nor the SQL scripts are used by SQL*Loader express mode. They are made available
to you in case you want to use them as a starting point to perform operations using
regular SQL*Loader or standalone external tables; the control file is for use with
SQL*Loader, whereas the SQL scripts are for use with standalone external tables
operations.
See Also:
13-2
Chapter 13
Using SQL*Loader Express Mode
• If a data file is not specified, then the data, log, and bad files take the following
default names. (The %p is replaced with the process ID of the Oracle Database
slave process.):
– table-name.dat for the data file
• If one or more data files are specified (using the DATA parameter), then the log and
bad files take the following default names. (The %p is replaced with the process ID
of the server slave process.):
– table-name.log for the SQL*Loader log file
See Also:
– "DATA" parameter
See Also:
• "Byte Ordering" for more information about how SQL*Loader handles byte
order in data files
13-3
Chapter 13
SQL*Loader Express Mode Parameter Reference
Note:
If parameter values include quotation marks, then it is recommended that you
specify them in a parameter file. See "Use of Quotation Marks on the Data
Pump Command Line” in Parameters Available in Export's Command-Line
Mode - the issues discussed there are also pertinent to SQL*Loader express
mode.
• BAD
• CHARACTERSET
• CSV
• DATA
• DATE_FORMAT
• DEGREE_OF_PARALLELISM
• DIRECT
• DNFS_ENABLE
• DNFS_READBUFFERS
• ENCLOSED_BY
• EXTERNAL_TABLE
• FIELD_NAMES
• LOAD
• NULLIF
• OPTIONALLY_ENCLOSED_BY
• PARFILE
• SILENT
• TABLE
• TERMINATED_BY
• TIMESTAMP_FORMAT
• TRIM
• USERID
13-4
Chapter 13
SQL*Loader Express Mode Parameter Reference
13.3.1 BAD
Default: The default depends on whether any data file(s) are specified (using the DATA
parameter). See "Default Values Used by SQL*Loader Express Mode".
Purpose
The BAD parameter specifies the location and name of the bad file.
The bad file stores records that cause errors during insert or that are improperly
formatted. If you specify the BAD parameter, you must supply either a directory or file
name, or both. If you do not specify the BAD parameter, and there are rejected records,
then the default file name is used.
The directory variable specifies a directory to which the bad file is written. The
specification can include the name of a device or a network node.
The filename variable specifies a file name recognized as valid on your platform. You
must specify only a name (and extension, if one other than .bad is desired). Any
spaces or punctuation marks in the file name must be enclosed in single quotation
marks.
The values of directory and filename are determined as follows:
• If the BAD parameter is specified with a file name but no directory, then the
directory defaults to the current directory.
• If the BAD parameter is specified with a directory but no file name, then the
specified directory is used and the default is used for the file name and the
extension.
The BAD parameter applies to all the files which match the specified DATA parameter (if it
is specified). It applies to the one data file (table-name.dat) if the data parameter is not
specified.
Restrictions
Caution:
• If the file name (either the default or one you specify) already exists, then it
is either overwritten or a new version is created, depending on your
operating system.
• If multiple data files are being loaded, then it is recommended that you
either not specify the BAD parameter or that you specify it with only a
directory for the bad file.
Example
The following specification creates a bad file named emp1.bad in the current directory:
13-5
Chapter 13
SQL*Loader Express Mode Parameter Reference
13.3.2 CHARACTERSET
Default: NLS client character set as specified in the NLS_LANG environment variable
Purpose
The CHARACTERSET parameter specifies a character set, other than the default, to use for
the load.
The CHARACTERSET parameter specifies the character set of the SQL*Loader input data
files. If the CHARACTERSET parameter is not specified, then the default character set for all
data files is the session character set, which is defined by the NLS_LANG environment
variable. Only character data (fields of the SQL*Loader data types CHAR, VARCHAR,
VARCHARC, numeric EXTERNAL, and the datetime and interval data types) is affected by
the character set of the data file.
The character_set_name variable specifies the character set name. Normally, the
specified name must be the name of a character set that is supported by Oracle
Database.
For UTF-16 Unicode encoding, use the name UTF16 rather than AL16UTF16.
AL16UTF16, which is the supported character set name for UTF-16 encoded data, is
only for UTF-16 data that is in big-endian byte order. However, because you are
allowed to set up data using the byte order of the system where you create the data
file, the data in the data file can be either big-endian or little-endian. Therefore, a
different character set name (UTF16) is used. The character set name AL16UTF16 is
also supported. But if you specify AL16UTF16 for a data file that has little-endian byte
order, then SQL*Loader issues a warning message and processes the data file as
little-endian.
The CHARACTERSET parameter value is assumed to the be same for all data files.
Note:
The term UTF-16 is a general reference to UTF-16 encoding for Unicode. The
term UTF16 (no hyphen) is the specific name of the character set and is what
you should specify for the CHARACTERSET parameter when you want to use
UTF-16 encoding. This also applies to UTF-8 and UTF8.
Restrictions
• None
Example
The following example specifies the UTF-8 character set:
> sqlldr hr TABLE=employees CHARACTERSETNAME=utf8
13-6
Chapter 13
SQL*Loader Express Mode Parameter Reference
13.3.3 CSV
Default: If the CSV parameter is not specified on the command line, then SQL*Loader
express assumes that the CSV file being loaded contains data that has no embedded
characters and no enclosures.
If CSV=WITHOUT_EMBEDDED is specified on the command line, then SQL*Loader express
assumes that the CSV file being loaded contains data that has no embedded
characters and that is optionally enclosed by '"'.
Purpose
The CSV parameter provides options that let you specify whether the comma-separated
value (CSV) format file being loaded contains fields in which record terminators are
embedded.
Restrictions
• Normally a file can be processed in parallel (split up and processed by more than
one execution server at a time). But in the case of CSV format files with embedded
record terminators, the file must be processed by only one execution server.
Therefore, parallel processing within a data file is disabled when
CSV=WITH_EMBEDDED.
Example
The following example processes the data files as CSV format files with embedded
record terminators.
> sqlldr hr TABLE=employees CSV=WITH_EMBEDDED
13.3.4 DATA
Default: The same name as the table name, but with an extension of .dat.
Purpose
The DATA parameter specifies the name(s) of the data file(s) containing the data to be
loaded.
13-7
Chapter 13
SQL*Loader Express Mode Parameter Reference
The file specification can contain wildcards (only in the file name and file extension,
not in a device or directory name). An asterisk (*) represents multiple characters and a
question mark (?) represents a single character. For example:
DATA='emp*.dat'
DATA='m?emp.dat'
To list multiple data file specifications (each of which can contain wild cards), the file
names must be separated by commas.
If the file name contains any special characters (for example, spaces, *, ?, ), then the
entire name must be enclosed within single quotation marks.
The following are three examples of possible valid uses of the DATA parameter (the
single quotation marks would only be necessary if the file name contained special
characters):
DATA='file1','file2','file3','file4','file5','file6'
DATA='file1','file2'
DATA='file3,'file4','file5'
DATA='file6'
DATA='file1'
DATA='file2'
DATA='file3'
DATA='file4'
DATA='file5'
DATA='file6'
Restrictions
Caution:
If multiple data files are being loaded and you are also specifying the BAD
parameter, it is recommended that you specify only a directory for the bad file,
not a file name. If you specify a file name, and a file with that name already
exists, then it is either overwritten or a new version is created, depending on
your operating system.
Example
Assume that the current directory contains data files with the names emp1.dat,
emp2.dat, m1emp.dat, and m2emp.dat and you issue the following command:
The command loads the emp1.dat, emp2.dat, and m1emp.dat files. The m2emp.dat file is
not loaded because it did not match any of the wildcard criteria.
13-8
Chapter 13
SQL*Loader Express Mode Parameter Reference
13.3.5 DATE_FORMAT
Default: If the DATE_FORMAT parameter is not specified, then the NLS_DATE_FORMAT,
NLS_LANGUAGE, or NLS_DATE_LANGUAGE environment variable settings (if defined for the
SQL*Loader session) are used. If the NLS_DATE_FORMAT is not defined, then dates are
assumed to be in the default format defined by the NLS_TERRITORY setting.
Purpose
The DATE_FORMAT parameter specifies a date format that overrides the default value for
all date fields.
The mask is a date format mask, normally enclosed in double quotation marks.
Restrictions
• None
Example
If the date in the data file was 17-March-2012, then the date format would be specified
as follows:
> sqlldr hr TABLE=employees DATE_FORMAT="DD-Month-YYYY"
13.3.6 DEGREE_OF_PARALLELISM
Default: AUTO
Purpose
The DEGREE_OF_PARALLELISM parameter specifies the degree of parallelism to use for the
load.
If DEFAULT is specified, then the default parallelism of the database (not the default
parameter value of AUTO) is used.
If AUTO is used, then the Oracle database automatically sets the degree of parallelism
for the load. This is also the default if the DEGREE_OF_PARALLELISM parameter is not
specified at all.
If NONE is specified, then the load is not performed in parallel. A value of NONE is the
same as a value of 1.
13-9
Chapter 13
SQL*Loader Express Mode Parameter Reference
See Also:
• Oracle Database VLDB and Partitioning Guide for more information about
parallel execution
Restrictions
• The DEGREE_OF_PARALLELISM parameter is ignored if you force the load method to be
conventional or direct path (the NONE option is used). Any time you specify the
DEGREE_OF_PARALLELISM parameter, for any value, you receive a message reminding
you of this.
• If the load is a default external tables load and an error occurs that causes
SQL*Loader express mode to use direct path load instead, then the job is not
performed in parallel, even if you had specified a degree of parallelism or had
accepted the external tables default of AUTO. A message is displayed alerting you
to this change.
Example
The following example loads the data without using parallelism:
> sqlldr hr TABLE=employees DEGREE_OF_PARALLELISM=NONE
13.3.7 DIRECT
Default: FALSE
Purpose
The DIRECT parameter specifies the load method to use, either conventional path or
direct path.
A value of TRUE specifies a direct path load. A value of FALSE specifies a conventional
path load.
This parameter overrides the default load method of external tables, used by
SQL*Loader express mode.
For some errors, SQL*Loader express mode automatically switches from the default
external tables load method to direct path load. An example of when this might occur
would be if a privilege violation caused the CREATE DIRECTORY SQL command to fail.
If you use the DIRECT parameter to specify a conventional or direct path load, then the
following regular SQL*Loader parameters are valid to use in express mode:
• BINDSIZE
• COLUMNARRAYROWS (direct path loads only)
• DATE_CACHE
• ERRORS
13-10
Chapter 13
SQL*Loader Express Mode Parameter Reference
Restrictions
• None
Example
In the following example, SQL*Loader uses the direct path load method for the load
instead of external tables:
> sqlldr hr TABLE=employees DIRECT=TRUE
13.3.8 DNFS_ENABLE
Default: TRUE
Purpose
The DNFS_ENABLE parameter lets you enable and disable use of the Direct NFS Client
on input data files during a SQL*Loader operation.
The Direct NFS Client is an API that can be implemented by file servers to allow
improved performance when Oracle accesses files on those servers.
SQL*Loader uses the Direct NFS Client interfaces by default when it reads data files
over 1 GB. For smaller files, the operating system's I/O interfaces are used. To use the
Direct NFS Client on all input data files, use DNFS_ENABLE=TRUE.
To disable use of the Direct NFS Client for all data files, specify DNFS_ENABLE=FALSE.
13-11
Chapter 13
SQL*Loader Express Mode Parameter Reference
See Also:
13.3.9 DNFS_READBUFFERS
Default: 4
Purpose
The DNFS_READBUFFERS parameter lets you control the number of read buffers used by
the Direct NFS Client. The Direct NFS Client is an API that can be implemented by file
servers to allow improved performance when Oracle accesses files on those servers.
Using values larger than the default might compensate for inconsistent I/O from the
Direct NFS Client file server, but it may result in increased memory usage.
To use this parameter without also specifying the DNFS_ENABLE parameter, the input file
must be larger than 1 GB.
See Also:
13.3.10 ENCLOSED_BY
Default: The default is that there is no enclosure character.
Purpose
The ENCLOSED_BY parameter specifies a field enclosure string.
13-12
Chapter 13
SQL*Loader Express Mode Parameter Reference
Restrictions
• The same string must be used to signify both the beginning and the ending of the
enclosure.
Example
In the following example, the field data is enclosed by the '/' character (forward slash).
> sqlldr hr TABLE=employees ENCLOSED_BY='/'
13.3.11 EXTERNAL_TABLE
Default: EXECUTE
Purpose
The EXTERNAL_TABLE parameter instructs SQL*Loader whether to load data using the
external tables option.
13-13
Chapter 13
SQL*Loader Express Mode Parameter Reference
Note:
The EXTERNAL_TABLE=EXECUTE qualifier tells SQL*Loader to create an external
table that can be used to load data and then execute the INSERT statement to
load the data. All files in the external table must be identified as being in a
directory object. SQL*Loader attempts to use directory objects that already
exist and that you have privileges to access. However, if SQL*Loader does not
find the matching directory object, then it attempts to create a temporary
directory object. If you do not have privileges to create new directory objects,
then the operation fails.
To work around this, use EXTERNAL_TABLE=GENERATE_ONLY to create the SQL
statements that SQL*Loader would try to execute. Extract those SQL
statements and change references to directory objects to be the directory
object that you have privileges to access. Then, execute those SQL
statements.
Restrictions
• None
Example
sqlldr hr TABLE=employees EXTERNAL_TABLE=NOT_USED
13.3.12 FIELD_NAMES
Default: NONE
Purpose
The FIELD_NAMES parameter is used to override the fields being in the order of the
columns in the database table. (By default, SQL*Loader Express uses the table
column definitions found in the ALL_TAB_COLUMNS view to determine the input field order
and data types.)
An example of when this parameter could be useful is when the data in the input file is
not in the same order as the columns in the table. In such a case, you can include a
field name record (similar to a column header row for a table) in the data file and use
the FIELD_NAMES parameter to notify SQL*Loader to process the field names in the first
record to determine the order of the fields.
• ALL_IGNORE — Ignore the first (field names) record in all the data files and process
the data records normally.
• FIRST — In the first data file, process the first (field names) record. For all other
data files, there is no field names record, so the data file is processed normally.
13-14
Chapter 13
SQL*Loader Express Mode Parameter Reference
• FIRST_IGNORE — In the first data file, ignore the first (field names) record and use
table column order for the field order.
• NONE — There are no field names records in any data file, so the data files are
processed normally. This is the default.
Restrictions
• If any field name has mixed case or special characters (for example, spaces), you
must use either the OPTIONALLY_ENCLOSED_BY parameter, or the ENCLOSED_BY
parameter to indicate that case should be preserved and special characters should
be included as part of the field name.
Example
If you are loading a CSV file that contains column headers into a table, and the fields
in each row in the input file are in the same order as the columns in the table, then you
could use the following:
> sqlldr hr TABLE=employees CSV=WITHOUT_EMBEDDED FIELD_NAMES=FIRST_IGNORE
13.3.13 LOAD
Default: All records are loaded.
Purpose
The LOAD parameter specifies the number of records to be loaded.
To test that all parameters you have specified for the load are set correctly, use the
LOAD parameter to specify a limited number of records rather than loading all records.
No error occurs if fewer than the maximum number of records are found.
Restrictions
• None
Example
The following example specifies that a maximum of 10 records be loaded:
> sqlldr hr TABLE=employees LOAD=10
For external tables method loads (the default load method for express mode), only
successfully loaded records are counted toward the total. So if there are 15 records in
the file and records 2 and 4 are bad, then the following records are loaded into the
table, for a total of 10 records - 1, 3, 5, 6, 7, 8, 9, 10, 11, and 12.
For conventional and direct path loads, both successful and unsuccessful load
attempts are counted toward the total. So if there are 15 records in the file and records
2 and 4 are bad, then only the following 8 records are actually loaded into the table - 1,
3, 5, 6, 7, 8, 9, and 10.
13-15
Chapter 13
SQL*Loader Express Mode Parameter Reference
13.3.14 NULLIF
Default: The default is that no NULLIF checking is done.
Purpose
The NULLIF parameter specifies a value that is used to determine whether a field is
loaded as a NULL column.
Or
NULLIF != "string"
SQL*Loader checks the specified value against the value of the field in the record. If
there is a match using the equal (=) or not equal (!=) specification, then the field is set
to NULL for that row. Any field that has a length of 0 after blank trimming is also set to
NULL.
Restrictions
• None
Example
In the following example, if there are any fields whose value is a period, then those
fields are set to NULL in their respective rows.
> sqlldr hr TABLE=employees NULLIF="."
13.3.15 OPTIONALLY_ENCLOSED_BY
Default: The default is that there is no optional field enclosure character.
Purpose
The OPTIONALLY_ENCLOSED_BY parameter specifies an optional field enclosure string.
Restrictions
• The same string must be used to signify both the beginning and the ending of the
enclosure.
Examples
The following example specifies the optional enclosure character as a double
quotation mark ("):
> sqlldr hr TABLE=employees OPTIONALLY_ENCLOSED_BY='"'
13-16
Chapter 13
SQL*Loader Express Mode Parameter Reference
13.3.16 PARFILE
Default: There is no default
Purpose
The PARFILE parameter specifies the name of a file that contains commonly used
command-line parameters.
Note:
Although it is not usually important, on some systems it may be necessary to
have no spaces around the equal sign (=) in the parameter specifications.
Restrictions
• For security reasons, you should not include your USERID password in a parameter
file. SQL*Loader will prompt you for the password after you specify the parameter
file at the command line, for example:
> sqlldr hr TABLE=employees PARFILE=daily_report.par
Password:
Example
Suppose you have the following parameter file, test.par:
table=employees
data='mydata*.dat'
enclosed_by='"'
Any fields enclosed by double quotation marks, in any data files that match
mydata*.dat, are loaded into table employees when you execute the following command:
13.3.17 SILENT
Default: If this parameter is not specified, then no content is suppressed.
13-17
Chapter 13
SQL*Loader Express Mode Parameter Reference
Purpose
The SILENT parameter suppresses some of the content that is written to the screen
during a SQL*Loader operation.
Use the appropriate values to suppress one or more of the following (if more than one
option is specified, they must be separated by commas):
• HEADER — Suppresses the SQL*Loader header messages that normally appear on
the screen. Header messages still appear in the log file.
• FEEDBACK — Suppresses the "commit point reached" messages and the status
messages for the load that normally appear on the screen.
• ERRORS — Suppresses the data error messages in the log file that occur when a
record generates an Oracle error that causes it to be written to the bad file. A
count of rejected records still appears.
• DISCARDS — Suppresses the messages in the log file for each record written to the
discard file. This option is ignored in express mode.
• PARTITIONS — Disables writing the per-partition statistics to the log file during a
direct load of a partitioned table. This option is meaningful only in a forced direct
path operation.
• ALL — Implements all of the suppression options.
Example
For example, you can suppress the header and feedback messages that normally
appear on the screen with the following command-line argument:
> sqlldr hr TABLE=employees SILENT=HEADER, FEEDBACK
13.3.18 TABLE
Default: There is no default
Purpose
The TABLE parameter activates SQL*Loader express mode.
If the schema name or table name includes lower case characters, spaces, or other
special characters, then the names must be enclosed in double quotation marks and
that entire string enclosed within single quotation marks. For example:
TABLE='"hr.Employees"'
13-18
Chapter 13
SQL*Loader Express Mode Parameter Reference
Restrictions
• The TABLE parameter is valid only in SQL*Loader express mode.
Example
The following example loads the table employees in express mode:
> sqlldr hr TABLE=employees
13.3.19 TERMINATED_BY
Default: comma
Purpose
The TERMINATED_BY parameter specifies a field terminator that overrides the default.
Restrictions
• None
Example
In the following example, fields are terminated by the | character.
> sqlldr hr TABLE=employees TERMINATED_BY="|"
13.3.20 TIMESTAMP_FORMAT
Default: The default is taken from the value of the NLS_TIMESTAMP_FORMAT environment
variable. If NLS_TIMESTAMP_FORMAT is not set up, then timestamps use the default format
defined in the NLS_TERRITORY environment variable, with 6 digits of fractional precision.
Purpose
The TIMESTAMP_FORMAT parameter specifies a timestamp format to use for the load.
13-19
Chapter 13
SQL*Loader Express Mode Parameter Reference
Restrictions
• None
Example
The following is an example of specifying a timestamp format:
> sqlldr hr TABLE=employees TIMESTAMP_FORMAT="MON-DD-YYYY HH:MI:SSXFF AM"
13.3.21 TRIM
Default: The default for conventional and direct path loads is LDRTRIM. The default for
external tables loads is LRTRIM.
Purpose
The TRIM parameter specifies the type of trimming to use during the load.
The TRIM parameter is used to specify that spaces should be trimmed from the
beginning of a text field, or the end of a text field, or both. Spaces include blanks and
other nonprinting characters such as tabs, line feeds, and carriage returns.
NOTRIM indicates that no characters will be trimmed from the field. This setting generally
yields the fastest performance.
LRTRIM, LTRIM, and RTRIM are used to indicate that characters should be trimmed from
the field. LRTRIM means that both leading and trailing spaces are trimmed. LTRIM means
that leading spaces will be trimmed. RTRIM means trailing spaces are trimmed.
Restrictions
• Only LDRTRIM is supported for forced conventional path and forced direct path
loads. Any time you specify the TRIM parameter, for any value, you receive a
message reminding you of this.
• If the load is a default external tables load and an error occurs that causes
SQL*Loader express mode to use direct path load instead, then LDRTRM is used as
the trimming method, even if you specified a different method or had accepted the
external tables default of LRTRIM. A message is displayed alerting you to this
change.
To use NOTRIM, use a control file with the PRESERVE BLANKS clause.
13-20
Chapter 13
SQL*Loader Express Mode Syntax Diagrams
Example
The following example reads the fields, trimming all spaces on the right (trailing
spaces).
> sqlldr hr TABLE=employees TRIM=RTRIM
13.3.22 USERID
Default: none
Purpose
The USERID parameter is used to provide your Oracle username and password.
If you do not specify the USERID parameter, then you are prompted for it. If only a slash
is used, then USERID defaults to your operating system login.
If you connect as user SYS, then you must also specify AS SYSDBA in the connect string.
Restrictions
• Because the string, AS SYSDBA, contains a blank, some operating systems may
require that the entire connect string be placed in quotation marks or marked as a
literal by some method. Some operating systems also require that quotation marks
on the command line be preceded by an escape character, such as backslashes.
See your Oracle operating system-specific documentation for information about
special and reserved characters on your system.
Example
The following example starts the job for user hr:
> sqlldr USERID=hr TABLE=employees
Password:
express_init
The following syntax diagrams show the parameters included in express_options in the
previous syntax diagram. SQL*Loader express mode parameters shown in the
following syntax diagrams are all optional and can appear in any order on the
13-21
Chapter 13
SQL*Loader Express Mode Syntax Diagrams
express_options
BAD = filename
CHARACTERSET = character_set_name
WITH_EMBEDDED
CSV =
WITHOUT_EMBEDDED
DATA = filename
DATE_FORMAT = mask
degree_num
DEFAULT
DEGREE_OF_PARALLELISM =
AUTO
NONE
TRUE
DIRECT =
FALSE
TRUE
DNFS_ENABLE =
FALSE
TRUE
DNFS_READBUFFERS =
FALSE
’char’
ENCLOSED_BY =
X’hex–char’
NOT_USED
EXTERNAL_TABLE = GENERATE_ONLY
EXECUTE
ALL
ALL_IGNORE
FIELD_NAMES = FIRST
FIRST_IGNORE
NONE
13-22
Chapter 13
SQL*Loader Express Mode Syntax Diagrams
express_options_cont
= X’hexstr’
!= BLANKS
NULLIF
’char’
OPTIONALLY_ENCLOSED_BY =
X’hex–char’
HEADER
FEEDBACK
ERRORS
SILENT =
DISCARDS
PARTITIONS
ALL
WHITESPACE
TERMINATED_BY = X’hex–char’
’char’
TIMESTAMP_FORMAT = timestamp_format
LRTRIM
NOTRIM
TRIM = LTRIM
RTRIM
LDRTRIM
13-23
Part III
External Tables
The following topics provide information necessary to successfully using external
tables:
External Tables Concepts
Describes basic concepts about external tables.
The ORACLE_LOADER Access Driver
Describes the ORACLE_LOADER access driver.
See Also:
Oracle Database Administrator's Guide for additional information about creating
and managing external tables, and about partitioning them.
14-1
Chapter 14
How Are External Tables Created?
statement. Once the dump file is created, it can be read any number of times,
but it cannot be modified (that is, no DML operations can be performed).
– ORACLE_HDFS — extracts data stored in a Hadoop Distributed File System
(HDFS).
– ORACLE_HIVE — extracts data stored in Apache HIVE.
• DEFAULT DIRECTORY — specifies the default directory to use for all input and output
files that do not explicitly name a directory object. The location is specified with a
directory object, not a directory path. You must create the directory object before
you create the external table; otherwise, an error is generated. See "Location of
Data Files and Output Files" for more information.
• ACCESS PARAMETERS — describe the external data source and implement the type of
external table that was specified. Each type of external table has its own access
driver that provides access parameters unique to that type of external table.
Access parameters are optional. See "Access Parameters".
• LOCATION — specifies the data files for the external table.
– For ORACLE_LOADER and ORACLE_DATAPUMP, the files are named in the form
directory:file. The directory portion is optional. If it is missing, then the
default directory is used as the directory for the file. If you are using the
ORACLE_LOADER access driver, then you can use wildcards in the file name: an
asterisk (*) signifies multiple characters, a question mark (?) signifies a single
character.
– For ORACLE_HDFS, the LOCATION clause is a list of Uniform Resource Identifiers
(URIs) for a directory or for a file. There is no directory object associated with
a URI.
– For ORACLE_HIVE, the LOCATION clause is not used. Instead, the Hadoop
HCatalog table is read to obtain information about the location of the data
source (which could be a file or another database).
The following examples briefly show the use of attributes for each of the access
drivers.
Example 14-1 Specifying Attributes for the ORACLE_LOADER Access Driver
The following example uses the ORACLE_LOADER access driver to show the use of each
of these attributes (it assumes that the default directory def_dir1 already exists):
SQL> CREATE TABLE emp_load
2 (employee_number CHAR(5),
3 employee_dob CHAR(20),
4 employee_last_name CHAR(20),
5 employee_first_name CHAR(15),
6 employee_middle_name CHAR(15),
7 employee_hire_date DATE)
8 ORGANIZATION EXTERNAL
9 (TYPE ORACLE_LOADER
10 DEFAULT DIRECTORY def_dir1
11 ACCESS PARAMETERS
12 (RECORDS DELIMITED BY NEWLINE
13 FIELDS (employee_number CHAR(2),
14 employee_dob CHAR(20),
15 employee_last_name CHAR(18),
16 employee_first_name CHAR(11),
17 employee_middle_name CHAR(11),
18 employee_hire_date CHAR(10) date_format DATE mask "mm/dd/yyyy"
14-2
Chapter 14
How Are External Tables Created?
19 )
20 )
21 LOCATION ('info.dat')
22 );
Table created.
The information you provide through the access driver ensures that data from the data
source is processed so that it matches the definition of the external table. The fields
listed after CREATE TABLE emp_load are actually defining the metadata for the data in the
info.dat source file.
14-3
Chapter 14
How Are External Tables Created?
Note:
The information in this section about directory objects does not apply to data
files for the ORACLE_HDFS access driver or ORACLE_HIVE access driver. With the
ORACLE_HDFS driver, the location of data is specified with a list of URIs for a
directory or for a file, and there is no directory object associated with a URI.
The ORACLE_HIVE driver does not specify a data source location; it reads the
Hive metastore table to get that information, so no directory object is needed.
The access driver runs inside the database server. This is different from SQL*Loader,
which is a client program that sends the data to be loaded over to the server. This
difference has the following implications:
• The server must have access to any files to be loaded by the access driver.
• The server must create and write the output files created by the access driver: the
log file, bad file, discard file, and also any dump files created by the
ORACLE_DATAPUMP access driver.
The access driver requires that a directory object be used to specify the location from
which to read and write files. A directory object maps a name to a directory name on
the file system. For example, the following statement creates a directory object named
ext_tab_dir that is mapped to a directory located at /usr/apps/datafiles.
Directory objects can be created by DBAs or by any user with the CREATE ANY DIRECTORY
privilege.
Note:
To use external tables in an Oracle Real Applications Cluster (Oracle RAC)
configuration, you must ensure that the directory object path is on a cluster-
wide file system.
After a directory is created, the user creating the directory object needs to grant READ
and WRITE privileges on the directory to other users. These privileges must be explicitly
granted, rather than assigned through the use of roles. For example, to allow the
server to read files on behalf of user scott in the directory named by ext_tab_dir, the
user who created the directory object must execute the following command:
GRANT READ ON DIRECTORY ext_tab_dir TO scott;
The SYS user is the only user that can own directory objects, but the SYS user can grant
other users the privilege to create directory objects. Note that READ or WRITE permission
to a directory object means only that the Oracle database will read or write that file on
your behalf. You are not given direct access to those files outside of the Oracle
database unless you have the appropriate operating system privileges. Similarly, the
14-4
Chapter 14
Data Type Conversion During External Table Use
Oracle database requires permission from the operating system to read and write files
in the directories.
Note:
These access parameters are collectively referred to as the opaque_format_spec
in the SQL CREATE TABLE...ORGANIZATION EXTERNAL statement.
See Also:
The external table KV_TAB_XT uses default values for the access parameters, which
means:
• Records are delimited by new lines.
• The data file and the database have the same character set.
14-5
Chapter 14
Data Type Conversion During External Table Use
• The fields in the data file have the same name and are in the same order as the
columns in the external table.
• The data type of the field is CHAR(255).
• Data for each field is terminated by a comma.
The records in the data file for the KV_TAB_XT external table should be:
• A string, up to 4 bytes long. If the string is empty, then the value for the field is
NULL.
• A terminating comma.
• A string of numeric characters. If the string is empty, then the value for this field is
NULL.
If the length of the value of the KEY field is greater than 4 or if there is a non-numeric
character in the value for VAL, then the ORACLE_LOADER access driver rejects the row
which results in a copy of the row being written to the bad file and an error message
being written to the log file.
All access drivers have to handle conversion from the data type of fields in the source
for the external table and the data type for the columns of the external tables. The
following are some examples of the types of conversions and checks that access
drivers perform:
• Convert character data from character set used by the source data to the
character set used by the database.
• Convert from character data to numeric data.
• Convert from numeric data to character data.
• Convert from character data to a date or timestamp.
• Convert from a date or timestamp to character data.
• Convert from character data to an interval data type.
• Convert from an interval data type to a character data.
• Verify that the length of data value for a character column does not exceed the
length limits of that column.
When the access driver encounters an error doing the required conversion or
verification, it can decide how to handle the error. When the ORACLE_LOADER and
ORACLE_DATAPUMP access drivers encounter errors, they reject the record and write an
error message to the log file. It is as if that record were not in the data source. When
the ORACLE_HDFS and ORACLE_HIVE access drivers encounter errors, the value of the field
in which the error is encountered is set to NULL. This is in keeping with the behavior of
how Hive handles errors in Hadoop.
Even after the access driver has converted the data from the data source to match the
data type of the external table columns, the SQL statement that is accessing the
external table could require additional data type conversions. If any of these additional
conversions encounter an error, then the entire statement fails. (The exception to this
is if you use the DML error logging feature in the SQL statement to handle these
14-6
Chapter 14
Data Type Conversion During External Table Use
errors.) These conversions are the same as any that might normally be required when
executing a SQL statement. For example, suppose you change the definition of the
KV_TAB_XT external table to only have columns with character data types, and then you
execute an INSERT statement to load data from the external table into another table that
has a NUMBER data type for column VAL:
SQL> CREATE TABLE KV_TAB_XT (KEY VARCHAR2(20), VAL VARCHAR2(20))
2 ORGANIZATION EXTERNAL
3 (DEFAULT DIRECTORY DEF_DIR1 LOCATION (‘key_val.csv’));
4 CREATE TABLE KV_TAB (KEY VARCHAR2(4), VAL NUMBER);
5 INSERT INTO KV_TAB SELECT * FROM KV_TAB_XT;
In this example, the access driver will not reject a record if the data for VAL contains a
non-numeric character because the data type of VAL in the external table is now
VARCHAR2 (instead of NUMBER). However, SQL execution now needs to handle the
conversion from character data type in KV_TAB_XT to number data type in KV_TAB. If
there is a non-numeric character in the value for VAL in the external table, then SQL
raises a conversion error and rolls back any rows that were inserted. To avoid
conversion errors in SQL execution, try to make the data types of the columns in the
external table match the data types expected by other tables or functions that will be
using the values of those columns.
The source table named LONG_TAB has a LONG column, therefore the corresponding
column in the external table being created, LONG_TAB_XT, must be a CLOB and the SELECT
subquery that is used to populate the external table must use the TO_LOB operator to
load the column.
14-7
15
The ORACLE_LOADER Access Driver
The ORACLE_LOADER access driver which provides a set of access parameters unique to
external tables of the type ORACLE_LOADER. You can use the access parameters to
modify the default behavior of the access driver. The information you provide through
the access driver ensures that data from the data source is processed so that it
matches the definition of the external table.
See the following topics for more information:
To successfully use the information in these topics, you must have some knowledge of
the file format and record format (including character sets and field data types) of the
data files on your platform. You must also know enough about SQL to be able to
create an external table and perform queries against it.
You may find it helpful to use the EXTERNAL_TABLE=GENERATE_ONLY parameter in
SQL*Loader to get the proper access parameters for a given SQL*Loader control file.
When you specify GENERATE_ONLY, all the SQL statements needed to do the load using
external tables, as described in the control file, are placed in the SQL*Loader log file.
These SQL statements can be edited and customized. The actual load can be done
later without the use of SQL*Loader by executing these statements in SQL*Plus.
See Also:
• "EXTERNAL_TABLE"
• Oracle Database Administrator's Guide for more information about creating
and managing external tables
Note:
15-1
Chapter 15
access_parameters Clause
• access_parameters Clause
• record_format_info Clause
• field_definitions Clause
• column_transforms Clause
• Parallel Loading Considerations for the ORACLE_LOADER Access Driver
• Performance Hints When Using the ORACLE_LOADER Access Driver
• Restrictions When Using the ORACLE_LOADER Access Driver
• Reserved Words for the ORACLE_LOADER Access Driver
Note:
These access parameters are collectively referred to as the opaque_format_spec
in the SQL CREATE TABLE...ORGANIZATION EXTERNAL statement.
See Also:
comments
Comments are lines that begin with two hyphens followed by text. Comments must be
placed before any access parameters, for example:
15-2
Chapter 15
record_format_info Clause
--This is a comment.
--This is another comment.
RECORDS DELIMITED BY NEWLINE
All text to the right of the double hyphen is ignored, until the end of the line.
record_format_info
The record_format_info clause is an optional clause that contains information about
the record, such as its format, the character set of the data, and what rules are used to
exclude records from being loaded. For a full description of the syntax, see
"record_format_info Clause".
field_definitions
The field_definitions clause is used to describe the fields in the data file. If a data file
field has the same name as a column in the external table, then the data from the field
is used for that column. For a full description of the syntax, see "field_definitions
Clause".
column_transforms
The column_transforms clause is an optional clause used to describe how to load
columns in the external table that do not map directly to columns in the data file. This
is done using the following transforms: NULL, CONSTANT, CONCAT, and LOBFILE. For a full
description of the syntax, see "column_transforms Clause".
The record_format_info clause is optional. The default value, whether the clause is
specified or not, is RECORDS DELIMITED BY NEWLINE. The syntax for the record_format_info
clause is as follows:
FIXED
integer
VARIABLE
et_record_spec_options
NEWLINE
RECORDS
DELIMITED BY
string
XMLTAG string
15-3
Chapter 15
record_format_info Clause
CHARACTERSET string
directory_spec :
PREPROCESSOR file_spec
LANGUAGE
string
TERRITORY
LITTLE
DATA IS ENDIAN
BIG
CHECK
BYTEORDERMARK
NOCHECK
BYTES
STRING SIZES ARE IN
CHARACTERS
et_output_files
READSIZE integer
DISABLE_DIRECTORY_LINK_CHECK
DATE_CACHE
integer
SKIP
IGNORE
FIRST FILE
IGNORE
FIELD_NAMES
ALL FILES
NONE
DIRECTIO
IO_OPTIONS ( )
NODIRECTIO
DNFS_ENABLE
DNFS_DISABLE
DNFS_READBUFFERS integer
The following et_output_files diagram shows the options for specifying the bad,
discard, and log files. For each of these clauses, you must supply either a directory
object name or a file name, or both.
15-4
Chapter 15
record_format_info Clause
NOBADFILE
NODISCARDFILE
NOLOGFILE
• FIXED length
• VARIABLE size
• DELIMITED BY
• XMLTAG
You can use the XMLTAG clause of the ORACLE_LOADER access driver to specify XML
tags that are used to load subdocuments from an XML document.
• CHARACTERSET
• EXTERNAL VARIABLE DATA
• PREPROCESSOR
• LANGUAGE
• TERRITORY
• DATA IS...ENDIAN
• BYTEORDERMARK (CHECK | NOCHECK)
• STRING SIZES ARE IN
• LOAD WHEN
• BADFILE | NOBADFILE
• DISCARDFILE | NODISCARDFILE
• LOGFILE | NOLOGFILE
• SKIP
• FIELD NAMES
• READSIZE
• DISABLE_DIRECTORY_LINK_CHECK
• DATE_CACHE
• string
• condition_spec
• [directory object name:] [filename]
• condition
15-5
Chapter 15
record_format_info Clause
• IO_OPTIONS clause
The IO_OPTIONS clause allows you to specify I/O options used by the operating
system for reading the data files.
• DNFS_DISABLE | DNFS_ENABLE
• DNFS_READBUFFERS
Alvin Tolliver1976
KennethBaer 1963
Mary Dube 1973
21Alvin,Tolliver,1976,
19Kenneth,Baer,1963,
16Mary,Dube,1973,
15-6
Chapter 15
record_format_info Clause
15.2.3 DELIMITED BY
The DELIMITED BY clause is used to indicate the characters that identify the end of a
record.
If DELIMITED BY NEWLINE is specified, then the actual value used is platform-specific. On
UNIX platforms, NEWLINE is assumed to be "\n". On Windows operating systems,
NEWLINE is assumed to be "\r\n".
Note:
Do not include any binary data, including binary counts for VARCHAR and VARRAW,
in a record that has delimiters. Doing so could cause errors or corruption,
because the binary data will be interpreted as characters during the search for
the delimiter.
Alvin,Tolliver,1976|Kenneth,Baer,1963|Mary,Dube,1973
15-7
Chapter 15
record_format_info Clause
15.2.4 XMLTAG
You can use the XMLTAG clause of the ORACLE_LOADER access driver to specify XML tags
that are used to load subdocuments from an XML document.
The access driver searches the data file for documents enclosed by those tags and
loads those documents as separate rows in the external table.
The XMLTAG clause accepts a list of one or more strings. The strings are used to build
tags that ORACLE_LOADER uses to search for subdocuments in the data file. The tags
specified in the access parameters do not include the “<” and “>” delimiters.
The ORACLE_LOADER access driver starts at the beginning of the file and looks for the
first occurrence of any of the tags listed in the XMLTAG clause. When it finds a match, it
searches for the corresponding closing tag. For example, if the tag is “ORDER_ITEM”,
then ORACLE_LOADER looks for the text string “<ORDER_ITEM>”, starting at the
beginning of the file. When it finds an occurrence of “<ORDER_ITEM>” it then looks
for “</ORDER_ITEM>”. Everything found between the <ORDER_ITEM> and </
ORDER_ITEM> tags is part of the document loaded for the row. ORACLE_LOADER then
searches for the next occurrence of any of the tags, starting from the first character
after the closing tag.
The ORACLE_LOADER access driver is not parsing the XML document to the elements that
match the tag names; it is only doing a string search through a text file. If the external
table is being accessed in parallel, then ORACLE_LOADER splits large files up so that
different sections are read independently. When it starts reading a section of the data
file, it starts looking for one of the tags specified by XMLTAG. If it reaches the end of a
section and is still looking for a matching end tag, then ORACLE_LOADER continues
reading into the next section until the matching end tag is found.
then ORACLE_LOADER extracts everything between the first <FOO> and the first </FOO>
as a document, which does not constitute a valid document.
Similarly, if XMLTAG(“FOO”,”BAR”) is specified and the data file contains the
following:
<FOO><BAR></BAR></FOO>
then <BAR> and </BAR> are loaded, but as the document for "FOO".
• The limit on how large an extracted sub-document can be is determined by the
READSIZE access parameter. If the ORACLE_LOADER access driver sees a
subdocument larger than READSIZE, then it returns an error.
15-8
Chapter 15
record_format_info Clause
"C0" VARCHAR2(2000)
)
ORGANIZATION external
(
TYPE oracle_loader
DEFAULT DIRECTORY DMPDIR
ACCESS PARAMETERS
(
RECORDS
XMLTAG ("home address", "work address"," home phone ")
READSIZE 1024
SKIP 0
FIELDS NOTRIM
MISSING FIELD VALUES ARE NULL
(
"C0" (1:2000) CHAR(2000)
)
)
location
(
't.dat'
)
)REJECT LIMIT UNLIMITED
/
exit;
C0
------------------------------------------------------------------
<home address>23 Oak St, Tripoli, CT</home address>
15.2.5 CHARACTERSET
The CHARACTERSET string clause identifies the character set of the data file. If a
character set is not specified, then the data is assumed to be in the default character
set for the database. See "string".
Note:
The settings of NLS environment variables on the client have no effect on the
character set used for the database.
See Also:
Oracle Database Globalization Support Guide for a listing of Oracle-supported
character sets
15-9
Chapter 15
record_format_info Clause
Note:
The EXTERNAL VARIABLE DATA clause is valid only for use with the Oracle SQL
Connector for Hadoop Distributed File System (HDFS). See Oracle Big Data
Connectors User's Guide for more information about the Oracle SQL Connector
for HDFS.
When you specify the EXTERNAL VARIABLE DATA clause, the ORACLE_LOADER access driver is
used to load dump files that were generated with the ORACLE_DATAPUMP access driver.
The syntax is as follows:
LOGFILE
NOLOGFILE
READSIZE
DISABLE_DIRECTORY_LINK_CHECK PREPROCESSOR
EXTERNAL VARIABLE DATA
The only access parameters that can be used with the EXTERNAL VARIABLE DATA clause
are the following:
• DISABLE_DIRECTORY_LINK_CHECK
• LOGFILE | NOLOGFILE
• READSIZE
• PREPROCESSOR
The following example uses the EXTERNAL VARIABLE DATA clause. The example assumes
that the deptxt1.dmp dump file was previously generated by the ORACLE_DATAPUMP access
driver. The tkexcat program specified by the PREPROCESSOR parameter is a user-supplied
program to manipulate the input data.
CREATE TABLE deptxt1
(
deptno number(2),
dname varchar2(14),
loc varchar2(13)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY dpump_dir
ACCESS PARAMETERS
(
EXTERNAL VARIABLE DATA
LOGFILE 'deptxt1.log'
READSIZE=10000
PREPROCESSOR tkexcat
)
15-10
Chapter 15
record_format_info Clause
LOCATION ('deptxt1.dmp')
)
REJECT LIMIT UNLIMITED
;
15.2.7 PREPROCESSOR
Caution:
There are security implications to consider when using the PREPROCESSOR clause.
See Oracle Database Security Guide for more information.
If the file you want to load contains data records that are not in a format supported by
the ORACLE_LOADER access driver, then use the PREPROCESSOR clause to specify a user-
supplied preprocessor program that will execute for every data file. Note that the
program specification must be enclosed in a shell script if it uses arguments (see the
description of "file_spec").
The preprocessor program converts the data to a record format supported by the
access driver and then writes the converted record data to standard output (stdout),
which the access driver reads as input. The syntax of the PREPROCESSOR clause is as
follows:
directory_spec :
PREPROCESSOR file_spec
directory_spec
Specifies the directory object containing the name of the preprocessor program to
execute for every data file. The user accessing the external table must have the
EXECUTE privilege for the directory object that is used. If directory_spec is omitted, then
the default directory specified for the external table is used.
Caution:
For security reasons, Oracle strongly recommends that a separate directory,
not the default directory, be used to store preprocessor programs. Do not store
any other files in the directory in which preprocessor programs are stored.
The preprocessor program must reside in a directory object, so that access to it can be
controlled for security reasons. The OS system manager must create a directory
corresponding to the directory object and must verify that OS-user ORACLE has
access to that directory. DBAs must ensure that only approved users are allowed
access to the directory object associated with the directory path. Although multiple
database users can have access to a directory object, only those with the EXECUTE
privilege can run a preprocessor in that directory. No existing database user with read-
write privileges to a directory object will be able to use the preprocessing feature.
15-11
Chapter 15
record_format_info Clause
DBAs can prevent preprocessors from ever being used by never granting the EXECUTE
privilege to anyone for a directory object.
See Also:
Oracle Database SQL Language Reference for information about granting the
EXECUTE privilege
file_spec
The name of the preprocessor program. It is appended to the path name associated
with the directory object that is being used (either the directory_spec or the default
directory for the external table). The file_spec cannot contain an absolute or relative
directory path.
If the preprocessor program requires any arguments (for example, gunzip -c), then
you must specify the program name and its arguments in an executable shell script (or
on Windows operating systems, in a batch (.bat) file). Shell scripts and batch files have
certain requirements, as discussed in the following sections.
It is important to verify that the correct version of the preprocessor program is in the
operating system directory.
The following is an example of specifying the PREPROCESSOR clause without using a shell
or batch file:
SQL> CREATE TABLE xtab (recno varchar2(2000))
2 ORGANIZATION EXTERNAL (
3 TYPE ORACLE_LOADER
4 DEFAULT DIRECTORY data_dir
5 ACCESS PARAMETERS (
6 RECORDS DELIMITED BY NEWLINE
7 PREPROCESSOR execdir:'zcat'
8 FIELDS (recno char(2000)))
9 LOCATION ('foo.dat.gz'))
10 REJECT LIMIT UNLIMITED;
Table created.
15-12
Chapter 15
record_format_info Clause
15-13
Chapter 15
record_format_info Clause
preprocessor exec_dir:'sed.bat'
fields terminated by ','
missing field values are null
)
location ('deptxt.dat')
)
reject limit unlimited ;
10,ACCOUNTING,NEW YORK
20,RESEARCH,DALLAS
30,SALES,CHICAGO
40,OPERATIONS,BOSTON
The PREPROCESSOR option passes the input data (deptxt.dat) to sed.bat. If you then
select from the deptxt table, the results show that the LOC column in the last row, which
used to be BOSTON, is now CALIFORNIA.
SQL> select * from deptxt ;
DE DNAME LOC
-- -------------- -------------
1a ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS CALIFORNIA
4 rows selected.
15-14
Chapter 15
record_format_info Clause
See Also:
• Oracle Database VLDB and Partitioning Guide for more information about
granules of parallelism
15.2.8 LANGUAGE
The LANGUAGE clause allows you to specify a language name (for example, FRENCH),
from which locale-sensitive information about the data can be derived. The following
are some examples of the type of information that can be derived from the language
name:
• Day and month names and their abbreviations
• Symbols for equivalent expressions for A.M., P.M., A.D., and B.C.
• Default sorting sequence for character data when the ORDER BY SQL clause is
specified
• Writing direction (right to left or left to right)
• Affirmative and negative response strings (for example, YES and NO)
See Also:
Oracle Database Globalization Support Guide for a listing of Oracle-supported
languages
15.2.9 TERRITORY
The TERRITORY clause allows you to specify a territory name to further determine input
data characteristics. For example, in some countries a decimal point is used in
numbers rather than a comma (for example, 531.298 instead of 531,298).
See Also:
Oracle Database Globalization Support Guide for a listing of Oracle-supported
territories
15-15
Chapter 15
record_format_info Clause
• UNSIGNED INTEGER
• FLOAT
• BINARY_FLOAT
• DOUBLE
• BINARY_DOUBLE
If the BOM is checked in the Unicode data file and the data is actually big-endian,
then an error is returned because you specified little-endian.
• If a BOM is not found and no endianness is specified with the DATA IS...ENDIAN
parameter, then the endianness of the platform is used.
15-16
Chapter 15
record_format_info Clause
See Also:
"Byte Ordering"
• If the condition specification references only ranges (and no field names), then the
clause is evaluated before the fields are parsed. This is useful for cases where the
records in the file that are not to be loaded cannot be parsed into the current
record definition without errors.
See "condition_spec".
The following are some examples of using LOAD WHEN:
LOAD WHEN (empid != BLANKS)
LOAD WHEN ((dept_id = "SPORTING GOODS" OR dept_id = "SHOES") AND total_sales != 0)
15-17
Chapter 15
record_format_info Clause
where %p is replaced with the PID of the process creating the file. The file is given an
extension of .bad. If the table name contains any characters that could be interpreted
as directory navigation (for example, %, /, or *), then those characters are not included
in the output file name.
Records that fail the LOAD WHEN clause are not written to the bad file but are written to
the discard file instead. Also, any errors in using a record from an external table (such
as a constraint violation when using INSERT INTO...AS SELECT... from an external
table) will not cause the record to be written to the bad file.
If you specify DISCARDFILE, then you must supply either a directory object name or file
name, or both. See "[directory object name:] [filename]".
If neither DISCARDFILE nor NODISCARDFILE is specified, then the default is to create a
discard file if at least one record fails the LOAD WHEN clause. The name of the file is the
table name followed by _%p, where %p is replaced with the PID of the process creating
the file. The file is given an extension of .dcs. If the table name contains any
characters that could be interpreted as directory navigation (for example, %, /, or *),
then those characters are not included in the file name.
If you specify LOGFILE, then you must supply either a directory object name or file
name, or both. See "[directory object name:] [filename]".
If neither LOGFILE nor NOLOGFILE is specified, then the default is to create a log file. The
name of the file is the table name followed by _%p, where %p is replaced with the PID of
the process creating the file. The file is given an extension of .log. If the table name
contains any characters that could be interpreted as directory navigation (for example,
%, /, or *), then those characters are not included in the file name.
15.2.17 SKIP
The SKIP parameter skips the specified number of records in the data file before
loading. It can be specified only when nonparallel access is being made to the data. If
there is more than one data file in the same location for the same table, then the SKIP
parameter skips the specified number of records in the first data file only.
15-18
Chapter 15
record_format_info Clause
• FIRST — Indicates that the first data file contains a list of field names for the data in
the first record. This list uses the same delimiter as the data in the data file. This
record is read and used to set up the mapping between the fields in the data file
and the columns in the target table. This record is skipped when the data is
processed. This can be useful if the order of the fields in the data file is different
from the order of the columns in the table, or if the number of fields in the data file
is different from the number of columns in the target table.
• FIRST IGNORE — Indicates that the first data file contains a list of field names for the
data in the first record, but that the information should be ignored. This record is
skipped when the data is processed, but is not used for setting up the fields.
• ALL — Indicates that all data files contain the list of column names for the data in
the first record. The first record is skipped in each data file when the data is
processed. It is assumed that the list is the same in each data file. If that is not the
case, then the load terminates when a mismatch is found on a data file.
• ALL IGNORE — Indicates that all data files contain a list of field names for the data in
the first record, but that the information should be ignored. This record is skipped
when the data is processed in every data file, but it is not used for setting up the
fields.
• NONE — Indicates that the data file contains normal data in the first record. This is
the default option.
15.2.19 READSIZE
The READSIZE parameter specifies the size of the read buffer used to process records.
The size of the read buffer must be at least as big as the largest input record the
access driver will encounter. The size is specified with an integer indicating the
number of bytes. The default value is 512 KB (524288 bytes). You must specify a
larger value if any of the records in the data file are larger than 512 KB. There is no
limit on how large READSIZE can be, but practically, it is limited by the largest amount of
memory that can be allocated by the access driver.
The amount of memory available for allocation is another limit because additional
buffers might be allocated. The additional buffer is used to correctly complete the
processing of any records that may have been split (either in the data; at the delimiter;
or if multi character/byte delimiters are used, in the delimiter itself).
15.2.20 DISABLE_DIRECTORY_LINK_CHECK
By default, the ORACLE_LOADER access driver checks before opening data and log files to
ensure that the directory being used is not a symbolic link. The
DISABLE_DIRECTORY_LINK_CHECK parameter (which takes no arguments) directs the
access driver to bypass this check, allowing you to use files for which the parent
directory may be a symbolic link.
15-19
Chapter 15
record_format_info Clause
Note:
Use of this parameter involves security risks because symbolic links can
potentially be used to redirect the input/output of the external table load
operation.
15.2.21 DATE_CACHE
By default, the date cache feature is enabled (for 1000 elements). To completely
disable the date cache feature, set it to 0.
DATE_CACHE specifies the date cache size (in entries). For example, DATE_CACHE=5000
specifies that each date cache created can contain a maximum of 5000 unique date
entries. Every table has its own date cache, if one is needed. A date cache is created
only if at least one date or timestamp value is loaded that requires data type
conversion in order to be stored in the table.
The date cache feature is enabled by default. The default date cache size is 1000
elements. If the default size is used and the number of unique input values loaded
exceeds 1000, then the date cache feature is automatically disabled for that table.
However, if you override the default and specify a nonzero date cache size and that
size is exceeded, then the cache is not disabled.
You can use the date cache statistics (entries, hits, and misses) contained in the log
file to tune the size of the cache for future similar loads.
See Also:
"Specifying a Value for the Date Cache"
15.2.22 string
A string is a quoted series of characters or hexadecimal digits. If it is a series of
characters, then those characters will be converted into the character set of the data
file. If it is a series of hexadecimal digits, then there must be an even number of
hexadecimal digits. The hexadecimal digits are converted into their binary translation,
and the translation is treated as a character string in the character set of the data file.
This means that once the hexadecimal digits have been converted into their binary
translation, there is no other character set translation that occurs. The syntax for a
string is as follows:
’ text ’
15-20
Chapter 15
record_format_info Clause
15.2.23 condition_spec
The condition_spec is an expression that evaluates to either true or false. It specifies
one or more conditions that are joined by Boolean operators. The conditions and
Boolean operators are evaluated from left to right. (Boolean operators are applied after
the conditions are evaluated.) Parentheses can be used to override the default order
of evaluation of Boolean operators. The evaluation of condition_spec clauses slows
record processing, so these clauses should be used sparingly. The syntax for
condition_spec is as follows:
condition
AND
condition_spec condition_spec
OR
condition
( )
AND
condition_spec condition_spec
OR
Note that if the condition specification contains any conditions that reference field
names, then the condition specifications are evaluated only after all fields have been
found in the record and after blank trimming has been done. It is not useful to compare
a field to BLANKS if blanks have been trimmed from the field.
See Also:
"condition"
The filename parameter is the name of the file to create in the directory object. The
access driver does some symbol substitution to help make file names unique in
parallel loads. The symbol substitutions supported for the UNIX and Windows
operating systems are as follows (other platforms may have different symbols):
15-21
Chapter 15
record_format_info Clause
• %a is replaced by the agent number of the current process. The agent number is
the unique number assigned to each parallel process accessing the external table.
This number is padded to the left with zeros to fill three characters. For example, if
the third parallel agent is creating a file and bad_data_%a.bad was specified as the
file name, then the agent would create a file named bad_data_003.bad.
• %% is replaced by %. If there is a need to have a percent sign in the file name, then
this symbol substitution is used.
If the % character is encountered followed by anything other than one of the preceding
characters, then an error is returned.
If %p or %a is not used to create unique file names for output files and an external table
is being accessed in parallel, then output files may be corrupted or agents may be
unable to write to the files.
If you do not specify BADFILE (or DISCARDFILE or LOGFILE), then the access driver uses
the name of the table followed by _%p as the name of the file. If no extension is
supplied for the file, then a default extension will be used. For bad files, the default
extension is .bad; for discard files, the default is .dsc; and for log files, the default
is .log.
15.2.25 condition
A condition compares a range of bytes or a field from the record against a constant
string. The source of the comparison can be either a field in the record or a byte range
in the record. The comparison is done on a byte-by-byte basis. If a string is specified
as the target of the comparison, then it will be translated into the character set of the
data file. If the field has a noncharacter data type, then no data type conversion is
performed on either the field value or the string. The syntax for a condition is as
follows:
AND
’string’
( FIELDNAME )
operator ’hexstring’
( range start : range end )
BLANKS
15-22
Chapter 15
record_format_info Clause
Note:
The data file should not mix binary data (including data types with binary
counts, such as VARCHAR) and character data that is in a varying-width character
set or more than one byte wide. In these cases, the access driver may not find
the correct start for the field, because it treats the binary data as character data
when trying to find the start.
The DIRECTIO option is used by default, so an attempt is made to open the data file and
read it using direct I/O. If successful, then the operating system and NFS server (if the
file is on an NFS server) do not cache the data read from the file. This can improve the
read performance for the data file, especially if the file is large. If direct I/O is not
supported for the data file being read, then the file is opened and read but the DIRECTIO
option is ignored.
If the IO_OPTIONS clause is specified with the NODIRECTIO option, then direct I/O is not
used to read the data files.
If the IO_OPTIONS clause is not specified at all, then the default DIRECTIO option is used.
To disable use of the Direct NFS Client for all data files, specify DNFS_DISABLE.
See Also:
• Oracle Grid Infrastructure Installation Guide for Linux for information about
enabling Direct NFS Client Oracle Disk Manager Control of NFS
15-23
Chapter 15
field_definitions Clause
15.2.28 DNFS_READBUFFERS
Use DNFS_READBUFFERS to control the number of read buffers used by the Direct NFS
Client. The Direct NFS Client is an API that can be implemented by file servers to
allow improved performance when Oracle accesses files on those servers.
The default value for DNFS_READBUFFERS is 4.
Using larger values might compensate for inconsistent I/O from the Direct NFS Client
file server, but it may result in increased memory usage.
See Also:
• Oracle Grid Infrastructure Installation Guide for Linux for information about
enabling Direct NFS Client Oracle Disk Manager Control of NFS
Alvin,Tolliver,1976
Kenneth,Baer,1963
15-24
Chapter 15
field_definitions Clause
IGNORE_CHARS_AFTER_EOR
WITH
EMBEDDED
WITHOUT
CSV
delim_spec
trim_spec
DATE
TIMESTAMP
DATE_FORMAT MASK string
NULLIF
NONULLIF
IGNORE_CHARS_AFTER_EOR
This optional parameter specifies that if extraneous characters are found after the last
end-of-record but before the end of the file that do not satisfy the record definition,
they will be ignored.
Error messages are written to the external tables log file if all four of the following
conditions apply:
• The IGNORE_CHARS_AFTER_EOR parameter is set or the field allows free formatting.
(Free formatting means either that the field is variable length or the field is
specified by a delimiter or enclosure characters and is also variable length).
• Characters remain after the last end-of-record in the file.
• The access parameter MISSING FIELD VALUES ARE NULL is not set.
• The field does not have absolute positioning.
The error messages that get written to the external tables log file are as follows:
KUP-04021: field formatting error for field Col1
KUP-04023: field start is after end of record
KUP-04101: record 2 rejected in file /home/oracle/datafiles/example.dat
CSV
To direct external tables to access the data files as comma-separated-values format
files, use the FIELDS CSV clause. This assumes that the file is a stream record format file
with the normal carriage return string (for example, \n on UNIX or Linux operating
systems and either \n or \r\n on Windows operating systems). Record terminators can
be included (embedded) in data values. The syntax for the FIELDS CSV clause is as
follows:
FIELDS CSV [WITH EMBEDDED | WITHOUT EMBEDDED] [TERMINATED BY ','] [OPTIONALLY
ENCLOSED BY '"']
The following are key points regarding the FIELDS CSV clause:
15-25
Chapter 15
field_definitions Clause
• The WITH EMBEDDED and WITHOUT EMBEDDED options specify whether record terminators
are included (embedded) in the data. The WITH EMBEDDED option is the default.
• If WITH EMBEDDED is used, then embedded record terminators must be enclosed, and
intra-datafile parallelism is disabled for external table loads.
• The TERMINATED BY ',' and OPTIONALLY ENCLOSED BY '"' options are the defaults
and do not have to be specified. You can override them with different termination
and enclosure characters.
• When the CSV clause is used, a delimiter specification is not allowed at the field
level and only delimitable data types are allowed. Delimitable data types include
CHAR, datetime, interval, and numeric EXTERNAL.
• The TERMINATED BY and ENCLOSED BY clauses cannot be used at the field level when
the CSV clause is specified.
• When the CSV clause is specified, the default trimming behavior is LDRTRIM. You can
override this by specifying one of the other external table trim options (NOTRIM,
LRTRIM, LTRIM, or RTRIM).
• The CSV clause must be specified after the IGNORE_CHARS_AFTER_EOR clause and
before the delim_spec clause.
delim_spec Clause
The delim_spec clause is used to identify how all fields are terminated in the record.
The delim_spec specified for all fields can be overridden for a particular field as part of
the field_list clause. For a full description of the syntax, see "delim_spec".
trim_spec Clause
The trim_spec clause specifies the type of whitespace trimming to be performed by
default on all character fields. The trim_spec clause specified for all fields can be
overridden for individual fields by specifying a trim_spec clause for those fields. For a
full description of the syntax, see "trim_spec".
15-26
Chapter 15
field_definitions Clause
DATE_FORMAT
The DATE_FORMAT clause allows you to specify a datetime format mask once at the fields
level, and have it apply to all fields of that type which do not have their own mask
specified. The datetime format mask must be specified after the optional REJECT ROWS
WITH ALL NULL FIELDS clause and before the fields_list clause.
The DATE_FORMAT can be specified for the following datetime types: DATE, TIME, TIME WITH
TIME ZONE, TIMESTAMP, and TIMESTAMP WITH TIME ZONE.
The following example shows a sample use of the DATE_FORMAT clause that applies a
date mask of DD-Month-YYYY to any DATE type fields:
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
DATE_FORMAT DATE MASK "DD-Month-YYYY"
(
EMPNO,
ENAME,
JOB,
MGR,
HIREDATE CHAR(20),
SAL,
COMM,
DEPTNO,
PROJNO,
ENTRYDATE CHAR(20)
)
NULLIF | NO NULLIF
The NULLIF clause applies to all character fields (for example, CHAR, VARCHAR, VARCHARC,
external NUMBER, and datetime).
If there is a match using the equal or not equal specification for a field, then the field is
set to NULL for that row.
The char_string and hex_string must be enclosed in single or double quotation marks.
If a NULLIF specification is specified at the field level, it overrides this NULLIF clause.
15-27
Chapter 15
field_definitions Clause
If there is a field to which you do not want the NULLIF clause to apply, you can specify
NO NULLIF at the field level (as shown in the following example).
The NULLIF clause must be specified after the optional REJECT ROWS WITH ALL NULL
FIELDS clause and before the fields_list clause.
The following is an example of using the NULLIF clause. The MGR field is set to NO NULLIF
which means that the NULLIF="NONE" clause will not apply to that field.
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
NULLIF = "NONE"
(
EMPNO,
ENAME,
JOB,
MGR
)
field_list Clause
The field_list clause identifies the fields in the data file and their data types. For a full
description of the syntax, see "field_list".
• delim_spec
• trim_spec
• MISSING FIELD VALUES ARE NULL
• field_list
• pos_spec Clause
• datatype_spec Clause
• init_spec Clause
• LLS Clause
If a field in a data file is a LOB location Specifier (LLS) field, then you can indicate
this by using the LLS clause.
15.3.1 delim_spec
The delim_spec clause is used to find the end (and if ENCLOSED BY is specified, the start)
of a field. Its syntax is as follows:
AND string
ENCLOSED BY string
If ENCLOSED BY is specified, then the access driver starts at the current position in the
record and skips over all whitespace looking for the first delimiter. All whitespace
between the current position and the first delimiter is ignored. Next, the access driver
looks for the second enclosure delimiter (or looks for the first one again if a second
15-28
Chapter 15
field_definitions Clause
one is not specified). Everything between those two delimiters is considered part of the
field.
If TERMINATED BY string is specified with the ENCLOSED BY clause, then the terminator
string must immediately follow the second enclosure delimiter. Any whitespace
between the second enclosure delimiter and the terminating delimiter is skipped. If
anything other than whitespace is found between the two delimiters, then the row is
rejected for being incorrectly formatted.
If TERMINATED BY is specified without the ENCLOSED BY clause, then everything between
the current position in the record and the next occurrence of the termination string is
considered part of the field.
If OPTIONALLY is specified, then TERMINATED BY must also be specified. The OPTIONALLY
parameter means the ENCLOSED BY delimiters can either both be present or both be
absent. The terminating delimiter must be present regardless of whether the ENCLOSED
BY delimiters are present. If OPTIONALLY is specified, then the access driver skips over
all whitespace, looking for the first nonblank character. Once the first nonblank
character is found, the access driver checks to see if the current position contains the
first enclosure delimiter. If it does, then the access driver finds the second enclosure
string and everything between the first and second enclosure delimiters is considered
part of the field. The terminating delimiter must immediately follow the second
enclosure delimiter (with optional whitespace allowed between the second enclosure
delimiter and the terminating delimiter). If the first enclosure string is not found at the
first nonblank character, then the access driver looks for the terminating delimiter. In
this case, leading blanks are trimmed.
See Also:
Trimming Whitespace for a description of the access driver's default trimming
behavior. You can override this behavior with LTRIM and RTRIM.
After the delimiters have been found, the current position in the record is set to the
spot after the last delimiter for the field. If TERMINATED BY WHITESPACE was specified, then
the current position in the record is set to after all whitespace following the field.
A missing terminator for the last field in the record is not an error. The access driver
proceeds as if the terminator was found. It is an error if the second enclosure delimiter
is missing.
The string used for the second enclosure can be included in the data field by including
the second enclosure twice. For example, if a field is enclosed by single quotation
marks, then it could contain a single quotation mark by specifying two single quotation
marks in a row, as shown in the word don't in the following example:
'I don''t like green eggs and ham'
There is no way to quote a terminator string in the field data without using enclosing
delimiters. Because the field parser does not look for the terminating delimiter until
after it has found the enclosing delimiters, the field can contain the terminating
delimiter.
In general, specifying single characters for the strings is faster than multiple
characters. Also, searching data in fixed-width character sets is usually faster than
searching data in varying-width character sets.
15-29
Chapter 15
field_definitions Clause
Note:
The use of the backslash character (\) within strings is not supported in external
tables.
(Alvin) , (Tolliver),(1976)
(Kenneth), (Baer) ,(1963)
(Mary),(Dube) , (1973)
15-30
Chapter 15
field_definitions Clause
15.3.2 trim_spec
The trim_spec clause is used to specify that spaces should be trimmed from the
beginning of a text field, the end of a text field, or both. Spaces include blanks and
other nonprinting characters such as tabs, line feeds, and carriage returns. The syntax
for the trim_spec clause is as follows:
LRTRIM
NOTRIM
LTRIM
RTRIM
LDRTRIM
LRTRIM, LTRIM, and RTRIM are used to indicate that characters should be trimmed from
the field. LRTRIM means that both leading and trailing spaces are trimmed. LTRIM means
that leading spaces will be trimmed. RTRIM means trailing spaces are trimmed.
LDRTRIM is used to provide compatibility with SQL*Loader trim features. It is the same
as NOTRIM except in the following cases:
• If the field is not a delimited field, then spaces will be trimmed from the right.
• If the field is a delimited field with OPTIONALLY ENCLOSED BY specified, and the
optional enclosures are missing for a particular instance, then spaces will be
trimmed from the left.
The default is LDRTRIM. Specifying NOTRIM yields the fastest performance.
The trim_spec clause can be specified before the field list to set the default trimming
for all fields. If trim_spec is omitted before the field list, then LDRTRIM is the default trim
setting. The default trimming can be overridden for an individual field as part of the
datatype_spec.
If trimming is specified for a field that is all spaces, then the field will be set to NULL.
In the following example, all data is fixed-length; however, the character data will not
be loaded with leading spaces. The example is followed by a sample of the data file
that can be used to load it.
CREATE TABLE emp_load (first_name CHAR(15), last_name CHAR(20),
year_of_birth CHAR(4))
ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS (FIELDS LTRIM)
LOCATION ('info.dat'));
Alvin, Tolliver,1976
Kenneth, Baer, 1963
Mary, Dube, 1973
15-31
Chapter 15
field_definitions Clause
Alvin,Tolliver,1976
Baer,Kenneth
Mary,Dube,1973
15.3.4 field_list
The field_list clause identifies the fields in the data file and their data types.
Evaluation criteria for the field_list clause are as follows:
Alvin|Tolliver|1976
15-32
Chapter 15
field_definitions Clause
Kenneth|Baer|1963
Mary|Dube|1973
field_name
The field_name is a string identifying the name of a field in the data file. If the string is
not within quotation marks, then the name is uppercased when matching field names
with column names in the external table.
If field_name matches the name of a column in the external table that is referenced in
the query, then the field value is used for the value of that external table column. If the
name does not match any referenced name in the external table, then the field is not
loaded but can be used for clause evaluation (for example WHEN or NULLIF).
pos_spec
The pos_spec clause indicates the position of the column within the record. For a full
description of the syntax, see "pos_spec Clause".
datatype_spec
The datatype_spec clause indicates the data type of the field. If datatype_spec is
omitted, then the access driver assumes the data type is CHAR(255). For a full
description of the syntax, see "datatype_spec Clause".
init_spec
The init_spec clause indicates when a field is NULL or has a default value. For a full
description of the syntax, see "init_spec Clause".
LLS Clause
When LLS is specified for a field, ORACLE_LOADER does not load the value of the field into
the corresponding column. Instead, it use the information in the value to determine
where to find the value of the field. See LLS Clause.
15-33
Chapter 15
field_definitions Clause
start
POSITION : end
( * )
– length
+
increment
–
• start
• *
• increment
• end
• length
15.3.5.1 start
The start parameter is the number of bytes or characters from the beginning of the
record to where the field begins. It positions the start of the field at an absolute spot in
the record rather than relative to the position of the previous field.
15.3.5.2 *
The * parameter indicates that the field begins at the first byte or character after the
end of the previous field. This is useful if you have a varying-length field followed by a
fixed-length field. This option cannot be used for the first field in the record.
15.3.5.3 increment
The increment parameter positions the start of the field at a fixed number of bytes or
characters from the end of the previous field. Use *-increment to indicate that the start
of the field starts before the current position in the record (this is a costly operation for
multibyte character sets). Use *+increment to move the start after the current position.
15.3.5.4 end
The end parameter indicates the absolute byte or character offset into the record for
the last byte of the field. If start is specified along with end, then end cannot be less
than start. If * or increment is specified along with end, and the start evaluates to an
offset larger than the end for a particular record, then that record will be rejected.
15.3.5.5 length
The length parameter indicates that the end of the field is a fixed number of bytes or
characters from the start. It is useful for fixed-length fields when the start is specified
with *.
15-34
Chapter 15
field_definitions Clause
phone CHAR(12),
area_code CHAR(3),
exchange CHAR(3),
extension CHAR(4))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS
(FIELDS RTRIM
(first_name (1:15) CHAR(15),
last_name (*:+20),
year_of_birth (36:39),
phone (40:52),
area_code (*-12: +3),
exchange (*+1: +3),
extension (*+1: +4)))
LOCATION ('info.dat'));
15-35
Chapter 15
field_definitions Clause
( len ) delim_spec
EXTERNAL
DECIMAL
, scale
ZONED ( precision )
ORACLE_DATE
COUNTED
ORACLE_NUMBER
DOUBLE
BINARY_DOUBLE
( len )
RAW
VARCHAR
VARRAW length_of_length ,
( max_len )
VARCHARC
VARRAWC
If the number of bytes or characters in any field is 0, then the field is assumed to be
NULL. The optional DEFAULTIF clause specifies when the field is set to its default value.
Also, the optional NULLIF clause specifies other conditions for when the column
associated with the field is set to NULL. If the DEFAULTIF or NULLIF clause is TRUE, then
the actions of those clauses override whatever values are read from the data file.
15-36
Chapter 15
field_definitions Clause
• CHAR
• date_format_spec
• VARCHAR and VARRAW
• VARCHARC and VARRAWC
See Also:
Note that there are different encoding formats of zoned decimal numbers depending
on whether the character set being used is EBCDIC-based or ASCII-based. If the
language of the source data is EBCDIC, then the zoned decimal numbers in that file
must match the EBCDIC encoding. If the language is ASCII-based, then the numbers
must match the ASCII encoding.
If the EXTERNAL parameter is specified, then the data field is a character string whose
length matches the precision of the field.
15-37
Chapter 15
field_definitions Clause
15.3.6.3 ORACLE_DATE
ORACLE_DATE is a field containing a date in the Oracle binary date format. This is the
format used by the DTYDAT data type in Oracle Call Interface (OCI) programs. The field
is a fixed length of 7.
15.3.6.4 ORACLE_NUMBER
ORACLE_NUMBER is a field containing a number in the Oracle number format. The field is a
fixed length (the maximum size of an Oracle number field) unless COUNTED is specified,
in which case the first byte of the field contains the number of bytes in the rest of the
field.
ORACLE_NUMBER is a fixed-length 22-byte field. The length of an ORACLE_NUMBER COUNTED
field is one for the count byte, plus the number of bytes specified in the count byte.
Note:
See Oracle Database SQL Language Reference for more information about
floating-point numbers
15.3.6.6 DOUBLE
The DOUBLE clause indicates that the field is the same format as the C language DOUBLE
data type on the platform where the access driver is executing. Use of the DATA IS {BIG
| LITTLE} ENDIAN clause may cause the data to be byte-swapped before it is stored.
This data type may not be portable between certain platforms.
15-38
Chapter 15
field_definitions Clause
15.3.6.8 BINARY_DOUBLE
BINARY_DOUBLE is a 64-bit, double-precision, floating-point number data type. Each
BINARY_DOUBLE value requires 9 bytes, including a length byte. See the information in
the note provided for the FLOAT data type for more details about floating-point numbers.
15.3.6.9 BINARY_FLOAT
BINARY_FLOAT is a 32-bit, single-precision, floating-point number data type. Each
BINARY_FLOAT value requires 5 bytes, including a length byte. See the information in the
note provided for the FLOAT data type for more details about floating-point numbers.
15.3.6.10 RAW
The RAW clause is used to indicate that the source data is binary data. The len for RAW
fields is always in number of bytes. When a RAW field is loaded in a character column,
the data that is written into the column is the hexadecimal representation of the bytes
in the RAW field.
15.3.6.11 CHAR
The CHAR clause is used to indicate that a field is a character data type. The length
(len) for CHAR fields specifies the largest number of bytes or characters in the field. The
len is in bytes or characters, depending on the setting of the STRING SIZES ARE IN
clause.
If no length is specified for a field of data type CHAR, then the size of the field is
assumed to be 1, unless the field is delimited:
• For a delimited CHAR field, if a length is specified, then that length is used as a
maximum.
• For a delimited CHAR field for which no length is specified, the default is 255 bytes.
• For a delimited CHAR field that is greater than 255 bytes, you must specify a
maximum length. Otherwise you will receive an error stating that the field in the
data file exceeds maximum length.
The following example shows the use of the CHAR clause.
SQL> CREATE TABLE emp_load
2 (employee_number CHAR(5),
3 employee_dob CHAR(20),
4 employee_last_name CHAR(20),
5 employee_first_name CHAR(15),
6 employee_middle_name CHAR(15),
7 employee_hire_date DATE)
8 ORGANIZATION EXTERNAL
9 (TYPE ORACLE_LOADER
10 DEFAULT DIRECTORY def_dir1
11 ACCESS PARAMETERS
12 (RECORDS DELIMITED BY NEWLINE
13 FIELDS (employee_number CHAR(2),
14 employee_dob CHAR(20),
15 employee_last_name CHAR(18),
16 employee_first_name CHAR(11),
17 employee_middle_name CHAR(11),
15-39
Chapter 15
field_definitions Clause
Table created.
15.3.6.12 date_format_spec
The date_format_spec clause is used to indicate that a character string field contains
date data, time data, or both, in a specific format. This information is used only when a
character field is converted to a date or time data type and only when a character
string field is mapped into a date column.
For detailed information about the correct way to specify date and time formats, see
Oracle Database SQL Language Reference.
The syntax for the date_format_spec clause is as follows:
DATE
YEAR_TO_MONTH
INTERVAL
DAY_TO_SECOND
• DATE
• MASK
• TIMESTAMP
• INTERVAL
15.3.6.12.1 DATE
The DATE clause indicates that the string contains a date.
15.3.6.12.2 MASK
The MASK clause is used to override the default globalization format mask for the data
type. If a date mask is not specified, then the settings of NLS parameters for the
database (not the session settings) for the appropriate globalization parameter for the
data type are used. The NLS_DATABASE_PARAMETERS view shows these settings.
15-40
Chapter 15
field_definitions Clause
15.3.6.12.3 TIMESTAMP
The TIMESTAMP clause indicates that a field contains a formatted timestamp.
15.3.6.12.4 INTERVAL
The INTERVAL clause indicates that a field contains a formatted interval. The type of
interval can be either YEAR TO MONTH or DAY TO SECOND.
The following example shows a sample use of a complex DATE character string and a
TIMESTAMP character string. It is followed by a sample of the data file that can be used
to load it.
SQL> CREATE TABLE emp_load
2 (employee_number CHAR(5),
3 employee_dob CHAR(20),
4 employee_last_name CHAR(20),
5 employee_first_name CHAR(15),
6 employee_middle_name CHAR(15),
7 employee_hire_date DATE,
8 rec_creation_date TIMESTAMP WITH TIME ZONE)
9 ORGANIZATION EXTERNAL
10 (TYPE ORACLE_LOADER
11 DEFAULT DIRECTORY def_dir1
12 ACCESS PARAMETERS
13 (RECORDS DELIMITED BY NEWLINE
14 FIELDS (employee_number CHAR(2),
15 employee_dob CHAR(20),
16 employee_last_name CHAR(18),
17 employee_first_name CHAR(11),
18 employee_middle_name CHAR(11),
19 employee_hire_date CHAR(22) date_format DATE mask "mm/dd/yyyy hh:mi:ss AM",
20 rec_creation_date CHAR(35) date_format TIMESTAMP WITH TIME ZONE mask "DD-MON-RR
HH.MI.SSXFF AM TZH:TZM"
21 )
22 )
23 LOCATION ('infoc.dat')
24 );
Table created.
15-41
Chapter 15
field_definitions Clause
2 rows selected.
The info.dat file looks like the following. Note that this is 2 long records. There is one
space between the data fields (09/01/2004, 01/01/2002) and the time field that follows.
56november, 15, 1980 baker mary alice 09/01/2004 08:23:01 AM01-DEC-04
11.22.03.034567 AM -08:00
87december, 20, 1970 roper lisa marie 01/01/2002 02:44:55 PM01-DEC-02
02.03.00.678573 AM -08:00
The VARIABLE 2 clause in the ACCESS PARAMETERS clause specifies the size of the binary
field that contains the length.
The optional length_of_length field in the specification is the number of bytes in the
count field. Valid values for length_of_length for VARCHAR are 1, 2, 4, and 8. If
length_of_length is not specified, then a value of 2 is used. The count field has the
same endianness as specified by the DATA IS…ENDIAN clause.
The max_len field is used to indicate the largest size of any instance of the field in the
data file. For VARRAW fields, max_len is number of bytes. For VARCHAR fields, max_len is
either number of characters or number of bytes depending on the STRING SIZES ARE IN
clause.
The following example shows various uses of VARCHAR and VARRAW. The content of the
data file, info.dat, is shown following the example.
CREATE TABLE emp_load
(first_name CHAR(15),
last_name CHAR(20),
resume CHAR(2000),
picture RAW(2000))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS
(RECORDS
VARIABLE 2
DATA IS BIG ENDIAN
CHARACTERSET US7ASCII
FIELDS (first_name VARCHAR(2,12),
last_name VARCHAR(2,20),
resume VARCHAR(4,10000),
picture VARRAW(4,100000)))
LOCATION ('info.dat'));
15-42
Chapter 15
field_definitions Clause
15-43
Chapter 15
field_definitions Clause
DEFAULTIF
condition_spec
NULLIF
Only one NULLIF clause and only one DEFAULTIF clause can be specified for any field.
These clauses behave as follows:
• If NULLIF condition_spec is specified and it evaluates to TRUE, then the field is set to
NULL.
An LLS field contains the file name, offset, and length of the LOB data in the data file.
SQL*Loader uses this information to read data for the LOB column. The LLS clause for
ORACLE_LOADER has the following syntax:
When the LLS clause is used, ORACLE_LOADER does not load the value of the field into the
corresponding column. Instead, it uses the information in the value to determine where
to find the value of the field. The LOB can be loaded in part or in whole and it can start
from an arbitrary position and for an arbitrary length. ORACLE_LOADER expects the
contents of the field to be filename.ext.nnn.mmm/ where each element is defined as
follows:
• filename.ext is the name of the file that contains the LOB
• mmm is the length of the LOB in bytes A value of -1 means the LOB is NULL. A
value of 0 means the lob exists, but is empty.
• The forward slash (/) terminates the field
The LLS clause has an optional DIRECTORY clause which specifies an Oracle directory
object:
15-44
Chapter 15
column_transforms Clause
• If DIRECTORY is specified, then the file must exist there and you must have READ
access to that directory object.
• If DIRECTORY is not specified, then the file must exist in the same directory as the
data file.
An error is returned and the row rejected if any of the following are true:
• The file name contains a relative or absolute path specification.
• The file is not found, the offset is invalid, or the length extends beyond the end of
the file.
• The contents of the field do not match the expected format.
• The data type for the column associated with an LLS field is not a CLOB, BLOB or
NCLOB.
If an LLS field is referenced by a clause for any other field (for example a NULLIF
clause), then in the access parameters, the value used for evaluating the clause is the
string in the data file, not the data in the file pointed to by that string.
The character set for the data in the file pointed to by the LLS clause is assumed to be
the same character set as the data file.
Note:
The COLUMN TRANSFORMS clause does not work in conjunction with the
PREPROCESSOR clause.
• transform
15.4.1 transform
Each transform specified in the transform clause identifies a column in the external
table and then a specifies how to calculate the value of the column. The syntax is as
follows:
15-45
Chapter 15
column_transforms Clause
NULL
CONSTANT string
field_name
CONCAT ( )
column_name FROM CONSTANT string
fieldname lobfile_attr_list
LOBFILE ( )
CONSTANT string :
The NULL transform is used to set the external table column to NULL in every row. The
CONSTANT transform is used to set the external table column to the same value in every
row. The CONCAT transform is used to set the external table column to the concatenation
of constant strings and/or fields in the current record from the data file. The LOBFILE
transform is used to load data into a field for a record from another data file. Each of
these transforms is explained further in the following sections.
• column_name FROM
• NULL
• CONSTANT
• CONCAT
• LOBFILE
• lobfile_attr_list
• STARTOF source_field (length)
15.4.1.2 NULL
When the NULL transform is specified, every value of the field is set to NULL for every
record.
15.4.1.3 CONSTANT
The CONSTANT transform uses the value of the string specified as the value of the
column in the record. If the column in the external table is not a character string type,
then the constant string will be converted to the data type of the column. This
conversion will be done for every row.
The character set of the string used for data type conversions is the character set of
the database.
15-46
Chapter 15
column_transforms Clause
15.4.1.4 CONCAT
The CONCAT transform concatenates constant strings and fields in the data file together
to form one string. Only fields that are character data types and that are listed in the
fields clause can be used as part of the concatenation. Other column transforms
cannot be specified as part of the concatenation.
15.4.1.5 LOBFILE
The LOBFILE transform is used to identify a file whose contents are to be used as the
value for a column in the external table. All LOBFILEs are identified by an optional
directory object and a file name in the form directory object:filename. The following
rules apply to use of the LOBFILE transform:
• Both the directory object and the file name can be either a constant string or the
name of a field in the field clause.
• If a constant string is specified, then that string is used to find the LOBFILE for
every row in the table.
• If a field name is specified, then the value of that field in the data file is used to find
the LOBFILE.
• If a field name is specified for either the directory object or the file name and if the
value of that field is NULL, then the column being loaded by the LOBFILE is also set
to NULL.
• If the directory object is not specified, then the default directory specified for the
external table is used.
• If a field name is specified for the directory object, then the FROM clause also needs
to be specified.
Note that the entire file is used as the value of the LOB column. If the same file is
referenced in multiple rows, then that file is reopened and reread in order to populate
each column.
15.4.1.6 lobfile_attr_list
The lobfile_attr_list lists additional attributes of the LOBFILE. The syntax is as
follows:
CLOB
BLOB
The FROM clause lists the names of all directory objects that will be used for LOBFILEs.
It is used only when a field name is specified for the directory object of the name of the
LOBFILE. The purpose of the FROM clause is to determine the type of access allowed to
15-47
Chapter 15
column_transforms Clause
the named directory objects during initialization. If directory object in the value of field
is not a directory object in this list, then the row will be rejected.
The CLOB attribute indicates that the data in the LOBFILE is character data (as opposed
to RAW data). Character data may need to be translated into the character set used to
store the LOB in the database.
The CHARACTERSET attribute contains the name of the character set for the data in the
LOBFILEs.
The BLOB attribute indicates that the data in the LOBFILE is raw data.
If neither CLOB nor BLOB is specified, then CLOB is assumed. If no character set is
specified for character LOBFILEs, then the character set of the data file is assumed.
Table created.
15-48
Chapter 15
Parallel Loading Considerations for the ORACLE_LOADER Access Driver
If you now perform a SELECT operation from the dept table, only the first four bytes of
the dname field are returned:
SQL> SELECT * FROM dept;
4 rows selected.
15-49
Chapter 15
Restrictions When Using the ORACLE_LOADER Access Driver
Performance can also sometimes be increased with use of date cache functionality. By
using the date cache to specify the number of unique dates anticipated during the
load, you can reduce the number of date conversions done when many duplicate date
or timestamp values are present in the input data. The date cache functionality
provided by external tables is identical to the date cache functionality provided by
SQL*Loader. See "DATE_CACHE" for a detailed description.
In addition to changing the degree of parallelism and using the date cache to improve
performance, consider the following information:
• Fixed-length records are processed faster than records terminated by a string.
• Fixed-length fields are processed faster than delimited fields.
• Single-byte character sets are the fastest to process.
• Fixed-width character sets are faster to process than varying-width character sets.
• Byte-length semantics for varying-width character sets are faster to process than
character-length semantics.
• Single-character delimiters for record terminators and field delimiters are faster to
process than multicharacter delimiters.
• Having the character set in the data file match the character set of the database is
faster than a character set conversion.
• Having data types in the data file match the data types in the database is faster
than data type conversion.
• Not writing rejected rows to a reject file is faster because of the reduced overhead.
• Condition clauses (including WHEN, NULLIF, and DEFAULTIF) slow down processing.
• The access driver takes advantage of multithreading to streamline the work as
much as possible.
15-50
Chapter 15
Reserved Words for the ORACLE_LOADER Access Driver
create a view of the external table that uses the DECODE clause and select from that
view rather than the external table.
• The use of the backslash character (\) within strings is not supported in external
tables. See "Use of the Backslash Escape Character".
• When identifiers (for example, column or table names) are specified in the external
table access parameters, certain values are considered to be reserved words by
the access parameter parser. If a reserved word is used as an identifier, then it
must be enclosed in double quotation marks.
• ALL
• AND
• ARE
• ASTERISK
• AT
• ATSIGN
• BADFILE
• BADFILENAME
• BACKSLASH
• BENDIAN
• BIG
• BLANKS
• BY
• BYTES
• BYTESTR
• CHAR
• CHARACTERS
• CHARACTERSET
• CHARSET
• CHARSTR
• CHECK
• CLOB
• COLLENGTH
15-51
Chapter 15
Reserved Words for the ORACLE_LOADER Access Driver
• COLON
• COLUMN
• COMMA
• CONCAT
• CONSTANT
• COUNTED
• DATA
• DATE
• DATE_CACHE
• DATE_FORMAT
• DATEMASK
• DAY
• DEBUG
• DECIMAL
• DEFAULTIF
• DELIMITBY
• DELIMITED
• DISCARDFILE
• DNFS_ENABLE
• DNFS_DISABLE
• DNFS_READBUFFERS
• DOT
• DOUBLE
• DOUBLETYPE
• DQSTRING
• DQUOTE
• DSCFILENAME
• ENCLOSED
• ENDIAN
• ENDPOS
• EOF
• EQUAL
• EXIT
• EXTENDED_IO_PARAMETERS
• EXTERNAL
• EXTERNALKW
• EXTPARM
15-52
Chapter 15
Reserved Words for the ORACLE_LOADER Access Driver
• FIELD
• FIELDS
• FILE
• FILEDIR
• FILENAME
• FIXED
• FLOAT
• FLOATTYPE
• FOR
• FROM
• HASH
• HEXPREFIX
• IN
• INTEGER
• INTERVAL
• LANGUAGE
• IS
• LEFTCB
• LEFTTXTDELIM
• LEFTP
• LENDIAN
• LDRTRIM
• LITTLE
• LOAD
• LOBFILE
• LOBPC
• LOBPCCONST
• LOCAL
• LOCALTZONE
• LOGFILE
• LOGFILENAME
• LRTRIM
• LTRIM
• MAKE_REF
• MASK
• MINUSSIGN
• MISSING
15-53
Chapter 15
Reserved Words for the ORACLE_LOADER Access Driver
• MISSINGFLD
• MONTH
• NEWLINE
• NO
• NOCHECK
• NOT
• NOBADFILE
• NODISCARDFILE
• NOLOGFILE
• NOTEQUAL
• NOTERMBY
• NOTRIM
• NULL
• NULLIF
• OID
• OPTENCLOSE
• OPTIONALLY
• OPTIONS
• OR
• ORACLE_DATE
• ORACLE_NUMBER
• PLUSSIGN
• POSITION
• PROCESSING
• QUOTE
• RAW
• READSIZE
• RECNUM
• RECORDS
• REJECT
• RIGHTCB
• RIGHTTXTDELIM
• RIGHTP
• ROW
• ROWS
• RTRIM
• SCALE
15-54
Chapter 15
Reserved Words for the ORACLE_LOADER Access Driver
• SECOND
• SEMI
• SETID
• SIGN
• SIZES
• SKIP
• STRING
• TERMBY
• TERMEOF
• TERMINATED
• TERMWS
• TERRITORY
• TIME
• TIMESTAMP
• TIMEZONE
• TO
• TRANSFORMS
• UNDERSCORE
• UINTEGER
• UNSIGNED
• VALUES
• VARCHAR
• VARCHARC
• VARIABLE
• VARRAW
• VARRAWC
• VLENELN
• VMAXLEN
• WHEN
• WHITESPACE
• WITH
• YEAR
• ZONED
15-55
16
The ORACLE_DATAPUMP Access Driver
The ORACLE_DATAPUMP access driver provides a set of access parameters unique to
external tables of the type ORACLE_DATAPUMP. You can use the access parameters to
modify the default behavior of the access driver. The information you provide through
the access driver ensures that data from the data source is processed so that it
matches the definition of the external table.
See the following topics for more information:
To successfully use the ORACLE_DATAPUMP access driver, you must have some
knowledge of the file format and record format (including character sets and field data
types) of the data files on your platform. You must also know enough about SQL to be
able to create an external table and perform queries against it.
Note:
• access_parameters Clause
• Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver
• Supported Data Types
• Unsupported Data Types
• Performance Hints When Using the ORACLE_DATAPUMP Access Driver
• Restrictions When Using the ORACLE_DATAPUMP Access Driver
• Reserved Words for the ORACLE_DATAPUMP Access Driver
16-1
Chapter 16
access_parameters Clause
Note:
These access parameters are collectively referred to as the opaque_format_spec
in the SQL CREATE TABLE...ORGANIZATION EXTERNAL statement.
See Also:
ENABLED
ENCRYPTION
DISABLED
NOLOGFILE
BASIC
LOW
ENABLED
MEDIUM
COMPRESSION
HIGH
DISABLED
ENABLED
HADOOP_TRAILERS
DISABLED
COMPATIBLE
VERSION LATEST
• comments
• COMPRESSION
• ENCRYPTION
• LOGFILE | NOLOGFILE
• VERSION Clause
• Effects of Using the SQL ENCRYPT Clause
16-2
Chapter 16
access_parameters Clause
16.1.1 comments
Comments are lines that begin with two hyphens followed by text. Comments must be
placed before any access parameters, for example:
--This is a comment.
--This is another comment.
NOLOG
All text to the right of the double hyphen is ignored, until the end of the line.
16.1.2 COMPRESSION
Default: DISABLED
Purpose
Specifies whether to compress data (and optionally, which compression algorithm to
use) before the data is written to the dump file set.
• If ENABLED is specified, then all data is compressed for the entire unload operation.
You can additionally specify one of the following compression options:
– BASIC - Offers a good combination of compression ratios and speed; the
algorithm used is the same as in previous versions of Oracle Data Pump.
– LOW - Least impact on unload throughput and suited for environments where
CPU resources are the limiting factor.
– MEDIUM - Recommended for most environments. This option, like the BASIC
option, provides a good combination of compression ratios and speed, but it
uses a different algorithm than BASIC.
– HIGH - Best suited for unloads over slower networks where the limiting factor is
network speed.
Note:
To use these compression algorithms, the COMPATIBLE initialization
parameter must be set to at least 12.0.0. This feature requires that the
Oracle Advanced Compression option be enabled.
16-3
Chapter 16
access_parameters Clause
environment, workload characteristics, and size and type of data is the only way to
ensure that the exported dump file set compression level meets your performance
and storage requirements.
• If DISABLED is specified, then no data is compressed for the upload operation.
Example
In the following example, the COMPRESSION parameter is set to ENABLED. Therefore, all
data written to the dept.dmp dump file will be in compressed format.
CREATE TABLE deptXTec3
ORGANIZATION EXTERNAL (TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY def_dir1
ACCESS PARAMETERS (COMPRESSION ENABLED) LOCATION ('dept.dmp'));
16.1.3 ENCRYPTION
Default: DISABLED
Purpose
Specifies whether to encrypt data before it is written to the dump file set.
If ENABLED is specified, then all data is written to the dump file set in encrypted format.
If DISABLED is specified, then no data is written to the dump file set in encrypted format.
Restrictions
This parameter is used only for export operations.
Example
In the following example, the ENCRYPTION parameter is set to ENABLED. Therefore, all data
written to the dept.dmp file will be in encrypted format.
CREATE TABLE deptXTec3
ORGANIZATION EXTERNAL (TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY def_dir1
ACCESS PARAMETERS (ENCRYPTION ENABLED) LOCATION ('dept.dmp'));
Purpose
LOGFILE specifies the name of the log file that contains any messages generated while
the dump file was being accessed. NOLOGFILE prevents the creation of a log file.
16-4
Chapter 16
access_parameters Clause
or
LOGFILE [directory_object:]logfile_name
If a directory object is not specified as part of the log file name, then the directory
object specified by the DEFAULT DIRECTORY attribute is used. If a directory object is not
specified and no default directory was specified, then an error is returned. See "File
Names for LOGFILE" for information about using substitution variables to create
unique file names during parallel loads or unloads.
Example
In the following example, the dump file, dept_dmp, is in the directory identified by the
directory object, load_dir, but the log file, deptxt.log, is in the directory identified by the
directory object, log_dir.
CREATE TABLE dept_xt (dept_no INT, dept_name CHAR(20), location CHAR(20))
ORGANIZATION EXTERNAL (TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY load_dir
ACCESS PARAMETERS (LOGFILE log_dir:deptxt) LOCATION ('dept_dmp'));
• %a is replaced by the agent number of the current process. The agent number is
the unique number assigned to each parallel process accessing the external table.
This number is padded to the left with zeros to fill three characters. For example, if
the third parallel agent is creating a file and exttab_%a.log was specified as the file
name, then the agent would create a file named exttab_003.log.
• %% is replaced by %. If there is a need to have a percent sign in the file name, then
this symbol substitution must be used.
If the % character is followed by anything other than one of the characters in the
preceding list, then an error is returned.
If %p or %a is not used to create unique file names for output files and an external table
is being accessed in parallel, then output files may be corrupted or agents may be
unable to write to the files.
If no extension is supplied for the file, then a default extension of .log is used. If the
name generated is not a valid file name, then an error is returned and no data is
loaded or unloaded.
16-5
Chapter 16
Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver
See Also:
Oracle Database SQL Language Reference for more information about using
the ENCRYPT clause on a CREATE TABLE statement
16-6
Chapter 16
Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver
Table created.
2. Describe both inventories and the new external table, as follows. They should
both match.
SQL> DESCRIBE inventories
Name Null? Type
---------------------------------------- --------- ----------------
PRODUCT_ID NOT NULL NUMBER(6)
WAREHOUSE_ID NOT NULL NUMBER(3)
QUANTITY_ON_HAND NOT NULL NUMBER(8)
COUNT(*)
----------
1112
4. Compare the data in the external table against the data in inventories. There
should be no differences.
SQL> SELECT * FROM inventories MINUS SELECT * FROM inventories_xt;
no rows selected
5. After an external table has been created and the dump file populated by the CREATE
TABLE AS SELECT statement, no rows may be added, updated, or deleted from the
external table. Any attempt to modify the data in the external table will fail with an
error.
The following example shows an attempt to use data manipulation language
(DML) on an existing external table. This will return an error, as shown.
SQL> DELETE FROM inventories_xt WHERE warehouse_id = 5;
DELETE FROM inventories_xt WHERE warehouse_id = 5
*
ERROR at line 1:
ORA-30657: operation not supported on external organized table
6. The dump file created for the external table can now be moved and used as the
dump file for another external table in the same database or different database.
Note that when you create an external table that uses an existing file, there is no
AS SELECT clause for the CREATE TABLE statement.
16-7
Chapter 16
Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver
9 TYPE ORACLE_DATAPUMP
10 DEFAULT DIRECTORY def_dir1
11 LOCATION ('inv_xt.dmp')
12 );
Table created.
7. Compare the data for the new external table against the data in the inventories
table. The product_id field will be converted to a compatible data type before the
comparison is done. There should be no differences.
SQL> SELECT * FROM inventories MINUS SELECT * FROM inventories_xt2;
no rows selected
8. Create an external table with three dump files and with a degree of parallelism of
three.
SQL> CREATE TABLE inventories_xt3
2 ORGANIZATION EXTERNAL
3 (
4 TYPE ORACLE_DATAPUMP
5 DEFAULT DIRECTORY def_dir1
6 LOCATION ('inv_xt1.dmp', 'inv_xt2.dmp', 'inv_xt3.dmp')
7 )
8 PARALLEL 3
9 AS SELECT * FROM inventories;
Table created.
9. Compare the data unload against inventories. There should be no differences.
SQL> SELECT * FROM inventories MINUS SELECT * FROM inventories_xt3;
no rows selected
10. Create an external table containing some rows from table inventories.
Table created.
11. Create another external table containing the rest of the rows from inventories.
Table dropped.
SQL>
SQL> CREATE TABLE inv_part_xt
2 ORGANIZATION EXTERNAL
3 (
4 TYPE ORACLE_DATAPUMP
5 DEFAULT DIRECTORY def_dir1
6 LOCATION ('inv_p2_xt.dmp')
7 )
8 AS SELECT * FROM inventories WHERE warehouse_id >= 5;
16-8
Chapter 16
Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver
Table created.
12. Create an external table that uses the two dump files created in Steps 10 and 11.
Table created.
13. Compare the new external table to the inventories table. There should be no
differences. This is because the two dump files used to create the external table
have the same metadata (for example, the same table name inv_part_xt and the
same column information).
SQL> SELECT * FROM inventories MINUS SELECT * FROM inv_part_all_xt;
no rows selected
Table created.
16-9
Chapter 16
Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver
When the ORACLE_DATAPUMP access driver is used to load data, parallel processes can
read multiple dump files or even chunks of the same dump file concurrently. Thus,
data can be loaded in parallel even if there is only one dump file, as long as that file is
large enough to contain multiple file offsets. The degree of parallelization is not tied to
the number of files in the LOCATION clause when reading from ORACLE_DATAPUMP external
tables.
Table created.
Table created.
16-10
Chapter 16
Supported Data Types
Table created.
no rows selected
The following data types are automatically converted during loads and unloads:
• Character (CHAR, NCHAR, VARCHAR2, NVARCHAR2)
• RAW
• NUMBER
• Date/Time
• BLOB
If you attempt to use a data type that is not supported for external tables, then you
receive an error. This is demonstrated in the following example, in which the
unsupported data type, LONG, is used:
SQL> CREATE TABLE bad_datatype_xt
2 (
3 product_id NUMBER(6),
4 language_id VARCHAR2(3),
5 translated_name NVARCHAR2(50),
6 translated_description LONG
7 )
8 ORGANIZATION EXTERNAL
9 (
10 TYPE ORACLE_DATAPUMP
11 DEFAULT DIRECTORY def_dir1
12 LOCATION ('proddesc.dmp')
13 );
translated_description LONG
*
ERROR at line 6:
ORA-30656: column type not supported on external organized table
See Also:
"Unsupported Data Types"
16-11
Chapter 16
Unsupported Data Types
1. Create a function to extract the directory object for a BFILE column. Note that if the
column is NULL, then NULL is returned.
SQL> CREATE FUNCTION get_dir_name (bf BFILE) RETURN VARCHAR2 IS
2 DIR_ALIAS VARCHAR2(255);
3 FILE_NAME VARCHAR2(255);
4 BEGIN
5 IF bf is NULL
6 THEN
7 RETURN NULL;
8 ELSE
9 DBMS_LOB.FILEGETNAME (bf, dir_alias, file_name);
10 RETURN dir_alias;
11 END IF;
12 END;
13 /
Function created.
2. Create a function to extract the file name for a BFILE column.
16-12
Chapter 16
Unsupported Data Types
Function created.
3. You can then add a row with a NULL value for the BFILE column, as follows:
SQL> INSERT INTO PRINT_MEDIA (product_id, ad_id, ad_graphic)
2 VALUES (3515, 12001, NULL);
1 row created.
You can use the newly created functions to populate an external table. Note that
the functions should set columns ad_graphic_dir and ad_graphic_file to NULL if the
BFILE column is NULL.
4. Create an external table to contain the data from the print_media table. Use the
get_dir_name and get_file_name functions to get the components of the BFILE
column.
SQL> CREATE TABLE print_media_xt
2 ORGANIZATION EXTERNAL
3 (
4 TYPE oracle_datapump
5 DEFAULT DIRECTORY def_dir1
6 LOCATION ('pm_xt.dmp')
7 ) AS
8 SELECT product_id, ad_id,
9 get_dir_name (ad_graphic) ad_graphic_dir,
10 get_file_name(ad_graphic) ad_graphic_file
11 FROM print_media;
Table created.
5. Create a function to load a BFILE column from the data that is in the external table.
This function will return NULL if the ad_graphic_dir column in the external table is
NULL.
16-13
Chapter 16
Unsupported Data Types
Function created.
6. The get_bfile function can be used to populate a new table containing a BFILE
column.
SQL> CREATE TABLE print_media_int AS
2 SELECT product_id, ad_id,
3 get_bfile (ad_graphic_dir, ad_graphic_file) ad_graphic
4 FROM print_media_xt;
Table created.
7. The data in the columns of the newly loaded table should match the data in the
columns of the print_media table.
SQL> SELECT product_id, ad_id,
2 get_dir_name(ad_graphic),
3 get_file_name(ad_graphic)
4 FROM print_media_int
5 MINUS
6 SELECT product_id, ad_id,
7 get_dir_name(ad_graphic),
8 get_file_name(ad_graphic)
9 FROM print_media;
no rows selected
1. If a table to be unloaded contains a LONG or LONG RAW column, then define the
corresponding columns in the external table as CLOB for LONG columns or BLOB for
LONG RAW columns.
Table created.
1 row created.
2. Now, an external table can be created that contains a CLOB column to contain the
data from the LONG column. Note that when loading the external table, the TO_LOB
operator is used to convert the LONG column into a CLOB.
SQL> CREATE TABLE long_tab_xt
2 ORGANIZATION EXTERNAL
3 (
4 TYPE ORACLE_DATAPUMP
5 DEFAULT DIRECTORY def_dir1
6 LOCATION ('long_tab_xt.dmp')
7 )
8 AS SELECT key, TO_LOB(description) description FROM long_tab;
16-14
Chapter 16
Unsupported Data Types
Table created.
3. The data in the external table can be used to create another table exactly like the
one that was unloaded except the new table will contain a LOB column instead of
a LONG column.
SQL> CREATE TABLE lob_tab
2 AS SELECT * from long_tab_xt;
Table created.
4. Verify that the table was created correctly.
SQL> SELECT * FROM lob_tab;
KEY DESCRIPTION
----------------------------------------------------------------------------
1 Description Text
Table created.
The columns in the external table containing the attributes of the object type can
now be used as arguments to the type constructor function when loading a column
of that type. Note that the warehouse column in the external table is used to
determine whether to call the constructor function for the object or set the column
to NULL.
2. Load a new internal table that looks exactly like the oc_inventories view. (The use
of the WHERE 1=0 clause creates a new table that looks exactly like the old table but
does not copy any data from the old table into the new table.)
SQL> CREATE TABLE oc_inventories_2 AS SELECT * FROM oc_inventories
WHERE 1 = 0;
16-15
Chapter 16
Unsupported Data Types
Table created.
Type created.
Table created.
1 row created.
2. Create an external table in which the column OID is used to hold the column
containing the system-generated OID.
SQL> CREATE TABLE people_xt
2 ORGANIZATION EXTERNAL
3 (
4 TYPE ORACLE_DATAPUMP
5 DEFAULT DIRECTORY def_dir1
6 LOCATION ('people.dmp')
7 )
8 AS SELECT SYS_NC_OID$ oid, name FROM people;
Table created.
3. Create another table of the same type with system-generated OIDs. Then, execute
an INSERT statement to load the new table with data unloaded from the old table.
16-16
Chapter 16
Performance Hints When Using the ORACLE_DATAPUMP Access Driver
Table created.
SQL>
SQL> INSERT INTO people2 (SYS_NC_OID$, SYS_NC_ROWINFO$)
2 SELECT oid, person(name) FROM people_xt;
1 row created.
SQL>
SQL> SELECT SYS_NC_OID$, name FROM people
2 MINUS
3 SELECT SYS_NC_OID$, name FROM people2;
no rows selected
16-17
Chapter 16
Reserved Words for the ORACLE_DATAPUMP Access Driver
• Handling of byte-order marks during a load: In an external table load for which the
data file character set is UTF8 or UTF16, it is not possible to suppress checking
for byte-order marks. Suppression of byte-order mark checking is necessary only if
the beginning of the data file contains binary data that matches the byte-order
mark encoding. (It is possible to suppress byte-order mark checking with
SQL*Loader loads.) Note that checking for a byte-order mark does not mean that
a byte-order mark must be present in the data file. If no byte-order mark is present,
then the byte order of the server platform is used.
• The external tables feature does not support the use of the backslash (\) escape
character within strings. See "Use of the Backslash Escape Character".
• When identifiers (for example, column or table names) are specified in the external
table access parameters, certain values are considered to be reserved words by
the access parameter parser. If a reserved word is used as an identifier, then it
must be enclosed in double quotation marks.
• BADFILE
• COMPATIBLE
• COMPRESSION
• DATAPUMP
• DEBUG
• ENCRYPTION
• INTERNAL
• JOB
• LATEST
• LOGFILE
• NOBADFILE
• NOLOGFILE
• PARALLEL
• TABLE
• VERSION
• WORKERID
16-18
17
ORACLE_HDFS and ORACLE_HIVE
Access Drivers
The properties used to create an external table that uses the ORACLE_HDFS or
ORACLE_HIVE access drivers are specified in a SQL CREATE TABLE ORGANIZATION EXTERNAL
statement, in the opaque_format_spec clause of ACCESS PARAMETERS.
See Also:
• The format of each keyword-value pair is a keyword, a colon or equal sign, and a
value. The following are valid keyword-value pairs:
keyword=value
keyword:value
The value is everything from the first non-whitespace character after the separator
to the end of the line. Whitespace between the separator and the value is ignored.
Trailing whitespace for the value is retained.
• A property definition can be on one line or multiple lines.
• A line terminator is a line feed, a carriage return, or a carriage return followed by
line feeds.
• When a property definition spans multiple lines, then precede the line terminators
with a backslash (escape character), except on the last line. In this example, the
value of the Keyword1 property is Value part 1 Value part 2 Value part 3.
17-1
Chapter 17
ORACLE_HDFS Access Parameters
17-2
Chapter 17
ORACLE_HIVE Access Parameters
• com.oracle.bigdata.colmap
• com.oracle.bigdata.erroropt
• com.oracle.bigdata.fields
• com.oracle.bigdata.fileformat
• com.oracle.bigdata.log.exec
• com.oracle.bigdata.log.qc
• com.oracle.bigdata.overflow
• com.oracle.bigdata.rowformat
The following example shows a CREATE TABLE statement in which multiple access
parameters are set.
Example 17-1 Setting Multiple Access Parameters for ORACLE_HDFS
CREATE TABLE ORDER (CUST_NUM VARCHAR2(10),
ORDER_NUM VARCHAR2(20),
ORDER_DATE DATE,
ITEM_CNT NUMBER,
DESCRIPTION VARCHAR2(100),
ORDER_TOTAL (NUMBER8,2)) ORGANIZATION EXTERNAL
(TYPE ORACLE_HDFS
ACCESS PARAMETERS (
com.oracle.bigdata.fields: (CUST_NUM, \
ORDER_NUM, \
ORDER_DATE, \
ORDER_LINE_ITEM_COUNT, \
DESCRIPTION, \
ORDER_TOTAL)
com.oracle.bigdata.colMap: {"col":"item_cnt", \
"field":"order_line_item_count"}
com.oracle.bigdata.overflow: {"action":"TRUNCATE", \
"col":"DESCRIPTION"}
com.oracle.bigdata.errorOpt: [{"action":"replace", \
"value":"INVALID NUM", \
"col":["CUST_NUM","ORDER_NUM"]} , \
{"action":"reject", \
"col":"ORDER_TOTAL}]
)
LOCATION ("hdfs:/usr/cust/summary/*"));
17-3
Chapter 17
Descriptions of com.oracle.bigdata Parameters
• com.oracle.bigdata.colmap
• com.oracle.bigdata.erroropt
• com.oracle.bigdata.log.exec
• com.oracle.bigdata.log.qc
• com.oracle.bigdata.overflow
• com.oracle.bigdata.tablename
The following example shows a CREATE TABLE statement in which multiple access
parameters are set.
Example 17-2 Setting Multiple Access Parameters for ORACLE_HIVE
CREATE TABLE ORDER (cust_num VARCHAR2(10),
order_num VARCHAR2(20),
order_date DATE,
item_cnt NUMBER,
description VARCHAR2(100),
order_total (NUMBER8,2)) ORGANIZATION EXTERNAL
(TYPE oracle_hive
ACCESS PARAMETERS (
com.oracle.bigdata.tableName: order_db.order_summary
com.oracle.bigdata.colMap: {"col":"ITEM_CNT", \
"field":"order_line_item_count"}
com.oracle.bigdata.overflow: {"action":"ERROR", \
"col":"DESCRIPTION"}
com.oracle.bigdata.errorOpt: [{"action":"replace", \
"value":"INV_NUM" , \
"col":["CUST_NUM","ORDER_NUM"]} ,\
{"action":"reject", \
"col":"ORDER_TOTAL}]
));
• com.oracle.bigdata.colmap
• com.oracle.bigdata.datamode
17-4
Chapter 17
Descriptions of com.oracle.bigdata Parameters
• com.oracle.bigdata.erroropt
• com.oracle.bigdata.fields
• com.oracle.bigdata.fileformat
• com.oracle.bigdata.log.exec
• com.oracle.bigdata.log.qc
• com.oracle.bigdata.overflow
• com.oracle.bigdata.rowformat
• com.oracle.bigdata.tablename
• com.oracle.bigdata.colmap
• com.oracle.bigdata.datamode
• com.oracle.bigdata.erroropt
• com.oracle.bigdata.fields
• com.oracle.bigdata.fileformat
• com.oracle.bigdata.log.exec
• com.oracle.bigdata.log.qc
• com.oracle.bigdata.overflow
• com.oracle.bigdata.rowformat
• com.oracle.bigdata.tablename
17.4.1 com.oracle.bigdata.colmap
Maps a column in the source data to a column in the Oracle external table. You can
define one or multiple pairs of column mappings. Use this property when the source
field names exceed the maximum length of Oracle column names, or when you want
to use different column names in the external table.
Default Value
A column in the external table with the same name as the Hive column
Syntax
A JSON document with the keyword-value pairs is shown in the following diagram:
colmap:
colmap_entry
=
com.oracle.bigdata.colmap ,
:
[ colmap_entry ]
colmap_entry:
17-5
Chapter 17
Descriptions of com.oracle.bigdata Parameters
Semantics
"col":name
"col": The keyword must be lowercase and enclosed in quotation marks.
name: The name of a column in the Oracle external table. It is case sensitive and must
be enclosed in quotation marks.
"field":name
"field": The keyword must be lowercase and enclosed in quotation marks.
name: The name of a field in the data source. It is not case sensitive, but it must be
enclosed in quotation marks. See "Syntax Rules for Specifying Properties".
Examples
This example maps a Hive column named ORDER_LINE_ITEM_COUNT to an Oracle column
named ITEM_CNT:
com.oracle.bigdata.colMap={"col":"ITEM_CNT", \
"field":"order_line_item_count"}
17.4.2 com.oracle.bigdata.datamode
Specifies the method that SmartScan uses to scan a Hadoop data source. The
method can make a significant difference in performance.
Default Value
automatic
Syntax
A JSON document with the keyword-value pairs shown in the following diagram:
datamode:
c
=
com.oracle.bigdata.datamode java
:
automatic
Semantics
automatic
Automatically selects the appropriate mode, based on the metadata. It selects c mode
if possible, or java mode if the data contains formats that are not supported by c mode.
17-6
Chapter 17
Descriptions of com.oracle.bigdata Parameters
Uses Java to read the file buffers, but C code to process the data and convert it to
Oracle format. Specify this mode for delimited data.
If the data contains formats that the C code does not support, then it returns an error.
java
Uses the Java SerDes and InputFormats to process the data and convert it to Oracle
format. Specify this mode for Parquet, RCFile, and other data formats that require a
SerDe.
17.4.3 com.oracle.bigdata.erroropt
Describes how to handle errors that occur while the value of a column is calculated.
Default Value
{"action":"setnull"}
Syntax
A JSON document with the keyword-value pairs is shown in the following diagram:
erroropt:
error_element
=
com.oracle.bigdata.erroropt ,
:
[ error_element ]
error_element:
name
, "col" : ,
"reject"
[ name ]
{ "action" : "setnull" }
Semantics
The "action", "reject", "setnull", "replace", "value", and "col" keywords must be
lowercase and enclosed in quotation marks. See "Syntax Rules for Specifying
Properties".
"action":value
value: One of these keywords:
17-7
Chapter 17
Descriptions of com.oracle.bigdata Parameters
"value":string
string: Replaces a bad value in the external table. It must be enclosed in quotation
marks.
"col":name
name: Identifies a column in an external table. The column name is case sensitive, must
be enclosed in quotation marks, and can be listed only once.
Example
This example sets the value of the CUST_NUM or ORDER_NUM columns to INVALID if the Hive
value causes an error. For any other columns, an error just causes the Hive value to
be rejected.
com.oracle.bigdata.errorOpt: {"action":"replace",\
"value":"INVALID", \
"col":["CUST_NUM","ORDER_NUM"]
17.4.4 com.oracle.bigdata.fields
Lists the field names and data types of the data source.
Default Value
Not defined
Syntax
A JSON document with the keyword-value pairs is shown in the following diagram:
fields:
= COMMENT col_comment
com.oracle.bigdata.fields ( field_name data_type )
:
data_type:
primitive_type
COMMENT col_comment
STRUCT < field_name data_type >
17-8
Chapter 17
Descriptions of com.oracle.bigdata Parameters
primitive_type:
TINYINT
SMALLINT
INT
BIGINT
BOOLEAN
FLOAT
DOUBLE
STRING
BINARY
TIMESTAMP
DECIMAL
Semantics
The syntax is the same as a field list for a Hive table. If you split the field list across
multiple lines, you must use a backslash to escape the new line characters.
field_name
The name of the Hive field. Use only alphanumeric characters and underscores (_).
The maximum length is 128 characters. Field names are case-insensitive.
data_type
The data type of the Hive field. Optional; the default is STRING. The character set must
be UTF8.
The data type can be complex or primitive:
Hive Complex Data Types
• ARRAY: Indexable list
17-9
Chapter 17
Descriptions of com.oracle.bigdata Parameters
See Also:
"Data Types" in the Apache Hive Language Manual at
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
COMMENT col_comment
A string literal enclosed in single quotation marks, which is stored as metadata for the
Hive table (comment property of TBLPROPERTIES).
17.4.5 com.oracle.bigdata.fileformat
Describes the row format of the data source, based on the ROW FORMAT clause for a Hive
table generated by ORACLE_HDFS.
Default Value
TEXTFILE
Syntax
A JSON document with the keyword-value pairs is shown in the following diagram.
fileformat:
SEQUENCEFILE
TEXTFILE
= RCFILE
com.oracle.bigdata.fileformat
: ORC
PARQUET
Semantics
ORC
Optimized row columnar file format
PARQUET
Column-oriented, binary file format
RCFILE
Record columnar file format
SEQUENCEFILE
17-10
Chapter 17
Descriptions of com.oracle.bigdata Parameters
17.4.6 com.oracle.bigdata.log.exec
Specifies how the access driver generates log files generated by the C code for a
query, when it is running as parallel processes on CDH.
The access driver does not create or write log files when executing on a Hadoop
cluster node; the parallel query processes write them. The log files from the Java code
are controlled by log4j properties, which are specified in the configuration file or the
access parameters.
Default Value
Not defined (no logging)
Syntax
[directory_object:]file_name_template
Semantics
directory_object
The Oracle directory object for the HDFS path on the Hadoop cluster where the log file
is created.
file_name_template
A string used to generate file names. The following table describes the optional
variables that you can use in the template.
Variable Value
%p Operating system process identifier (PID)
%a A number that uniquely identifies the process
%% A percent sign (%)
Example
The following example generates log file names that include the PID and a unique
number, such as xtlogp_hive14_3413_57:
com.oracle.bigdata.log.exec= xtlogp_hive14_%p_%a
17-11
Chapter 17
Descriptions of com.oracle.bigdata Parameters
17.4.7 com.oracle.bigdata.log.qc
Specifies how the access driver generates log files for a query.
Default Value
Not defined (no logging)
Syntax
[directory_object:]file_name_template
Semantics
directory_object
Name of an Oracle directory object that points to the path where the log files are
written. If this value is omitted, then the logs are written to the default directory for the
external table.
file_name_template
A string used to generate file names. Table 17-3 describes the optional variables that
you can use in the string.
Variable Value
%p Operating system process identifier (PID)
%% A percent sign (%)
Example
This example creates log file names that include the PID and a percent sign, such as
xtlogp_hive213459_%:
com.oracle.bigdata.log.qc= xtlogp_hive21%p_%%
17.4.8 com.oracle.bigdata.overflow
Describes how to handle string data that is too long for the columns in the external
table. The data source can be character or binary. For Hive, the data source can also
be STRUCT, UNIONTYPES, MAP, or ARRAY.
Default Value
{"action":"error"}
Syntax
A JSON document with the keyword-value pairs is shown in the following diagram:
overflow ::=
17-12
Chapter 17
Descriptions of com.oracle.bigdata Parameters
overflow_element
=
com.oracle.bigdata.overflow ,
:
[ overflow_element ]
overflow_element ::=
name
, "col" : ,
"truncate" [ name ]
{ "action" : }
"error"
Semantics
The "action", "truncate", "error", and "col" tags must be lowercase and enclosed in
quotation marks. See "Syntax Rules for Specifying Properties".
"action":value
The value of "action" can be one of the following keywords:
Example
This example truncates the source data for the DESCRIPTION column, if it exceeds the
column width:
com.oracle.bigdata.overflow={"action":"truncate", \
"col":"DESCRIPTION"}
17.4.9 com.oracle.bigdata.rowformat
Provides the information the access driver needs to extract fields from the records in a
file.
17-13
Chapter 17
Descriptions of com.oracle.bigdata Parameters
Important:
The com.oracle.bigdata.rowformat is unrelated to the access parameter syntax
of traditional external tables that use "type ORACLE_LOADER." There are
keywords such as FIELDS, TERMINATED, and others that appear in both clauses,
but the commonality in naming is coincidental and does not imply common
functionality. The com.oracle.bigdata.rowformat access parameter is passed
without change to the default Hive serde. The Hive serde to extract columns
from rows is deliberately limited. Complex cases are handled by specialized
serdes.
Default Value
DELIMITED
Syntax
A JSON document with the keyword-value pairs is shown in the following diagram.
rowformat:
ESCAPED BY char
FIELDS TERMINATED BY char
Semantics
DELIMITED
Describes the characters used to delimit the fields in a record:
• FIELDS TERMINATED BY: The character that delimits every field in the record. The
optional ESCAPED BY character precedes the delimit character when it appears
within a field value.
• COLLECTION ITEMS TERMINATED BY: The character that marks the end of an array
element. Used when a column is a collection or a nested record. In this case the
resulting value will be a JSON array.
• MAP KEYS TERMINATED BY: The character that marks the end of an entry in a MAP
field. Used when a column is a collection or a nested record. The resulting value is
a JSON object.
• LINES TERMINATED BY: The character that marks the end of a record.
17-14
Chapter 17
Descriptions of com.oracle.bigdata Parameters
SERDE
Identifies a SerDe that can parse the data and any properties of the SerDe that the
access driver might need.
Example
This example specifies a SerDe for an Avro container file:
com.oracle.bigdata.rowformat:
SERDE'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
The next example specifies a SerDe for a file containing regular expressions:
com.oracle.bigdata.rowformat=\
SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' \
WITH SERDEPROPERTIES \
("input.regex" = "(\\\\d{6}) (\\\\d{5}) (.{29}) .*")
17.4.10 com.oracle.bigdata.tablename
Identifies the Hive table that contains the source data.
Default Value
DEFAULT.external_table_name
Syntax
[hive_database_name.]table_name
Semantics
The maximum length of hive_database_name and table_name is 128 UTF-8
characters (512 bytes).
hive_database_name
The Hive database where the source data resides. DEFAULT is the name of the initial
Hive database.
table_name
The Hive table with the data. If you omit table_name, then ORACLE_HIVE searches for a
Hive table with the same name as the external table. Table names are case-
insensitive.
Example
This setting indicates that the source data is in a table named ORDER_SUMMARY in the
Hive ORDER_DB database:
com.oracle.bigdata.tablename ORDER_DB.ORDER_SUMMARY
17-15
18
External Tables Examples
The following table lists examples of how to create external tables using various
access drivers and methods.
18-1
Chapter 18
Using the ORACLE_LOADER Access Driver to Create Partitioned External Tables
p1b.dat:
51, DIY Supplies,61614,
87, Fast Frames,22201,
89, Friendly Pharmacy,89901,
p2.dat:
121, Pleasant Pets,33893,
130, Bailey the Bookmonger,99915,
105, Le Bistrot du Chat Noir,94114,
p3.dat:
210, The Electric Eel Diner,07101,
222, Everyt'ing General Store,80118,
231, Big Rocket Market,01754,
There are three fields in the data file: CUSTOMER_NUMBER, CUSTOMER_NAME and POSTAL_CODE.
The external table uses range partitioning on CUSTOMER_NUMBER to create three partitions.
Table created.
SQL>
The following is the output from SELECT * for the entire table:
18-2
Chapter 18
Using the ORACLE_LOADER Access Driver to Create Partitioned External Tables
12 rows selected.
SQL>
The following query should only read records from the first partition:
SQL> select customer_number, customer_name, postal_code
2 from customer_list_xt
3 where customer_number < 20
4 order by customer_number;
2 rows selected.
SQL>
The following query specifies the partition to read as part of the SELECT statement.
SQL> select customer_number, customer_name, postal_code
2 from customer_list_xt partition (p1)
3 order by customer_number;
6 rows selected.
SQL>
18-3
Chapter 18
Using the ORACLE_DATAPUMP Access Driver to Create Partitioned External Tables
The following statement creates a file with data for the first subpartition (postal_code
less than 50000) of partition p1 (customer_number less than 100).
SQL> create table customer_list_dp_p1_sp1_xt
2 organization external
3 (type oracle_datapump default directory def_dir1 location('p1_sp1.dmp'))
4 as
5 select customer_number, customer_name, postal_code
6 from customer_list_xt partition (p1)
7 where to_number(postal_code) < 50000;
Table created.
SQL>
This statement creates a file with data for the second subpartition (all other values for
postal_code) of partition p1 (customer_number less than 100).
SQL> create table customer_list_dp_p1_sp2_xt
2 organization external
3 (type oracle_datapump default directory def_dir1 location('p1_sp2.dmp'))
4 as
5 select customer_number, customer_name, postal_code
6 from customer_list_xt partition (p1)
7 where to_number(postal_code) >= 50000;
Table created.
The files for other partitions are created in a similar fashion, as follows:
SQL> create table customer_list_dp_p2_sp1_xt
2 organization external
3 (type oracle_datapump default directory def_dir1 location('p2_sp1.dmp'))
4 as
5 select customer_number, customer_name, postal_code
6 from customer_list_xt partition (p2)
7 where to_number(postal_code) < 50000;
Table created.
18-4
Chapter 18
Using the ORACLE_DATAPUMP Access Driver to Create Partitioned External Tables
SQL>
SQL> create table customer_list_dp_p2_sp2_xt
2 organization external
3 (type oracle_datapump default directory def_dir1 location('p2_sp2.dmp'))
4 as
5 select customer_number, customer_name, postal_code
6 from customer_list_xt partition (p2)
7 where to_number(postal_code) >= 50000;
Table created.
SQL>
SQL> create table customer_list_dp_p3_sp1_xt
2 organization external
3 (type oracle_datapump default directory def_dir1 location('p3_sp1.dmp'))
4 as
5 select customer_number, customer_name, postal_code
6 from customer_list_xt partition (p3)
7 where to_number(postal_code) < 50000;
Table created.
SQL>
SQL> create table customer_list_dp_p3_sp2_xt
2 organization external
3 (type oracle_datapump default directory def_dir1 location('p3_sp2.dmp'))
4 as
5 select customer_number, customer_name, postal_code
6 from customer_list_xt partition (p3)
7 where to_number(postal_code) >= 50000;
Table created.
SQL>
You can select from each of these external tables to verify that it has the data you
intended to write out. After you have executed the SQL CREATE TABLE AS SELECT
statement, you can drop these external tables.
To use a virtual column to partition the table, create the partitioned ORACLE_DATAPUMP
table. Again, the table is partitioned on the customer_number column and subpartitioned
on the postal_code column. The postal_code column is a character field that contains
numbers, but this example partitions it based on the numeric value, not a character
string. In order to do this, create a virtual column, postal_code_num, whose value is the
postal_code field converted to a NUMBER data type. The SUBPARTITION clause uses the
virtual column to determine the subpartition for the row.
SQL> create table customer_list_dp_xt
2 (customer_number number,
3 CUSTOMER_NAME VARCHAR2(50),
4 postal_code CHAR(5),
5 postal_code_NUM as (to_number(postal_code)))
6 organization external
7 (type oracle_datapump default directory def_dir1)
8 partition by range(customer_number)
9 subpartition by range(postal_code_NUM)
10 (
11 partition p1 values less than (100)
12 (subpartition p1_sp1 values less than (50000) location('p1_sp1.dmp'),
13 subpartition p1_sp2 values less than (MAXVALUE) location('p1_sp2.dmp')),
18-5
Chapter 18
Using the ORACLE_DATAPUMP Access Driver to Create Partitioned External Tables
Table created.
SQL>
If you select all rows, then the data returned is the same as was returned in the
previous example using the ORACLE_LOADER access driver.
SQL> select customer_number, customer_name, postal_code
2 from customer_list_dp_xt
3 order by customer_number;
12 rows selected.
SQL>
The WHERE clause can limit the rows read to a subpartition. The following query should
only read the first subpartition of the first partition.
SQL> select customer_number, customer_name, postal_code
2 from customer_list_dp_xt
3 where customer_number < 20 and postal_code_NUM < 39998
4 order by customer_number;
1 row selected.
SQL>
18-6
Chapter 18
Using the ORACLE_HDFS Access Driver to Create Partitioned External Tables
2 rows selected.
SQL>
p1b.dat
51, DIY Supplies,07101,
87, Fast Frames,01754,
89, Friendly Pharmacy,01372,
p2.dat
121, Pleasant Pets,01754,
130, Bailey the Bookmonger,01754,
105, Le Bistrot du Chat Noir,01754,
p3.dat
210, The Electric Eel Diner,07101,
222, Everyt'ing General Store,01372,
231, Big Rocket Market,01754,
For the purposes of this example, the data files are written to the HDFS directory using
the following:
hadoop dfs -mkdir hdfs_pet
hadoop dfs -put p1a.dat hdfs_pet/p1a.dat
hadoop dfs -put p1b.dat hdfs_pet/p1b.dat
hadoop dfs -put p2.dat hdfs_pet/p2.dat
hadoop dfs -put p3.dat hdfs_pet/p3.dat
The following is the CREATE TABLE command to create the partitioned external table:
create table customer_list_hdfs
(CUSTOMER_NUMBER number, CUSTOMER_NAME VARCHAR2(50), POSTAL_CODE CHAR(5))
organization external
(type oracle_hdfs
default directory def_dir1
access parameters
(com.oracle.bigdata.cluster = hadoop_cl_1
com.oracle.bigdata.rowformat = delimited fields terminated by ','))
partition by range(CUSTOMER_NUMBER)
(
18-7
Chapter 18
Using the ORACLE_HDFS Access Driver to Create Partitioned External Tables
The following query shows a SELECT operation from the external table:
SQL> select * from customer_list_hdfs order by customer_number;
12 rows selected.
SQL>
You can also execute queries with a WHERE clause that excludes partitions that cannot
match the conditions in the WHERE clause from being read, as follows:
SQL> select customer_number, customer_name, postal_code
2 from customer_list_hdfs
3 where customer_number < 20
4 order by customer_number;
2 rows selected.
SQL>
You could also specify the partition you want to read as part of the FROM clause, as
shown in the following:
SQL> select customer_number, customer_name, postal_code
2 from customer_list_hdfs partition (p3)
3 order by customer_number;
3 rows selected.
18-8
Chapter 18
Using the ORACLE_HIVE Access Driver to Create Partitioned External Tables
SQL>
Then execute the following commands to tell Hive to create the partitions dynamically:
set hive.exec.dynamic.partition=true
set hive.exec.dynamic.partition.mode=nonstrict
Populate the hive table with data from table customer_list_no_part. This should create
the files for each partition with the correct rows.
insert overwrite table customer_list partition (postal_code) select * from
customer_list_no_part
The Hive customer_list table is populated with the rows. as shown in the following
query:
select * from customer_list order by customer_number
1 AAAAA Plumbing 01372
13 Andi's Doughnuts 01372
28 Sparkly Laundry 07101
51 DIY Supplies 07101
87 Fast Frames 01754
89 Friendly Pharmacy 01372
18-9
Chapter 18
Using the ORACLE_HIVE Access Driver to Create Partitioned External Tables
Now you can go back to SQL*Plus to create the partitioned external table inside the
Oracle database. First, use PL/SQL function DBMS_HADOOP.CREATE_EXTDDL_FOR_HIVE() to
create the external table. The arguments are as follows:
1. the name of the Hadoop cluster
2. the name of the Hive user that owns the table
3. the name of the partitioned Hive table
4. a boolean value indicating whether you want the partition columns in the Hive
table to be included as columns in the external table
5. the name of the partitioned ORACLE_HIVE table that is created
6. a boolean value indicating whether the CREATE DDL is executed
7. a CLOB contains the CREATE DDL string
This example gets the CLOB for the CREATE DDL string and uses the
DBMS_OUTPUT.PUT_LINE() procedure to write it. Setting SERVEROUTPUT ON tells SQL*Plus to
display the data from the DBMS_OUTPUT.PUT_LINE() procedure. Setting LINESIZE to 132
makes sure there are no line breaks at odd places when displaying the data from the
DBMS_OUTPUT.PUT_LINE() procedure.
18-10
Chapter 18
Using the ORACLE_HIVE Access Driver to Create Partitioned External Tables
Because Hive does not specify a maximum character count for STRING columns, the
column definition for the external table is VARCHAR2(4000). If you want a smaller length
for some columns, you can call the DBMS_HADOOP.CREATE_EXTDDL_FOR_HIVE() procedure
and specify that you do not want to execute the CREATE DDL. Then, you can edit the
CREATE statement returned in the CLOB to set the length of the VARCHAR2 columns to a
more appropriate value.
Also, note that the numbers in the partition name can vary.
Now that the table is created, executing a SELECT * statement returns all of the rows.
Note that the SET LINESIZE executed above means that SQL*Plus uses 132 character
for customer_name and postal_code.
SQL> select * from customer_list_hive order by customer_number;
CUSTOMER_NUMBER
---------------
CUSTOMER_NAME
-------------------------------------------------------------------------------------
-----------------------------------------POSTAL_CODE
-------------------------------------------------------------------------------------
----------------------------------------- 1
AAAAA Plumbing
01372
13
Andi's Doughnuts
01372
28
Sparkly Laundry
07101
51
DIY Supplies
07101
87
Fast Frames
01754
89
Friendly Pharmacy
01372
105
Le Bistrot du Chat Noir
01754
121
Pleasant Pets
01754
130
Bailey the Bookmonger
01754
210
The Electric Eel Diner
07101
18-11
Chapter 18
Loading LOBs From External Tables
222
Everyt'ing General Store
01372
231
Big Rocket Market
01754
12 rows selected.
SQL>
SQL execution uses the partition information to prune partitions that do not match the
criteria in the WHERE clause.
SQL> select customer_number, customer_name, postal_code
2 from customer_list_hive
3 where postal_code = '01754'
4 order by customer_number;
CUSTOMER_NUMBER
---------------
CUSTOMER_NAME
-------------------------------------------------------------------------------------
-----------------------------------------POSTAL_CODE
-------------------------------------------------------------------------------------
----------------------------------------- 87
Fast Frames
01754
105
Le Bistrot du Chat Noir
01754
121
Pleasant Pets
01754
130
Bailey the Bookmonger
01754
231
Big Rocket Market
01754
5 rows selected.
SQL>
18-12
Chapter 18
Loading LOBs From External Tables
The second line in the dump file requires quotation marks around the full text string;
otherwise the field would be terminated at the comma.
Note:
Although not a problem in the dump file being used in this example, if
something in the full text string contained quotation marks, then you would
enclose it in another set of quotation marks, as follows for the word alone:
2,John,2012-01-01,"The angry aligator, acting ""alone"", ate the antelope"
If the full text might contain the record delimiter character (0x'0A', or newline), you can
specify a separate file for each document. External tables do not support filler fields,
so instead you must use a COLUMN TRANSFORMS clause to specify that the fname field
contains the name of the external file:
DROP TABLE my_ext_table2;
18-13
Chapter 18
Loading CSV Files From External Tables
Note:
The FROM (MY_DIRECTORY) clause is not actually necessary since it has already
been specified as the default directory. However it is being shown here for
example purposes because if the loader.txt file and the individual CLOB files
were in different locations, it would be needed.
Once the data is in an external table, you can either leave it there and perform normal
table operations (DML and most DDL) on the external table, or you can use the
external table as a staging table to get the data into a normal table. To create a new
normal (non-external) table, you could use the following SQL statement:
CREATE TABLE normaltable AS SELECT * FROM externaltable;
You can similarly use the following SQL statement to insert data into the new normal
table:
INSERT INTO normaltable AS SELECT * FROM externaltable;
18-14
Chapter 18
Loading CSV Files From External Tables
Table created.
7 rows selected.
SQL>
Example 18-7 Default Date Mask For the Session Does Not Match the Format of
Data Fields in the Data File
This example is the same as the previous example, except that the default date mask
for the session does not match the format of date fields in the data file. In the example
below, the session format for dates is DD-Mon-YYYY whereas the format of dates in the
data file is MM/DD/YYYY. If the external table definition does not have a date mask, then
the ORACLE_LOADER access driver uses the session date mask to attempt to convert the
character data in the data file to a date data type. ou specify an access parameter for
the date mask to use for all fields in the data file that are used to load date columns in
the external table.
The following is the contents of the data file for the external table:
events_all_date_fmt.csv
Winter Games,1/10/2010,10
Hockey Tournament,3/18/2009,3
Baseball Expo,4/28/2009,2
International Football Meeting,5/2/2009,14
Track and Field Finale,5/12/2009,3
Mid-summer Swim Meet,7/5/2010,4
Rugby Kickoff,9/28/2009,6
18-15
Chapter 18
Loading CSV Files From External Tables
8 location ('events_all_date_fmt.csv'));
Table created.
SQL>
7 rows selected.
"EVENT","START DATE","LENGTH",
"Winter Games", "10-JAN-2010", "10"
"Hockey Tournament", "18-MAR-2009", "3"
18-16
Chapter 18
Loading CSV Files From External Tables
events_2.csv
Event,Start date,Length,
Track and Field Finale, 12-MAY-2009, 3
Mid-summer Swim Meet, 5-JUL-2010, 4
Rugby Kickoff, 28-SEP-2009, 6
Table created.
The following shows the result of a SELECT operation on the EVENTS_XT_3 external table:
SQL> select "START DATE", EVENT, LENGTH
2 from EVENTS_XT_3
3 order by "START DATE";
7 rows selected.
Example 18-9 Data Is Split Across Two Files and Only the First File Has a Row
of Field Names
This example is the same as example 3 except that only the 1st file has a row of field
names. The first row of the second file has real data. The RECORDS clause changes
to "field names first file".
The two data files are as follows:
events_1.csv (same as for example 3)
"EVENT","START DATE","LENGTH",
"Winter Games", "10-JAN-2010", "10"
"Hockey Tournament", "18-MAR-2009", "3"
"Baseball Expo", "28-APR-2009", "2"
"International Football Meeting", "2-MAY-2009", "14"
events_2_no_header_row.csv
18-17
Chapter 18
Loading CSV Files From External Tables
Table created.
7 rows selected.
Example 18-10 The Order of the Fields in the File Match the Order of the
Columns in the Table
This example has the following conditions:
• The order of the fields in the file match the order of the columns in the table.
• Fields are separated by newlines and are optionally enclosed in double quotation
marks.
• There are fields that have embedded newlines in their value and those fields are
enclosed in double quotation marks.
The contents of the data files are as follows:
event_contacts_1.csv
event_contacts_2.csv
18-18
Chapter 18
Loading CSV Files From External Tables
The table definition is as follows. The CSV WITH EMBEDDED RECORD TERMINATORS clause
tells the access driver how to handle fields enclosed by double quotation marks that
also have embedded new lines.
SQL> CREATE TABLE EVENTS_CONTACTS_1
2 (EVENT varchar2(30),
3 START_DATE date,
4 CONTACT varchar2(120))
5 ORGANIZATION EXTERNAL
6 (default directory def_dir1
7 access parameters (fields CSV with embedded record terminators)
8 location ('event_contacts_1.csv', 'event_contacts_2.csv'));
Table created.
The following shows the result of a SELECT operation on the EVENT_CONTACTS_1 external
table:
SQL> column contact format a30
SQL> select START_DATE, EVENT, CONTACT
2 from EVENTS_CONTACTS_1
3 order by START_DATE;
7 rows selected.
Example 18-11 Not All Fields in the Data File Use Default Settings for the
Access Parameters
This example shows what to do when most field in the data file use default settings for
the access parameters but a few do not. Instead of listing the setting for all fields, this
example shows how you can set attributes for just the fields that are different from the
default. The differences are as follows:
• there are two date fields, one of which uses the session format, but
registration_deadline uses a different format
18-19
Chapter 18
Loading CSV Files From External Tables
Winter Games,10-JAN-2010,10,12/1/2009,
Hockey Tournament,18-MAR-2009,3,3/11/2009,
Baseball Expo,28-APR-2009,2,NONE
International Football Meeting,2-MAY-2009,14,3/1/2009
Track and Field Finale,12-MAY-2010,3,5/10/010
Mid-summer Swim Meet,5-JUL-2010,4,6/20/2010
Rugby Kickoff,28-SEP-2009,6,NONE
The table definition is as follows. The ALL FIELDS OVERRIDE clause allows you to specify
information for that field while using defaults for the remaining fields. The remaining
fields have a data type of CHAR(255) and the field data is terminated by a comma with a
trimming option of LDRTRIM.
SQL> CREATE TABLE EVENT_REGISTRATION_1
2 (EVENT varchar2(30),
3 START_DATE date,
4 LENGTH number,
5 REGISTRATION_DEADLINE date)
6 ORGANIZATION EXTERNAL
7 (default directory def_dir1
8 access parameters
9 (fields all fields override
10 (REGISTRATION_DEADLINE CHAR (10) DATE_FORMAT DATE MASK "mm/dd/yyyy"
11 NULLIF REGISTRATION_DEADLINE = 'NONE'))
12 location ('events_reg.csv'));
Table created.
7 rows selected.
18-20
Part IV
Other Utilities
ADRCI: ADR Command Interpreter
Describes the Automatic Diagnostic Repository Command Interpreter (ADRCI), a
command-line tool used to manage Oracle Database diagnostic data.
DBVERIFY: Offline Database Verification Utility
Describes how to use the offline database verification utility, DBVERIFY.
DBNEWID Utility
Describes how to use the DBNEWID utility to change the name or ID, or both, for a
database.
Using LogMiner to Analyze Redo Log Files
Describes the Oracle LogMiner utility, which enables you to query redo logs through a
SQL interface.
Using the Metadata APIs
Describes the Metadata API, which you can use to extract and manipulate complete
representations of the metadata for database objects.
Original Export
Describes how to use the original Export utility to write data from an Oracle database
into dump files for use by the original Import utility.
Original Import
Describes how to use the original Import utility to import dump files created by the
original Export utility.
• ADRCI: ADR Command Interpreter
• DBVERIFY: Offline Database Verification Utility
• DBNEWID Utility
• Using LogMiner to Analyze Redo Log Files
• Using the Metadata APIs
• Original Export
• Original Import
19
ADRCI: ADR Command Interpreter
The Automatic Diagnostic Repository Command Interpreter (ADRCI) utility is a
command-line tool that you use to manage Oracle Database diagnostic data.
See the following topics:
See Also:
Oracle Database Administrator's Guide for more information about managing
diagnostic data.
19-1
Chapter 19
Definitions
Note:
The easier and recommended way to manage diagnostic data is with the
Oracle Enterprise Manager Support Workbench (Support Workbench). ADRCI
provides a command-line alternative to most of the functionality of the Support
Workbench, and adds capabilities such as listing and querying trace files.
See Oracle Database Administrator's Guide for complete information about the
Support Workbench.
19.2 Definitions
The following are definitions of terms used for ADRCI and the Oracle Database fault
diagnosability infrastructure:
Problem
A problem is a critical error in the database. Critical errors include internal errors such
as ORA-00600 and other severe errors such as ORA-07445 (operating system exception)
or ORA-04031 (out of memory in the shared pool). Problems are tracked in the ADR.
Each problem has a problem key and a unique problem ID. (See "Problem Key".)
Incident
An incident is a single occurrence of a problem. When a problem occurs multiple
times, an incident is created for each occurrence. Incidents are tracked in the ADR.
Each incident is identified by a numeric incident ID, which is unique within the ADR.
When an incident occurs, the database makes an entry in the alert log, sends an
incident alert to Oracle Enterprise Manager, gathers diagnostic data about the incident
in the form of dump files (incident dumps), tags the incident dumps with the incident
ID, and stores the incident dumps in an ADR subdirectory created for that incident.
Diagnosis and resolution of a critical error usually starts with an incident alert. You can
obtain a list of all incidents in the ADR with an ADRCI command. Each incident is
mapped to a single problem only.
Incidents are flood-controlled so that a single problem does not generate too many
incidents and incident dumps. See Oracle Database Administrator's Guide for more
information about incident flood control.
19-2
Chapter 19
Definitions
Problem Key
Every problem has a problem key, which is a text string that includes an error code
(such as ORA 600) and in some cases, one or more error parameters. Two incidents are
considered to have the same root cause if their problem keys match.
Incident Package
An incident package (package) is a collection of data about incidents for one or more
problems. Before sending incident data to Oracle Support it must be collected into a
package using the Incident Packaging Service (IPS). After a package is created, you
can add external files to the package, remove selected files from the package, or
scrub (edit) selected files in the package to remove sensitive data.
A package is a logical construct only, until you create a physical file from the package
contents. That is, an incident package starts out as a collection of metadata in the
ADR. As you add and remove package contents, only the metadata is modified. When
you are ready to upload the data to Oracle Support, you create a physical package
using ADRCI, which saves the data into a zip file. You can then upload the zip file to
Oracle Support.
Finalizing
Before ADRCI can generate a physical package from a logical package, the package
must be finalized. This means that other components are called to add any correlated
diagnostic data files to the incidents already in this package. Finalizing also adds
recent trace files, alert log entries, Health Monitor reports, SQL test cases, and
configuration information. This step is run automatically when a physical package is
generated, and can also be run manually using the ADRCI utility. After manually
finalizing a package, you can review the files that were added and then remove or edit
any that contain sensitive information.
See Also:
Oracle Database Administrator's Guide for more information about correlated
diagnostic data
ADR Home
An ADR home is the root directory for all diagnostic data—traces, dumps, alert log,
and so on—for a particular instance of a particular Oracle product or component. For
example, in an Oracle RAC environment with Oracle ASM, each database instance
and each Oracle ASM instance has an ADR home. All ADR homes share the same
hierarchical directory structure. Some of the standard subdirectories in each ADR
home include alert (for the alert log), trace (for trace files), and incident (for incident
information). All ADR homes are located within the ADR base directory. (See "ADR
Base".)
Some ADRCI commands can work with multiple ADR homes simultaneously. The
current ADRCI homepath determines the ADR homes that are searched for diagnostic
data when an ADRCI command is issued. See "Homepath" for more information.
19-3
Chapter 19
Starting ADRCI and Getting Help
ADR Base
To permit correlation of diagnostic data across multiple ADR homes, ADR homes are
grouped together under the same root directory called the ADR base. For example, in
an Oracle RAC environment, the ADR base could be on a shared disk, and the ADR
home for each Oracle RAC instance could be located under this ADR base.
The location of the ADR base for a database instance is set by the DIAGNOSTIC_DEST
initialization parameter. If this parameter is omitted or is null, the database sets it to a
default value. See Oracle Database Administrator's Guide for details.
When multiple database instances share an Oracle home, whether they are multiple
single instances or the instances of an Oracle RAC database, and when one or more
of these instances set ADR base in different locations, the last instance to start up
determines the default ADR base for ADRCI.
Homepath
All ADRCI commands operate on diagnostic data in the current ADR homes. More
than one ADR home can be current at any one time. Some ADRCI commands (such
as SHOW INCIDENT) search for and display diagnostic data from all current ADR homes,
while other commands require that only one ADR home be current, and display an
error message if more than one are current.
The ADRCI homepath determines the ADR homes that are current. It does so by
pointing to a directory within the ADR base hierarchy. If it points to a single ADR home
directory, that ADR home is the only current ADR home. If the homepath points to a
directory that is above the ADR home directory level in the hierarchy, all ADR homes
that are below the directory that is pointed to become current.
The homepath is null by default when ADRCI starts. This means that all ADR homes
under ADR base are current.
The SHOW HOME and SHOW HOMEPATH commands display a list of the ADR homes that are
current, and the SET HOMEPATH command sets the homepath.
See Also:
19-4
Chapter 19
Starting ADRCI and Getting Help
For example, to get help on the SHOW TRACEFILE command, enter the following:
HELP SHOW TRACEFILE
To view a list of command line options:
19-5
Chapter 19
Starting ADRCI and Getting Help
The following command line parameters are available for batch operation:
Parameter Description
EXEC Enables you to submit one or more ADRCI commands on the operating
system command line that starts ADRCI. Commands are separated by
semicolons (;).
SCRIPT Enables you to run a script containing ADRCI commands.
For example, to run the SHOW HOMES command in batch mode, enter the following
command at the operating system command prompt:
ADRCI EXEC="SHOW HOMES"
To run the SHOW HOMES command followed by the SHOW INCIDENT command, enter the
following:
ADRCI EXEC="SHOW HOMES; SHOW INCIDENT"
To run ADRCI scripts:
• Enter the following command at the operating system command prompt:
• ADRCI SCRIPT=SCRIPT_FILE_NAME
For example, to run a script file named adrci_script.txt, enter the following
command at the operating system command prompt:
ADRCI SCRIPT=adrci_script.txt
19-6
Chapter 19
Setting the ADRCI Homepath Before Using ADRCI Commands
In all ADRCI commands and output, ADR home directory paths (ADR homes) are
always expressed relative to ADR base. So if ADR base is currently /u01/app/oracle,
the absolute paths of these two ADR homes are the following:
/u01/app/oracle/diag/rdbms/orclbi/orclbi1/
/u01/app/oracle/diag/rdbms/orclbi/orclbi2/
You use the SET HOMEPATH command to set one or more ADR homes to be current. If
ADR base is /u01/app/oracle and you want to set the homepath to /u01/app/oracle/
diag/rdbms/orclbi/orclbi2/, you use this command:
adrci> set homepath diag/rdbms/orclbi/orclbi2
When ADRCI starts, the homepath is null by default, which means that all ADR homes
under ADR base are current. In the previously cited example, therefore, the ADR
homes for both Oracle RAC instances would be current.
adrci> show homes
ADR Homes:
diag/rdbms/orclbi/orclbi1
diag/rdbms/orclbi/orclbi2
In this case, any ADRCI command that you run, assuming that the command supports
more than one current ADR home, works with diagnostic data from both ADR homes.
If you were to set the homepath to /diag/rdbms/orclbi/orclbi2, only the ADR home for
the instance with SID orclbi2 would be current.
19-7
Chapter 19
Viewing the Alert Log
In this case, any ADRCI command that you run would work with diagnostic data from
this single ADR home only.
See Also:
If more than one ADR home is current, you are prompted to select a single ADR
home from a list. The alert log is displayed, with XML tags omitted, in your default
editor.
4. Exit the editor to return to the ADRCI command prompt.
The following are variations on the SHOW ALERT command:
SHOW ALERT -TAIL
19-8
Chapter 19
Finding Trace Files
This displays the last portion of the alert log (the last 10 entries) in your terminal
session.
SHOW ALERT -TAIL 50
This displays the last 50 entries in the alert log in your terminal session.
SHOW ALERT -TAIL -F
This displays the last 10 entries in the alert log, and then waits for more messages to
arrive in the alert log. As each message arrives, it is appended to the display. This
command enables you to perform live monitoring of the alert log. Press CTRL+C to
stop waiting and return to the ADRCI prompt.
SPOOL /home/steve/MYALERT.LOG
SHOW ALERT -TERM
SPOOL OFF
This outputs the alert log, without XML tags, to the file /home/steve/MYALERT.LOG.
This displays only alert log messages that contain the string 'ORA-600'. The output
looks something like this:
ADR Home = /u01/app/oracle/product/11.1.0/db_1/log/diag/rdbms/orclbi/orclbi:
******************************************************************************
01-SEP-06 09.17.44.849000000 PM -07:00
AlertMsg1: ORA-600 dbgris01, addr=0xa9876541
See Also:
• "SHOW ALERT"
• "SET EDITOR"
• Oracle Database Administrator's Guide for instructions for viewing the alert
log with Oracle Enterprise Manager or with a text editor
19-9
Chapter 19
Viewing Incidents
multiple ADR homes are current, the traces file lists from all ADR homes are output
one after another.
The following statement lists the names of all trace files in the current ADR homes,
without any filtering:
SHOW TRACEFILE
The following statement lists the name of every trace file that has the string mmon in its
file name. The percent sign (%) is used as a wildcard character, and the search string
is case sensitive.
SHOW TRACEFILE %mmon%
This statement lists the name of every trace file that is located in the /home/steve/temp
directory and that has the string mmon in its file name:
SHOW TRACEFILE %mmon% -PATH /home/steve/temp
This statement lists the names of trace files in reverse order of last modified time. That
is, the most recently modified trace files are listed first.
SHOW TRACEFILE -RT
This statement lists the names of all trace files related to incident number 1681:
SHOW TRACEFILE -I 1681
See Also:
• "SHOW TRACEFILE"
• Oracle Database Administrator's Guide for information about the directory
structure of the ADR
19-10
Chapter 19
Packaging Incidents
See Also:
"ADRCI Command Reference"
19-11
Chapter 19
Packaging Incidents
where:
• packageName consists of a portion of the problem key followed by a timestamp
• sequence is an integer
For example, if you generate a complete zip file for a logical package that was created
on September 6, 2006 at 4:53 p.m., and then generate an incremental zip file for the
same logical package, you would create files with names similar to the following:
ORA603_20060906165316_COM_1.zip
ORA603_20060906165316_INC_2.zip
See Also:
"About Packaging Incidents"
19-12
Chapter 19
Packaging Incidents
This creates an empty package. You must use the IPS ADD INCIDENT or IPS ADD FILE
commands to add diagnostic data to the package before generating it.
IPS CREATE PACKAGE PROBLEM problem_ID
This creates a package and includes diagnostic information for incidents that reference
the specified problem ID. (Problem IDs are integers.) You can obtain the problem ID
for an incident from the report displayed by the SHOW INCIDENT -MODE BRIEF command.
Because there can be many incidents with the same problem ID, ADRCI adds to the
package the diagnostic information for the first three incidents (early incidents) that
occurred and last three incidents (late incidents) that occurred with this problem ID,
excluding any incidents that are older than 90 days.
Note:
The number of early and late incidents, and the 90-day age limit are defaults
that can be changed. See "IPS SET CONFIGURATION".
ADRCI may also add other incidents that correlate closely in time or in other criteria
with the already added incidents.
IPS CREATE PACKAGE PROBLEMKEY "problem_key"
This creates a package and includes diagnostic information for incidents that reference
the specified problem key. You can obtain problem keys from the report displayed by
the SHOW INCIDENT command. Because there can be many incidents with the same
problem key, ADRCI adds to the package only the diagnostic information for the first
19-13
Chapter 19
Packaging Incidents
three early incidents and last three late incidents with this problem key, excluding
incidents that are older than 90 days.
Note:
The number of early and late incidents, and the 90-day age limit are defaults
that can be changed. See "IPS SET CONFIGURATION".
ADRCI may also add other incidents that correlate closely in time or in other criteria
with the already added incidents.
The problem key must be enclosed in single quotation marks (') or double quotation
marks (") if it contains spaces or quotation marks.
IPS CREATE PACKAGE SECONDS sec
This creates a package and includes diagnostic information for all incidents that
occurred from sec seconds ago until now. sec must be an integer.
IPS CREATE PACKAGE TIME 'start_time' TO 'end_time'
This creates a package and includes diagnostic information for all incidents that
occurred within the specified time range. start_time and end_time must be in the
format 'YYYY-MM-DD HH24:MI:SS.FF TZR'. This is a valid format string for the
NLS_TIMESTAMP_TZ_FORMAT initialization parameter. The fraction (FF) portion of the time is
optional, and the HH24:MI:SS delimiters can be colons or periods.
For example, the following command creates a package with incidents that occurred
between July 24th and July 30th of 2010:
IPS CREATE PACKAGE TIME '2010-07-24 00:00:00 -07:00' to '2010-07-30 23.59.59 -07:00'
See Also:
"IPS CREATE PACKAGE"
19-14
Chapter 19
ADRCI Command Reference
filespec must be a fully qualified file name (with path). Only files that are within the
ADR base directory hierarchy may be added.
See Also:
"ADRCI Command Reference"
This generates a complete physical package (zip file) in the designated path. For
example, the following command creates a complete physical package in the
directory /home/steve/diagnostics from logical package number 2:
IPS GENERATE PACKAGE 2 IN /home/steve/diagnostics
You can also generate an incremental package containing only the incidents that have
occurred since the last package generation.
To generate an incremental physical incident package:
• At the ADRCI prompt, enter the following command:
IPS GENERATE PACKAGE package_number IN path INCREMENTAL
See Also:
19-15
Chapter 19
ADRCI Command Reference
Command Description
CREATE REPORT Creates a report for the specified report type and ID.
ECHO Echoes the input string.
EXIT Exits the current ADRCI session.
HOST Executes operating system commands from ADRCI.
IPS Invokes the IPS utility. See Table 19-3 for the IPS commands
available within ADRCI.
PURGE Purges diagnostic data in the current ADR home, according to
current purging policies.
QUIT Exits the current ADRCI session.
RUN Runs an ADRCI script.
SELECT Retrieves qualified records from the specified incident or problem.
SET BASE Sets the ADR base for the current ADRCI session.
SET BROWSER Reserved for future use.
SET CONTROL Set purging policies for ADR contents.
SET ECHO Toggles command output.
SET EDITOR Sets the default editor for displaying trace and alert log contents.
SET HOMEPATH Makes current one or more ADR homes.
SET TERMOUT Toggles terminal output.
SHOW ALERT Shows alert log messages.
SHOW BASE Shows the current ADR base.
SHOW CONTROL Shows ADR information, including the current purging policy.
SHOW HM_RUN Shows Health Monitor run information.
SHOW HOMEPATH Shows the current homepath.
SHOW HOMES Lists the current ADR homes.
SHOW INCDIR Lists the trace files created for the specified incidents.
SHOW INCIDENT Outputs a list of incidents.
SHOW LOG Shows diagnostic log messages.
SHOW PROBLEM Outputs a list of problems.
SHOW REPORT Shows a report for the specified report type and ID.
SHOW TRACEFILE Lists qualified trace file names.
19-16
Chapter 19
ADRCI Command Reference
Command Description
SPOOL Directs output to a file.
Note:
Unless otherwise specified, all commands work with multiple current ADR
homes.
• CREATE REPORT
• ECHO
• EXIT
• HOST
• IPS
• PURGE
• QUIT
• RUN
• SELECT
• SET BASE
• SET BROWSER
• SET CONTROL
• SET ECHO
• SET EDITOR
• SET HOMEPATH
• SET TERMOUT
• SHOW ALERT
• SHOW BASE
• SHOW CONTROL
• SHOW HM_RUN
• SHOW HOMEPATH
• SHOW HOMES
• SHOW INCDIR
• SHOW INCIDENT
• SHOW LOG
• SHOW PROBLEM
• SHOW REPORT
19-17
Chapter 19
ADRCI Command Reference
• SHOW TRACEFILE
• SPOOL
Note:
Results of Health Monitor runs are stored in the ADR in an internal format. To
view these results, you must create a Health Monitor report from them and then
view the report. You need create the report only once. You can then view it
multiple times.
report_type must be hm_run. run_name is a Health Monitor run name. Obtain run names
with the SHOW HM_RUN command.
If the report already exists it is overwritten. Use the SHOW REPORT command to view
the report.
This command does not support multiple ADR homes.
Example
This example creates a report for the Health Monitor run with run name hm_run_1421:
create report hm_run hm_run_1421
Note:
CREATE REPORT does not work when multiple ADR homes are set. For information
about setting a single ADR home, see "Setting the ADRCI Homepath Before
Using ADRCI Commands".
19.9.2 ECHO
Purpose
Prints the input string. You can use this command to print custom text from ADRCI
scripts.
19-18
Chapter 19
ADRCI Command Reference
Example
These examples print the string "Hello, world!":
echo "Hello, world!"
19.9.3 EXIT
Purpose
Exits the ADRCI utility.
This command does not require an ADR home to be set before you can use it.
19.9.4 HOST
Purpose
Execute operating system commands without leaving ADRCI.
Use host by itself to enter an operating system shell, which allows you to enter multiple
operating system commands. Enter EXIT to leave the shell and return to ADRCI.
You can also specify the command on the same line (host_command_string) enclosed in
double quotation marks.
This command does not require an ADR home to be set before you can use it.
Examples
host
19.9.5 IPS
Purpose
Invokes the Incident Packaging Service (IPS). The IPS command provides options for
creating logical incident packages (packages), adding diagnostic data to packages,
and generating physical packages for transmission to Oracle Support.
19-19
Chapter 19
ADRCI Command Reference
See Also:
"Packaging Incidents" for more information about packaging
Command Description
IPS ADD Adds an incident, problem, or problem key to a package.
IPS ADD FILE Adds a file to a package.
IPS ADD NEW INCIDENTS Finds and adds new incidents for the problems in the specified
package.
IPS COPY IN FILE Copies files into the ADR from the external file system.
IPS COPY OUT FILE Copies files out of the ADR to the external file system.
IPS CREATE PACKAGE Creates a new (logical) package.
IPS DELETE PACKAGE Deletes a package and its contents from the ADR.
IPS FINALIZE Finalizes a package before uploading.
IPS GENERATE PACKAGE Generates a zip file of the specified package contents in the
target directory.
IPS GET MANIFEST Retrieves and displays the manifest from a package zip file.
IPS GET METADATA Extracts metadata from a package zip file and displays it.
IPS PACK Creates a physical package (zip file) directly from incidents,
problems, or problem keys.
IPS REMOVE Removes incidents from an existing package.
IPS REMOVE FILE Remove a file from an existing package.
IPS SET CONFIGURATION Changes the value of an IPS configuration parameter.
IPS SHOW Displays the values of IPS configuration parameters.
CONFIGURATION
IPS SHOW FILES Lists the files in a package.
IPS SHOW INCIDENTS Lists the incidents in a package.
IPS SHOW PACKAGE Displays information about the specified package.
IPS UNPACK FILE Unpackages a package zip file into a specified path.
Note:
IPS commands do not work when multiple ADR homes are set. For information
about setting a single ADR home, see "Setting the ADRCI Homepath Before
Using ADRCI Commands".
19-20
Chapter 19
ADRCI Command Reference
Use the <ADR_BASE> variable to access the ADR base directory as follows:
ips add file <ADR_BASE>/diag/rdbms/orcl/orcl/trace/orcl_ora_13579.trc package 12
Note:
Type the angle brackets (< >) as shown.
19-21
Chapter 19
ADRCI Command Reference
Argument Description
incident first [n] Adds the first n incidents to the package, where n is a
positive integer. For example, if n is set to 5, then the
first five incidents are added. If n is omitted, then the
default is 1, and the first incident is added.
incident inc_id Adds an incident with ID inc_id to the package.
incident last [n] Adds the last n incidents to the package, where n is a
positive integer. For example, if n is set to 5, then the
last five incidents are added. If n is omitted, then the
default is 1, and the last incident is added.
problem first [n] Adds the incidents for the first n problems to the
package, where n is a positive integer. For example, if n
is set to 5, then the incidents for the first five problems
are added. If n is omitted, then the default is 1, and the
incidents for the first problem is added.
Adds only the first three early incidents and last three
late incidents for each problem, excluding any older than
90 days. (Note: These limits are defaults and can be
changed. See "IPS SET CONFIGURATION".)
problem prob_id Adds all incidents with problem ID prob_id to the
package. Adds only the first three early incidents and
last three late incidents for the problem, excluding any
older than 90 days. (Note: These limits are defaults and
can be changed. See "IPS SET CONFIGURATION".)
problem last [n] Adds the incidents for the last n problems to the
package, where n is a positive integer. For example, if n
is set to 5, then the incidents for the last five problems
are added. If n is omitted, then the default is 1, and the
incidents for the last problem is added.
Adds only the first three early incidents and last three
late incidents for each problem, excluding any older than
90 days. (Note: These limits are defaults and can be
changed. See "IPS SET CONFIGURATION".)
problemkey pr_key Adds incidents with problem key pr_key to the package.
Adds only the first three early incidents and last three
late incidents for the problem key, excluding any older
than 90 days. (Note: These limits are defaults and can
be changed.)
seconds secs Adds all incidents that have occurred within secs
seconds of the present time.
19-22
Chapter 19
ADRCI Command Reference
Argument Description
time start_time to end_time Adds all incidents between start_time and end_time to
the package. Time format is 'YYYY-MM-YY HH24:MI:SS.FF
TZR'. Fractional part (FF) is optional.
package package_id Specifies the package to which to add incidents.
Examples
This example adds incident 22 to package 12:
ips add incident 22 package 12
This example adds the first three early incidents and the last three late incidents with
problem ID 6 to package 2, exuding any incidents older than 90 days:
ips add problem 6 package 2
This example adds all incidents taking place during the last minute to package 5:
ips add seconds 60 package 5
This example adds all incidents taking place between 10:00 a.m. and 11:00 p.m. on
May 1, 2010:
ips add time '2010-05-01 10:00:00.00 -07:00' to '2010-05-01 23:00:00.00 -07:00'
file_name is the full path name of the file. You can use the <ADR_HOME> and <ADR_BASE>
variables if desired. The file must be under the same ADR base as the package.
package_id is the package ID.
Example
This example adds a trace file to package 12:
ips add file <ADR_HOME>/trace/orcl_ora_13579.trc package 12
See Also:
See "Using the <ADR_HOME> and <ADR_BASE> Variables in IPS
Commands" for information about the <ADR_HOME> directory syntax
19-23
Chapter 19
ADRCI Command Reference
package_id is the ID of the package to update. Only new incidents of the problems in
the package are added.
Example
This example adds up to three of the new late incidents for the problems in package
12:
ips add new incidents package 12
Note:
The number of late incidents added is a default that can be changed. See "IPS
SET CONFIGURATION".
Copies an external file, filename (specified with full path name) into the ADR,
associating it with an existing package, package_id, and optionally an incident, incid.
Use the to new_name option to give the copied file a new file name within the ADR. Use
the overwrite option to overwrite a file that exists already.
Example
This example copies a trace file from the file system into the ADR, associating it with
package 2 and incident 4:
ips copy in file /home/nick/trace/orcl_ora_13579.trc to <ADR_HOME>/trace/
orcl_ora_13579.trc package 2 incident 4
19-24
Chapter 19
ADRCI Command Reference
See Also:
Copies a file, source, to a location outside the ADR, target (specified with full path
name). Use the overwrite option to overwrite the file that exists already.
Example
This example copies the file orcl_ora_13579.trc, in the trace subdirectory of the current
ADR home, to a local folder.
ips copy out file <ADR_HOME>/trace/orcl_ora_13579.trc to /home/nick/trace/
orcl_ora_13579.trc
See Also:
19-25
Chapter 19
ADRCI Command Reference
Optionally, you can add incidents to the new package using the provided options.
Table 19-5 describes the arguments for IPS CREATE PACKAGE.
Argument Description
incident first [n] Adds the first n incidents to the package, where n is a
positive integer. For example, if n is set to 5, then the
first five incidents are added. If n is omitted, then the
default is 1, and the first incident is added.
incident inc_id Adds an incident with ID inc_id to the package.
incident last [n] Adds the last n incidents to the package, where n is a
positive integer. For example, if n is set to 5, then the
last five incidents are added. If n is omitted, then the
default is 1, and the last incident is added.
problem first [n] Adds the incidents for the first n problems to the
package, where n is a positive integer. For example, if n
is set to 5, then the incidents for the first five problems
are added. If n is omitted, then the default is 1, and the
incidents for the first problem is added.
Adds only the first three early incidents and last three
late incidents for each problem, excluding any older than
90 days. (Note: These limits are defaults and can be
changed. See "IPS SET CONFIGURATION".)
problem prob_id Adds all incidents with problem ID prob_id to the
package. Adds only the first three early incidents and
last three late incidents for the problem, excluding any
older than 90 days. (Note: These limits are defaults and
can be changed. See "IPS SET CONFIGURATION".)
problem last [n] Adds the incidents for the last n problems to the
package, where n is a positive integer. For example, if n
is set to 5, then the incidents for the last five problems
are added. If n is omitted, then the default is 1, and the
incidents for the last problem is added.
Adds only the first three early incidents and last three
late incidents for each problem, excluding any older than
90 days. (Note: These limits are defaults and can be
changed. See "IPS SET CONFIGURATION".)
problemkey pr_key Adds all incidents with problem key pr_key to the
package. Adds only the first three early incidents and
last three late incidents for the problem key, excluding
any older than 90 days. (Note: These limits are defaults
and can be changed.)
seconds secs Adds all incidents that have occurred within secs
seconds of the present time.
time start_time to end_time Adds all incidents taking place between start_time and
end_time to the package. Time format is 'YYYY-MM-YY
HH24:MI:SS.FF TZR'. Fractional part (FF) is optional.
19-26
Chapter 19
ADRCI Command Reference
Argument Description
correlate {basic |typical | all} Selects a method of including correlated incidents in the
package. There are three options for this argument:
• correlate basic includes incident dumps and
incident process trace files.
• correlate typical includes incident dumps and
any trace files that were modified within five minutes
of each incident. You can alter the time interval by
modifying the INCIDENT_TIME_WINDOW configuration
parameter.
• correlate all includes the incident dumps, and all
trace files that were modified between the time of
the first selected incident and the last selected
incident.
The default value is correlate typical.
Examples
This example creates a package with no incidents:
ips create package
Output:
Created package 5 without any contents, correlation level typical
Output:
Created package 6 based on time range 2010-05-01 10:00:00.00 -07:00 to 2010-05-01
23:00:00.00 -07:00, correlation level typical
This example creates a package and adds the first three early incidents and the last
three late incidents with problem ID 3, excluding incidents that are older than 90 days:
ips create package problem 3
Output:
Created package 7 based on problem id 3, correlation level typical
Note:
The number of early and late incidents added, and the 90-day age limit are
defaults that can be changed. See "IPS SET CONFIGURATION".
19-27
Chapter 19
ADRCI Command Reference
See Also:
"Creating Incident Packages"
Example
ips delete package 12
Example
ips finalize package 12
See Also:
Oracle Database Administrator's Guide for more information about finalizing
packages
19-28
Chapter 19
ADRCI Command Reference
package_id is the ID of the package to generate. Optionally, you can save the file in the
directory path. Otherwise, the package is generated in the current working directory.
The complete option means the package forces ADRCI to include all package files.
This is the default behavior.
The incremental option includes only files that have been added or changed since the
last time that this package was generated. With the incremental option, the command
finishes more quickly.
Example
This example generates a physical package file in path /home/steve:
ips generate package 12 in /home/steve
This example generates a physical package from files added or changed since the last
generation:
ips generate package 14 incremental
See Also:
"Generating a Physical Incident Package"
filename is a package zip file. The manifest is an XML-formatted set of metadata for
the package file, including information about ADR configuration, correlated files,
incidents, and how the package was generated.
This command does not require an ADR home to be set before you can use it.
Example
ips get manifest from file /home/steve/ORA603_20060906165316_COM_1.zip
19-29
Chapter 19
ADRCI Command Reference
filename is a package zip file. The metadata in a package file (stored in the file
metadata.xml) contains information about the ADR home, ADR base, and product.
Use the from adr option to get the metadata from a package zip file that has been
unpacked into an ADR home using IPS UNPACK.
Example
This example displays metadata from a package file:
ips get metadata from file /home/steve/ORA603_20060906165316_COM_1.zip
This next example displays metadata from a package file that was unpacked into the
directory /scratch/oracle/package1:
set base /scratch/oracle/package1
ips get metadata from adr
In this previous example, upon receiving the SET BASE command, ADRCI automatically
adds to the homepath the ADR home that was created in /scratch/oracle/package1 by
the IPS UNPACK FILE command.
See Also:
"IPS UNPACK FILE" for more information about unpacking package files
ADRCI automatically generates the package number for the new package. IPS PACK
creates an empty package if no package contents are specified.
Table 19-6 describes the arguments for IPS PACK.
Argument Description
incident first [n] Adds the first n incidents to the package, where n is a
positive integer. For example, if n is set to 5, then the
first five incidents are added. If n is omitted, then the
default is 1, and the first incident is added.
incident inc_id Adds an incident with ID inc_id to the package.
19-30
Chapter 19
ADRCI Command Reference
Argument Description
incident last [n] Adds the last n incidents to the package, where n is a
positive integer. For example, if n is set to 5, then the
last five incidents are added. If n is omitted, then the
default is 1, and the last incident is added.
problem first [n] Adds the incidents for the first n problems to the
package, where n is a positive integer. For example, if n
is set to 5, then the incidents for the first five problems
are added. If n is omitted, then the default is 1, and the
incidents for the first problem is added.
Adds only the first three early incidents and last three
late incidents for each problem, excluding any older than
90 days. (Note: These limits are defaults and can be
changed. See "IPS SET CONFIGURATION".)
problem prob_id Adds all incidents with problem ID prob_id to the
package. Adds only the first three early incidents and
last three late incidents for the problem, excluding any
older than 90 days. (Note: These limits are defaults and
can be changed. See "IPS SET CONFIGURATION".)
problem last [n] Adds the incidents for the last n problems to the
package, where n is a positive integer. For example, if n
is set to 5, then the incidents for the last five problems
are added. If n is omitted, then the default is 1, and the
incidents for the last problem is added.
Adds only the first three early incidents and last three
late incidents for each problem, excluding any older than
90 days. (Note: These limits are defaults and can be
changed. See "IPS SET CONFIGURATION".)
problemkey pr_key Adds incidents with problem key pr_key to the package.
Adds only the first three early incidents and last three
late incidents for the problem key, excluding any older
than 90 days. (Note: These limits are defaults and can
be changed.)
seconds secs Adds all incidents that have occurred within secs
seconds of the present time.
time start_time to end_time Adds all incidents taking place between start_time and
end_time to the package. Time format is 'YYYY-MM-YY
HH24:MI:SS.FF TZR'. Fractional part (FF) is optional.
19-31
Chapter 19
ADRCI Command Reference
Argument Description
correlate {basic |typical | all} Selects a method of including correlated incidents in the
package. There are three options for this argument:
• correlate basic includes incident dumps and
incident process trace files.
• correlate typical includes incident dumps and
any trace files that were modified within five minutes
of each incident. You can alter the time interval by
modifying the INCIDENT_TIME_WINDOW configuration
parameter.
• correlate all includes the incident dumps, and all
trace files that were modified between the time of
the first selected incident and the last selected
incident.
The default value is correlate typical.
in path Saves the physical package to directory path.
Example
This example creates an empty package:
ips pack
This example creates a physical package containing all information for incident 861:
ips pack incident 861
This example creates a physical package for all incidents in the last minute, fully
correlated:
ips pack seconds 60 correlate all
See Also:
"IPS SET CONFIGURATION" for more information about setting configuration
parameters.
After removing incidents from a package, the incidents continue to be tracked within
the package metadata to prevent ADRCI from automatically including them later (such
as with ADD NEW INCIDENTS).
19-32
Chapter 19
ADRCI Command Reference
Argument Description
incident inc_id Removes the incident with ID inc_id from the package
problem prob_id Removes all incidents with problem ID prob_id from the
package
problemkey pr_key Removes all incidents with problem key pr_key from the
package
package package_id Removes incidents from the package with ID
package_id.
Example
This example removes incident 22 from package 12:
ips remove incident 22 package 12
See Also:
"IPS GET MANIFEST" for information about package metadata
file_name is the file to remove from package package_id. The complete path of the file
must be specified. (You can use the <ADR_HOME> and <ADR_BASE> variables if desired.)
After removal, the file continues to be tracked within the package metadata to prevent
ADRCI from automatically including it later (such as with ADD NEW INCIDENTS). Removing
a file, therefore, only sets the EXCLUDE flag for the file to Explicitly excluded.
Example
This example removes a trace file from package 12:
ips remove file <ADR_HOME>/trace/orcl_ora_13579.trc package 12
Removed file <ADR_HOME>/trace/orcl_ora_13579.trc from package 12
ips show files package 12
.
.
.
FILE_ID 4
FILE_LOCATION <ADR_HOME>/trace
19-33
Chapter 19
ADRCI Command Reference
FILE_NAME orcl_ora_13579.trc
LAST_SEQUENCE 0
EXCLUDE Explicitly excluded
.
.
.
See Also:
Example
ips set configuration 3 10
IPS SHOW CONFIGURATION lists the following information for each configuration parameter:
• Parameter ID
• Name
• Description
• Unit used by parameter (such as days or hours)
• Value
19-34
Chapter 19
ADRCI Command Reference
• Default value
• Minimum Value
• Maximum Value
• Flags
Optionally, you can get information about a specific parameter by supplying a
parameter_id or a parameter_name.
Example
This command describes all IPS configuration parameters:
ips show configuration
Output:
PARAMETER INFORMATION:
PARAMETER_ID 1
NAME CUTOFF_TIME
DESCRIPTION Maximum age for an incident to be considered for
inclusion
UNIT Days
VALUE 90
DEFAULT_VALUE 90
MINIMUM 1
MAXIMUM 4294967295
FLAGS 0
PARAMETER INFORMATION:
PARAMETER_ID 2
NAME NUM_EARLY_INCIDENTS
DESCRIPTION How many incidents to get in the early part of the range
UNIT Number
VALUE 3
DEFAULT_VALUE 3
MINIMUM 1
MAXIMUM 4294967295
FLAGS 0
PARAMETER INFORMATION:
PARAMETER_ID 3
NAME NUM_LATE_INCIDENTS
DESCRIPTION How many incidents to get in the late part of the range
UNIT Number
VALUE 3
DEFAULT_VALUE 3
MINIMUM 1
MAXIMUM 4294967295
FLAGS 0
PARAMETER INFORMATION:
PARAMETER_ID 4
NAME INCIDENT_TIME_WINDOW
DESCRIPTION Incidents this close to each other are considered
correlated
UNIT Minutes
VALUE 5
DEFAULT_VALUE 5
MINIMUM 1
MAXIMUM 4294967295
19-35
Chapter 19
ADRCI Command Reference
FLAGS 0
PARAMETER INFORMATION:
PARAMETER_ID 5
NAME PACKAGE_TIME_WINDOW
DESCRIPTION Time window for content inclusion is from x hours
before first included incident to x hours after last
incident
UNIT Hours
VALUE 24
DEFAULT_VALUE 24
MINIMUM 1
MAXIMUM 4294967295
FLAGS 0
PARAMETER INFORMATION:
PARAMETER_ID 6
NAME DEFAULT_CORRELATION_LEVEL
DESCRIPTION Default correlation level for packages
UNIT Number
VALUE 2
DEFAULT_VALUE 2
MINIMUM 1
MAXIMUM 4
FLAGS 0
Examples
This command describes configuration parameter NUM_EARLY_INCIDENTS:
ips show configuration num_early_incidents
Parameter ID Description
CUTOFF_TIME 1 Maximum age, in days, for an incident to be
considered for inclusion.
NUM_EARLY_INCIDENTS 2 Number of incidents to include in the early part of the
range when creating a package based on a problem.
By default, ADRCI adds the three earliest incidents
and three most recent incidents to the package.
NUM_LATE_INCIDENTS 3 Number of incidents to include in the late part of the
range when creating a package based on a problem.
By default, ADRCI adds the three earliest incidents
and three most recent incidents to the package.
INCIDENT_TIME_WINDOW 4 Number of minutes between two incidents in order for
them to be considered correlated.
19-36
Chapter 19
ADRCI Command Reference
Parameter ID Description
PACKAGE_TIME_WINDOW 5 Number of hours to use as a time window for
including incidents in a package. For example, a
value of 5 includes incidents five hours before the
earliest incident in the package, and five hours after
the most recent incident in the package.
DEFAULT_CORRELATION_LEVEL 6 The default correlation level to use for correlating
incidents in a package. The correlation levels are:
• 1 (basic): includes incident dumps and incident
process trace files.
• 2 (typical): includes incident dumps and any
trace files that were modified within the time
window specified by INCIDENT_TIME_WINDOW (see
above).
• 4 (all): includes the incident dumps, and all trace
files that were modified between the first
selected incident and the last selected incident.
Additional incidents can be included
automatically if they occurred in the same time
range.
See Also:
"IPS SET CONFIGURATION"
Example
This example shows all files associated with package 1:
ips show files package 1
Output:
FILE_ID 1
FILE_LOCATION <ADR_HOME>/alert
FILE_NAME log.xml
LAST_SEQUENCE 1
EXCLUDE Included
19-37
Chapter 19
ADRCI Command Reference
FILE_ID 2
FILE_LOCATION <ADR_HOME>/trace
FILE_NAME alert_adcdb.log
LAST_SEQUENCE 1
EXCLUDE Included
FILE_ID 27
FILE_LOCATION <ADR_HOME>/incident/incdir_4937
FILE_NAME adcdb_ora_692_i4937.trm
LAST_SEQUENCE 1
EXCLUDE Included
FILE_ID 28
FILE_LOCATION <ADR_HOME>/incident/incdir_4937
FILE_NAME adcdb_ora_692_i4937.trc
LAST_SEQUENCE 1
EXCLUDE Included
FILE_ID 29
FILE_LOCATION <ADR_HOME>/trace
FILE_NAME adcdb_ora_692.trc
LAST_SEQUENCE 1
EXCLUDE Included
FILE_ID 30
FILE_LOCATION <ADR_HOME>/trace
FILE_NAME adcdb_ora_692.trm
LAST_SEQUENCE 1
EXCLUDE Included
.
.
.
Example
This example lists the incidents in package 1:
ips show incidents package 1
Output:
MAIN INCIDENTS FOR PACKAGE 1:
INCIDENT_ID 4985
PROBLEM_ID 1
EXCLUDE Included
19-38
Chapter 19
ADRCI Command Reference
Use the basic option to display a minimal amount of information. It is the default when
no package_id is specified.
Use the brief option to display more information about the package than the basic
option. It is the default when a package_id is specified.
Use the detail option to show the information displayed by the brief option, as well as
some package history and information about the included incidents and files.
Example
ips show package 12
file_name is the full path name of the physical package (zip file) to unpack. Optionally,
you can unpack the file into directory path, which must exist and be writable. If you
omit the path, the current working directory is used. The destination directory is treated
as an ADR base, and the entire ADR base directory hierarchy is created, including a
valid ADR home.
This command does not require an ADR home to be set before you can use it.
Example
ips unpack file /tmp/ORA603_20060906165316_COM_1.zip into /tmp/newadr
19.9.6 PURGE
Purpose
Purges diagnostic data in the current ADR home, according to current purging policies.
Only ADR contents that are due to be purged are purged.
19-39
Chapter 19
ADRCI Command Reference
Diagnostic data in the ADR has a default lifecycle. For example, information about
incidents and problems is subject to purging after one year, whereas the associated
dump files (dumps) are subject to purging after only 30 days.
Some Oracle products, such as Oracle Database, automatically purge diagnostic data
at the end of its life cycle. Other products and components require you to purge
diagnostic data manually with this command. You can also use this command to purge
data that is due to be automatically purged.
The SHOW CONTROL command displays the default purging policies for short-lived
ADR contents and long-lived ADR contents.
Flag Description
-i {id1 | start_id end_id} Purges either a specific incident ID (id) or a
range of incident IDs (start_id and
end_id)
-age mins Purges only data older than mins minutes.
-type {ALERT|INCIDENT|TRACE|CDUMP|HM| Specifies the type of diagnostic data to
UTSCDMP} purge. Used with the -age clause.
The following types can be specified:
• ALERT - Alert logs
• INCIDENT - Incident data
• TRACE - Trace files (including dumps)
• CDUMP - Core dump files
• HM - Health Monitor run data and
reports
• UTSCDMP - Dumps of in-memory traces
for each session
The UTSCDMP data is stored in
directories under the trace directory.
Each of these directories is named
cdmp_timestamp. In response to a
critical error (such as an ORA-600 or
ORA-7445 error), a background
process creates such a directory and
writes each session's in-memory
tracing data into a trace file. This data
might be useful in determining what the
instance was doing in the seconds
leading up to the failure.
Examples
This example purges all diagnostic data in the current ADR home based on the default
purging policies:
purge
19-40
Chapter 19
ADRCI Command Reference
This example purges all diagnostic data for all incidents between 123 and 456:
purge -i 123 456
This example purges all incident data from before the last hour:
purge -age 60 -type incident
Note:
PURGE does not work when multiple ADR homes are set. For information about
setting a single ADR home, see "Setting the ADRCI Homepath Before Using
ADRCI Commands".
19.9.7 QUIT
See "EXIT".
19.9.8 RUN
Purpose
Runs an ADRCI script.
@ script_name
@@ script_name
script_name is the file containing the ADRCI commands to execute. ADRCI looks for
the script in the current directory unless a full path name is supplied. If the file name is
given without a file extension, ADRCI uses the default extension .adi.
The run and @ commands are synonyms. The @@ command is similar to run and @
except that when used inside a script, @@ uses the path of the calling script to locate
script_name, rather than the current directory.
This command does not require an ADR home to be set before you can use it.
Example
run my_script
@my_script
19.9.9 SELECT
Purpose
Retrieves qualified records for the specified incident or problem.
19-41
Chapter 19
ADRCI Command Reference
Flag Description
field1, field2, ... Lists the fields to retrieve. If * is specified, then all fields are
retrieved.
incident|problem Indicates whether to query incidents or problems.
WHERE "predicate_string" Uses a SQL-like predicate string to show only the incident or
problem for which the predicate is true. The predicate string
must be enclosed in double quotation marks.
Table 19-16 lists the fields that can be used in the predicate
string incidents.
Table 19-20 lists the fields that can be used in the predicate
string for problems.
ORDER BY field1, Show results sorted by field in the given order, as well as in
field2, ... [ASC|DSC|DESC] ascending (ASC) and descending order (DSC or DESC). When the
ORDER BY clause is specified, results are shown in ascending
order by default.
GROUP BY field1, Show results grouped by the specified fields.
field2, ... The GROUP BY flag groups rows but does not guarantee the order
of the result set. To order the groupings, use the ORDER BY flag.
HAVING Restrict the groups of returned rows to those groups for which
"having_predicate_string" the having predicate is true. The HAVING flag must be used in
combination with the GROUP BY flag.
Note:
The WHERE, ORDER BY, GROUP BY, and HAVING flags are similar to the clauses with
the same names in a SELECT SQL statement. See Oracle Database SQL
Language Reference for more information about the clauses in a SELECT SQL
statement.
Restrictions
The following restrictions apply when you use the SELECT command:
19-42
Chapter 19
ADRCI Command Reference
Examples
This example retrieves the incident_id and create_time for incidents with an
incident_id greater than 1:
This example retrieves the problem_id and first_incident for each problem with a
problem_key that includes 600:
Functions
This section describes functions that you can use with the SELECT command.
The purpose and syntax of these functions are similar to the corresponding SQL
functions, but there are some differences. This section notes the differences between
the functions used with the ADRCI utility and the SQL functions.
The following restrictions apply to all of the functions:
• The expressions must be simple expressions. See Oracle Database SQL
Language Reference for information about simple expressions.
• You cannot combine function calls. For example, the following combination of
function calls is not supported:
sum(length(column_name))
• No functions are overloaded.
• All function arguments are mandatory.
• The functions cannot be used with other ADRCI Utility commands.
19-43
Chapter 19
ADRCI Command Reference
Function Description
AVG Returns the average value of an expression.
CONCAT Returns the concatenation of two character strings.
COUNT Returns the number of rows returned by the query.
DECODE Compares an expression to each search value one by
one.
LENGTH Returns the length of a character string using as
defined by the input character set.
MAX Returns the maximum value of an expression.
MIN Returns the minimum value of an expression
NVL Replaces null (returned as a blank) with character data
in the results of a query.
REGEXP_LIKE Returns rows that match a specified pattern in a
specified regular expression.
SUBSTR Returns a portion of character data.
SUM Returns the sum of values of an expression.
TIMESTAMP_TO_CHAR Converts a value of TIMESTAMP data type to a value of
VARCHAR2 data type in a specified format.
TOLOWER Returns character data, with all letters lowercase.
TOUPPER Returns character data, with all letters uppercase.
• AVG
• CONCAT
• COUNT
• DECODE
• LENGTH
• MAX
• MIN
• NVL
• REGEXP_LIKE
• SUBSTR
• SUM
• TIMESTAMP_TO_CHAR
• TOLOWER
• TOUPPER
19.9.9.1 AVG
Returns the average value of an expression.
19-44
Chapter 19
ADRCI Command Reference
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the AVG function in the SELECT command:
19.9.9.2 CONCAT
Returns a concatenation of two character strings. The character data can be of the
data types CHAR and VARCHAR2. The return value is the same data type as the character
data.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the CONCAT function in the SELECT
command:
• The function does not support LOB data types, including BLOB, CLOB, NCLOB, and
BFILE data types.
• The function does not support national character set data types, including NCHAR,
NVARCHAR2, and NCLOB data types.
19.9.9.3 COUNT
Returns the number of rows returned by the query.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the COUNT function in the SELECT
command:
• The expression must be a column, a numeric constant, or a string constant.
• The function does not support the DISTINCT or ALL keywords.
• The function does not support the OVER clause.
• The function always counts all rows for the query, including duplicates and nulls.
Examples
This example returns the number of incidents for which flood_controlled is 0 (zero):
19-45
Chapter 19
ADRCI Command Reference
This example returns the number of problems for which problem_key includes ORA-600:
select count(*) from problem where problem_key like '%ORA-600%';
19.9.9.4 DECODE
Compares an expression to each search value one by one. If the expression is equal
to a search, then Oracle Database returns the corresponding result. If no match is
found, then Oracle returns the specified default value.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the DECODE function in the SELECT
command:
• The search arguments must be character data.
• A default value must be specified.
Example
This example shows each incident_id and whether or not the incident is flood-
controlled. The example uses the DECODE function to display text instead of numbers for
the flood_controlled field.
select incident_id, decode(flood_controlled, 0, \
"Not flood-controlled", "Flood-controlled") from incident;
19.9.9.5 LENGTH
Returns the length of a character string using as defined by the input character set.
The character string can be any of the data types CHAR, VARCHAR2, NCHAR, NVARCHAR2,
CLOB, or NCLOB. The return value is of data type NUMBER. If the character sting has data
type CHAR, then the length includes all trailing blanks. If the character string is null, then
this function returns 0 (zero).
Note:
The SQL function returns null if the character string is null.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The SELECT command does not support the following functions: LENGTHB, LENGTHC,
LENGTH2, and LENGTH4.
19-46
Chapter 19
ADRCI Command Reference
Example
This example shows the problem_id and the length of the problem_key for each
problem.
select problem_id, length(problem_key) from problem;
19.9.9.6 MAX
Returns the maximum value of an expression.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the MAX function in the SELECT command:
Example
This example shows the maximum last_incident value for all of the recorded
problems.
select max(last_incident) from problem;
19.9.9.7 MIN
Returns the minimum value of an expression.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the MIN function in the SELECT command:
Example
This example shows the minimum first_incident value for all of the recorded
problems.
select min(first_incident) from problem;
19.9.9.8 NVL
Replaces null (returned as a blank) with character data in the results of a query. If the
first expression specified is null, then NVL returns second expression specified. If first
expression specified is not null, then NVL returns the value of the first expression.
19-47
Chapter 19
ADRCI Command Reference
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the NVL function in the SELECT command:
Example
This example replaces NULL in the output for singalling_component with the text "No
component."
select nvl(signalling_component, 'No component') from incident;
19.9.9.9 REGEXP_LIKE
Returns rows that match a specified pattern in a specified regular expression.
Note:
In SQL, REGEXP_LIKE is a condition instead of a function.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the REGEXP_LIKE function in the SELECT
command:
• The pattern match is always case-sensitive.
• The function does not support the match_param argument.
Example
This example shows the problem_id and problem_key for all problems where the
problem_key ends with a number.
19.9.9.10 SUBSTR
Returns a portion of character data. The portion of data returned begins at the
specified position and is the specified substring length characters long. SUBSTR
calculates lengths using characters as defined by the input character set.
19-48
Chapter 19
ADRCI Command Reference
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the SUBSTR function in the SELECT
command:
• The function supports only positive integers. It does not support negative values or
floating-point numbers.
• The SELECT command does not support the following functions: SUBSTRB, SUBSTRC,
SUBSTR2, and SUBSTR4.
Example
This example shows each problem_key starting with the fifth character in the key.
select substr(problem_key, 5) from problem;
19.9.9.11 SUM
Returns the sum of values of an expression.
Syntax
See Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the SUM function in the SELECT command:
19.9.9.12 TIMESTAMP_TO_CHAR
Converts a value of TIMESTAMP data type to a value of VARCHAR2 data type in a specified
format. If you do not specify a format, then the function converts values to the default
timestamp format.
Syntax
See the syntax of the TO_CHAR function in Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the TIMESTAMP_TO_CHAR function in the
SELECT command:
• The function converts only TIMESTAMP data type. TIMESTAMP WITH TIME ZONE, TIMESTAMP
WITH LOCAL TIME ZONE, and other data types are not supported.
• The function does not support the nlsparm argument. The function uses the default
language for your session.
19-49
Chapter 19
ADRCI Command Reference
Example
This example converts the create_time for each incident from a TIMESTAMP data type to
a VARCHAR2 data type in the DD-MON-YYYY format.
select timestamp_to_char(create_time, 'DD-MON-YYYY') from incident;
19.9.9.13 TOLOWER
Returns character data, with all letters lowercase. The character data can be of the
data types CHAR and VARCHAR2. The return value is the same data type as the character
data. The database sets the case of the characters based on the binary mapping
defined for the underlying character set.
Syntax
See the syntax of the LOWER function in Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the TOLOWER function in the SELECT
command:
• The function does not support LOB data types, including BLOB, CLOB, NCLOB, and
BFILE data types.
• The function does not support national character set data types, including NCHAR,
NVARCHAR2, and NCLOB data types.
Example
This example shows each problem_key in all lowercase letters.
select tolower(problem_key) from problem;
19.9.9.14 TOUPPER
Returns character data, with all letters uppercase. The character data can be of the
data types CHAR and VARCHAR2. The return value is the same data type as the character
data. The database sets the case of the characters based on the binary mapping
defined for the underlying character set.
Syntax
See the syntax of the UPPER function in Oracle Database SQL Language Reference.
Restrictions
The following restrictions apply when you use the TOUPPER function in the SELECT
command:
• The function does not support LOB data types, including BLOB, CLOB, NCLOB, and
BFILE data types.
• The function does not support national character set data types, including NCHAR,
NVARCHAR2, and NCLOB data types.
19-50
Chapter 19
ADRCI Command Reference
Example
This example shows each problem_key in all uppercase letters.
select toupper(problem_key) from problem;
base_str is a full path to a directory. The format for base_str depends on the operating
system. If there are valid ADR homes under the base directory, these homes are
added to the homepath of the current ADRCI session.
This command does not require an ADR home to be set before you can use it.
Example
set base /u01/app/oracle
See Also:
"ADR Base"
Note:
This command is reserved for future use. At this time ADRCI does not support
HTML-formatted reports in a browser.
browser_program is the browser program name (it is assumed the browser can be
started from the current ADR working directory). If no browser is set, ADRCI will
display reports to the terminal or spool file.
This command does not require an ADR home to be set before you can use it.
19-51
Chapter 19
ADRCI Command Reference
Example
set browser mozilla
See Also:
The SHORTP_POLICY and LONGP_POLICY are not mutually exclusive. Each policy controls
different types of content.
This command works with a single ADR home only.
Example
set control (SHORTP_POLICY = 360)
This command does not require an ADR home to be set before you can use it.
Example
set echo off
19-52
Chapter 19
ADRCI Command Reference
See Also:
"SPOOL" for more information about spooling
editor_program is the editor program name. If no editor is set, ADRCI uses the editor
specified by the operating system environment variable EDITOR. If EDITOR is not set,
ADRCI uses vi as the default editor.
This command does not require an ADR home to be set before you can use it.
Example
set editor xemacs
The homepath_strn strings are the paths of the ADR homes relative to the current ADR
base. The diag directory name can be omitted from the path. If the specified path
contains multiple ADR homes, all of the homes are added to the homepath.
If a desired new ADR home is not within the current ADR base, use SET BASE to set a
new ADR base and then use SET HOMEPATH.
This command does not require an ADR home to be set before you can use it.
Example
set homepath diag/rdbms/orcldw/orcldw1 diag/rdbms/orcldw/orcldw2
The following command sets the same homepath as the previous example:
set homepath rdbms/orcldw/orcldw1 rdbms/orcldw/orcldw2
19-53
Chapter 19
ADRCI Command Reference
See Also:
"Homepath"
This setting is independent of spooling. That is, the output can be directed to both
terminal and a file at the same time.
This command does not require an ADR home to be set before you can use it.
See Also:
"SPOOL" for more information about spooling
Example
set termout on
Except when using the -term flag, this command works with only a single current ADR
home. If more than one ADR home is set, ADRCI prompts you to choose the ADR
home to use.
Flag Description
-p "predicate_string" Uses a SQL-like predicate string to show only the alert log
entries for which the predicate is true. The predicate string must
be enclosed in double quotation marks.
Table 19-13 lists the fields that can be used in the predicate
string.
19-54
Chapter 19
ADRCI Command Reference
Flag Description
-tail [num] [-f] Displays the most recent entries in the alert log.
Use the num option to display the last num entries in the alert log.
If num is omitted, the last 10 entries are displayed.
If the -f option is given, after displaying the requested
messages, the command does not return. Instead, it remains
active and continuously displays new alert log entries to the
terminal as they arrive in the alert log. You can use this
command to perform live monitoring of the alert log. To terminate
the command, press CTRL+C.
-term Directs results to the terminal. Outputs the entire alert logs from
all current ADR homes, one after another. If this option is not
given, the results are displayed in the default editor.
-file alert_file_name Enables you to specify an alert file outside the ADR.
alert_file_name must be specified with a full path name. Note
that this option cannot be used with the -tail option.
Field Type
ORIGINATING_TIMESTAMP timestamp
NORMALIZED_TIMESTAMP timestamp
ORGANIZATION_ID text(65)
COMPONENT_ID text(65)
HOST_ID text(65)
HOST_ADDRESS text(17)
MESSAGE_TYPE number
MESSAGE_LEVEL number
MESSAGE_ID text(65)
MESSAGE_GROUP text(65)
CLIENT_ID text(65)
MODULE_ID text(65)
PROCESS_ID text(33)
THREAD_ID text(65)
USER_ID text(65)
INSTANCE_ID text(65)
DETAILED_LOCATION text(161)
UPSTREAM_COMP_ID text(101)
DOWNSTREAM_COMP_ID text(101)
EXECUTION_CONTEXT_ID text(101)
EXECUTION_CONTEXT_SEQUENCE number
ERROR_INSTANCE_ID number
19-55
Chapter 19
ADRCI Command Reference
Field Type
ERROR_INSTANCE_SEQUENCE number
MESSAGE_TEXT text(2049)
MESSAGE_ARGUMENTS text(129)
SUPPLEMENTAL_ATTRIBUTES text(129)
SUPPLEMENTAL_DETAILS text(4000)
PROBLEM_KEY text(65)
Examples
This example shows all alert messages for the current ADR home in the default editor:
show alert
This example shows all alert messages for the current ADR home and directs the
output to the terminal instead of the default editor:
show alert -term
This example shows all alert messages for the current ADR home with message text
describing an incident:
show alert -p "message_text like '%incident%'"
This example shows the last twenty alert messages, and then keeps the alert log
open, displaying new alert log entries as they arrive:
show alert -tail 20 -f
This example shows all alert messages for a single ADR home in the default editor
when multiple ADR homes have been set:
show alert
1: diag/tnslsnr/dbhost1/listener
2: diag/asm/+asm/+ASM
3: diag/rdbms/orcl/orcl
4: diag/clients/user_oracle/host_9999999999_11
Q: to quit
See Also:
"SET EDITOR"
19-56
Chapter 19
ADRCI Command Reference
Optionally, you can show the product's ADR base location for a specific product. The
products currently supported are CLIENT and ADRCI.
This command does not require an ADR home to be set before you can use it.
Example
This example shows the current ADR base:
show base
Output:
ADR base is "/u01/app/oracle"
This example shows the current ADR base for Oracle Database clients:
show base -product client
Displays various attributes of the ADR, including the following purging policy attributes:
19-57
Chapter 19
ADRCI Command Reference
Note:
The SHORTP_POLICY and LONGP_POLICY attributes are not mutually exclusive. Each
policy controls different types of content.
Field Type
RUN_ID number
RUN_NAME text(31)
CHECK_NAME text(31)
NAME_ID number
MODE number
START_TIME timestamp
RESUME_TIME timestamp
END_TIME timestamp
MODIFIED_TIME timestamp
TIMEOUT number
FLAGS number
STATUS number
SRC_INCIDENT_ID number
19-58
Chapter 19
ADRCI Command Reference
Field Type
NUM_INCIDENTS number
ERR_NUMBER number
REPORT_FILE bfile
Examples
This example displays data for all Health Monitor runs:
show hm_run
This example displays data for the Health Monitor run with ID 123:
show hm_run -p "run_id=123"
See Also:
Oracle Database Administrator's Guide for more information about Health
Monitor
This command does not require an ADR home to be set before you can use it.
Example
show homepath
Output:
ADR Homes:
diag/tnslsnr/dbhost1/listener
diag/asm/+asm/+ASM
diag/rdbms/orcl/orcl
diag/clients/user_oracle/host_9999999999_11
See Also:
"SET HOMEPATH" for information about how to set the homepath
19-59
Chapter 19
ADRCI Command Reference
This command does not require an ADR home to be set before you can use it.
Example
show homes
Output:
ADR Homes:
diag/tnslsnr/dbhost1/listener
diag/asm/+asm/+ASM
diag/rdbms/orcl/orcl
diag/clients/user_oracle/host_9999999999_11
You can provide a single incident ID (id) or a range of incidents (id_low to id_high). If
no incident ID is given, trace files for all incidents are listed.
Examples
This example shows all trace files for all incidents:
show incdir
Output:
ADR Home = /u01/app/oracle/log/diag/rdbms/emdb/emdb:
*************************************************************************
diag/rdbms/emdb/emdb/incident/incdir_3801/emdb_ora_23604_i3801.trc
diag/rdbms/emdb/emdb/incident/incdir_3801/emdb_m000_23649_i3801_a.trc
diag/rdbms/emdb/emdb/incident/incdir_3802/emdb_ora_23604_i3802.trc
diag/rdbms/emdb/emdb/incident/incdir_3803/emdb_ora_23604_i3803.trc
diag/rdbms/emdb/emdb/incident/incdir_3804/emdb_ora_23604_i3804.trc
diag/rdbms/emdb/emdb/incident/incdir_3805/emdb_ora_23716_i3805.trc
diag/rdbms/emdb/emdb/incident/incdir_3805/emdb_m000_23767_i3805_a.trc
diag/rdbms/emdb/emdb/incident/incdir_3806/emdb_ora_23716_i3806.trc
diag/rdbms/emdb/emdb/incident/incdir_3633/emdb_pmon_28970_i3633.trc
diag/rdbms/emdb/emdb/incident/incdir_3633/emdb_m000_23778_i3633_a.trc
diag/rdbms/emdb/emdb/incident/incdir_3713/emdb_smon_28994_i3713.trc
diag/rdbms/emdb/emdb/incident/incdir_3713/emdb_m000_23797_i3713_a.trc
19-60
Chapter 19
ADRCI Command Reference
diag/rdbms/emdb/emdb/incident/incdir_3807/emdb_ora_23783_i3807.trc
diag/rdbms/emdb/emdb/incident/incdir_3807/emdb_m000_23803_i3807_a.trc
diag/rdbms/emdb/emdb/incident/incdir_3808/emdb_ora_23783_i3808.trc
Output:
ADR Home = /u01/app/oracle/log/diag/rdbms/emdb/emdb:
*************************************************************************
diag/rdbms/emdb/emdb/incident/incdir_3713/emdb_smon_28994_i3713.trc
diag/rdbms/emdb/emdb/incident/incdir_3713/emdb_m000_23797_i3713_a.trc
This example shows all tracefiles for incidents between 3801 and 3804:
show incdir 3801 3804
Output:
ADR Home = /u01/app/oracle/log/diag/rdbms/emdb/emdb:
*************************************************************************
diag/rdbms/emdb/emdb/incident/incdir_3801/emdb_ora_23604_i3801.trc
diag/rdbms/emdb/emdb/incident/incdir_3801/emdb_m000_23649_i3801_a.trc
diag/rdbms/emdb/emdb/incident/incdir_3802/emdb_ora_23604_i3802.trc
diag/rdbms/emdb/emdb/incident/incdir_3803/emdb_ora_23604_i3803.trc
diag/rdbms/emdb/emdb/incident/incdir_3804/emdb_ora_23604_i3804.trc
Flag Description
-p "predicate_string" Use a predicate string to show only the incidents for
which the predicate is true. The predicate string
must be enclosed in double quotation marks.
Table 19-16 lists the fields that can be used in the
predicate string.
19-61
Chapter 19
ADRCI Command Reference
Flag Description
-mode {BASIC|BRIEF|DETAIL} Choose an output mode for incidents. BASIC is the
default.
• BASIC displays only basic incident information
(the INCIDENT_ID, PROBLEM_ID, and
CREATE_TIME fields). It does not display flood-
controlled incidents.
• BRIEF displays all information related to the
incidents, as given by the fields in Table 19-16.
It includes flood-controlled incidents.
• DETAIL displays all information for the incidents
(as with BRIEF mode) as well as information
about incident dumps. It includes flood-
controlled incidents.
-orderby field1, field2, ... [ASC| Show results sorted by field in the given order, as
DSC] well as in ascending (ASC) and descending order
(DSC). By default, results are shown in ascending
order.
19-62
Chapter 19
ADRCI Command Reference
Examples
This example shows all incidents for this ADR home:
show incident
Output:
ADR Home = /u01/app/oracle/log/diag/rdbms/emdb/emdb:
*************************************************************************
INCIDENT_ID PROBLEM_KEY CREATE_TIME
-------------------- -------------------------------------------- ----------------------------
3808 ORA 603 2010-06-18 21:35:49.322161 -07:00
3807 ORA 600 [4137] 2010-06-18 21:35:47.862114 -07:00
3806 ORA 603 2010-06-18 21:35:26.666485 -07:00
3805 ORA 600 [4136] 2010-06-18 21:35:25.012579 -07:00
3804 ORA 1578 2010-06-18 21:35:08.483156 -07:00
3713 ORA 600 [4136] 2010-06-18 21:35:44.754442 -07:00
3633 ORA 600 [4136] 2010-06-18 21:35:35.776151 -07:00
7 rows fetched
19-63
Chapter 19
ADRCI Command Reference
Output:
ADR Home = /u01/app/oracle/log/diag/rdbms/emdb/emdb:
*************************************************************************
**********************************************************
INCIDENT INFO RECORD 1
**********************************************************
INCIDENT_ID 3805
STATUS closed
CREATE_TIME 2010-06-18 21:35:25.012579 -07:00
PROBLEM_ID 2
CLOSE_TIME 2010-06-18 22:26:54.143537 -07:00
FLOOD_CONTROLLED none
ERROR_FACILITY ORA
ERROR_NUMBER 600
ERROR_ARG1 4136
ERROR_ARG2 2
ERROR_ARG3 18.0.628
ERROR_ARG4 <NULL>
ERROR_ARG5 <NULL>
ERROR_ARG6 <NULL>
ERROR_ARG7 <NULL>
ERROR_ARG8 <NULL>
SIGNALLING_COMPONENT <NULL>
SIGNALLING_SUBCOMPONENT <NULL>
SUSPECT_COMPONENT <NULL>
SUSPECT_SUBCOMPONENT <NULL>
ECID <NULL>
IMPACTS 0
PROBLEM_KEY ORA 600 [4136]
FIRST_INCIDENT 3805
FIRSTINC_TIME 2010-06-18 21:35:25.012579 -07:00
LAST_INCIDENT 3713
LASTINC_TIME 2010-06-18 21:35:44.754442 -07:00
IMPACT1 0
IMPACT2 0
IMPACT3 0
IMPACT4 0
KEY_NAME Client ProcId
KEY_VALUE oracle@dbhost1 (TNS V1-V3).23716_3083142848
KEY_NAME SID
KEY_VALUE 127.52237
KEY_NAME ProcId
KEY_VALUE 23.90
KEY_NAME PQ
KEY_VALUE (0, 1182227717)
OWNER_ID 1
INCIDENT_FILE /.../emdb/emdb/incident/incdir_3805/emdb_ora_23716_i3805.trc
OWNER_ID 1
INCIDENT_FILE /.../emdb/emdb/trace/emdb_ora_23716.trc
OWNER_ID 1
INCIDENT_FILE /.../emdb/emdb/incident/incdir_3805/emdb_m000_23767_i3805_a.trc
1 rows fetched
19-64
Chapter 19
ADRCI Command Reference
Flag Description
-l log_name Name of the log to show.
If no log name is specified, then this command displays all
messages from all diagnostic logs under the current ADR Home.
-p "predicate_string" Use a SQL-like predicate string to show only the log entries for
which the predicate is true. The predicate string must be
enclosed in double quotation marks.
Table 19-18 lists the fields that can be used in the predicate
string.
-term Direct results to the terminal.
If this option is not specified, then this command opens the
results in an editor. By default, it opens the results in emacs, but
you can use the SET EDITOR command to open the results in
other editors.
-tail [num] [-f] Displays the most recent entries in the log.
Use the num option to display the last num entries in the log. If
num is omitted, the last 10 entries are displayed.
If the -f option is given, after displaying the requested
messages, the command does not return. Instead, it remains
active and continuously displays new log entries to the terminal
as they arrive in the log. You can use this command to perform
live monitoring of the log. To terminate the command, press
CTRL+C.
Field Type
ORIGINATING_TIMESTAMP timestamp
NORMALIZED_TIMESTAMP timestamp
ORGANIZATION_ID text(65)
COMPONENT_ID text(65)
HOST_ID text(65)
HOST_ADDRESS text(17)
MESSAGE_TYPE number
MESSAGE_LEVEL number
19-65
Chapter 19
ADRCI Command Reference
Field Type
MESSAGE_ID text(65)
MESSAGE_GROUP text(65)
CLIENT_ID text(65)
MODULE_ID text(65)
PROCESS_ID text(33)
THREAD_ID text(65)
USER_ID text(65)
INSTANCE_ID text(65)
DETAILED_LOCATION text(161)
UPSTREAM_COMP_ID text(101)
DOWNSTREAM_COMP_ID text(101)
EXECUTION_CONTEXT_ID text(101)
EXECUTION_CONTEXT_SEQUENCE number
ERROR_INSTANCE_ID number
ERROR_INSTANCE_SEQUENCE number
MESSAGE_TEXT text(2049)
MESSAGE_ARGUMENTS text(129)
SUPPLEMENTAL_ATTRIBUTES text(129)
SUPPLEMENTAL_DETAILS text(4000)
PROBLEM_KEY text(65)
Flag Description
-p "predicate_string" Use a SQL-like predicate string to show only the incidents for
which the predicate is true. The predicate string must be
enclosed in double quotation marks.
The table "Problem Fields for SHOW PROBLEM" lists the fields
that can be used in the predicate string.
19-66
Chapter 19
ADRCI Command Reference
Flag Description
-last num | -all Shows the last num problems, or lists all the problems. By
default, SHOW PROBLEM lists the most recent 50 problems.
-orderby field1, Show results sorted by field in the given order (field1,
field2, ... [ASC|DSC] field2, ...), as well as in ascending (ASC) and descending order
(DSC). By default, results are shown in ascending order.
Example
This example lists all the problems in the current ADR home:
show problem -all
19-67
Chapter 19
ADRCI Command Reference
report_type must be hm_run. run_name is the Health Monitor run name from which you
created the report. You must first create the report using the CREATE REPORT command.
This command does not require an ADR home to be set before you can use it.
Example
show report hm_run hm_run_1421
See Also:
• "CREATE REPORT"
• "SHOW HM_RUN"
This command searches for one or more files under the trace directory and all incident
directories of the current ADR homes, unless the -i or -path flags are given.
This command does not require an ADR home to be set unless using the -i option.
Argument Description
file1 file2 ... Filter results by file name. The % symbol is a wildcard character.
19-68
Chapter 19
ADRCI Command Reference
Flag Description
-rt | -t Order the trace file names by timestamp. -t sorts the file names
in ascending order by timestamp, and -rt sorts them in reverse
order. Note that file names are only ordered relative to their
directory. Listing multiple directories of trace files applies a
separate ordering to each directory.
Timestamps are listed next to each file name when using this
option.
-i inc1 inc2 ... Select only the trace files produced for the given incident IDs.
-path path1 path2 ... Query only the trace files under the given path names.
Examples
This example shows all the trace files under the current ADR home:
show tracefile
This example shows all the mmon trace files, sorted by timestamp in reverse order:
show tracefile %mmon% -rt
This example shows all trace files for incidents 1 and 4, under the path /home/steve/
temp:
show tracefile -i 1 4 -path /home/steve/temp
19.9.29 SPOOL
Purpose
Directs ADRCI output to a file.
filename is the file name where the output is to be directed. If a full path name is not
given, the file is created in the current ADRCI working directory. If no file extension is
given, the default extension .ado is used. APPEND causes the output to be appended to
the end of the file. Otherwise, the file is overwritten. Use OFF to turn off spooling.
This command does not require an ADR home to be set before you can use it.
Example
spool myfile
spool off
spool
19-69
Chapter 19
Troubleshooting ADRCI
DIA-48447: The input path [path] does not contain any ADR homes
Cause: When using SET HOMEPATH to set an ADR home, you must supply a path relative
to the current ADR base.
Action: If the new desired ADR home is not within the current ADR base, first set ADR
base with SET BASE, and then use SHOW HOMES to check the ADR homes under the new
ADR base. Next, use SET HOMEPATH to set a new ADR home if necessary.
19-70
20
DBVERIFY: Offline Database Verification
Utility
DBVERIFY is an external command-line utility that performs a physical data structure
integrity check.
DBVERIFY can be used on offline or online databases, as well on backup files. You
use DBVERIFY primarily when you need to ensure that a backup database (or data
file) is valid before it is restored, or as a diagnostic aid when you have encountered
data corruption problems. Because DBVERIFY can be run against an offline database,
integrity checks are significantly faster.
DBVERIFY checks are limited to cache-managed blocks (that is, data blocks).
Because DBVERIFY is only for use with data files, it does not work against control files
or redo logs.
There are two command-line interfaces to DBVERIFY. With the first interface, you
specify disk blocks of a single data file for checking. With the second interface, you
specify a segment for checking. Both interfaces are started with the dbv command. The
following sections provide descriptions of these interfaces:
• Using DBVERIFY to Validate Disk Blocks of a Single Data File
• Using DBVERIFY to Validate a Segment
Note:
If the file you are verifying is an Oracle Automatic Storage Management (Oracle
ASM) file, then you must supply a USERID. This is because DBVERIFY needs to
connect to an Oracle instance to access Oracle ASM files.
20-1
Chapter 20
Using DBVERIFY to Validate Disk Blocks of a Single Data File
USERID = username/password
FILE = filename
START
= block_address
END
BLOCKSIZE = integer
FEEDBACK = integer
Y
HELP =
N
PARFILE = filename
HIGH_SCN = integer
Parameter Description
USERID Specifies your username and password.
This parameter is only necessary when the files being verified are
Oracle ASM files.
If you do specify this parameter, both a username and a password
must be entered; otherwise a DBV-00112: USERID incorrectly
specified error is returned.
FILE The name of the database file to verify.
START The starting block address to verify. Specify block addresses in
Oracle blocks (as opposed to operating system blocks). If you do
not specify START, then DBVERIFY defaults to the first block in the
file.
END The ending block address to verify. If you do not specify END, then
DBVERIFY defaults to the last block in the file.
BLOCKSIZE BLOCKSIZE is required only if the file to be verified does not have a
block size of 2 KB. If the file does not have block size of 2 KB and
you do not specify BLOCKSIZE, then you will receive the error
DBV-00103.
20-2
Chapter 20
Using DBVERIFY to Validate Disk Blocks of a Single Data File
Parameter Description
HIGH_SCN When a value is specified for HIGH_SCN, DBVERIFY writes
diagnostic messages for each block whose block-level SCN
exceeds the value specified.
This parameter is optional. There is no default.
LOGFILE Specifies the file to which logging information should be written.
The default sends output to the terminal display.
FEEDBACK Causes DBVERIFY to send a progress display to the terminal in
the form of a single period (.) for n number of pages verified during
the DBVERIFY run. If n = 0, then there is no progress display.
HELP Provides online help.
PARFILE Specifies the name of the parameter file to use. You can store
various values for DBVERIFY parameters in flat files. This enables
you to customize parameter files to handle different types of data
files and to perform specific types of integrity checks on data files.
................................................................................
Notes:
• Pages = Blocks
• Total Pages Examined = number of blocks in the file
• Total Pages Processed = number of blocks that were verified (formatted blocks)
• Total Pages Failing (Data) = number of blocks that failed the data block checking
routine
• Total Pages Failing (Index) = number of blocks that failed the index block checking
routine
20-3
Chapter 20
Using DBVERIFY to Validate a Segment
• Total Pages Marked Corrupt = number of blocks for which the cache header is
invalid, thereby making it impossible for DBVERIFY to identify the block type
• Total Pages Influx = number of blocks that are being read and written to at the
same time. If the database is open when DBVERIFY is run, then DBVERIFY reads
blocks multiple times to get a consistent image. But because the database is open,
there may be blocks that are being read and written to at the same time (INFLUX).
DBVERIFY cannot get a consistent image of pages that are in flux.
USERID = username/password
SEGMENT_ID = tsn.segfile.segblock
LOGFILE = filename
FEEDBACK = integer
dbv
Y
HELP =
N
PARFILE = filename
HIGH_SCN = integer
20-4
Chapter 20
Using DBVERIFY to Validate a Segment
Parameter Description
USERID Specifies your username and password. If you do not enter both a
username and a password, the error DBV-00112: USERID
incorrectly specified is returned.
If you are connecting to a container database (CDB), you would
enter username@cdbname/password.
SEGMENT_ID Specifies the segment to verify. It is composed of the tablespace
ID number (tsn), segment header file number (segfile), and
segment header block number (segblock). You can get this
information from SYS_USER_SEGS. The relevant columns are
TABLESPACE_ID, HEADER_FILE, and HEADER_BLOCK. You must have
SYSDBA privileges to query SYS_USER_SEGS.
HIGH_SCN When a value is specified for HIGH_SCN, DBVERIFY writes
diagnostic messages for each block whose block-level SCN
exceeds the value specified.
This parameter is optional. There is no default.
LOGFILE Specifies the file to which logging information should be written.
The default sends output to the terminal display.
FEEDBACK Causes DBVERIFY to send a progress display to the terminal in
the form of a single period (.) for n number of pages verified during
the DBVERIFY run. If n = 0, then there is no progress display.
HELP Provides online help.
PARFILE Specifies the name of the parameter file to use. You can store
various values for DBVERIFY parameters in flat files. This enables
you to customize parameter files to handle different types of data
files and to perform specific types of integrity checks on data files.
20-5
21
DBNEWID Utility
DBNEWID is a database utility that can change the internal database identifier (DBID)
and the database name (DBNAME) for an operational database.
See the following topics:
• What Is the DBNEWID Utility?
• Ramifications of Changing the DBID and DBNAME
• DBNEWID Considerations for CDBs and PDBs
The DBNEWID parameter PDB allows you to change the DBID on pluggable
databases (PDBs).
• Changing the DBID and DBNAME of a Database
• DBNEWID Syntax
21-1
Chapter 21
DBNEWID Considerations for CDBs and PDBs
of the control file (before the name change), then you should use the initialization
parameter file and password file from before the database name change.
Note:
Do not change the DBID or DBNAME of a database if you are using a capture
process to capture changes to the database. See Oracle Streams Concepts
and Administration for more information about capture processes.
The global database name is made up of a database name and a domain, which are
determined by the DB_NAME and DB_DOMAIN initialization parameters when the database
is first created.
The following example changes the database name to sales in the domain
us.example.com:
You would do this after you finished using DBNEWID to change the database name.
See Also:
Oracle Database Administrator's Guide for more information about global
database names
21-2
Chapter 21
Changing the DBID and DBNAME of a Database
PDB=[ALL | NONE]
• If you specify ALL, then in addition to the DBID for the CDB changing, the DBIDs
for all PDBs comprising the CDB are also changed.
• Specifying NONE (the default) leaves the PDB DBIDs the same, even if the CDB
DBID is changed.
Oracle recommends that you use PDB=ALL, but PDB=NONE is the default for backward
compatibility reasons.
To change the database name in addition to the DBID, also specify the DBNAME
parameter on the command line (you will be prompted for a password). The
following example changes the database name to test_db:
% nid TARGET=SYS DBNAME=test_db
The DBNEWID utility performs validations in the headers of the data files and
control files before attempting I/O to the files. If validation is successful, then
DBNEWID prompts you to confirm the operation (unless you specify a log file, in
which case it does not prompt), changes the DBID (and the DBNAME, if specified,
as in this example) for each data file, including offline normal and read-only data
files, shuts down the database, and then exits. The following is an example of
what the output for this would look like:
.
.
.
Connected to database PROD (DBID=86997811)
.
.
21-3
Chapter 21
Changing the DBID and DBNAME of a Database
.
Control Files in database:
/oracle/TEST_DB/data/cf1.dbf
/oracle/TEST_DB/data/cf2.dbf
If validation is not successful, then DBNEWID terminates and leaves the target
database intact, as shown in the following sample output. You can open the
database, fix the error, and then either resume the DBNEWID operation or
continue using the database without changing its DBID.
.
.
.
Connected to database PROD (DBID=86997811)
.
.
.
Control Files in database:
/oracle/TEST_DB/data/cf1.dbf
/oracle/TEST_DB/data/cf2.dbf
21-4
Chapter 21
Changing the DBID and DBNAME of a Database
Make a new database backup. Because you reset the online redo logs, the old
backups and archived logs are no longer usable in the current incarnation of the
database.
21-5
Chapter 21
Changing the DBID and DBNAME of a Database
DBNEWID performs validations in the headers of the control files (not the data
files) before attempting I/O to the files. If validation is successful, then DBNEWID
prompts for confirmation, changes the database name in the control files, shuts
down the database and exits. The following is an example of what the output for
this would look like:
.
.
.
Control Files in database:
/oracle/TEST_DB/data/cf1.dbf
/oracle/TEST_DB/data/cf2.dbf
21-6
Chapter 21
Changing the DBID and DBNAME of a Database
If validation is not successful, then DBNEWID terminates and leaves the target
database intact. You can open the database, fix the error, and then either resume
the DBNEWID operation or continue using the database without changing the
database name. (For an example of what the output looks like for an unsuccessful
validation, see Step 3 in "Changing the DBID and Database Name".)
4. Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to
the new database name.
Note:
The DBNEWID utility does not change the server parameter file (SPFILE).
Therefore, if you use SPFILE to start your Oracle database, then you must
re-create the initialization parameter file from the server parameter file,
remove the server parameter file, change the DB_NAME in the initialization
parameter file, and then re-create the server parameter file.
Because you have changed only the database name, and not the database ID, it is
not necessary to use the RESETLOGS option when you open the database. This
means that all previous backups are still usable.
21-7
Chapter 21
DBNEWID Syntax
If you choose to continue with the change, then re-execute your original command.
The DBNEWID utility resumes and attempts to continue the change until all data files
and control files have the new value or values. At this point, the database is shut
down. You should mount it before opening it with the RESETLOGS option.
If you choose to revert a DBNEWID operation, and if the reversion succeeds, then
DBNEWID reverts all performed changes and leaves the database in a mounted state.
If DBNEWID is run against a release 10.1 or later Oracle database, then a summary of
the operation is written to the alert file. For example, for a change of database name
and database ID, you might see something similar to the following:
*** DBNEWID utility started ***
DBID will be changed from 86997811 to new DBID of 1250452230 for
database PROD
DBNAME will be changed from PROD to new DBNAME of TEST_DB
Starting datafile conversion
Setting recovery target incarnation to 1
Datafile conversion complete
Database name changed to TEST_DB.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST_DB changed to 1250452230.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open with RESETLOGS option.
Successfully changed database name and ID.
*** DBNEWID utility finished successfully ***
For a change of just the database name, the alert file might show something similar to
the following:
*** DBNEWID utility started ***
DBNAME will be changed from PROD to new DBNAME of TEST_DB
Starting datafile conversion
Datafile conversion complete
Database name changed to TEST_DB.
Modify parameter file and generate a new password file before restarting.
Successfully changed database name.
*** DBNEWID utility finished successfully ***
In case of failure during DBNEWID the alert will also log the failure:
*** DBNEWID utility started ***
DBID will be changed from 86997811 to new DBID of 86966847 for database
AV3
Change of database ID failed.
Must finish change or REVERT changes before attempting any database
operation.
*** DBNEWID utility finished with errors ***
21-8
Chapter 21
DBNEWID Syntax
YES
REVERT =
NO
YES
SETNAME =
NO
DBNAME = new_db_name
ALL
PDB =
NONE
YES
APPEND = YES
NO HELP =
LOGFILE = logfile NO
• DBNEWID Parameters
• Restrictions and Usage Notes
• Additional Restrictions for Releases Earlier Than Oracle Database 10g
Parameter Description
TARGET Specifies the username and password used to connect to the database. The user
must have the SYSDBA privilege. If you are using operating system authentication,
then you can connect with the slash (/). If the $ORACLE_HOME and $ORACLE_SID
variables are not set correctly in the environment, then you can specify a secure (IPC
or BEQ) service to connect to the target database. A target database must be
specified in all invocations of the DBNEWID utility.
REVERT Specify YES to indicate that a failed change of DBID should be reverted (default is
NO). The utility signals an error if no change DBID operation is in progress on the
target database. A successfully completed change of DBID cannot be reverted.
REVERT=YES is valid only when a DBID change failed.
DBNAME=new_db_name Changes the database name of the database. You can change the DBID and the
DBNAME of a database at the same time. To change only the DBNAME, also specify
the SETNAME parameter.
SETNAME Specify YES to indicate that DBNEWID should change the database name of the
database but should not change the DBID (default is NO). When you specify
SETNAME=YES, the utility writes only to the target database control files.
21-9
Chapter 21
DBNEWID Syntax
Parameter Description
PDB Changes the DBID on either all or none of the pluggable databases (PDBs) in a
multitenant container database (CDB). (By default, when you run the DBNEWID
utility on a container database (CDB) it changes the DBID of only the CDB; the
DBIDs of the pluggable databases (PDBs) comprising the CDB remain the same.)
The PDB parameter is applicable only in a CDB environment.
LOGFILE=logfile Specifies that DBNEWID should write its messages to the specified file. By default
the utility overwrites the previous log. If you specify a log file, then DBNEWID does
not prompt for confirmation.
APPEND Specify YES to append log output to the existing log file (default is NO).
HELP Specify YES to print a list of the DBNEWID syntax options (default is NO).
21-10
Chapter 21
DBNEWID Syntax
• The DBNEWID utility must access the data files of the database directly through a
local connection. Although DBNEWID can accept a net service name, it cannot
change the DBID of a nonlocal database.
21-11
22
Using LogMiner to Analyze Redo Log Files
Oracle LogMiner, which is part of Oracle Database, enables you to query online and
archived redo log files through a SQL interface. Redo log files contain information
about the history of activity on a database.
See the following topics:
You can use LogMiner from a command line or you can access it through the Oracle
LogMiner Viewer graphical user interface. Oracle LogMiner Viewer is a part of Oracle
Enterprise Manager. See the Oracle Enterprise Manager online Help for more
information about Oracle LogMiner Viewer.
Note:
Many of the examples in this section make use of the LogMiner CONTINUOUS_MINE
option. As of Oracle Database 12c Release 2 (12.2.0.1), the LogMiner
CONTINUOUS_MINE option is deprecated. It is still supported for backward
compatibility reasons, but Oracle recommends that you discontinue using it.
There is no replacement functionality.
• LogMiner Benefits
• Introduction to LogMiner
• Using LogMiner in a CDB
• LogMiner Dictionary Files and Redo Log Files
• Starting LogMiner
• Querying V$LOGMNR_CONTENTS for Redo Data of Interest
You access the redo data of interest by querying the V$LOGMNR_CONTENTS view.
• Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
LogMiner can potentially deal with large amounts of information. You can limit the
information that is returned to the V$LOGMNR_CONTENTS view, and the speed at which
it is returned.
• Reapplying DDL Statements Returned to V$LOGMNR_CONTENTS
Some DDL statements that you issue cause Oracle to internally execute one or
more other DDL statements.
• Calling DBMS_LOGMNR.START_LOGMNR Multiple Times
• Supplemental Logging
• Accessing LogMiner Operational Information in Views
• Steps in a Typical LogMiner Session
• Examples Using LogMiner
• Supported Data Types, Storage Attributes, and Database and Redo Log File
Versions
22-1
Chapter 22
LogMiner Benefits
22-2
Chapter 22
Introduction to LogMiner
Source Mining
Database Database
Archived Redo Log Files
Boston containing LogMiner dictionary San Francisco
22-3
Chapter 22
Introduction to LogMiner
Figure 22-1 shows just one valid LogMiner configuration. Other valid configurations
are those that use the same database for both the source and mining database, or use
another method for providing the data dictionary. These other data dictionary options
are described in "LogMiner Dictionary Options".
22.2.1.2 Requirements
The following are requirements for the source and mining database, the data
dictionary, and the redo log files that LogMiner will mine:
• Source and mining database
– Both the source database and the mining database must be running on the
same hardware platform.
– The mining database can be the same as, or completely separate from, the
source database.
– The mining database must run the same release or a later release of the
Oracle Database software as the source database.
– The mining database must use the same character set (or a superset of the
character set) used by the source database.
• LogMiner dictionary
– The dictionary must be produced by the same source database that generates
the redo log files that LogMiner will analyze.
• All redo log files:
– Must be produced by the same source database.
– Must be associated with the same database RESETLOGS SCN.
– Must be from a release 8.0 or later Oracle Database. However, several of the
LogMiner features introduced as of release 9.0.1 work only with redo log files
produced on an Oracle9i or later database. See "Supported Databases and
Redo Log File Versions".
LogMiner does not allow you to mix redo log files from different databases or to use a
dictionary from a different database than the one that generated the redo log files to be
analyzed.
22-4
Chapter 22
Introduction to LogMiner
Note:
You must enable supplemental logging before generating log files that will be
analyzed by LogMiner.
When you enable supplemental logging, additional information is recorded in
the redo stream that is needed to make the information in the redo log files
useful to you. Therefore, at the very least, you must enable minimal
supplemental logging, as the following SQL statement shows:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
22-5
Chapter 22
Using LogMiner in a CDB
Note:
When mining a specified time or SCN range of interest within archived logs
generated by an Oracle RAC database, you must ensure that you have
specified all archived logs from all redo threads that were active during that
time or SCN range. If you fail to do this, then any queries of V$LOGMNR_CONTENTS
return only partial results (based on the archived logs specified to LogMiner
through the DBMS_LOGMNR.ADD_LOGFILE procedure). This restriction is also in effect
when you are mining the archived logs at the source database using the
CONTINUOUS_MINE option. You should only use CONTINUOUS_MINE on an Oracle RAC
database if no thread is being enabled or disabled.
See Also:
"Steps in a Typical LogMiner Session" for an example of using LogMiner
See Also:
22-6
Chapter 22
Using LogMiner in a CDB
The CON_ID column identifies the container ID associated with the session for which
information is being displayed. When you query the view from a pluggable database
(PDB), only information associated with the database is displayed. The following views
are affected by this new behavior:
• V$LOGMNR_DICTIONARY_LOAD
• V$LOGMNR_LATCH
• V$LOGMNR_PROCESS
• V$LOGMNR_SESSION
• V$LOGMNR_STATS
Note:
To support CDBs, the V$LOGMNR_CONTENTS view has several other new columns in
addition to CON_ID.
The following DBA views have analogous CDB views whose names begin with CDB.
The DBA views show only information related to sessions defined in the container in
which they are queried.
The CDB views contain an additional CON_ID column, which identifies the container
whose data a given row represents. When CDB views are queried from the root, they
can be used to see information about all containers.
• CON_ID — contains the ID associated with the container from which the query is
executed. Because V$LOGMNR_CONTENTS is restricted to the root database, this
column returns a value of 1 when a query is done on a CDB.
• SRC_CON_NAME — the PDB name. This information is available only when mining is
performed with a LogMiner dictionary.
22-7
Chapter 22
LogMiner Dictionary Files and Redo Log Files
• SRC_CON_ID — the container ID of the PDB that generated the redo record. This
information is available only when mining is performed with a LogMiner dictionary.
• SRC_CON_DBID — the PDB identifier. This information is available only when mining
is performed with a current LogMiner dictionary.
• SRC_CON_GUID — contains the GUID associated with the PDB. This information is
available only when mining is performed with a current LogMiner dictionary.
22-8
Chapter 22
LogMiner Dictionary Files and Redo Log Files
Figure 22-2 shows a decision tree to help you select a LogMiner dictionary, depending
on your situation.
Will Will
LogMiner the database Will
have access to be open for the instance
the source No write No be started?
database? access?
Will
column Might
definitions be column
unchanged? No definitions
change? No
Yes Yes
Will
the database
No be open?
Yes
22-9
Chapter 22
LogMiner Dictionary Files and Redo Log Files
The following sections provide instructions on how to specify each of the available
dictionary options.
• Using the Online Catalog
• Extracting a LogMiner Dictionary to the Redo Log Files
• Extracting the LogMiner Dictionary to a Flat File
In addition to using the online catalog to analyze online redo log files, you can use it to
analyze archived redo log files, if you are on the same system that generated the
archived redo log files.
The online catalog contains the latest information about the database and may be the
fastest way to start your analysis. Because DDL operations that change important
tables are somewhat rare, the online catalog generally contains the information you
need for your analysis.
Remember, however, that the online catalog can only reconstruct SQL statements that
are executed on the latest version of a table. As soon as a table is altered, the online
catalog no longer reflects the previous version of the table. This means that LogMiner
will not be able to reconstruct any SQL statements that were executed on the previous
version of the table. Instead, LogMiner generates nonexecutable SQL (including
hexadecimal-to-raw formatting of binary values) in the SQL_REDO column of the
V$LOGMNR_CONTENTS view similar to the following example:
22-10
Chapter 22
LogMiner Dictionary Files and Redo Log Files
See Also:
The process of extracting the dictionary to the redo log files does consume database
resources, but if you limit the extraction to off-peak hours, then this should not be a
problem, and it is faster than extracting to a flat file. Depending on the size of the
dictionary, it may be contained in multiple redo log files. If the relevant redo log files
have been archived, then you can find out which redo log files contain the start and
end of an extracted dictionary. To do so, query the V$ARCHIVED_LOG view, as follows:
SELECT NAME FROM V$ARCHIVED_LOG WHERE DICTIONARY_BEGIN='YES';
SELECT NAME FROM V$ARCHIVED_LOG WHERE DICTIONARY_END='YES';
Specify the names of the start and end redo log files, and other redo logs in between
them, with the ADD_LOGFILE procedure when you are preparing to begin a LogMiner
session.
Oracle recommends that you periodically back up the redo log files so that the
information is saved and available at a later date. Ideally, this will not involve any extra
steps because if your database is being properly managed, then there should already
be a process in place for backing up and restoring archived redo log files. Again,
because of the time required, it is good practice to do this during off-peak hours.
The following steps describe how to extract a dictionary to a flat file. Steps 1 and 2 are
preparation steps. You only need to do them once, and then you can extract a
dictionary to a flat file as many times as you want to.
1. The DBMS_LOGMNR_D.BUILD procedure requires access to a directory where it can
place the dictionary file. Because PL/SQL procedures do not normally access user
directories, you must specify a directory location or the procedure will fail. The
directory location must be a directory object. The following is an example of using
the SQL CREATE DIRECTORY statement to create a directory object named
my_dictionary_dir for the path /oracle/database.
22-11
Chapter 22
LogMiner Dictionary Files and Redo Log Files
Note:
Prior to Oracle Database 12c release 2 (12.2), you used the UTL_FILE_DIR
initialization parameter to specify a directory location. However, as of
Oracle Database 12c release 2 (12.2), the UTL_FILE_DIR initialization
parameter is deprecated. It is still supported for backward compatibility, but
Oracle strongly recommends that you instead use directory objects.
2. If the database is closed, then use SQL*Plus to mount and open the database
whose redo log files you want to analyze. For example, entering the SQL STARTUP
command mounts and opens the database:
SQL> STARTUP
3. Execute the PL/SQL procedure DBMS_LOGMNR_D.BUILD. The following example
extracts the LogMiner dictionary file to a flat file named dictionary.ora in the
directory object my_dictionary_dir that was created in step 1.
SQL> EXECUTE dbms_logmnr_d.build(dictionary_location=>'my_dictionary_dir', -
dictionary_filename=>'dictionary.ora', -
options => dbms_logmnr_d.store_in_flat_file);
You could also specify a file name and location without specifying the
STORE_IN_FLAT_FILE option. The result would be the same.
You can direct LogMiner to automatically and dynamically create a list of redo log files
to analyze, or you can explicitly specify a list of redo log files for LogMiner to analyze,
as follows:
• Automatically
If LogMiner is being used on the source database, then you can direct LogMiner to
find and create a list of redo log files for analysis automatically. Use the
CONTINUOUS_MINE option when you start LogMiner with the DBMS_LOGMNR.START_LOGMNR
procedure, and specify a time or SCN range. Although this example specifies the
dictionary from the online catalog, any LogMiner dictionary can be used. (The
CONTINUOUS_MINE option requires that the database be mounted and that archiving
be enabled. )
Note:
As of Oracle Database 12c Release 2 (12.2.0.1), the LogMiner
CONTINUOUS_MINE option is deprecated. It is still supported for backward
compatibility reasons, but Oracle recommends that you discontinue using
it. There is no replacement functionality.
LogMiner will use the database control file to find and add redo log files that satisfy
your specified time or SCN range to the LogMiner redo log file list. For example:
22-12
Chapter 22
Starting LogMiner
(To avoid the need to specify the date format in the PL/SQL call to the
DBMS_LOGMNR.START_LOGMNR procedure, this example uses the SQL ALTER SESSION SET
NLS_DATE_FORMAT statement first.)
You can also direct LogMiner to automatically build a list of redo log files to
analyze by specifying just one redo log file using DBMS_LOGMNR.ADD_LOGFILE, and
then specifying the CONTINUOUS_MINE option when you start LogMiner. The
previously described method is more typical, however.
• Manually
Use the DBMS_LOGMNR.ADD_LOGFILE procedure to manually create a list of redo log
files before you start LogMiner. After the first redo log file has been added to the
list, each subsequently added redo log file must be from the same database and
associated with the same database RESETLOGS SCN. When using this method,
LogMiner need not be connected to the source database.
For example, to start a new list of redo log files, specify the NEW option of the
DBMS_LOGMNR.ADD_LOGFILE PL/SQL procedure to signal that this is the beginning of a
new list. For example, enter the following to specify /oracle/logs/log1.f:
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/oracle/logs/log1.f', -
OPTIONS => DBMS_LOGMNR.NEW);
If desired, add more redo log files by specifying the ADDFILE option of the PL/SQL
DBMS_LOGMNR.ADD_LOGFILE procedure. For example, enter the following to add /
oracle/logs/log2.f:
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/oracle/logs/log2.f', -
OPTIONS => DBMS_LOGMNR.ADDFILE);
To determine which redo log files are being analyzed in the current LogMiner
session, you can query the V$LOGMNR_LOGS view, which contains one row for each
redo log file.
22-13
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
The following list is a summary of LogMiner settings that you can specify with the
OPTIONS parameter to DBMS_LOGMNR.START_LOGMNR and where to find more information
about them.
• DICT_FROM_ONLINE_CATALOG — See "Using the Online Catalog"
(Note that you must have either the SYSDBA or LOGMINING privilege to query
V$LOGMNR_CONTENTS.) This view provides historical information about changes made to
the database, including (but not limited to) the following:
• The type of change made to the database: INSERT, UPDATE, DELETE, or DDL (OPERATION
column).
• The SCN at which a change was made (SCN column).
• The SCN at which a change was committed (COMMIT_SCN column).
• The transaction to which a change belongs (XIDUSN, XIDSLT, and XIDSQN columns).
• The table and schema name of the modified object (SEG_NAME and SEG_OWNER
columns).
• The name of the user who issued the DDL or DML statement to make the change
(USERNAME column).
• If the change was due to a SQL DML statement, the reconstructed SQL
statements showing SQL DML that is equivalent (but not necessarily identical) to
the SQL DML used to generate the redo records (SQL_REDO column).
22-14
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
Note:
LogMiner supports Transparent Data Encryption (TDE), in that
V$LOGMNR_CONTENTS shows DML operations performed on tables with encrypted
columns (including the encrypted columns being updated), provided the
LogMiner data dictionary contains the metadata for the object in question and
provided the appropriate master key is in the Oracle wallet. The wallet must be
open or V$LOGMNR_CONTENTS cannot interpret the associated redo records. TDE
support is not available if the database is not open (either read-only or read-
write).
See Also:
Oracle Database Advanced Security Guide for more information about TDE
The following output is produced by the query. The formatting may be different on your
display than that shown here.
OPERATION SQL_REDO SQL_UNDO
22-15
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
This output shows that user Ron deleted two rows from the oe.orders table. The
reconstructed SQL statements are equivalent, but not necessarily identical, to the
actual statement that Ron issued. The reason for this difference is that the original
WHERE clause is not logged in the redo log files, so LogMiner can only show deleted (or
updated or inserted) rows individually.
Therefore, even though a single DELETE statement may be responsible for the deletion
of both rows, the output in V$LOGMNR_CONTENTS does not reflect that fact. The actual
DELETE statement may have been DELETE FROM OE.ORDERS WHERE CUSTOMER_ID ='101' or it
may have been DELETE FROM OE.ORDERS WHERE PROMOTION_ID = NULL.
When a SQL select operation is executed against the V$LOGMNR_CONTENTS view, the redo
log files are read sequentially. Translated information from the redo log files is returned
as rows in the V$LOGMNR_CONTENTS view. This continues until either the filter criteria
specified at startup are met or the end of the redo log file is reached.
In some cases, certain columns in V$LOGMNR_CONTENTS may not be populated. For
example:
• The TABLE_SPACE column is not populated for rows where the value of the OPERATION
column is DDL. This is because a DDL may operate on more than one tablespace.
For example, a table can be created with multiple partitions spanning multiple
table spaces; hence it would not be accurate to populate the column.
• LogMiner does not generate SQL redo or SQL undo for temporary tables. The
SQL_REDO column will contain the string "/* No SQL_REDO for temporary tables */"
and the SQL_UNDO column will contain the string "/* No SQL_UNDO for temporary
tables */".
22-16
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
LogMiner returns all the rows in SCN order unless you have used the
COMMITTED_DATA_ONLY option to specify that only committed transactions should be
retrieved. SCN order is the order normally applied in media recovery.
See Also:
"Showing Only Committed Transactions" for more information about the
COMMITTED_DATA_ONLY option to DBMS_LOGMNR.START_LOGMNR
Note:
Because LogMiner populates the V$LOGMNR_CONTENTS view only in response to a
query and does not store the requested data in the database, the following is
true:
• Every time you query V$LOGMNR_CONTENTS, LogMiner analyzes the redo log
files for the data you request.
• The amount of memory consumed by the query is not dependent on the
number of rows that must be returned to satisfy a query.
• The time it takes to return the requested data is dependent on the amount
and type of redo log data that must be mined to find that data.
For the reasons stated in the previous note, Oracle recommends that you create a
table to temporarily hold the results from a query of V$LOGMNR_CONTENTS if you need to
maintain the data for further analysis, particularly if the amount of data returned by a
query is small in comparison to the amount of redo data that LogMiner must analyze to
provide that data.
The following is an example of how you could use the MINE_VALUE function to select all
updates to hr.employees that increased the salary column to more than twice its
original value:
SELECT SQL_REDO FROM V$LOGMNR_CONTENTS
WHERE
SEG_NAME = 'EMPLOYEES' AND
SEG_OWNER = 'HR' AND
OPERATION = 'UPDATE' AND
22-17
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
• The first one specifies whether to mine the redo (REDO_VALUE) or undo (UNDO_VALUE)
portion of the data. The redo portion of the data is the data that is in the column
after an insert, update, or delete operation; the undo portion of the data is the data
that was in the column before an insert, update, or delete operation. It may help to
think of the REDO_VALUE as the new value and the UNDO_VALUE as the old value.
• The second argument is a string that specifies the fully qualified name of the
column to be mined (in this case, hr.employees.salary). The MINE_VALUE function
always returns a string that can be converted back to the original data type.
• The Meaning of NULL Values Returned by the MINE_VALUE Function
• Usage Rules for the MINE_VALUE and COLUMN_PRESENT Functions
• Restrictions When Using the MINE_VALUE Function To Get an NCHAR Value
• The specified column is not present in the redo or undo portion of the data.
• The specified column is present and has a null value.
To distinguish between these two cases, use the DBMS_LOGMNR.COLUMN_PRESENT function
which returns a 1 if the column is present in the redo or undo portion of the data.
Otherwise, it returns a 0. For example, suppose you wanted to find out the increment
by which the values in the salary column were modified and the corresponding
transaction identifier. You could issue the following SQL query:
SELECT
(XIDUSN || '.' || XIDSLT || '.' || XIDSQN) AS XID,
(DBMS_LOGMNR.MINE_VALUE(REDO_VALUE, 'HR.EMPLOYEES.SALARY') -
DBMS_LOGMNR.MINE_VALUE(UNDO_VALUE, 'HR.EMPLOYEES.SALARY')) AS INCR_SAL
FROM V$LOGMNR_CONTENTS
WHERE
OPERATION = 'UPDATE' AND
DBMS_LOGMNR.COLUMN_PRESENT(REDO_VALUE, 'HR.EMPLOYEES.SALARY') = 1 AND
DBMS_LOGMNR.COLUMN_PRESENT(UNDO_VALUE, 'HR.EMPLOYEES.SALARY') = 1;
• They do not support LONG, LONG RAW, CLOB, BLOB, NCLOB, ADT, or COLLECTION data
types.
22-18
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
Note:
XMLType data stored as CLOB is deprecated as of Oracle Database 12c Release 1
(12.1).
22-19
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
In the SQL_REDO columns for the XML DOC WRITE operations there will be actual data for
the XML document. It will not be the string 'XML Data'.
This output shows that the general model for an insert into a table with an XMLType
column is the following:
1. An initial insert with all of the scalar columns.
2. An XML DOC BEGIN operation with an update statement that sets the value for one
XMLType column using a bind variable.
3. One or more XML DOC WRITE operations with the data for the XML document.
4. An XML DOC END operation to indicate that all of the data for that XML document has
been seen.
5. If there is more than one XMLType column in the table, then steps 2 through 4 will
be repeated for each XMLType column that is modified by the original DML.
If the XML document is not stored as an out-of-line column, then there will be no XML
DOC BEGIN, XML DOC WRITE, or XML DOC END operations for that column. The document will
be included in an update statement similar to the following:
OPERATION STATUS SQL_REDO
22-20
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
Therefore, LogMiner cannot generate SQL_REDO which is executable that includes this
value.
The V$LOGMNR_CONTENTS view has a new OBJECT_ID column which is populated for
changes to XMLType tables. This value is the object identifier from the original table.
However, even if this same XML document is inserted into the same XMLType table, a
new object identifier will be generated. The SQL_REDO for subsequent DMLs, such as
updates and deletes, on the XMLType table will include the object identifier in the WHERE
clause to uniquely identify the row from the original table.
• Restrictions When Using LogMiner With XMLType Data
• Example of a PL/SQL Procedure for Assembling XMLType Data
Note:
This procedure is an example only and is simplified. It is only intended to
illustrate that DMLs to tables with XMLType data can be mined and assembled
using LogMiner.
Before calling this procedure, all of the relevant logs must be added to a LogMiner
session and DBMS_LOGMNR.START_LOGMNR() must be called with the COMMITTED_DATA_ONLY
option. The MINE_AND_ASSEMBLE() procedure can then be called with the schema and
table name of the table that has XML data to be mined.
-- table to store assembled XML documents
create table employee_xml_docs (
employee_name varchar2(100),
sql_stmt varchar2(4000),
xml_doc SYS.XMLType);
22-21
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
loc_c CLOB;
row_op VARCHAR2(100);
row_status NUMBER;
stmt VARCHAR2(4000);
row_redo VARCHAR2(4000);
xml_data VARCHAR2(32767 CHAR);
data_len NUMBER;
xml_lob clob;
xml_doc XMLType;
BEGIN
-- Look for the rows in V$LOGMNR_CONTENTS that are for the appropriate schema
-- and table name but limit it to those that are valid sql or that need assembly
-- because they are XML documents.
CASE row_op
-- reset
xml_data := '';
data_len := 0;
xml_lob := NULL;
END;
22-22
Chapter 22
Querying V$LOGMNR_CONTENTS for Redo Data of Interest
ELSE
BEGIN
stmt := row_redo;
DBMS_OUTPUT.PUT_LINE('Other - ' || stmt);
IF row_status != DBMS_LOGMNR.VALID_SQL then
DBMS_OUTPUT.PUT_LINE('Skip rows marked non-executable');
ELSE
dbms_output.put_line('Status : ' || row_status);
END IF;
END;
END CASE;
End LOOP;
End;
/
show errors;
This procedure can then be called to mine the changes to the SCOTT.XML_DATA_TAB and
apply the DMLs.
EXECUTE MINE_AND_ASSEMBLE ('SCOTT', 'XML_DATA_TAB');
As a result of this procedure, the EMPLOYEE_XML_DOCS table will have a row for each out-
of-line XML column that was changed. The EMPLOYEE_NAME column will have the value
extracted from the XML document and the SQL_STMT column and the XML_DOC column
reflect the original row change.
The following is an example query to the resulting table that displays only the
employee name and SQL statement:
SELECT EMPLOYEE_NAME, SQL_STMT FROM EMPLOYEE_XML_DOCS;
EMPLOYEE_NAME
SQL_STMT
22-23
Chapter 22
Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
In addition, LogMiner offers features for formatting the data that is returned to
V$LOGMNR_CONTENTS, as described in the following sections:
When you specify the COMMITTED_DATA_ONLY option, LogMiner groups together all DML
operations that belong to the same transaction. Transactions are returned in the order
in which they were committed.
22-24
Chapter 22
Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
Note:
If the COMMITTED_DATA_ONLY option is specified and you issue a query, then
LogMiner stages all redo records within a single transaction in memory until
LogMiner finds the commit record for that transaction. Therefore, it is possible
to exhaust memory, in which case an "Out of Memory" error will be returned. If
this occurs, then you must restart LogMiner without the COMMITTED_DATA_ONLY
option specified and reissue the query.
The default is for LogMiner to show rows corresponding to all transactions and to
return them in the order in which they are encountered in the redo log files.
For example, suppose you start LogMiner without specifying the COMMITTED_DATA_ONLY
option and you execute the following query:
SELECT (XIDUSN || '.' || XIDSLT || '.' || XIDSQN) AS XID,
USERNAME, SQL_REDO FROM V$LOGMNR_CONTENTS WHERE USERNAME != 'SYS'
AND SEG_OWNER IS NULL OR SEG_OWNER NOT IN ('SYS', 'SYSTEM');
The output is as follows. Both committed and uncommitted transactions are returned
and rows from different transactions are interwoven.
XID USERNAME SQL_REDO
22-25
Chapter 22
Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
Now suppose you start LogMiner, but this time you specify the COMMITTED_DATA_ONLY
option. If you execute the previous query again, then the output is as follows:
1.15.3045 RON set transaction read write;
1.15.3045 RON insert into "HR"."JOBS"("JOB_ID","JOB_TITLE",
"MIN_SALARY","MAX_SALARY") values ('9782',
'HR_ENTRY',NULL,NULL);
1.15.3045 RON commit;
1.18.3046 JANE set transaction read write;
1.18.3046 JANE insert into "OE"."CUSTOMERS"("CUSTOMER_ID",
"CUST_FIRST_NAME","CUST_LAST_NAME",
"CUST_ADDRESS","PHONE_NUMBERS","NLS_LANGUAGE",
"NLS_TERRITORY","CREDIT_LIMIT","CUST_EMAIL",
"ACCOUNT_MGR_ID") values ('9839','Edgar',
'Cummings',NULL,NULL,NULL,NULL,
NULL,NULL,NULL);
1.18.3046 JANE commit;
1.11.3047 JANE set transaction read write;
1.11.3047 JANE insert into "OE"."CUSTOMERS"("CUSTOMER_ID",
"CUST_FIRST_NAME","CUST_LAST_NAME",
"CUST_ADDRESS","PHONE_NUMBERS","NLS_LANGUAGE",
"NLS_TERRITORY","CREDIT_LIMIT","CUST_EMAIL",
"ACCOUNT_MGR_ID") values ('8933','Ronald',
'Frost',NULL,NULL,NULL,NULL,NULL,NULL,NULL);
1.11.3047 JANE commit;
1.8.3054 RON set transaction read write;
1.8.3054 RON insert into "HR"."JOBS"("JOB_ID","JOB_TITLE",
"MIN_SALARY","MAX_SALARY") values ('9566',
'FI_ENTRY',NULL,NULL);
1.8.3054 RON commit;
Because the COMMIT statement for the 1.15.3045 transaction was issued before the
COMMIT statement for the 1.18.3046 transaction, the entire 1.15.3045 transaction is
returned first. This is true even though the 1.18.3046 transaction started before the
1.15.3045 transaction. None of the 1.9.3041 transaction is returned because a COMMIT
statement was never issued for it.
See Also:
See "Examples Using LogMiner" for a complete example that uses the
COMMITTED_DATA_ONLY option
Be aware that the skipped records may include changes to ongoing transactions in the
corrupted blocks; such changes will not be reflected in the data returned from the
V$LOGMNR_CONTENTS view.
22-26
Chapter 22
Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
The default is for the select operation to terminate at the first corruption it encounters
in the redo log file.
The following SQL example shows how this option works:
-- Add redo log files of interest.
--
EXECUTE DBMS_LOGMNR.ADD_LOGFILE(-
logfilename => '/usr/oracle/data/db1arch_1_16_482701534.log' -
options => DBMS_LOGMNR.NEW);
-- Start LogMiner
--
EXECUTE DBMS_LOGMNR.START_LOGMNR();
-- Select from the V$LOGMNR_CONTENTS view. This example shows corruptions are -- in
the redo log files.
--
SELECT rbasqn, rbablk, rbabyte, operation, status, info
FROM V$LOGMNR_CONTENTS;
ERROR at line 3:
ORA-00368: checksum error in redo log block
ORA-00353: log corruption near block 6 change 73528 time 11/06/2011 11:30:23
ORA-00334: archived log: /usr/oracle/data/dbarch1_16_482701534.log
-- Select from the V$LOGMNR_CONTENTS view again. The output indicates that
-- corrupted blocks were skipped: CORRUPTED_BLOCKS is in the OPERATION
-- column, 1343 is in the STATUS column, and the number of corrupt blocks
-- skipped is in the INFO column.
--
SELECT rbasqn, rbablk, rbabyte, operation, status, info
FROM V$LOGMNR_CONTENTS;
To avoid the need to specify the date format in the call to the PL/SQL
DBMS_LOGMNR.START_LOGMNR procedure, you can use the SQL ALTER SESSION SET
NLS_DATE_FORMAT statement first, as shown in the following example.
22-27
Chapter 22
Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
The timestamps should not be used to infer ordering of redo records. You can infer the
order of redo records by using the SCN.
See Also:
The STARTSCN and ENDSCN parameters override the STARTTIME and ENDTIME parameters in
situations where all are specified.
See Also:
22-28
Chapter 22
Filtering and Formatting Data Returned to V$LOGMNR_CONTENTS
or SQL_UNDO statements against a different database than the one against which
they were originally executed, then specify the NO_ROWID_IN_STMT option when you
start LogMiner.
• Specify the NO_SQL_DELIMITER option when you start LogMiner.
This suppresses the semicolon from the reconstructed statements. This is helpful
for applications that open a cursor and then execute the reconstructed statements.
Note that if the STATUS field of the V$LOGMNR_CONTENTS view contains the value 2 (invalid
sql), then the associated SQL statement cannot be executed.
update "HR"."JOBS"
set
"JOB_TITLE" = 'FI_ENTRY'
where
"JOB_TITLE" = 'HR_ENTRY' and
ROWID = 'AAAHSeAABAAAY+CAAX';
SQL statements that are reconstructed when the PRINT_PRETTY_SQL option is enabled
are not executable, because they do not use standard SQL syntax.
See Also:
"Examples Using LogMiner" for a complete example of using the
PRINT_PRETTY_SQL option
22-29
Chapter 22
Reapplying DDL Statements Returned to V$LOGMNR_CONTENTS
Note:
If you execute DML statements that were executed internally by Oracle, then
you may corrupt your database. See Step 5 of "Example 4: Using the LogMiner
Dictionary in the Redo Log Files" for an example.
To differentiate between DDL statements that were issued by a user from those that
were issued internally by Oracle, query the INFO column of V$LOGMNR_CONTENTS. The
value of the INFO column indicates whether the DDL was executed by a user or by
Oracle.
To reapply SQL DDL as it was originally applied, re-execute the DDL SQL contained in
the SQL_REDO or SQL_UNDO column of V$LOGMNR_CONTENTS only if the INFO column contains
the value USER_DDL.
Example 1: Mining Only a Subset of the Data in the Redo Log Files
Suppose the list of redo log files that LogMiner has to mine include those generated
for an entire week. However, you want to analyze only what happened from 12:00 to
1:00 each day. You could do this most efficiently by:
22-30
Chapter 22
Supplemental Logging
3. Adds additional redo log files that have newly arrived in the directory
4. Repeats Steps 2 and 3, indefinitely
22-31
Chapter 22
Supplemental Logging
See Also:
Querying Views for Supplemental Logging Settings
22-32
Chapter 22
Supplemental Logging
This option specifies that when a row is updated, all columns of that row (except
for LOBs, LONGS, and ADTs) are placed in the redo log file.
To enable all column logging at the database level, execute the following
statement:
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
• PRIMARY KEY system-generated unconditional supplemental log group
This option causes the database to place all columns of a row's primary key in the
redo log file whenever a row containing a primary key is updated (even if no value
in the primary key has changed).
If a table does not have a primary key, but has one or more non-null unique index
key constraints or index keys, then one of the unique index keys is chosen for
logging as a means of uniquely identifying the row being updated.
If the table has neither a primary key nor a non-null unique index key, then all
columns except LONG and LOB are supplementally logged; this is equivalent to
specifying ALL supplemental logging for that row. Therefore, Oracle recommends
that when you use database-level primary key supplemental logging, all or most
tables be defined to have primary or unique index keys.
To enable primary key logging at the database level, execute the following
statement:
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
• UNIQUE system-generated conditional supplemental log group
This option causes the database to place all columns of a row's composite unique
key or bitmap index in the redo log file if any column belonging to the composite
unique key or bitmap index is modified. The unique key can be due to either a
unique constraint or a unique index.
To enable unique index key and bitmap index logging at the database level,
execute the following statement:
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (UNIQUE) COLUMNS;
• FOREIGN KEY system-generated conditional supplemental log group
This option causes the database to place all columns of a row's foreign key in the
redo log file if any column belonging to the foreign key is modified.
To enable foreign key logging at the database level, execute the following SQL
statement:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (FOREIGN KEY) COLUMNS;
22-33
Chapter 22
Supplemental Logging
Note:
Regardless of whether identification key logging is enabled, the SQL
statements returned by LogMiner always contain the ROWID clause. You can
filter out the ROWID clause by using the NO_ROWID_IN_STMT option to the
DBMS_LOGMNR.START_LOGMNR procedure call. See "Formatting Reconstructed
SQL Statements for Re-execution" for details.
Keep the following in mind when you use identification key logging:
• If the database is open when you enable identification key logging, then all DML
cursors in the cursor cache are invalidated. This can affect performance until the
cursor cache is repopulated.
• When you enable identification key logging at the database level, minimal
supplemental logging is enabled implicitly.
• Supplemental logging statements are cumulative. If you issue the following SQL
statements, then both primary key and unique key supplemental logging is
enabled:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (UNIQUE) COLUMNS;
22-34
Chapter 22
Supplemental Logging
• After the second statement, primary key and unique key supplemental logging are
enabled.
• After the third statement, only unique key supplemental logging is enabled.
• After the fourth statement, all supplemental logging is not disabled. The following
error is returned: ORA-32589: unable to drop minimal supplemental logging.
To disable all database supplemental logging, you must first disable any identification
key logging that has been enabled, then disable minimal supplemental logging. The
following example shows the correct order:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (UNIQUE) COLUMNS;
ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (UNIQUE) COLUMNS;
ALTER DATABASE DROP SUPPLEMENTAL LOG DATA;
However, if you enter the following SQL statement (specifying table-level supplemental
logging) instead, then only when a column in the employees table is changed will the
entire row (except for LOB, LONGs, and ADTs) of the table be placed in the redo log file.
If a column changes in the departments table, then only the changed column will be
placed in the redo log file.
ALTER TABLE HR.EMPLOYEES ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
Keep the following in mind when you use table-level identification key logging:
• If the database is open when you enable identification key logging on a table, then
all DML cursors for that table in the cursor cache are invalidated. This can affect
performance until the cursor cache is repopulated.
22-35
Chapter 22
Supplemental Logging
• Supplemental logging statements are cumulative. If you issue the following SQL
statements, then both primary key and unique index key table-level supplemental
logging is enabled:
ALTER TABLE HR.EMPLOYEES
ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
ALTER TABLE HR.EMPLOYEES
ADD SUPPLEMENTAL LOG DATA (UNIQUE) COLUMNS;
See "Database-Level Identification Key Logging" for a description of each of the
identification key logging options.
This creates a log group named emp_parttime on the hr.employees table that
consists of the columns employee_id, last_name, and department_id. These columns
are logged every time an UPDATE statement is executed on the hr.employees table,
regardless of whether the update affected these columns. (To have the entire row
image logged any time an update is made, use table-level ALL identification key
logging, as described previously).
Note:
LOB, LONG, and ADT columns cannot be supplementally logged.
22-36
Chapter 22
Supplemental Logging
option, you must specify at least one column in the log group without the NO LOG option,
as shown in the following example:
ALTER TABLE HR.EMPLOYEES
ADD SUPPLEMENTAL LOG GROUP emp_parttime(
DEPARTMENT_ID NO LOG, EMPLOYEE_ID);
This enables you to associate this column with other columns in the named
supplemental log group such that any modification to the NO LOG column causes the
other columns in the supplemental log group to be placed in the redo log file. This
might be useful, for example, for logging certain columns in a group if a LONG column
changes. You cannot supplementally log the LONG column itself; however, you can use
changes to that column to trigger supplemental logging of other columns in the same
row.
See "Example 5: Tracking DDL Statements in the Internal Dictionary" for a complete
example.
With this option set, LogMiner applies any DDL statements seen in the redo log files to
its internal dictionary.
Note:
In general, it is a good idea to keep supplemental logging and the DDL tracking
feature enabled, because if they are not enabled and a DDL event occurs, then
LogMiner returns some of the redo data as binary data. Also, a metadata
version mismatch could occur.
22-37
Chapter 22
Supplemental Logging
Note:
It is important to understand that the LogMiner internal dictionary is not the
same as the LogMiner dictionary contained in a flat file, in redo log files, or in
the online catalog. LogMiner does update its internal dictionary, but it does not
update the dictionary that is contained in a flat file, in redo log files, or in the
online catalog.
The following list describes the requirements for specifying the DDL_DICT_TRACKING
option with the DBMS_LOGMNR.START_LOGMNR procedure.
– A DML transaction is encountered in the redo log file, then LogMiner will not
assume that the current version of the table (underlying the DML) in its
dictionary is correct, and columns in V$LOGMNR_CONTENTS will be set as follows:
* The SQL_REDO column will contain binary data.
* The STATUS column will contain a value of 2 (which indicates that the SQL
is not valid).
* The INFO column will contain the string 'Dictionary Mismatch'.
22-38
Chapter 22
Supplemental Logging
22-39
Chapter 22
Accessing LogMiner Operational Information in Views
you want to see (using DBMS_LOGMNR.START_LOGMNR) are recorded in the third redo log file.
You then do the following:
1. Call DBMS_LOGMNR.START_LOGMNR. LogMiner will read:
a. The first log file to load the dictionary
b. The second redo log file to pick up any possible DDLs contained within it
c. The third log file to retrieve the data of interest
2. Call DBMS_LOGMNR.START_LOGMNR again with the same requested range.
LogMiner will begin with redo log file 3; it no longer needs to read redo log file 2,
because it has already processed any DDL statements contained within it.
3. Call DBMS_LOGMNR.START_LOGMNR again, this time specifying parameters that require
data to be read from redo log file 5.
LogMiner will start reading from redo log file 4 to pick up any DDL statements that
may be contained within it.
Query the REQUIRED_START_DATE or the REQUIRED_START_SCN columns of the
V$LOGMNR_PARAMETERS view to see where LogMiner will actually start reading. Regardless
of where LogMiner starts reading, only rows in your requested range will be returned
from the V$LOGMNR_CONTENTS view.
Shows information about a LogMiner dictionary file that was created using the
STORE_IN_FLAT_FILE option to DBMS_LOGMNR.START_LOGMNR. The information shown
includes information about the database from which the LogMiner dictionary was
created.
• V$LOGMNR_LOGS
22-40
Chapter 22
Accessing LogMiner Operational Information in Views
• 0
Indicates that the redo log file will be processed during a query of the
V$LOGMNR_CONTENTS view.
• 1
Indicates that this will be the first redo log file to be processed by LogMiner during
a select operation against the V$LOGMNR_CONTENTS view.
• 2
Indicates that the redo log file has been pruned and therefore will not be
processed by LogMiner during a query of the V$LOGMNR_CONTENTS view. It has been
pruned because it is not needed to satisfy your requested time or SCN range.
• 4
Indicates that a redo log file (based on sequence number) is missing from the
LogMiner redo log file list.
The V$LOGMNR_LOGS view contains a row for each redo log file that is missing from the
list, as follows:
• The FILENAME column will contain the consecutive range of sequence numbers and
total SCN range gap.
For example: 'Missing log file(s) for thread number 1, sequence number(s) 100 to
102'.
• The INFO column will contain the string 'MISSING_LOGFILE'.
Information about files missing from the redo log file list can be useful for the following
reasons:
• The DDL_DICT_TRACKING and CONTINUOUS_MINE options that can be specified when you
call DBMS_LOGMNR.START_LOGMNR will not allow redo log files to be missing from the
LogMiner redo log file list for the requested time or SCN range. If a call to
DBMS_LOGMNR.START_LOGMNR fails, then you can query the STATUS column in the
V$LOGMNR_LOGS view to determine which redo log files are missing from the list. You
can then find and manually add these redo log files and attempt to call
DBMS_LOGMNR.START_LOGMNR again.
22-41
Chapter 22
Accessing LogMiner Operational Information in Views
Note:
As of Oracle Database 12c Release 2 (12.2.0.1), the LogMiner
CONTINUOUS_MINE option is deprecated. It is still supported for backward
compatibility reasons, but Oracle recommends that you discontinue using
it. There is no replacement functionality.
• Although all other options that can be specified when you call
DBMS_LOGMNR.START_LOGMNR allow files to be missing from the LogMiner redo log file
list, you may not want to have missing files. You can query the V$LOGMNR_LOGS view
before querying the V$LOGMNR_CONTENTS view to ensure that all required files are in
the list. If the list is left with missing files and you query the V$LOGMNR_CONTENTS view,
then a row is returned in V$LOGMNR_CONTENTS with the following column values:
– In the OPERATION column, a value of 'MISSING_SCN'
– In the STATUS column, a value of 1291
– In the INFO column, a string indicating the missing SCN range (for example,
'Missing SCN 100 - 200')
– SUPPLEMENTAL_LOG_DATA_FK column
22-42
Chapter 22
Steps in a Typical LogMiner Session
– ALWAYS column
– LOG_GROUP_TYPE column
This column contains one of the following values to indicate the type of logging
defined for this log group. USER LOG GROUP indicates that the log group was
user-defined (as opposed to system-generated).
* ALL COLUMN LOGGING
22-43
Chapter 22
Steps in a Typical LogMiner Session
See Also:
22-44
Chapter 22
Steps in a Typical LogMiner Session
22.12.3 Typical LogMiner Session Task 3: Specify Redo Log Files for
Analysis
Before you can start LogMiner, you must specify the redo log files that you want to
analyze. To do so, execute the DBMS_LOGMNR.ADD_LOGFILE procedure, as demonstrated
in the following steps. You can add and remove redo log files in any order.
Note:
If you will be mining in the database instance that is generating the redo log
files, then you only need to specify the CONTINUOUS_MINE option and one of the
following when you start LogMiner:
• The STARTSCN parameter
• The STARTTIME parameter
For more information, see "Redo Log File Options".
1. Use SQL*Plus to start an Oracle instance, with the database either mounted or
unmounted. For example, enter the STARTUP statement at the SQL prompt:
STARTUP
2. Create a list of redo log files. Specify the NEW option of the DBMS_LOGMNR.ADD_LOGFILE
PL/SQL procedure to signal that this is the beginning of a new list. For example,
enter the following to specify the /oracle/logs/log1.f redo log file:
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/oracle/logs/log1.f', -
OPTIONS => DBMS_LOGMNR.NEW);
3. If desired, add more redo log files by specifying the ADDFILE option of the
DBMS_LOGMNR.ADD_LOGFILE PL/SQL procedure. For example, enter the following to
add the /oracle/logs/log2.f redo log file:
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/oracle/logs/log2.f', -
OPTIONS => DBMS_LOGMNR.ADDFILE);
22-45
Chapter 22
Steps in a Typical LogMiner Session
The OPTIONS parameter is optional when you are adding additional redo log files.
For example, you could simply enter the following:
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME=>'/oracle/logs/log2.f');
4. If desired, remove redo log files by using the DBMS_LOGMNR.REMOVE_LOGFILE PL/SQL
procedure. For example, enter the following to remove the /oracle/logs/log2.f
redo log file:
EXECUTE DBMS_LOGMNR.REMOVE_LOGFILE( -
LOGFILENAME => '/oracle/logs/log2.f');
If you are not specifying a flat file dictionary name, then use the OPTIONS parameter
to specify either the DICT_FROM_REDO_LOGS or DICT_FROM_ONLINE_CATALOG option.
If you specify DICT_FROM_REDO_LOGS, then LogMiner expects to find a dictionary in
the redo log files that you specified with the DBMS_LOGMNR.ADD_LOGFILE procedure. To
determine which redo log files contain a dictionary, look at the V$ARCHIVED_LOG
view. See "Extracting a LogMiner Dictionary to the Redo Log Files" for an
example.
Note:
If you add additional redo log files after LogMiner has been started, you
must restart LogMiner. LogMiner will not retain options that were included
in the previous call to DBMS_LOGMNR.START_LOGMNR; you must respecify the
options you want to use. However, LogMiner will retain the dictionary
specification from the previous call if you do not specify a dictionary in the
current call to DBMS_LOGMNR.START_LOGMNR.
For more information about the DICT_FROM_ONLINE_CATALOG option, see "Using the
Online Catalog".
2. Optionally, you can filter your query by time or by SCN. See "Filtering Data by
Time" or "Filtering Data by SCN".
22-46
Chapter 22
Examples Using LogMiner
3. You can also use the OPTIONS parameter to specify additional characteristics of
your LogMiner session. For example, you might decide to use the online catalog
as your LogMiner dictionary and to have only committed transactions shown in the
V$LOGMNR_CONTENTS view, as follows:
This procedure closes all the redo log files and allows all the database and system
resources allocated by LogMiner to be released.
If this procedure is not executed, then LogMiner retains all its allocated resources until
the end of the Oracle session in which it was called. It is particularly important to use
this procedure to end the LogMiner session if either the DDL_DICT_TRACKING option or
the DICT_FROM_REDO_LOGS option was used.
22-47
Chapter 22
Examples Using LogMiner
Note:
All examples in this section assume that minimal supplemental logging has
been enabled:
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
Because LogMiner displays date data using the setting for the
NLS_DATE_FORMAT parameter that is active for the user session, this step is
optional. However, setting the parameter explicitly lets you predict the date
format.
22.13.1.1 Example 1: Finding All Modifications in the Last Archived Redo Log
File
The easiest way to examine the modification history of a database is to mine at the
source database and use the online catalog to translate the redo log files. This
example shows how to do the simplest analysis using LogMiner.
22-48
Chapter 22
Examples Using LogMiner
This example assumes that you know you want to mine the redo log file that was most
recently archived. It finds all modifications that are contained in the last archived redo
log generated by the database (assuming that the database is not an Oracle Real
Application Clusters (Oracle RAC) database).
1. Determine which redo log file was most recently archived.
SELECT NAME FROM V$ARCHIVED_LOG
WHERE FIRST_TIME = (SELECT MAX(FIRST_TIME) FROM V$ARCHIVED_LOG);
NAME
-------------------------------------------
/usr/oracle/data/db1arch_1_16_482701534.dbf
2. Specify the list of redo log files to be analyzed. In this case, it is the redo log file
that was returned by the query in Step 1.
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/usr/oracle/data/db1arch_1_16_482701534.dbf', -
OPTIONS => DBMS_LOGMNR.NEW);
3. Start LogMiner and specify the dictionary to use.
EXECUTE DBMS_LOGMNR.START_LOGMNR( -
OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
4. Query the V$LOGMNR_CONTENTS view.
Note that there are four transactions (two of them were committed within the redo
log file being analyzed, and two were not). The output shows the DML statements
in the order in which they were executed; thus transactions interleave among
themselves.
SELECT username AS USR, (XIDUSN || '.' || XIDSLT || '.' || XIDSQN) AS XID,
SQL_REDO, SQL_UNDO FROM V$LOGMNR_CONTENTS WHERE username IN ('HR', 'OE');
22-49
Chapter 22
Examples Using LogMiner
OE 1.1.1484 commit;
HR 1.11.1476 commit;
5. End the LogMiner session.
SQL> EXECUTE DBMS_LOGMNR.END_LOGMNR();
22-50
Chapter 22
Examples Using LogMiner
NAME
-------------------------------------------
/usr/oracle/data/db1arch_1_16_482701534.dbf
2. Specify the redo log file that was returned by the query in Step 1. The list will
consist of one redo log file.
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/usr/oracle/data/db1arch_1_16_482701534.dbf', -
OPTIONS => DBMS_LOGMNR.NEW);
3. Start LogMiner by specifying the dictionary to use and the COMMITTED_DATA_ONLY
option.
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/usr/oracle/data/db1arch_1_16_482701534.dbf', -
OPTIONS => DBMS_LOGMNR.NEW);
4. Query the V$LOGMNR_CONTENTS view.
Although transaction 1.11.1476 was started before transaction 1.1.1484 (as
revealed in "Example 1: Finding All Modifications in the Last Archived Redo Log
File"), it committed after transaction 1.1.1484 committed. In this example,
therefore, transaction 1.1.1484 is shown in its entirety before transaction
1.11.1476. The two transactions that did not commit within the redo log file being
analyzed are not returned.
SELECT username AS USR, (XIDUSN || '.' || XIDSLT || '.' || XIDSQN) AS XID, SQL_REDO,
SQL_UNDO FROM V$LOGMNR_CONTENTS WHERE username IN ('HR', 'OE');
;
USR XID SQL_REDO SQL_UNDO
---- --------- ------------------------------- ---------------------------------
22-51
Chapter 22
Examples Using LogMiner
OE 1.1.1484 commit;
HR 1.11.1476 commit;
5. End the LogMiner session.
EXECUTE DBMS_LOGMNR.END_LOGMNR();
NAME
22-52
Chapter 22
Examples Using LogMiner
-------------------------------------------
/usr/oracle/data/db1arch_1_16_482701534.dbf
2. Specify the redo log file that was returned by the query in Step 1.
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
LOGFILENAME => '/usr/oracle/data/db1arch_1_16_482701534.dbf', -
OPTIONS => DBMS_LOGMNR.NEW);
3. Start LogMiner by specifying the dictionary to use and the COMMITTED_DATA_ONLY and
PRINT_PRETTY_SQL options.
EXECUTE DBMS_LOGMNR.START_LOGMNR(-
OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + -
DBMS_LOGMNR.COMMITTED_DATA_ONLY + -
DBMS_LOGMNR.PRINT_PRETTY_SQL);
OE 1.1.1484 commit;
22-53
Chapter 22
Examples Using LogMiner
"MANAGER_ID" = 105,
"DEPARTMENT_ID" = 10;
OE 1.1.1484 commit;
22-54
Chapter 22
Examples Using LogMiner
22.13.1.4 Example 4: Using the LogMiner Dictionary in the Redo Log Files
This example shows how to use the dictionary that has been extracted to the redo log
files. When you use the dictionary in the online catalog, you must mine the redo log
files in the same database that generated them. Using the dictionary contained in the
redo log files enables you to mine redo log files in a different database.
1. Determine which redo log file was most recently archived by the database.
SELECT NAME, SEQUENCE# FROM V$ARCHIVED_LOG
WHERE FIRST_TIME = (SELECT MAX(FIRST_TIME) FROM V$ARCHIVED_LOG);
NAME SEQUENCE#
-------------------------------------------- --------------
/usr/oracle/data/db1arch_1_210_482701534.dbf 210
2. The dictionary may be contained in more than one redo log file. Therefore, you
need to determine which redo log files contain the start and end of the dictionary.
Query the V$ARCHIVED_LOG view, as follows:
a. Find a redo log file that contains the end of the dictionary extract. This redo log
file must have been created before the redo log file that you want to analyze,
but should be as recent as possible.
SELECT NAME, SEQUENCE#, DICTIONARY_BEGIN d_beg, DICTIONARY_END d_end
FROM V$ARCHIVED_LOG
WHERE SEQUENCE# = (SELECT MAX (SEQUENCE#) FROM V$ARCHIVED_LOG
WHERE DICTIONARY_END = 'YES' and SEQUENCE# <= 210);
22-55
Chapter 22
Examples Using LogMiner
EXECUTE DBMS_LOGMNR.START_LOGMNR(-
OPTIONS => DBMS_LOGMNR.DICT_FROM_REDO_LOGS + -
DBMS_LOGMNR.COMMITTED_DATA_ONLY + -
DBMS_LOGMNR.PRINT_PRETTY_SQL);
4. Query the V$LOGMNR_CONTENTS view.
To reduce the number of rows returned by the query, exclude from the query all
DML statements done in the SYS or SYSTEM schemas. (This query specifies a
timestamp to exclude transactions that were involved in the dictionary extraction.)
The output shows three transactions: two DDL transactions and one DML
transaction. The DDL transactions, 1.2.1594 and 1.18.1602, create the table
oe.product_tracking and create a trigger on table oe.product_information,
respectively. In both transactions, the DML statements done to the system tables
(tables owned by SYS) are filtered out because of the query predicate.
The DML transaction, 1.9.1598, updates the oe.product_information table. The
update operation in this transaction is fully translated. However, the query output
also contains some untranslated reconstructed SQL statements. Most likely, these
statements were done on the oe.product_tracking table that was created after the
data dictionary was extracted to the redo log files.
(The next example shows how to run LogMiner with the DDL_DICT_TRACKING option
so that all SQL statements are fully translated; no binary data is returned.)
SELECT USERNAME AS usr, SQL_REDO FROM V$LOGMNR_CONTENTS
WHERE SEG_OWNER IS NULL OR SEG_OWNER NOT IN ('SYS', 'SYSTEM') AND
TIMESTAMP > '10-jan-2012 15:59:53';
22-56
Chapter 22
Examples Using LogMiner
OE 1.9.1598 commit;
5. Issue additional queries, if desired.
Display all the DML statements that were executed as part of the CREATE TABLE
DDL statement. This includes statements executed by users and internally by
Oracle.
22-57
Chapter 22
Examples Using LogMiner
Note:
If you choose to reapply statements displayed by a query such as the one
shown here, then reapply DDL statements only. Do not reapply DML
statements that were executed internally by Oracle, or you risk corrupting
your database. In the following output, the only statement that you should
use in a reapply operation is the CREATE TABLE OE.PRODUCT_TRACKING
statement.
SQL_REDO
--------------------------------------------------------------------------------
set transaction read write;
22-58
Chapter 22
Examples Using LogMiner
"BLKCNT" IS NULL,
"EMPCNT" IS NULL,
"AVGSPC" IS NULL,
"CHNCNT" IS NULL,
"AVGRLN" IS NULL,
"AVGSPC_FLB" IS NULL,
"FLBCNT" IS NULL,
"ANALYZETIME" IS NULL,
"SAMPLESIZE" IS NULL,
"DEGREE" IS NULL,
"INSTANCES" IS NULL,
"INTCOLS" = 5,
"KERNELCOLS" = 5,
"PROPERTY" = 536870912,
"TRIGFLAG" = 0,
"SPARE1" = 178,
"SPARE2" IS NULL,
"SPARE3" IS NULL,
"SPARE4" IS NULL,
"SPARE5" IS NULL,
"SPARE6" = TO_DATE('13-jan-2012 14:01:05', 'dd-mon-yyyy hh24:mi:ss'),
22-59
Chapter 22
Examples Using LogMiner
"SCALE" IS NULL,
"NULL$" = 0,
"DEFLENGTH" IS NULL,
"SPARE6" IS NULL,
"INTCOL#" = 2,
"PROPERTY" = 0,
"CHARSETID" = 0,
"CHARSETFORM" = 0,
"SPARE1" = 0,
"SPARE2" = 0,
"SPARE3" = 0,
"SPARE4" IS NULL,
"SPARE5" IS NULL,
"DEFAULT$" IS NULL;
22-60
Chapter 22
Examples Using LogMiner
"CHARSETFORM" = 0,
"SPARE1" = 0,
"SPARE2" = 2,
"SPARE3" = 0,
"SPARE4" IS NULL,
"SPARE5" IS NULL,
"DEFAULT$" IS NULL;
update "SYS"."SEG$"
set
"TYPE#" = 5,
"BLOCKS" = 5,
"EXTENTS" = 1,
"INIEXTS" = 5,
"MINEXTS" = 1,
"MAXEXTS" = 121,
"EXTSIZE" = 5,
22-61
Chapter 22
Examples Using LogMiner
"EXTPCT" = 50,
"USER#" = 37,
"LISTS" = 0,
"GROUPS" = 0,
"CACHEHINT" = 0,
"HWMINCR" = 33415,
"SPARE1" = 1024
where
"TS#" = 0 and
"FILE#" = 1 and
"BLOCK#" = 121034 and
"TYPE#" = 3 and
"BLOCKS" = 5 and
"EXTENTS" = 1 and
"INIEXTS" = 5 and
"MINEXTS" = 1 and
"MAXEXTS" = 121 and
"EXTSIZE" = 5 and
"EXTPCT" = 50 and
"USER#" = 37 and
"LISTS" = 0 and
"GROUPS" = 0 and
"BITMAPRANGES" = 0 and
"CACHEHINT" = 0 and
"SCANHINT" = 0 and
"HWMINCR" = 33415 and
"SPARE1" = 1024 and
"SPARE2" IS NULL and
ROWID = 'AAAAAIAABAAAdMOAAB';
commit;
6. End the LogMiner session.
EXECUTE DBMS_LOGMNR.END_LOGMNR();
NAME SEQUENCE#
22-62
Chapter 22
Examples Using LogMiner
-------------------------------------------- --------------
/usr/oracle/data/db1arch_1_210_482701534.dbf 210
2. Because the dictionary may be contained in more than one redo log file, you need
to determine which redo log files contain the start and end of the data dictionary.
Query the V$ARCHIVED_LOG view, as follows:
a. Find a redo log that contains the end of the data dictionary extract. This redo
log file must have been created before the redo log files that you want to
analyze, but should be as recent as possible.
SELECT NAME, SEQUENCE#, DICTIONARY_BEGIN d_beg, DICTIONARY_END d_end
FROM V$ARCHIVED_LOG
WHERE SEQUENCE# = (SELECT MAX (SEQUENCE#) FROM V$ARCHIVED_LOG
WHERE DICTIONARY_END = 'YES' and SEQUENCE# < 210);
NAME
--------------------------------------------
/usr/oracle/data/db1arch_1_207_482701534.dbf
/usr/oracle/data/db1arch_1_208_482701534.dbf
/usr/oracle/data/db1arch_1_209_482701534.dbf
/usr/oracle/data/db1arch_1_210_482701534.dbf
4. Specify the list of the redo log files of interest.
Include the redo log files that contain the beginning and end of the dictionary, the
redo log file that you want to mine, and any redo log files required to create a list
without gaps. You can add the redo log files in any order.
EXECUTE DBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME => '/usr/oracle/data/db1arch_1_210_482701534.dbf', -
22-63
Chapter 22
Examples Using LogMiner
EXECUTE DBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME => '/usr/oracle/data/db1arch_1_209_482701534.dbf');
EXECUTE DBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME => '/usr/oracle/data/db1arch_1_208_482701534.dbf');
EXECUTE DBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME => '/usr/oracle/data/db1arch_1_207_482701534.dbf');
5. Start LogMiner by specifying the dictionary to use and the DDL_DICT_TRACKING,
COMMITTED_DATA_ONLY, and PRINT_PRETTY_SQL options.
EXECUTE DBMS_LOGMNR.START_LOGMNR(-
OPTIONS => DBMS_LOGMNR.DICT_FROM_REDO_LOGS + -
DBMS_LOGMNR.DDL_DICT_TRACKING + -
DBMS_LOGMNR.COMMITTED_DATA_ONLY + -
DBMS_LOGMNR.PRINT_PRETTY_SQL);
6. Query the V$LOGMNR_CONTENTS view.
To reduce the number of rows returned, exclude from the query all DML
statements done in the SYS or SYSTEM schemas. (This query specifies a timestamp
to exclude transactions that were involved in the dictionary extraction.)
The query returns all the reconstructed SQL statements correctly translated and
the insert operations on the oe.product_tracking table that occurred because of
the trigger execution.
SELECT USERNAME AS usr,(XIDUSN || '.' || XIDSLT || '.' || XIDSQN) as XID, SQL_REDO FROM
V$LOGMNR_CONTENTS
WHERE SEG_OWNER IS NULL OR SEG_OWNER NOT IN ('SYS', 'SYSTEM') AND
TIMESTAMP > '10-jan-2012 15:59:53';
22-64
Chapter 22
Examples Using LogMiner
OE 1.9.1598 commit;
7. End the LogMiner session.
EXECUTE DBMS_LOGMNR.END_LOGMNR();
count pls_integer := 0;
my_option pls_integer := DBMS_LOGMNR.NEW;
BEGIN
FOR c_log_rec IN c_log
LOOP
22-65
Chapter 22
Examples Using LogMiner
22-66
Chapter 22
Examples Using LogMiner
Note:
As of Oracle Database 12c Release 2 (12.2.0.1), the LogMiner CONTINUOUS_MINE
option is deprecated. It is still supported for backward compatibility reasons, but
Oracle recommends that you discontinue using it. There is no replacement
functionality.
This section contains the following list of examples; these examples are best read in
sequential order, because each example builds on the example or examples that
precede it:
The SQL output formatting may be different on your display than that shown in these
examples.
22-67
Chapter 22
Examples Using LogMiner
NAME FIRST_TIME
-------------------------------------------- --------------------
/usr/oracle/data/db1arch_1_207_482701534.dbf 10-jan-2012 12:01:34
2. Display all the redo log files that have been generated so far.
This step is not required, but is included to demonstrate that the CONTINUOUS_MINE
option works as expected, as will be shown in Step 4.
SELECT FILENAME name FROM V$LOGMNR_LOGS
WHERE LOW_TIME > '10-jan-2012 12:01:34';
NAME
----------------------------------------------
/usr/oracle/data/db1arch_1_207_482701534.dbf
/usr/oracle/data/db1arch_1_208_482701534.dbf
/usr/oracle/data/db1arch_1_209_482701534.dbf
/usr/oracle/data/db1arch_1_210_482701534.dbf
3. Start LogMiner by specifying the dictionary to use and the COMMITTED_DATA_ONLY,
PRINT_PRETTY_SQL, and CONTINUOUS_MINE options.
EXECUTE DBMS_LOGMNR.START_LOGMNR(-
STARTTIME => '10-jan-2012 12:01:34', -
ENDTIME => SYSDATE, -
OPTIONS => DBMS_LOGMNR.DICT_FROM_REDO_LOGS + -
DBMS_LOGMNR.COMMITTED_DATA_ONLY + -
DBMS_LOGMNR.PRINT_PRETTY_SQL + -
DBMS_LOGMNR.CONTINUOUS_MINE);
4. Query the V$LOGMNR_LOGS view.
This step shows that the DBMS_LOGMNR.START_LOGMNR procedure with the
CONTINUOUS_MINE option includes all of the redo log files that have been generated
so far, as expected. (Compare the output in this step to the output in Step 2.)
SELECT FILENAME name FROM V$LOGMNR_LOGS;
NAME
------------------------------------------------------
/usr/oracle/data/db1arch_1_207_482701534.dbf
/usr/oracle/data/db1arch_1_208_482701534.dbf
22-68
Chapter 22
Examples Using LogMiner
/usr/oracle/data/db1arch_1_209_482701534.dbf
/usr/oracle/data/db1arch_1_210_482701534.dbf
5. Query the V$LOGMNR_CONTENTS view.
To reduce the number of rows returned by the query, exclude all DML statements
done in the SYS or SYSTEM schema. (This query specifies a timestamp to exclude
transactions that were involved in the dictionary extraction.)
Note that all reconstructed SQL statements returned by the query are correctly
translated.
SELECT USERNAME AS usr,(XIDUSN || '.' || XIDSLT || '.' || XIDSQN) as XID,
SQL_REDO FROM V$LOGMNR_CONTENTS
WHERE SEG_OWNER IS NULL OR SEG_OWNER NOT IN ('SYS', 'SYSTEM') AND
TIMESTAMP > '10-jan-2012 15:59:53';
22-69
Chapter 22
Examples Using LogMiner
"PRODUCT_ID" = 2340,
"MODIFIED_TIME" = TO_DATE('13-jan-2012 16:07:07',
'dd-mon-yyyy hh24:mi:ss'),
"OLD_LIST_PRICE" = 72,
"OLD_WARRANTY_PERIOD" = TO_YMINTERVAL('+05-00');
OE 1.9.1598 commit;
22.13.2.2 Example 2: Mining the Redo Log Files in a Given SCN Range
This example shows how to specify an SCN range of interest and mine the redo log
files that satisfy that range. You can use LogMiner to see all committed DML
statements whose effects have not yet been made permanent in the data files.
Note that in this example (unlike the other examples) it is not assumed that you have
set the NLS_DATE_FORMAT parameter.
CHECKPOINT_CHANGE# CURRENT_SCN
------------------ ---------------
56453576 56454208
2. Start LogMiner and specify the CONTINUOUS_MINE option.
EXECUTE DBMS_LOGMNR.START_LOGMNR(-
Note that the redo log file that LogMiner added does not contain the whole SCN
range. When you specify the CONTINUOUS_MINE option, LogMiner adds only archived
redo log files when you call the DBMS_LOGMNR.START_LOGMNR procedure. LogMiner will
add the rest of the SCN range contained in the online redo log files automatically,
as needed during the query execution. Use the following query to determine
whether the redo log file added is the latest archived redo log file produced.
SELECT NAME FROM V$ARCHIVED_LOG
WHERE SEQUENCE# = (SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG);
NAME
--------------------------------------------
/usr/oracle/data/db1arch_1_215_482701534.dbf
22-70
Chapter 22
Examples Using LogMiner
4. Query the V$LOGMNR_CONTENTS view for changes made to the user tables.
The following query does not return the SET TRANSACTION READ WRITE and COMMIT
statements associated with transaction 1.6.1911 because these statements do not
have a segment owner (SEG_OWNER) associated with them.
Note that the default NLS_DATE_FORMAT, 'DD-MON-RR', is used to display the column
MODIFIED_TIME of type DATE.
SELECT SCN, (XIDUSN || '.' || XIDSLT || '.' || XIDSQN) as XID, SQL_REDO
FROM V$LOGMNR_CONTENTS
WHERE SEG_OWNER NOT IN ('SYS', 'SYSTEM');
22-71
Chapter 22
Examples Using LogMiner
22-72
Chapter 22
Examples Using LogMiner
3. Start LogMiner and limit the search to the specified time range:
EXECUTE DBMS_LOGMNR.START_LOGMNR( -
DICTFILENAME => 'orcldict.ora', -
STARTTIME => TO_DATE('01-Jan-1998 08:30:00','DD-MON-YYYY HH:MI:SS'), -
ENDTIME => TO_DATE('01-Jan-1998 08:45:00', 'DD-MON-YYYY HH:MI:SS'));
4. Query the V$LOGMNR_CONTENTS view.
At this point, the V$LOGMNR_CONTENTS view is available for queries. You decide to find
all of the changes made by user joedevo to the salary table. Execute the following
SELECT statement:
For both the SQL_REDO and SQL_UNDO columns, two rows are returned (the format of
the data display will be different on your screen). You discover that joedevo
requested two operations: he deleted his old salary and then inserted a new,
higher salary. You now have the data necessary to undo this operation.
SQL_REDO SQL_UNDO
-------- --------
delete from SALARY insert into SALARY(NAME, EMPNO, SAL)
where EMPNO = 12345 values ('JOEDEVO', 12345, 500)
and NAME='JOEDEVO'
and SAL=500;
22-73
Chapter 22
Supported Data Types, Storage Attributes, and Database and Redo Log File Versions
The values in the Hits column show the number of times that the named table had
an insert, delete, or update operation performed on it during the 2-week period
specified in the query. In this example, the cust.account table was modified the
most during the specified 2-week period, and the hr.employees and sys.donor
tables were modified the least during the same time period.
4. End the LogMiner session.
Use the DBMS_LOGMNR.END_LOGMNR procedure to finish the LogMiner session properly:
DBMS_LOGMNR.END_LOGMNR( );
Note:
As of Oracle Database 12c Release 1 (12.1), the maximum size of the
VARCHAR2, NVARCHAR2, and RAW data types has been increased to 32 KB when the
COMPATIBLE initialization parameter is set to 12.0 or higher and the
MAX_STRING_SIZE initialization parameter is set to EXTENDED.
LogMiner supports the following data types and table storage attributes. As described
in "Compatibility Requirements", some data types are supported only in certain
releases.
22-74
Chapter 22
Supported Data Types, Storage Attributes, and Database and Redo Log File Versions
Data Types
• BINARY_DOUBLE
• BINARY_FLOAT
• BLOB
• CHAR
• DATE
• LONG RAW
• NCHAR
• NUMBER
• NVARCHAR2
• TIMESTAMP
• XDB
• XMLType data for all storage models, assuming the following primary database
compatibility requirements:
– XMLType stored in CLOB format requires that the database be run at a
compatibility setting of 11.0 or higher (XMLType stored as CLOB is deprecated as
of Oracle Database 12c Release 1 (12.1).)
– XMLType stored in object-relational format or as binary XML requires that the
database be running Oracle Database 11g Release 2 (11.2.0.3) or higher with
a redo compatibility setting of 11.2.0.3 or higher. The contents of the SQL_REDO
column for the XML data-related operations is never valid SQL or PL/SQL.
22-75
Chapter 22
Supported Data Types, Storage Attributes, and Database and Redo Log File Versions
See Also:
• Compatibility Requirements
See Also:
22-76
Chapter 22
Supported Data Types, Storage Attributes, and Database and Redo Log File Versions
• Nested tables
• Objects with nested tables
• Tables with identity columns
• Temporal validity columns
• PKREF columns
• PKOID columns
• Nested table attributes and stand-alone nested table columns
See Also:
"Steps in a Typical LogMiner Session" and "Supplemental Logging"
22-77
23
Using the Metadata APIs
The DBMS_METADATA API enables you to do the following:
23-1
Chapter 23
Overview of the DBMS_METADATA API
The DBMS_METADATA API does not require you to make any source code changes when
you change database releases because it is upwardly compatible across different
Oracle releases. XML documents retrieved by one release can be processed by the
submit interface on the same or later release. For example, XML documents retrieved
by an Oracle9i database can be submitted to Oracle Database 10g.
The DBMS_METADATA API makes use of XML (Extensible Markup Language) and XSLT
(Extensible Stylesheet Language Transformation). The DBMS_METADATA API represents
object metadata as XML because it is a universal format that can be easily parsed and
transformed. The DBMS_METADATA API uses XSLT to transform XML documents into
either other XML documents or into SQL DDL.
You can use the DBMS_METADATA API to specify one or more transforms (XSLT scripts) to
be applied to the XML when the metadata is fetched (or when it is resubmitted). The
API provides some predefined transforms, including one named DDL that transforms
the XML document into SQL creation DDL.
You can then specify conditions on the transform by using transform parameters. You
can also specify optional parse items to access specific attributes of an object's
metadata.
For more details about all of these options and examples of their implementation, see
the following sections:
• Using the DBMS_METADATA API to Retrieve an Object's Metadata
• Using the DBMS_METADATA API to Re-Create a Retrieved Object
• Using the DBMS_METADATA API to Retrieve Collections of Different Object
Types
23-2
Chapter 23
Overview of the DBMS_METADATA API
For example, suppose you want to know which transforms are allowed for INDEX
objects. The following query returns the transforms that are valid for INDEX objects, the
required input types, and the resulting output types:
SQL> SELECT transform, output_type, input_type, description
2 FROM dbms_metadata_transforms
3 WHERE object_type='INDEX';
You might then want to know which transform parameters are valid for the DDL
transform:
SQL> SELECT param, datatype, default_val, description
2 FROM dbms_metadata_transform_params
3 WHERE object_type='INDEX' and transform='DDL'
4 ORDER BY param;
You can also perform the following query which returns specific metadata about the
INDEX object type::
23-3
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
PARSE_ITEM DESCRIPTION
-------------------- --------------------------------------------------------------
OBJECT_TYPE Object type
TABLESPACE Object tablespace (default tablespace for partitioned objects)
BASE_OBJECT_SCHEMA Schema of the base object
SCHEMA Object schema, if any
NAME Object name
BASE_OBJECT_NAME Name of the base object
BASE_OBJECT_TYPE Object type of the base object
SYSTEM_GENERATED Y = system-generated object; N = not system-generated
Note:
To access objects that are not in your own schema you must have the
SELECT_CATALOG_ROLE role. However, roles are disabled within many PL/SQL
objects (stored procedures, functions, definer's rights APIs). Therefore, if you
are writing a PL/SQL program that will access objects in another schema (or, in
general, any objects for which you need the SELECT_CATALOG_ROLE role), then you
must put the code in an invoker's rights API.
You can use the programmatic interface for casual browsing, or you can use it to
develop applications. You would use the browsing interface if you simply wanted to
make ad hoc queries of the system metadata. You would use the programmatic
interface when you want to extract dictionary metadata as part of an application. In
such cases, the procedures provided by the DBMS_METADATA API can be used in place of
SQL scripts and customized code that you may be currently using to do the same
thing.
• Typical Steps Used for Basic Metadata Retrieval
• Retrieving Multiple Objects
• Placing Conditions on Transforms
• Accessing Specific Metadata Attributes
23-4
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
-- Release resources.
DBMS_METADATA.CLOSE(h);
RETURN doc;
END;
/
2. Connect as user hr.
3. Run the program to create the get_table_md function:
SQL> @metadata_program
23-5
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
"HOURS_WORKED" NUMBER(4,2),
FOREIGN KEY ("EMPLOYEE_ID")
REFERENCES "HR"."EMPLOYEES" ("EMPLOYEE_ID") ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "EXAMPLE"
Example 23-2 Using the DBMS_METADATA Browsing Interface to Retrieve
Data
SQL> SET PAGESIZE 0
SQL> SET LONG 1000000
SQL> SELECT DBMS_METADATA.GET_DDL('TABLE','TIMECARDS','HR') FROM dual;
The results of this query are same as shown in step 5 in the DBMS_METADATA
programmatic interface example.
The following example demonstrates use of this construct and retrieving multiple
objects. Connect as user scott for this example. The password is tiger.
23-6
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
-- Release resources.
DBMS_METADATA.CLOSE(h);
END;
/
2. Execute the procedure:
EXECUTE get_tables_md;
3. Query the my_metadata table to see what was retrieved:
SET LONG 9000000
SET PAGES 0
SELECT * FROM my_metadata;
23-7
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
DBMS_METADATA.SET_TRANSFORM_PARAM(th,'SEGMENT_ATTRIBUTES',false);
-- Release resources.
DBMS_METADATA.CLOSE(h);
RETURN doc;
END;
/
2. Perform the following query:
SQL> SELECT get_table_md FROM dual;
Example 23-5 shows a sample use of the SET_REMAP_PARAM procedure. It first adds the
MODIFY transform and specifies remap parameters to change the schema name from hr
to scott. It then adds the DDL transform. The output of the MODIFY transform is an XML
document that becomes the input to the DDL transform. The end result is the creation
DDL for the timecards table with all instances of schema hr changed to scott.
23-8
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
-- Release resources.
DBMS_METADATA.CLOSE(h);
RETURN doc;
END;
/
2. Perform the following query:
SELECT remap_schema FROM dual;
If you are familiar with XSLT, then you can add your own user-written transforms
to process the XML.
Example 23-6 fetches all tables in a schema. For each table, a parse item is used to
get its name. The name is then used to get all indexes on the table. The example
illustrates the use of the FETCH_DDL function, which returns metadata in a sys.ku$_ddls
object.
This example assumes you are connected to a schema that contains some tables and
indexes. It also creates a table named my_metadata.
23-9
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
23-10
Chapter 23
Using the DBMS_METADATA API to Retrieve an Object's Metadata
LOOP
idxddls := dbms_metadata.fetch_ddl(h2);
23-11
Chapter 23
Using the DBMS_METADATA API to Re-Create a Retrieved Object
23-12
Chapter 23
Using the DBMS_METADATA API to Re-Create a Retrieved Object
-- Release resources.
DBMS_METADATA.CLOSE(h1);
-- Now add the DDL transform so that the modified XML can be
-- transformed into creation DDL.
th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
DBMS_METADATA.CLOSE(h2);
IF NOT result THEN
-- Process the error information.
FOR i IN errs.FIRST..errs.LAST LOOP
err := errs(i);
FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
dbms_output.put_line(err.errorLines(j).errorText);
END LOOP;
END LOOP;
END IF;
END;
END example_pkg;
/
3. Now create a table named my_example in the schema SCOTT:
CONNECT scott
Enter password:
-- The password is tiger.
CONNECT system
Enter password: password
23-13
Chapter 23
Using the DBMS_METADATA API to Retrieve Collections of Different Object Types
These object types were developed for use by the Data Pump Export utility, but you
can use them in your own applications.
You can use only the programmatic retrieval interface (OPEN, FETCH, CLOSE) with these
types, not the browsing interface or the submit interface.
You can specify filters for heterogeneous object types, just as you do for the
homogeneous types. For example, you can specify the SCHEMA and NAME filters for
TABLE_EXPORT, or the SCHEMA filter for SCHEMA_EXPORT.
Example 23-8 shows how to retrieve the object types in the scott schema. Connect as
user scott. The password is tiger.
23-14
Chapter 23
Using the DBMS_METADATA API to Retrieve Collections of Different Object Types
th := DBMS_METADATA.ADD_TRANSFORM(h,'DDL');
-- Release resources.
DBMS_METADATA.CLOSE(h);
END;
/
2. Execute the procedure:
EXECUTE get_schema_md;
3. Perform the following query to see what was retrieved:
SET LONG 9000000
SET PAGESIZE 0
SELECT * FROM my_metadata;
In this example, objects are returned ordered by object type; for example, all tables are
returned, then all grants on tables, then all indexes on tables, and so on. The order is,
generally speaking, a valid creation order. Thus, if you take the objects in the order in
which they were returned and use the submit interface to re-create them in the same
order in another schema or database, then there will usually be no errors. (The
exceptions usually involve circular references; for example, if package A contains a
call to package B, and package B contains a call to package A, then one of the
packages will need to be recompiled a second time.)
• Filtering the Return of Heterogeneous Object Types
Example 23-9 shows how you can use SET_FILTER to specify finer control on the
objects returned. Connect as user scott. The password is tiger.
23-15
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
-- Release resources.
DBMS_METADATA.CLOSE(h);
END;
/
2. Execute the procedure:
EXECUTE get_schema_md2;
3. Perform the following query to see what was retrieved:
SET LONG 9000000
SET PAGESIZE 0
SELECT * FROM my_metadata;
23-16
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
Table created.
Table created.
2. Create a function to return the table metadata in SXML format. The following are
some key points to keep in mind about SXML when you are using the
DBMS_METADATA_DIFF API:
23-17
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
12 --
13 -- Use this transform parameter to suppress physical properties
14 --
15 DBMS_METADATA.SET_TRANSFORM_PARAM(transform_handle,'PHYSICAL_PROPERTIES',
16 FALSE);
17 doc := DBMS_METADATA.FETCH_CLOB(open_handle);
18 DBMS_METADATA.CLOSE(open_handle);
19 RETURN doc;
20 END;
21 /
Function created.
3. Use the get_table_sxml function to fetch the table SXML for the two tables:
SQL> SELECT get_table_sxml('TAB1') FROM dual;
1 row selected.
23-18
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
<SCALE>0</SCALE>
</COL_LIST_ITEM>
<COL_LIST_ITEM>
<NAME>ENAME</NAME>
<DATATYPE>VARCHAR2</DATATYPE>
<LENGTH>20</LENGTH>
</COL_LIST_ITEM>
<COL_LIST_ITEM>
<NAME>MGR</NAME>
<DATATYPE>NUMBER</DATATYPE>
<PRECISION>4</PRECISION>
<SCALE>0</SCALE>
</COL_LIST_ITEM>
<COL_LIST_ITEM>
<NAME>DEPTNO</NAME>
<DATATYPE>NUMBER</DATATYPE>
<PRECISION>2</PRECISION>
<SCALE>0</SCALE>
</COL_LIST_ITEM>
</COL_LIST>
<PRIMARY_KEY_CONSTRAINT_LIST>
<PRIMARY_KEY_CONSTRAINT_LIST_ITEM>
<COL_LIST>
<COL_LIST_ITEM>
<NAME>EMPNO</NAME>
</COL_LIST_ITEM>
</COL_LIST>
</PRIMARY_KEY_CONSTRAINT_LIST_ITEM>
</PRIMARY_KEY_CONSTRAINT_LIST>
</RELATIONAL_TABLE>
</TABLE>
1 row selected.
23-19
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
19 --
20 DBMS_METADATA_DIFF.ADD_DOCUMENT(openc_handle,doc1);
21 DBMS_METADATA_DIFF.ADD_DOCUMENT(openc_handle,doc2);
22 --
23 -- Fetch the SXML difference document
24 --
25 diffdoc := DBMS_METADATA_DIFF.FETCH_CLOB(openc_handle);
26 DBMS_METADATA_DIFF.CLOSE(openc_handle);
27 RETURN diffdoc;
28 END;
29 /
Function created.
6. Use the function to fetch the SXML difference document for the two tables:
SQL> SELECT compare_table_sxml('TAB1','TAB2') FROM dual;
23-20
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
</TABLE>
1 row selected.
The SXML difference document shows the union of the two SXML documents,
with the XML attributes value1 and src identifying the differences. When an
element exists in only one document it is marked with src. Thus, <COL_LIST_ITEM
src="1"> means that this element is in the first document (TAB1) but not in the
second. When an element is present in both documents but with different values,
the element's value is the value in the second document and the value1 gives its
value in the first. For example, <LENGTH value1="10">20</LENGTH> means that the
length is 10 in TAB1 (the first document) and 20 in TAB2.
7. Compare the result using the DBMS_METADATA_DIFF browsing APIs:
SQL> SELECT dbms_metadata_diff.compare_sxml('TABLE','TAB1','TAB2') FROM dual;
8. Create a function using the DBMS_METADATA.CONVERT API to generate an ALTERXML
document. This is an XML document containing ALTER statements to make one
object like another. You can also use parse items to get information about the
individual ALTER statements. (This example uses the functions defined thus far.)
SQL> CREATE OR REPLACE FUNCTION get_table_alterxml(name1 IN VARCHAR2,
2 name2 IN VARCHAR2) RETURN CLOB IS
3 diffdoc CLOB;
4 openw_handle NUMBER;
5 transform_handle NUMBER;
6 alterxml CLOB;
7 BEGIN
8 --
9 -- Use the function just defined to get the difference document
10 --
11 diffdoc := compare_table_sxml(name1,name2);
12 --
13 -- Specify the object type in the OPENW call
14 --
15 openw_handle := DBMS_METADATA.OPENW('TABLE');
16 --
17 -- Use the ALTERXML transform to generate the ALTER_XML document
18 --
19 transform_handle := DBMS_METADATA.ADD_TRANSFORM(openw_handle,'ALTERXML');
20 --
21 -- Request parse items
22 --
23 DBMS_METADATA.SET_PARSE_ITEM(openw_handle,'CLAUSE_TYPE');
24 DBMS_METADATA.SET_PARSE_ITEM(openw_handle,'NAME');
25 DBMS_METADATA.SET_PARSE_ITEM(openw_handle,'COLUMN_ATTRIBUTE');
26 --
27 -- Create a temporary LOB
28 --
29 DBMS_LOB.CREATETEMPORARY(alterxml, TRUE );
30 --
31 -- Call CONVERT to do the transform
32 --
33 DBMS_METADATA.CONVERT(openw_handle,diffdoc,alterxml);
34 --
35 -- Close context and return the result
36 --
37 DBMS_METADATA.CLOSE(openw_handle);
38 RETURN alterxml;
23-21
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
39 END;
40 /
Function created.
9. Use the function to fetch the ALTER_XML document:
SQL> SELECT get_table_alterxml('TAB1','TAB2') FROM dual;
23-22
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
<VALUE>MODIFY_COLUMN</VALUE>
</PARSE_LIST_ITEM>
<PARSE_LIST_ITEM>
<ITEM>COLUMN_ATTRIBUTE</ITEM>
<VALUE> SIZE_INCREASE</VALUE>
</PARSE_LIST_ITEM>
</PARSE_LIST>
<SQL_LIST>
<SQL_LIST_ITEM>
<TEXT>ALTER TABLE "SCOTT"."TAB1" MODIFY
("ENAME" VARCHAR2(20))
</TEXT>
</SQL_LIST_ITEM>
</SQL_LIST>
</ALTER_LIST_ITEM>
<ALTER_LIST_ITEM>
<PARSE_LIST>
<PARSE_LIST_ITEM>
<ITEM>CLAUSE_TYPE</ITEM>
<VALUE>ADD_CONSTRAINT</VALUE>
</PARSE_LIST_ITEM>
</PARSE_LIST>
<SQL_LIST>
<SQL_LIST_ITEM>
<TEXT>ALTER TABLE "SCOTT"."TAB1" ADD PRIMARY KEY
("EMPNO") ENABLE
</TEXT>
</SQL_LIST_ITEM>
</SQL_LIST>
</ALTER_LIST_ITEM>
<ALTER_LIST_ITEM>
<PARSE_LIST>
<PARSE_LIST_ITEM>
<ITEM>NAME</ITEM>
<VALUE>TAB1</VALUE>
</PARSE_LIST_ITEM>
<PARSE_LIST_ITEM>
<ITEM>CLAUSE_TYPE</ITEM>
<VALUE>RENAME_TABLE</VALUE>
</PARSE_LIST_ITEM>
</PARSE_LIST>
<SQL_LIST>
<SQL_LIST_ITEM>
<TEXT>ALTER TABLE "SCOTT"."TAB1" RENAME TO "TAB2"</TEXT>
</SQL_LIST_ITEM>
</SQL_LIST>
</ALTER_LIST_ITEM>
</ALTER_LIST>
</ALTER_XML>
1 row selected.
23-23
Chapter 23
Using the DBMS_METADATA_DIFF API to Compare Object Metadata
parse this document and decide which of the SQL statements to execute, using
the information in the PARSE_LIST. (Note, for example, that in this case one of
the alters is a DROP_COLUMN, and you might choose not to execute that.)
12. Create one last function that uses the DBMS_METADATA.CONVERT API and the ALTER DDL
transform to convert the ALTER_XML document into SQL DDL:
SQL> CREATE OR REPLACE FUNCTION get_table_alterddl(name1 IN VARCHAR2,
2 name2 IN VARCHAR2) RETURN CLOB IS
3 alterxml CLOB;
4 openw_handle NUMBER;
5 transform_handle NUMBER;
6 alterddl CLOB;
7 BEGIN
8 --
9 -- Use the function just defined to get the ALTER_XML document
10 --
11 alterxml := get_table_alterxml(name1,name2);
12 --
13 -- Specify the object type in the OPENW call
14 --
15 openw_handle := DBMS_METADATA.OPENW('TABLE');
16 --
17 -- Use ALTERDDL transform to convert the ALTER_XML document to SQL DDL
18 --
19 transform_handle := DBMS_METADATA.ADD_TRANSFORM(openw_handle,'ALTERDDL');
20 --
21 -- Use the SQLTERMINATOR transform parameter to append a terminator
22 -- to each SQL statement
23 --
24 DBMS_METADATA.SET_TRANSFORM_PARAM(transform_handle,'SQLTERMINATOR',true);
25 --
26 -- Create a temporary lob
27 --
28 DBMS_LOB.CREATETEMPORARY(alterddl, TRUE );
29 --
30 -- Call CONVERT to do the transform
31 --
32 DBMS_METADATA.CONVERT(openw_handle,alterxml,alterddl);
33 --
34 -- Close context and return the result
35 --
36 DBMS_METADATA.CLOSE(openw_handle);
37 RETURN alterddl;
38 END;
39 /
Function created.
23-24
Chapter 23
Performance Tips for the Programmatic Interface of the DBMS_METADATA API
1 row selected.
1 row selected.
1. Fetch all of one type of object before fetching the next. For example, if you are
retrieving the definitions of all objects in your schema, first fetch all tables, then all
indexes, then all triggers, and so on. This will be much faster than nesting OPEN
contexts; that is, fetch one table then all of its indexes, grants, and triggers, then
the next table and all of its indexes, grants, and triggers, and so on. "Example
Usage of the DBMS_METADATA API" reflects this second, less efficient means,
but its purpose is to demonstrate most of the programmatic calls, which are best
shown by this method.
2. Use the SET_COUNT procedure to retrieve more than one object at a time. This
minimizes server round trips and eliminates many redundant function calls.
3. When writing a PL/SQL package that calls the DBMS_METADATA API, declare LOB
variables and objects that contain LOBs (such as SYS.KU$_DDLS) at package scope
rather than within individual functions. This eliminates the creation and deletion of
LOB duration structures upon function entrance and exit, which are very expensive
operations.
23-25
Chapter 23
Example Usage of the DBMS_METADATA API
it retrieves the DDL for the table's associated dependent objects; indexes, grants,
and triggers. All the DDL is written to a table named MDDEMO.DDL.
To execute the example, do the following:
1. Start SQL*Plus as user system. You will be prompted for a password.
sqlplus system
2. Install the demo, which is located in the file mddemo.sql in rdbms/demo:
SQL> @mddemo
For an explanation of what happens during this step, see "What Does the
DBMS_METADATA Example Do?".
3. Connect as user mddemo. You will be prompted for a password, which is also
mddemo.
23-26
Chapter 23
Example Usage of the DBMS_METADATA API
3 create sequence,
4 create trigger,
5 create view,
6 create synonym,
7 alter session,
8 TO mddemo;
3. Creates user mddemo_clerk, identified by clerk:
CREATE USER mddemo_clerk IDENTIFIED BY clerk;
4. Creates user mddemo_mgr, identified by mgr:
CREATE USER mddemo_mgr IDENTIFIED BY mgr;
5. Connect to SQL*Plus as mddemo (the password is also mddemo):
CONNECT mddemo
Enter password:
6. Creates some payroll-type tables:
SQL> CREATE TABLE payroll_emps
2 ( lastname VARCHAR2(60) NOT NULL,
3 firstname VARCHAR2(20) NOT NULL,
4 mi VARCHAR2(2),
5 suffix VARCHAR2(10),
6 dob DATE NOT NULL,
7 badge_no NUMBER(6) PRIMARY KEY,
8 exempt VARCHAR(1) NOT NULL,
9 salary NUMBER (9,2),
10 hourly_rate NUMBER (7,2) )
11 /
23-27
Chapter 23
Example Usage of the DBMS_METADATA API
Note that the security is kept fairly loose to keep the example simple.
SQL> CREATE OR REPLACE TRIGGER salary_trigger BEFORE INSERT OR UPDATE OF salary
ON payroll_emps
FOR EACH ROW WHEN (new.salary > 150000)
CALL check_sal(:new.salary)
/
Note:
To see the entire script for this example, including the contents of the
PAYROLL_DEMO package, see the file mddemo.sql located in your $ORACLE_HOME/
rdbms/demo directory.
The results are as follows, which reflect all the DDL executed by the script as
described in the previous section.
CREATE TABLE "MDDEMO"."PAYROLL_EMPS"
( "LASTNAME" VARCHAR2(60) NOT NULL ENABLE,
"FIRSTNAME" VARCHAR2(20) NOT NULL ENABLE,
"MI" VARCHAR2(2),
"SUFFIX" VARCHAR2(10),
"DOB" DATE NOT NULL ENABLE,
"BADGE_NO" NUMBER(6,0),
"EXEMPT" VARCHAR2(1) NOT NULL ENABLE,
"SALARY" NUMBER(9,2),
"HOURLY_RATE" NUMBER(7,2),
PRIMARY KEY ("BADGE_NO") ENABLE
23-28
Chapter 23
Example Usage of the DBMS_METADATA API
) ;
23-29
Chapter 23
Summary of DBMS_METADATA Procedures
Returns the text of the queries that are used by FETCH_xxx. You
DBMS_METADATA.GET_QUERY()
can use this as a debugging aid.
Enables output parsing by specifying an object attribute to be
DBMS_METADATA.SET_PARSE_ITEM()
parsed and returned. You can query the
DBMS_METADATA_PARSE_ITEMS to see all valid parse items.
Specifies a transform that FETCH_xxx applies to the XML
DBMS_METADATA.ADD_TRANSFORM()
representation of the retrieved objects. You can query the
DBMS_METADATA_TRANSFORMS view to see all valid Oracle-supplied
transforms.
Specifies parameters to the XSLT stylesheet identified by
DBMS_METADATA.SET_TRANSFORM_PARAM()
transform_handle. You can query the
DBMS_METADATA_TRANSFORM_PARAMS view to see all the valid
transform parameters for each transform.
Specifies parameters to the XSLT stylesheet identified by
DBMS_METADATA.SET_REMAP_PARAM()
transform_handle.
Returns metadata for objects meeting the criteria established by
DBMS_METADATA.FETCH_xxx()
OPEN, SET_FILTER, SET_COUNT, ADD_TRANSFORM, and so on.
Invalidates the handle returned by OPEN and cleans up the
DBMS_METADATA.CLOSE()
associated state.
The following table lists the procedures provided by the DBMS_METADATA browsing
interface and provides a brief description of each one. These functions return
metadata for one or more dependent or granted objects. These procedures do not
support heterogeneous object types.
23-30
Chapter 23
Summary of DBMS_METADATA Procedures
The following table provides a brief description of the DBMS_METADATA procedures and
functions used for XML submission.
23-31
Chapter 23
Summary of DBMS_METADATA_DIFF Procedures
23-32
24
Original Export
The original Export utility (exp) writes data from an Oracle database into an operating
system file in binary format. This file is stored outside the database, and it can be read
into another Oracle database using the original Import utility.
Note:
Original Export is desupported for general use as of Oracle Database 11g. The
only supported use of original Export in Oracle Database 11g is backward
migration of XMLType data to Oracle Database 10g release 2 (10.2) or earlier.
Therefore, Oracle recommends that you use the new Data Pump Export and
Import utilities, except in the following situations which require original Export
and Import:
• You want to import files that were created using the original Export utility
(exp).
• You want to export files that will be imported using the original Import utility
(imp). An example of this would be exporting data from Oracle Database
10g and then importing it into an earlier database release.
24-1
Chapter 24
What is the Export Utility?
The catexp.sql or catalog.sql script needs to be run only once on a database. The
script performs the following tasks to prepare the database for export and import
operations:
24-2
Chapter 24
Invoking Export
• Creates the necessary export and import views in the data dictionary
• Creates the EXP_FULL_DATABASE and IMP_FULL_DATABASE roles
• Assigns all necessary privileges to the EXP_FULL_DATABASE and IMP_FULL_DATABASE
roles
• Assigns EXP_FULL_DATABASE and IMP_FULL_DATABASE to the DBA role
• Records the version of catexp.sql that has been installed
The EXP_FULL_DATABASE and IMP_FULL_DATABASE roles are powerful. Database
administrators should use caution when granting these roles to users.
The result of the query does not include disk space used for data stored in LOB (large
object) or VARRAY columns or in partitioned tables.
See Also:
Oracle Database Reference for more information about dictionary views
24-3
Chapter 24
Invoking Export
• Interactive mode
Before you use one of these methods, be sure to read the descriptions of the available
parameters. See "Export Parameters ".
• Invoking Export as SYSDBA
• Command-Line Entries
• Parameter Files
• Interactive Mode
• Getting Online Help
or
exp PARAMETER=(value1,value2,...,valuen)
The number of parameters cannot exceed the maximum length of a command line on
the system.
24-4
Chapter 24
Invoking Export
GRANTS=y
INDEXES=y
CONSISTENT=y
Note:
The maximum size of the parameter file may be limited by the operating
system. The name of the parameter file is subject to the file-naming
conventions of the operating system.
You can add comments to the parameter file by preceding them with the pound (#)
sign. Export ignores all characters to the right of the pound (#) sign.
You can specify a parameter file at the same time that you are entering parameters on
the command line. In fact, you can specify the same parameter in both places. The
position of the PARFILE parameter and other parameters on the command line
determines which parameters take precedence. For example, assume the parameter
file params.dat contains the parameter INDEXES=y and Export is started with the
following line:
exp PARFILE=params.dat INDEXES=n
24-5
Chapter 24
Export Modes
• If you specify a null table list to the prompt "Table to be exported," then the Export
utility exits.
Note:
The original Export utility does not export any table that was created with
deferred segment creation and has not had a segment created for it. The most
common way for a segment to be created is to store a row into the table,
though other operations such as ALTER TABLE ALLOCATE EXTENTS will also create
a segment. If a segment does exist for the table and the table is exported, then
the SEGMENT CREATION DEFERRED clause is not included in the CREATE TABLE
statement that is executed by the original Import utility.
You can use conventional path Export or direct path Export to export in any mode
except tablespace mode.The differences between conventional path Export and direct
path Export are described in "Conventional Path Export Versus Direct Path Export".
24-6
Chapter 24
Export Modes
24-7
Chapter 24
Export Modes
1 Nonprivileged users can export and import only indexes they own on tables they own. They cannot export
indexes they own that are on tables owned by other users, nor can they export indexes owned by other
users on their own tables. Privileged users can export and import indexes on the specified users' tables,
even if the indexes are owned by other users. Indexes owned by the specified user on other users' tables
are not included, unless those other users are included in the list of users to export.
2 Nonprivileged and privileged users can export and import all triggers owned by the user, even if they are
on tables owned by other users.
3 A full export does not export triggers owned by schema SYS. You must manually re-create SYS triggers
either before or after the full import. Oracle recommends that you re-create them after the import in case
they define actions that would impede progress of the import.
24-8
Chapter 24
Export Parameters
24-9
Chapter 24
Export Parameters
• INDEXES
• LOG
• OBJECT_CONSISTENT
• OWNER
• PARFILE
• QUERY
• RECORDLENGTH
• RESUMABLE
• RESUMABLE_NAME
• RESUMABLE_TIMEOUT
• ROWS
• STATISTICS
• TABLES
• TABLESPACES
• TRANSPORT_TABLESPACE
• TRIGGERS
• TTS_FULL_CHECK
• USERID (username/password)
• VOLSIZE
24.5.1 BUFFER
Default: operating system-dependent. See your Oracle operating system-specific
documentation to determine the default value for this parameter.
Specifies the size, in bytes, of the buffer used to fetch rows. As a result, this parameter
determines the maximum number of rows in an array fetched by Export. Use the
following formula to calculate the buffer size:
buffer_size = rows_in_array * maximum_row_size
If you specify zero, then the Export utility fetches only one row at a time.
Tables with columns of type LOBs, LONG, BFILE, REF, ROWID, LOGICAL ROWID, or DATE are
fetched one row at a time.
Note:
The BUFFER parameter applies only to conventional path Export. It has no effect
on a direct path Export. For direct path Exports, use the RECORDLENGTH
parameter to specify the size of the buffer that Export uses for writing to the
export file.
24-10
Chapter 24
Export Parameters
The maximum size of the name column is 30, plus 2 bytes for the indicator. The
maximum size of the weight column is 22 (the size of the internal representation for
Oracle numbers), plus 2 bytes for the indicator.
Therefore, the maximum row size is 56 (30+2+22+2).
To perform array operations for 100 rows, a buffer size of 5600 should be specified.
24.5.2 COMPRESS
Default: y
Specifies how Export and Import manage the initial extent for table data.
The default, COMPRESS=y, causes Export to flag table data for consolidation into one
initial extent upon import. If extent sizes are large (for example, because of the
PCTINCREASE parameter), then the allocated space will be larger than the space required
to hold the data.
If you specify COMPRESS=n, then Export uses the current storage parameters, including
the values of initial extent size and next extent size. The values of the parameters may
be the values specified in the CREATE TABLE or ALTER TABLE statements or the values
modified by the database system. For example, the NEXT extent size value may be
modified if the table grows and if the PCTINCREASE parameter is nonzero.
Note:
Although the actual consolidation is performed upon import, you can specify the
COMPRESS parameter only when you export, not when you import. The Export
utility, not the Import utility, generates the data definitions, including the storage
parameter definitions. Therefore, if you specify COMPRESS=y when you export,
then you can import the data in consolidated form only.
Note:
Neither LOB data nor subpartition data is compressed. Rather, values of initial
extent size and next extent size at the time of export are used.
24-11
Chapter 24
Export Parameters
24.5.3 CONSISTENT
Default: n
Specifies whether Export uses the SET TRANSACTION READ ONLY statement to ensure that
the data seen by Export is consistent to a single point in time and does not change
during the execution of the exp command. You should specify CONSISTENT=y when you
anticipate that other applications will be updating the target data after an export has
started.
If you use CONSISTENT=n, then each table is usually exported in a single transaction.
However, if a table contains nested tables, then the outer table and each inner table
are exported as separate transactions. If a table is partitioned, then each partition is
exported as a separate transaction.
Therefore, if nested tables and partitioned tables are being updated by other
applications, then the data that is exported could be inconsistent. To minimize this
possibility, export those tables at a time when updates are not being done.
Table 24-2 shows a sequence of events by two users: user1 exports partitions in a
table and user2 updates data in that table.
If the export uses CONSISTENT=y, then none of the updates by user2 are written to the
export file.
If the export uses CONSISTENT=n, then the updates to TAB:P1 are not written to the
export file. However, the updates to TAB:P2 are written to the export file, because the
update transaction is committed before the export of TAB:P2 begins. As a result, the
user2 transaction is only partially recorded in the export file, making it inconsistent.
If you use CONSISTENT=y and the volume of updates is large, then the rollback segment
usage will be large. In addition, the export of each table will be slower, because the
rollback segment must be scanned for uncommitted transactions.
Keep in mind the following points about using CONSISTENT=y:
• CONSISTENT=y is unsupported for exports that are performed when you are
connected as user SYS or you are using AS SYSDBA, or both.
• Export of certain metadata may require the use of the SYS schema within recursive
SQL. In such situations, the use of CONSISTENT=y will be ignored. Oracle
recommends that you avoid making metadata changes during an export process
in which CONSISTENT=y is selected.
• To minimize the time and space required for such exports, you should export
tables that need to remain consistent separately from those that do not. For
24-12
Chapter 24
Export Parameters
example, export the emp and dept tables together in a consistent export, and then
export the remainder of the database in a second pass.
• A "snapshot too old" error occurs when rollback space is used up, and space
taken up by committed transactions is reused for new transactions. Reusing space
in the rollback segment allows database integrity to be preserved with minimum
space requirements, but it imposes a limit on the amount of time that a read-
consistent image can be preserved.
If a committed transaction has been overwritten and the information is needed for
a read-consistent view of the database, then a "snapshot too old" error results.
To avoid this error, you should minimize the time taken by a read-consistent
export. (Do this by restricting the number of objects exported and, if possible, by
reducing the database transaction rate.) Also, make the rollback segment as large
as possible.
Note:
Rollback segments will be deprecated in a future Oracle database release.
Oracle recommends that you use automatic undo management instead.
See Also:
"OBJECT_CONSISTENT"
24.5.4 CONSTRAINTS
Default: y
24.5.5 DIRECT
Default: n
24.5.6 FEEDBACK
Default: 0 (zero)
Specifies that Export should display a progress meter in the form of a period for n
number of rows exported. For example, if you specify FEEDBACK=10, then Export
24-13
Chapter 24
Export Parameters
displays a period each time 10 rows are exported. The FEEDBACK value applies to all
tables being exported; it cannot be set individually for each table.
24.5.7 FILE
Default: expdat.dmp
Specifies the names of the export dump files. The default extension is .dmp, but you
can specify any extension. Because Export supports multiple export files, you can
specify multiple file names to be used. For example:
exp scott FILE = dat1.dmp, dat2.dmp, dat3.dmp FILESIZE=2048
When Export reaches the value you have specified for the maximum FILESIZE, Export
stops writing to the current file, opens another export file with the next name specified
by the FILE parameter, and continues until complete or the maximum value of FILESIZE
is again reached. If you do not specify sufficient export file names to complete the
export, then Export prompts you to provide additional file names.
24.5.8 FILESIZE
Default: Data is written to one file until the maximum size, as specified in Table 24-3, is
reached.
Export supports writing to multiple export files, and Import can read from multiple
export files. If you specify a value (byte limit) for the FILESIZE parameter, then Export
will write only the number of bytes you specify to each dump file.
When the amount of data Export must write exceeds the maximum value you specified
for FILESIZE, it will get the name of the next export file from the FILE parameter (see
"FILE" for more information) or, if it has used all the names specified in the FILE
parameter, then it will prompt you to provide a new export file name. If you do not
specify a value for FILESIZE (note that a value of 0 is equivalent to not specifying
FILESIZE), then Export will write to only one file, regardless of the number of files
specified in the FILE parameter.
Note:
If the space requirements of your export file exceed the available disk space,
then Export will terminate, and you will have to repeat the Export after making
sufficient disk space available.
The FILESIZE parameter has a maximum value equal to the maximum value that can
be stored in 64 bits.
Table 24-3 shows that the maximum size for dump files depends on the operating
system you are using and on the release of the Oracle database that you are using.
24-14
Chapter 24
Export Parameters
The maximum value that can be stored in a file is dependent on your operating
system. You should verify this maximum value in your Oracle operating system-
specific documentation before specifying FILESIZE. You should also ensure that the file
size you specify for Export is supported on the system on which Import will run.
The FILESIZE value can also be specified as a number followed by KB (number of
kilobytes). For example, FILESIZE=2KB is the same as FILESIZE=2048. Similarly, MB
specifies megabytes (1024 * 1024) and GB specifies gigabytes (1024**3). B remains
the shorthand for bytes; the number is not multiplied to obtain the final file size
(FILESIZE=2048B is the same as FILESIZE=2048).
24.5.9 FLASHBACK_SCN
Default: none
Specifies the system change number (SCN) that Export will use to enable flashback.
The export operation is performed with data consistent as of this specified SCN.
See Also:
• Oracle Database Backup and Recovery User's Guide for more information
about performing flashback recovery
The following is an example of specifying an SCN. When the export is performed, the
data will be consistent as of SCN 3482971.
> exp FILE=exp.dmp FLASHBACK_SCN=3482971
24.5.10 FLASHBACK_TIME
Default: none
Enables you to specify a timestamp. Export finds the SCN that most closely matches
the specified timestamp. This SCN is used to enable flashback. The export operation
is performed with data consistent as of this SCN.
You can specify the time in any format that the DBMS_FLASHBACK.ENABLE_AT_TIME
procedure accepts. This means that you can specify it in either of the following ways:
> exp FILE=exp.dmp FLASHBACK_TIME="TIMESTAMP '2006-05-01 11:00:00'"
24-15
Chapter 24
Export Parameters
Also, the old format, as shown in the following example, will continue to be accepted to
ensure backward compatibility:
> exp FILE=exp.dmp FLASHBACK_TIME="'2006-05-01 11:00:00'"
See Also:
• Oracle Database Backup and Recovery User's Guide for more information
about performing flashback recovery
• Oracle Database PL/SQL Packages and Types Reference for more
information about the DBMS_FLASHBACK PL/SQL package
24.5.11 FULL
Default: n
Indicates that the export is a full database mode export (that is, it exports the entire
database). Specify FULL=y to export in full database mode. You need to have the
EXP_FULL_DATABASE role to export in this mode.
24-16
Chapter 24
Export Parameters
• If you are creating a completely new database from an export, then remember to
create an extra rollback segment in SYSTEM and to make it available in your
initialization parameter file (init.ora)before proceeding with the import.
• When you perform the import, ensure you are pointing at the correct instance. This
is very important because on some UNIX systems, just the act of entering a
subshell can change the database against which an import operation was
performed.
• Do not perform a full import on a system that has more than one database unless
you are certain that all tablespaces have already been created. A full import
creates any undefined tablespaces using the same data file names as the
exported database. This can result in problems in the following situations:
– If the data files belong to any other database, then they will become corrupted.
This is especially true if the exported database is on the same system,
because its data files will be reused by the database into which you are
importing.
– If the data files have names that conflict with existing operating system files.
24.5.12 GRANTS
Default: y
Specifies whether the Export utility exports object grants. The object grants that are
exported depend on whether you use full database mode or user mode. In full
database mode, all grants on a table are exported. In user mode, only those granted
by the owner of the table are exported. System privilege grants are always exported.
24.5.13 HELP
Default: none
Displays a description of the Export parameters. Enter exp help=y on the command line
to display the help content.
24.5.14 INDEXES
Default: y
24.5.15 LOG
Default: none
Specifies a file name (for example, export.log) to receive informational and error
messages.
If you specify this parameter, then messages are logged in the log file and displayed to
the terminal display.
24.5.16 OBJECT_CONSISTENT
Default: n
24-17
Chapter 24
Export Parameters
Specifies whether the Export utility uses the SET TRANSACTION READ ONLY statement to
ensure that the data exported is consistent to a single point in time and does not
change during the export. If OBJECT_CONSISTENT is set to y, then each object is exported
in its own read-only transaction, even if it is partitioned. In contrast, if you use the
CONSISTENT parameter, then there is only one read-only transaction.
See Also:
"CONSISTENT"
24.5.17 OWNER
Default: none
Indicates that the export is a user-mode export and lists the users whose objects will
be exported. If the user initiating the export is the database administrator (DBA), then
multiple users can be listed.
User-mode exports can be used to back up one or more database users. For example,
a DBA may want to back up the tables of deleted users for a period of time. User
mode is also appropriate for users who want to back up their own data or who want to
move objects from one owner to another.
24.5.18 PARFILE
Default: none
Specifies a file name for a file that contains a list of Export parameters. For more
information about using a parameter file, see "Invoking Export".
24.5.19 QUERY
Default: none
This parameter enables you to select a subset of rows from a set of tables when doing
a table mode export. The value of the query parameter is a string that contains a WHERE
clause for a SQL SELECT statement that will be applied to all tables (or table partitions)
listed in the TABLES parameter.
For example, if user scott wants to export only those employees whose job title is
SALESMAN and whose salary is less than 1600, then he could do the following (this
example is UNIX-based):
exp scott TABLES=emp QUERY=\"WHERE job=\'SALESMAN\' and sal \<1600\"
24-18
Chapter 24
Export Parameters
Note:
Because the value of the QUERY parameter contains blanks, most operating
systems require that the entire string WHERE job=\'SALESMAN\' and sal\<1600 be
placed in double quotation marks or marked as a literal by some method.
Operating system reserved characters also need to be preceded by an escape
character. See your Oracle operating system-specific documentation for
information about special and reserved characters on your system.
When executing this query, Export builds a SQL SELECT statement similar to the
following:
SELECT * FROM emp WHERE job='SALESMAN' and sal <1600;
The values specified for the QUERY parameter are applied to all tables (or table
partitions) listed in the TABLES parameter. For example, the following statement will
unload rows in both emp and bonus that match the query:
exp scott TABLES=emp,bonus QUERY=\"WHERE job=\'SALESMAN\' and sal\<1600\"
Again, the SQL statements that Export executes are similar to the following:
SELECT * FROM emp WHERE job='SALESMAN' and sal <1600;
If a table is missing the columns specified in the QUERY clause, then an error message
will be produced, and no rows will be exported for the offending table.
• Restrictions When Using the QUERY Parameter
24.5.20 RECORDLENGTH
Default: operating system-dependent
Specifies the length, in bytes, of the file record. The RECORDLENGTH parameter is
necessary when you must transfer the export file to another operating system that
uses a different default value.
If you do not define this parameter, then it defaults to your platform-dependent value
for buffer size.
24-19
Chapter 24
Export Parameters
You can set RECORDLENGTH to any value equal to or greater than your system's buffer
size. (The highest value is 64 KB.) Changing the RECORDLENGTH parameter affects only
the size of data that accumulates before writing to the disk. It does not affect the
operating system file block size.
Note:
You can use this parameter to specify the size of the Export I/O buffer.
24.5.21 RESUMABLE
Default: n
The RESUMABLE parameter is used to enable and disable resumable space allocation.
Because this parameter is disabled by default, you must set RESUMABLE=y to use its
associated parameters, RESUMABLE_NAME and RESUMABLE_TIMEOUT.
See Also:
24.5.22 RESUMABLE_NAME
Default: 'User USERNAME (USERID), Session SESSIONID, Instance INSTANCEID'
The value for this parameter identifies the statement that is resumable. This value is a
user-defined text string that is inserted in either the USER_RESUMABLE or DBA_RESUMABLE
view to help you identify a specific resumable statement that has been suspended.
This parameter is ignored unless the RESUMABLE parameter is set to y to enable
resumable space allocation.
24.5.23 RESUMABLE_TIMEOUT
Default: 7200 seconds (2 hours)
The value of the parameter specifies the time period during which an error must be
fixed. If the error is not fixed within the timeout period, then execution of the statement
is terminated.
This parameter is ignored unless the RESUMABLE parameter is set to y to enable
resumable space allocation.
24.5.24 ROWS
Default: y
24-20
Chapter 24
Export Parameters
24.5.25 STATISTICS
Default: ESTIMATE
Specifies the type of database optimizer statistics to generate when the exported data
is imported. Options are ESTIMATE, COMPUTE, and NONE.
In some cases, Export will place the precalculated statistics in the export file, and also
the ANALYZE statements to regenerate the statistics.
However, the precalculated optimizer statistics will not be used at export time if a table
has columns with system-generated names.
The precalculated optimizer statistics are flagged as questionable at export time if:
• There are row errors while exporting
• The client character set or NCHAR character set does not match the server character
set or NCHAR character set
• A QUERY clause is specified
• Only certain partitions or subpartitions are exported
Note:
Specifying ROWS=n does not preclude saving the precalculated statistics in
the export file. This enables you to tune plan generation for queries in a
nonproduction database using statistics from a production database.
24.5.26 TABLES
Default: none
Specifies that the export is a table-mode export and lists the table names and partition
and subpartition names to export. You can specify the following when you specify the
name of the table:
• schemaname specifies the name of the user's schema from which to export the table
or partition. If a schema name is not specified, then the exporter's schema is used
as the default. System schema names such as ORDSYS, MDSYS, CTXSYS, LBACSYS, and
ORDPLUGINS are reserved by Export.
24-21
Chapter 24
Export Parameters
If you use tablename:partition_name, then the specified table must be partitioned, and
partition_name must be the name of one of its partitions or subpartitions. If the
specified table is not partitioned, then the partition_name is ignored and the entire
table is exported.
See "Example Export Session Using Partition-Level Export" for several examples of
partition-level Exports.
• Table Name Restrictions
However, given the following line, the Export utility exports all three tables,
because emp# is enclosed in quotation marks:
TABLES=("emp#", dept, mydata)
24-22
Chapter 24
Export Parameters
Note:
Some operating systems require single quotation marks rather than double
quotation marks, or the reverse. Different operating systems also have
other restrictions on table naming.
24.5.27 TABLESPACES
Default: none
The TABLESPACES parameter specifies that all tables in the specified tablespace be
exported to the Export dump file. This includes all tables contained in the list of
tablespaces and all tables that have a partition located in the list of tablespaces.
Indexes are exported with their tables, regardless of where the index is stored.
You must have the EXP_FULL_DATABASE role to use TABLESPACES to export all tables in the
tablespace.
When TABLESPACES is used in conjunction with TRANSPORT_TABLESPACE=y, you can specify
a limited list of tablespaces to be exported from the database to the export file.
24.5.28 TRANSPORT_TABLESPACE
Default: n
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
See Also:
• "Transportable Tablespaces"
• Oracle Database Administrator's Guide for more information about
transportable tablespaces
24.5.29 TRIGGERS
Default: y
24-23
Chapter 24
Example Export Sessions
24.5.30 TTS_FULL_CHECK
Default: n
When TTS_FULL_CHECK is set to y, Export verifies that a recovery set (set of tablespaces
to be recovered) has no dependencies (specifically, IN pointers) on objects outside the
recovery set, and the reverse.
See Also:
• The user's guide for your Oracle Net protocol for information about
specifying a connect string for Oracle Net
24.5.32 VOLSIZE
Default: none
Specifies the maximum number of bytes in an export file on each volume of tape.
The VOLSIZE parameter has a maximum value equal to the maximum value that can be
stored in 64 bits on your platform.
The VOLSIZE value can be specified as a number followed by KB (number of kilobytes).
For example, VOLSIZE=2KB is the same as VOLSIZE=2048. Similarly, MB specifies
megabytes (1024 * 1024) and GB specifies gigabytes (1024**3). B remains the
shorthand for bytes; the number is not multiplied to get the final file size (VOLSIZE=2048B
is the same as VOLSIZE=2048).
24-24
Chapter 24
Example Export Sessions
Command-Line Method
> exp FULL=y FILE=dba.dmp GRANTS=y ROWS=y
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Status messages are written out as the
entire database is exported. A final completion message is returned when the export
completes successfully, without warnings.
Command-Line Method
> exp scott FILE=scott.dmp OWNER=scott GRANTS=y ROWS=y COMPRESS=y
24-25
Chapter 24
Example Export Sessions
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
. about to export SCOTT's tables via Conventional Path ...
. . exporting table BONUS 0 rows exported
. . exporting table DEPT 4 rows exported
. . exporting table EMP 14 rows exported
. . exporting table SALGRADE 5 rows exported
.
.
.
Export terminated successfully without warnings.
If schemaname is not specified, then Export defaults to the exporter's schema name. In
the following example, Export defaults to the SYSTEM schema for table a and table c:
> exp TABLES=(a, scott.b, c, mary.d)
A user with the EXP_FULL_DATABASE role can also export dependent objects that are
owned by other users. A nonprivileged user can export only dependent objects for the
specified tables that the user owns.
Exports in table mode do not include cluster definitions. As a result, the data is
exported as unclustered tables. Thus, you can use table mode to uncluster tables.
• Example 1: DBA Exporting Tables for Two Users
• Example 2: User Exports Tables That He Owns
• Example 3: Using Pattern Matching to Export Various Tables
24-26
Chapter 24
Example Export Sessions
Command-Line Method
> exp FILE=expdat.dmp TABLES=(scott.emp,blake.dept) GRANTS=y INDEXES=y
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
About to export specified tables via Conventional Path ...
Current user changed to SCOTT
. . exporting table EMP 14 rows exported
Current user changed to BLAKE
. . exporting table DEPT 8 rows exported
Export terminated successfully without warnings.
Command-Line Method
> exp blake FILE=blake.dmp TABLES=(dept, manager) ROWS=y COMPRESS=y
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
24-27
Chapter 24
Example Export Sessions
Command-Line Method
> exp FILE=misc.dmp TABLES=(scott.%P%,blake.%,scott.%S%)
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
About to export specified tables via Conventional Path ...
Current user changed to SCOTT
. . exporting table DEPT 4 rows exported
. . exporting table EMP 14 rows exported
Current user changed to BLAKE
. . exporting table DEPT 8 rows exported
. . exporting table MANAGER 4 rows exported
Current user changed to SCOTT
. . exporting table BONUS 0 rows exported
. . exporting table SALGRADE 5 rows exported
Export terminated successfully without warnings.
24-28
Chapter 24
Example Export Sessions
Command-Line Method
> exp scott TABLES=emp rows=y
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
About to export specified tables via Conventional Path ...
. . exporting table EMP
. . exporting partition M 8 rows exported
. . exporting partition Z 6 rows exported
Export terminated successfully without warnings.
Command-Line Method
> exp scott TABLES=emp:m rows=y
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
About to export specified tables via Conventional Path ...
. . exporting table EMP
. . exporting partition M 8 rows exported
Export terminated successfully without warnings.
24-29
Chapter 24
Warning, Error, and Completion Messages
partition m, then all its subpartitions (sp1 and sp2) will be exported. If you export the
table and specify a subpartition (sp4), then only the specified subpartition is exported.
Command-Line Method
> exp scott TABLES=(emp:m, emp:sp4) ROWS=y
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
About to export specified tables via Conventional Path ...
. . exporting table EMP
. . exporting composite partition M
. . exporting subpartition SP1 1 rows exported
. . exporting subpartition SP2 3 rows exported
. . exporting composite partition Z
. . exporting subpartition SP4 1 rows exported
Export terminated successfully without warnings.
24-30
Chapter 24
Exit Codes for Inspection and Display
next table, and continues processing. These recoverable errors are known as
warnings.
Export also issues warnings when invalid objects are encountered.
For example, if a nonexistent table is specified as part of a table-mode Export, then
the Export utility exports all other tables. Then it issues a warning and terminates
successfully.
If one or more recoverable errors occurs but the job continues to completion, then a
message similar to the following is displayed:
Export terminated successfully with warnings
If a nonrecoverable error occurs, then the job terminates immediately and displays a
message stating so, for example:
Export terminated unsuccessfully
24-31
Chapter 24
Conventional Path Export Versus Direct Path Export
24-32
Chapter 24
Network Considerations
See Also:
24-33
Chapter 24
Character Set and Globalization Support Considerations
See Also:
24-34
Chapter 24
Character Set and Globalization Support Considerations
This partitioning scheme makes sense because z comes after Z in ASCII character
sets.
When this table is imported into a database based upon an EBCDIC character set, all
of the rows in the part_mid partition will migrate to the part_low partition because z
comes before Z in EBCDIC character sets. To obtain the desired results, the owner of
partlist must repartition the table following the import.
See Also:
Oracle Database Globalization Support Guide for more information about
character sets
24-35
Chapter 24
Using Instance Affinity with Export and Import
To minimize data loss due to character set conversions, ensure that the export
database, the export user session, the import user session, and the import database
all use the same character set.
Note:
When the character set width differs between the Export server and the Import
server, truncation of data can occur if conversion causes expansion of data. If
truncation occurs, then Import displays a warning message.
See Also:
24-36
Chapter 24
Considerations When Exporting Database Objects
All data in a LOB column does not need to be held in memory at the same time. LOB
data is loaded and unloaded in sections.
Note:
Oracle also recommends that you convert existing LONG columns to LOB
columns. LOB columns are subject to far fewer restrictions than LONG columns.
Further, LOB functionality is enhanced in every release, whereas LONG
functionality has been static for several releases.
24-37
Chapter 24
Considerations When Exporting Database Objects
24-38
Chapter 24
Considerations When Exporting Database Objects
It is important to perform a full database mode export regularly to preserve all object
type definitions. Alternatively, if object type definitions from different schemas are
used, then the DBA should perform a user mode export of the appropriate set of users.
For example, if table1 belonging to user scott contains a column on blake's type
type1, then the DBA should perform a user mode export of both blake and scott to
preserve the type definitions needed by the table.
See Also:
Oracle Database Advanced Queuing User's Guide
CONNECT blake/paper;
CREATE TRIGGER t_emp BEFORE INSERT ON emp BEGIN NULL; END;
CREATE VIEW emp AS SELECT * FROM dual;
If the database in the preceding example were exported, then the reference to emp in
the trigger would refer to blake's view rather than to scott's table. This would cause an
error when Import tried to reestablish the t_emp trigger.
24-39
Chapter 24
Transportable Tablespaces
If Java is enabled, then ensure that both the DBMS_JAVA synonym and DBMS_JAVA
package are created and valid before rerunning the export.
If Java is not enabled, then remove Java-related objects before rerunning the export.
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
To move or copy a set of tablespaces, you must make the tablespaces read-only, copy
the data files of these tablespaces, and use Export and Import to move the database
information (metadata) stored in the data dictionary. Both the data files and the
metadata export file must be copied to the target database. The transport of these files
can be done using any facility for copying flat binary files, such as the operating
system copying facility, binary-mode FTP, or publishing on CD-ROMs.
After copying the data files and exporting the metadata, you can optionally put the
tablespaces in read/write mode.
Export and Import provide the following parameters to enable movement of
transportable tablespace metadata.
• TABLESPACES
• TRANSPORT_TABLESPACE
24-40
Chapter 24
Exporting From a Read-Only Database
See Also:
24-41
Chapter 24
Using Different Releases of Export and Import
All exports can be done in parallel. When the import of full.dmp completes, all
remaining imports can also be done in parallel.
24-42
Chapter 24
Using Different Releases of Export and Import
• The Import utility cannot read export dump files created by the Export utility of a
later maintenance release. For example, a release 9.2 export dump file cannot be
imported by a release 9.0.1 Import utility.
• Whenever a lower version of the Export utility runs with a later release of the
Oracle database, categories of database objects that did not exist in the earlier
release are excluded from the export.
• Export files generated by Oracle9i Export, either direct path or conventional path,
are incompatible with earlier releases of Import and can be imported only with
Oracle9i Import. When backward compatibility is an issue, use the earlier release
or version of the Export utility against the Oracle9i database.
Table 24-5 covers moving data only between the original Export and Import utilities.
For Oracle Database 10g release 1 (10.1) or later, Oracle recommends the Data
Pump Export and Import utilities in most cases because these utilities provide greatly
enhanced performance compared to the original Export and Import utilities.
See Also:
Oracle Database Upgrade Guide for more information about exporting and
importing data between different releases, including releases later than 10.1
24-43
25
Original Import
The original Import utility (imp) imports dump files that were created using the original
Export utility.
See the following topics:
• What Is the Import Utility?
• Before Using Import
• Importing into Existing Tables
• Effect of Schema and Database Triggers on Import Operations
• Invoking Import
• Import Modes
• Import Parameters
• Example Import Sessions
• Exit Codes for Inspection and Display
• Error Handling During an Import
• Table-Level and Partition-Level Import
• Controlling Index Creation and Maintenance
• Network Considerations
• Character Set and Globalization Support Considerations
• Using Instance Affinity
• Considerations When Importing Database Objects
• Support for Fine-Grained Access Control
• Snapshots and Snapshot Logs
• Transportable Tablespaces
• Storage Parameters
• Read-Only Tablespaces
• Dropping a Tablespace
• Reorganizing Tablespaces
• Importing Statistics
• Using Export and Import to Partition a Database Migration
• Tuning Considerations for Import Operations
• Using Different Releases of Export and Import
25-1
Chapter 25
What Is the Import Utility?
25-2
Chapter 25
Before Using Import
The catexp.sql or catalog.sql script needs to be run only once on a database. The
script performs the following tasks to prepare the database for export and import
operations:
• Creates the necessary import views in the data dictionary
• Creates the EXP_FULL_DATABASE and IMP_FULL_DATABASE roles
• Assigns all necessary privileges to the EXP_FULL_DATABASE and IMP_FULL_DATABASE
roles
• Assigns EXP_FULL_DATABASE and IMP_FULL_DATABASE to the DBA role
• Records the version of catexp.sql that has been installed
You can perform an import operation even if you did not create the export file.
However, keep in mind that if the export file was created by a user with the
EXP_FULL_DATABASE role, then you must have the IMP_FULL_DATABASE role to import it.
Both of these roles are typically assigned to database administrators (DBAs).
• Importing Objects Into Your Own Schema
• Importing Grants
• Importing Objects Into Other Schemas
• Importing System Objects
Table 25-1 Privileges Required to Import Objects into Your Own Schema
25-3
Chapter 25
Before Using Import
Table 25-1 (Cont.) Privileges Required to Import Objects into Your Own
Schema
Grant Conditions
Object privileges The object must exist in the user's schema, or
the user must have the object privileges with the WITH GRANT
OPTION or,
the user must have the IMP_FULL_DATABASE role enabled.
System privileges User must have the SYSTEM privilege and also the WITH ADMIN
OPTION.
25-4
Chapter 25
Importing into Existing Tables
• Profiles
• Public database links
• Public synonyms
• Roles
• Rollback segment definitions
• Resource costs
• Foreign function libraries
• Context objects
• System procedural objects
• System audit options
• System privileges
• Tablespace definitions
• Tablespace quotas
• User definitions
• Directory aliases
• System event triggers
25-5
Chapter 25
Importing into Existing Tables
• Change the data type of a column to an incompatible data type (LONG to NUMBER, for
example)
• Change the definition of object types used in a table
• Change DEFAULT column values
Note:
When tables are manually created before data is imported, the CREATE TABLE
statement in the export dump file will fail because the table already exists.
To avoid this failure and continue loading data into the table, set the Import
parameter IGNORE=y. Otherwise, no data will be loaded into the table
because of the table creation error.
25-6
Chapter 25
Effect of Schema and Database Triggers on Import Operations
Note:
A full export does not export triggers owned by schema SYS. You must
manually re-create SYS triggers either before or after the full import. Oracle
recommends that you re-create them after the import in case they define
actions that would impede progress of the import.
25-7
Chapter 25
Invoking Import
or
imp PARAMETER=(value1,value2,...,valuen)
The number of parameters cannot exceed the maximum length of a command line on
the system.
Note:
The maximum size of the parameter file may be limited by the operating
system. The name of the parameter file is subject to the file-naming
conventions of the operating system.
You can add comments to the parameter file by preceding them with the pound (#)
sign. Import ignores all characters to the right of the pound (#) sign.
You can specify a parameter file at the same time that you are entering parameters on
the command line. In fact, you can specify the same parameter in both places. The
position of the PARFILE parameter and other parameters on the command line
determines which parameters take precedence. For example, assume the parameter
file params.dat contains the parameter INDEXES=y and Import is started with the
following line:
imp PARFILE=params.dat INDEXES=n
25-8
Chapter 25
Import Modes
See Also:
• "Import Parameters"
• "Network Considerations" for information about how to specify an export
from a remote database
Commonly used parameters are then displayed. You can accept the default value, if
one is provided, or enter a different value. The command-line interactive method does
not provide prompts for all functionality and is provided only for backward compatibility.
25-9
Chapter 25
Import Modes
Note:
When you use table mode to import tables that have columns of type
ANYDATA, you may receive the following error:
A user with the IMP_FULL_DATABASE role must specify one of these modes. Otherwise, an
error results. If a user without the IMP_FULL_DATABASE role fails to specify one of these
modes, then a user-level Import is performed.
Note:
As of Oracle Database 12c release 2 (12.2) the import utility (imp), for security
reasons, will no longer import objects as user SYS. If a dump file contains
objects that need to be re-created as user SYS, then the imp utility tries to re-
create them as user SYSTEM instead. If the object cannot be re-created by user
SYSTEM, then you must manually re-create the object yourself after the import is
completed.
If the import job is run by a user with the DBA role, and not all objects can be re-
created by user SYSTEM, then the following warning message is written to the log
file:
IMP-00403:
Warning: This import generated a separate SQL file "logfilename_sys" which
contains DDL that failed due to a privilege issue.
The SQL file that is generated contains the failed DDL of objects that could not
be re-created by user SYSTEM. To re-create those objects, you must manually
execute the failed DDL after the import finishes.
The SQL file is automatically named by appending '_sys.sql' to the file name
specified for the LOG parameter. For example, if the log file name was
JulyImport, then the SQL file name would be JulyImport_sys.sql.
If no log file was specified, then the default name of the SQL file is
import_sys.sql.
Note: Not all import jobs generate a SQL file; only those jobs run as user DBA.
The following table lists the objects that are imported in each mode.
25-10
Chapter 25
Import Modes
25-11
Chapter 25
Import Modes
1 Nonprivileged users can export and import only indexes they own on tables they own. They cannot export
indexes they own that are on tables owned by other users, nor can they export indexes owned by other
users on their own tables. Privileged users can export and import indexes on the specified users' tables,
even if the indexes are owned by other users. Indexes owned by the specified user on other users' tables
are not included, unless those other users are included in the list of users to export.
2 Nonprivileged and privileged users can export and import all triggers owned by the user, even if they are
on tables owned by other users.
25-12
Chapter 25
Import Parameters
3 A full export does not export triggers owned by schema SYS. You must manually re-create SYS triggers
either before or after the full import. Oracle recommends that you re-create them after the import in case
they define actions that would impede progress of the import.
25-13
Chapter 25
Import Parameters
• TOUSER
• TRANSPORT_TABLESPACE
• TTS_OWNERS
• USERID (username/password)
• VOLSIZE
25.7.1 BUFFER
Default: operating system-dependent
The integer specified for BUFFER is the size, in bytes, of the buffer through which data
rows are transferred.
BUFFER determines the number of rows in the array inserted by Import. The following
formula gives an approximation of the buffer size that inserts a given array of rows:
buffer_size = rows_in_array * maximum_row_size
For tables containing LOBs, LONG, BFILE, REF, ROWID,UROWID, or TIMESTAMP columns,
rows are inserted individually. The size of the buffer must be large enough to contain
the entire row, except for LOB and LONG columns. If the buffer cannot hold the longest
row in a table, then Import attempts to allocate a larger buffer.
For DATE columns, two or more rows are inserted at once if the buffer is large enough.
Note:
See your Oracle operating system-specific documentation to determine the
default value for this parameter.
25.7.2 COMMIT
Default: n
Specifies whether Import should commit after each array insert. By default, Import
commits only after loading each table, and Import performs a rollback when an error
occurs, before continuing with the next object.
If a table has nested table columns or attributes, then the contents of the nested tables
are imported as separate tables. Therefore, the contents of the nested tables are
always committed in a transaction distinct from the transaction used to commit the
outer table.
If COMMIT=n and a table is partitioned, then each partition and subpartition in the Export
file is imported in a separate transaction.
For tables containing LOBs, LONG, BFILE, REF, ROWID, UROWID, or TIMESTAMP columns,
array inserts are not done. If COMMIT=y, then Import commits these tables after each
row.
25-14
Chapter 25
Import Parameters
25.7.3 COMPILE
Default: y
Specifies whether Import should compile packages, procedures, and functions as they
are created.
If COMPILE=n, then these units are compiled on their first use. For example, packages
that are used to build domain indexes are compiled when the domain indexes are
created.
See Also:
"Importing Stored Procedures_ Functions_ and Packages "
25.7.4 CONSTRAINTS
Default: y
Note that primary key constraints for index-organized tables (IOTs) and object tables
are always imported.
25.7.5 DATA_ONLY
Default: n
To import only data (no metadata) from a dump file, specify DATA_ONLY=y.
When you specify DATA_ONLY=y, any import parameters related to metadata that are
entered on the command line (or in a parameter file) become invalid. This means that
no metadata from the dump file will be imported.
The metadata-related parameters are the following: COMPILE, CONSTRAINTS, DATAFILES,
DESTROY, GRANTS, IGNORE, INDEXES, INDEXFILE, ROWS=n, SHOW, SKIP_UNUSABLE_INDEXES,
STATISTICS, STREAMS_CONFIGURATION, STREAMS_INSTANTIATION, TABLESPACES,
TOID_NOVALIDATE, TRANSPORT_TABLESPACE, TTS_OWNERS.
25.7.6 DATAFILES
Default: none
When TRANSPORT_TABLESPACE is specified as y, use this parameter to list the data files to
be transported into the database.
25-15
Chapter 25
Import Parameters
See Also:
"TRANSPORT_TABLESPACE"
25.7.7 DESTROY
Default: n
Specifies whether the existing data files making up the database should be reused.
That is, specifying DESTROY=y causes Import to include the REUSE option in the data file
clause of the SQL CREATE TABLESPACE statement, which causes Import to reuse the
original database's data files after deleting their contents.
Note that the export file contains the data file names used in each tablespace. If you
specify DESTROY=y and attempt to create a second database on the same system (for
testing or other purposes), then the Import utility will overwrite the first database's data
files when it creates the tablespace. In this situation you should use the default,
DESTROY=n, so that an error occurs if the data files already exist when the tablespace is
created. Also, when you need to import into the original database, you will need to
specify IGNORE=y to add to the existing data files without replacing them.
Note:
If data files are stored on a raw device, thenDESTROY=n does not prevent files
from being overwritten.
25.7.8 FEEDBACK
Default: 0 (zero)
Specifies that Import should display a progress meter in the form of a period for n
number of rows imported. For example, if you specify FEEDBACK=10, then Import displays
a period each time 10 rows have been imported. The FEEDBACK value applies to all
tables being imported; it cannot be individually set for each table.
25.7.9 FILE
Default: expdat.dmp
Specifies the names of the export files to import. The default extension is .dmp.
Because Export supports multiple export files (see the following description of the
FILESIZE parameter), you may need to specify multiple file names to be imported. For
example:
imp scott IGNORE=y FILE = dat1.dmp, dat2.dmp, dat3.dmp FILESIZE=2048
You need not be the user who exported the export files; however, you must have read
access to the files. If you were not the exporter of the export files, then you must also
have the IMP_FULL_DATABASE role granted to you.
25-16
Chapter 25
Import Parameters
25.7.10 FILESIZE
Default: operating system-dependent
Lets you specify the same maximum dump file size you specified on export.
Note:
The maximum size allowed is operating system-dependent. You should verify
this maximum value in your Oracle operating system-specific documentation
before specifying FILESIZE.
25.7.11 FROMUSER
Default: none
A comma-delimited list of schemas to import. This parameter is relevant only to users
with the IMP_FULL_DATABASE role. The parameter enables you to import a subset of
schemas from an export file containing multiple schemas (for example, a full export
dump file or a multischema, user-mode export dump file).
Schema names that appear inside function-based indexes, functions, procedures,
triggers, type bodies, views, and so on, are not affected by FROMUSER or TOUSER
processing. Only the name of the object is affected. After the import has completed,
items in any TOUSER schema should be manually checked for references to old
(FROMUSER) schemas, and corrected if necessary.
You will typically use FROMUSER in conjunction with the Import parameter TOUSER, which
you use to specify a list of usernames whose schemas will be targets for import (see
"TOUSER"). The user that you specify with TOUSER must exist in the target database
before the import operation; otherwise an error is returned.
If you do not specify TOUSER, then Import will do the following:
• Import objects into the FROMUSER schema if the export file is a full dump or a
multischema, user-mode export dump file
• Create objects in the importer's schema (regardless of the presence of or absence
of the FROMUSER schema on import) if the export file is a single-schema, user-mode
export dump file created by an unprivileged user
Note:
Specifying FROMUSER=SYSTEM causes only schema objects belonging to user
SYSTEM to be imported; it does not cause system objects to be imported.
25-17
Chapter 25
Import Parameters
25.7.12 FULL
Default: y
25-18
Chapter 25
Import Parameters
25.7.13 GRANTS
Default: y
Note:
Export does not export grants on data dictionary views for security reasons that
affect Import. If such grants were exported, then access privileges would be
changed and the importer would not be aware of this.
25.7.14 HELP
Default: none
Displays a description of the Import parameters. Enter imp HELP=y on the command line
to display the help content.
25.7.15 IGNORE
Default: n
Specifies how object creation errors should be handled. If you accept the default,
IGNORE=n, then Import logs or displays object creation errors before continuing.
If you specify IGNORE=y, then Import overlooks object creation errors when it attempts to
create database objects, and continues without reporting the errors.
Note that only object creation errors are ignored; other errors, such as operating
system, database, and SQL errors, are not ignored and may cause processing to stop.
In situations where multiple refreshes from a single export file are done with IGNORE=y,
certain objects can be created multiple times (although they will have unique system-
defined names). You can prevent this for certain objects (for example, constraints) by
doing an import with CONSTRAINTS=n. If you do a full import with CONSTRAINTS=n, then no
constraints for any tables are imported.
If a table already exists and IGNORE=y, then rows are imported into existing tables
without any errors or messages being given. You might want to import data into tables
that already exist in order to use new storage parameters or because you have
already created the table in a cluster.
25-19
Chapter 25
Import Parameters
If a table already exists and IGNORE=n, then errors are reported and the table is skipped
with no rows inserted. Also, objects dependent on tables, such as indexes, grants, and
constraints, will not be created.
Note:
When you import into existing tables, if no column in the table is uniquely
indexed, rows could be duplicated.
25.7.16 INDEXES
Default: y
If indexes for the target table already exist at the time of the import, then Import
performs index maintenance when data is inserted into the table.
25.7.17 INDEXFILE
Default: none
Specifies a file to receive index-creation statements.
When this parameter is specified, index-creation statements for the requested mode
are extracted and written to the specified file, rather than used to create indexes in the
database. No database objects are imported.
If the Import parameter CONSTRAINTS is set to y, then Import also writes table constraints
to the index file.
The file can then be edited (for example, to change storage parameters) and used as
a SQL script to create the indexes.
To make it easier to identify the indexes defined in the file, the export file's CREATE TABLE
statements and CREATE CLUSTER statements are included as comments.
25-20
Chapter 25
Import Parameters
25.7.18 LOG
Default: none
Specifies a file (for example, import.log) to receive informational and error messages.
If you specify a log file, then the Import utility writes all information to the log in addition
to the terminal display.
25.7.19 PARFILE
Default: none
Specifies a file name for a file that contains a list of Import parameters. For more
information about using a parameter file, see "Parameter Files".
25.7.20 RECORDLENGTH
Default: operating system-dependent
Specifies the length, in bytes, of the file record. The RECORDLENGTH parameter is
necessary when you must transfer the export file to another operating system that
uses a different default value.
If you do not define this parameter, then it defaults to your platform-dependent value
for BUFSIZ.
You can set RECORDLENGTH to any value equal to or greater than your system's BUFSIZ.
(The highest value is 64 KB.) Changing the RECORDLENGTH parameter affects only the
size of data that accumulates before writing to the database. It does not affect the
operating system file block size.
You can also use this parameter to specify the size of the Import I/O buffer.
25.7.21 RESUMABLE
Default: n
The RESUMABLE parameter is used to enable and disable resumable space allocation.
Because this parameter is disabled by default, you must set RESUMABLE=y to use its
associated parameters, RESUMABLE_NAME and RESUMABLE_TIMEOUT.
See Also:
25.7.22 RESUMABLE_NAME
Default: 'User USERNAME (USERID), Session SESSIONID, Instance INSTANCEID'
25-21
Chapter 25
Import Parameters
The value for this parameter identifies the statement that is resumable. This value is a
user-defined text string that is inserted in either the USER_RESUMABLE or DBA_RESUMABLE
view to help you identify a specific resumable statement that has been suspended.
This parameter is ignored unless the RESUMABLE parameter is set to y to enable
resumable space allocation.
25.7.23 RESUMABLE_TIMEOUT
Default: 7200 seconds (2 hours)
The value of the parameter specifies the time period during which an error must be
fixed. If the error is not fixed within the timeout period, then execution of the statement
is terminated.
This parameter is ignored unless the RESUMABLE parameter is set to y to enable
resumable space allocation.
25.7.24 ROWS
Default: y
25.7.25 SHOW
Default: n
When SHOW=y, the contents of the export dump file are listed to the display and not
imported. The SQL statements contained in the export are displayed in the order in
which Import will execute them.
The SHOW parameter can be used only with the FULL=y, FROMUSER, TOUSER, or TABLES
parameter.
25.7.26 SKIP_UNUSABLE_INDEXES
Default: the value of the Oracle database configuration parameter,
SKIP_UNUSABLE_INDEXES, as specified in the initialization parameter file
Both Import and the Oracle database provide a SKIP_UNUSABLE_INDEXES parameter. The
Import SKIP_UNUSABLE_INDEXES parameter is specified at the Import command line. The
Oracle database SKIP_UNUSABLE_INDEXES parameter is specified as a configuration
parameter in the initialization parameter file. It is important to understand how they
affect each other.
If you do not specify a value for SKIP_UNUSABLE_INDEXES at the Import command line,
then Import uses the database setting for the SKIP_UNUSABLE_INDEXES configuration
parameter, as specified in the initialization parameter file.
If you do specify a value for SKIP_UNUSABLE_INDEXES at the Import command line, then it
overrides the value of the SKIP_UNUSABLE_INDEXES configuration parameter in the
initialization parameter file.
25-22
Chapter 25
Import Parameters
A value of y means that Import will skip building indexes that were set to the Index
Unusable state (by either system or user). Other indexes (not previously set to Index
Unusable) continue to be updated as rows are inserted.
This parameter enables you to postpone index maintenance on selected index
partitions until after row data has been inserted. You then have the responsibility to
rebuild the affected index partitions after the Import.
Note:
Indexes that are unique and marked Unusable are not allowed to skip index
maintenance. Therefore, the SKIP_UNUSABLE_INDEXES parameter has no effect on
unique indexes.
You can use the INDEXFILE parameter in conjunction with INDEXES=n to provide the SQL
scripts for re-creating the index. If the SKIP_UNUSABLE_INDEXES parameter is not
specified, then row insertions that attempt to update unusable indexes will fail.
See Also:
The ALTER SESSION statement in the Oracle Database SQL Language Reference
25.7.27 STATISTICS
Default: ALWAYS
Specifies what is done with the database optimizer statistics at import time.
The options are:
• ALWAYS
Import database optimizer statistics only if they are not questionable. If they are
questionable, then recalculate the optimizer statistics.
• RECALCULATE
25-23
Chapter 25
Import Parameters
See Also:
25.7.28 STREAMS_CONFIGURATION
Default: y
Specifies whether to import any general Streams metadata that may be present in the
export dump file.
See Also:
Oracle Streams Replication Administrator's Guide
25.7.29 STREAMS_INSTANTIATION
Default: n
Specifies whether to import Streams instantiation metadata that may be present in the
export dump file. Specify y if the import is part of an instantiation in a Streams
environment.
See Also:
Oracle Streams Replication Administrator's Guide
25.7.30 TABLES
Default: none
Specifies that the import is a table-mode import and lists the table names and partition
and subpartition names to import. Table-mode import lets you import entire partitioned
or nonpartitioned tables. The TABLES parameter restricts the import to the specified
tables and their associated objects, as listed in Import Modes. You can specify the
following values for the TABLES parameter:
• tablename specifies the name of the table or tables to be imported. If a table in the
list is partitioned and you do not specify a partition name, then all its partitions and
subpartitions are imported. To import all the exported tables, specify an asterisk (*)
as the only table name parameter.
tablename can contain any number of '%' pattern matching characters, which can
each match zero or more characters in the table names in the export file. All the
tables whose names match all the specified patterns of a specific table name in
25-24
Chapter 25
Import Parameters
the list are selected for import. A table name in the list that consists of all pattern
matching characters and no partition name results in all exported tables being
imported.
• partition_name and subpartition_name let you restrict the import to one or more
specified partitions or subpartitions within a partitioned table.
The syntax you use to specify the preceding is in the form:
tablename:partition_name
tablename:subpartition_name
If you use tablename:partition_name, then the specified table must be partitioned, and
partition_name must be the name of one of its partitions or subpartitions. If the
specified table is not partitioned, then the partition_name is ignored and the entire
table is imported.
The number of tables that can be specified at the same time is dependent on
command-line limits.
As the export file is processed, each table name in the export file is compared against
each table name in the list, in the order in which the table names were specified in the
parameter. To avoid ambiguity and excessive processing time, specific table names
should appear at the beginning of the list, and more general table names (those with
patterns) should appear at the end of the list.
Although you can qualify table names with schema names (as in scott.emp) when
exporting, you cannot do so when importing. In the following example, the TABLES
parameter is specified incorrectly:
imp TABLES=(jones.accts, scott.emp, scott.dept)
For a more detailed example, see "Example Import Using Pattern Matching to Import
Various Tables".
Note:
Some operating systems, such as UNIX, require that you use escape
characters before special characters, such as a parenthesis, so that the
character is not treated as a special character. On UNIX, use a backslash (\) as
the escape character, as shown in the following example:
TABLES=\(emp,dept\)
25-25
Chapter 25
Import Parameters
• By default, table names in a database are stored as uppercase. If you have a table
name in mixed-case or lowercase, and you want to preserve case-sensitivity for
the table name, then you must enclose the name in quotation marks. The name
must exactly match the table name stored in the database.
Some operating systems require that quotation marks on the command line be
preceded by an escape character. The following are examples of how case-
sensitivity can be preserved in the different Import modes.
– In command-line mode:
tables='\"Emp\"'
– In interactive mode:
Table(T) to be exported: "Exp"
– In parameter file mode:
tables='"Emp"'
• Table names specified on the command line cannot include a pound (#) sign,
unless the table name is enclosed in quotation marks. Similarly, in the parameter
file, if a table name includes a pound (#) sign, then the Import utility interprets the
rest of the line as a comment, unless the table name is enclosed in quotation
marks.
For example, if the parameter file contains the following line, then Import interprets
everything on the line after emp# as a comment and does not import the tables dept
and mydata:
TABLES=(emp#, dept, mydata)
However, given the following line, the Import utility imports all three tables because
emp# is enclosed in quotation marks:
Note:
Some operating systems require single quotation marks rather than double
quotation marks, or the reverse; see your Oracle operating system-specific
documentation. Different operating systems also have other restrictions on
table naming.
For example, the UNIX C shell attaches a special meaning to a dollar sign
($) or pound sign (#) (or certain other special characters). You must use
escape characters to get such characters in the name past the shell and
into Import.
25.7.31 TABLESPACES
Default: none
When TRANSPORT_TABLESPACE is specified as y, use this parameter to list the tablespaces
to be transported into the database. If there is more than one tablespace in the export
file, then you must specify all of them as part of the import operation.
See "TRANSPORT_TABLESPACE" for more information.
25-26
Chapter 25
Import Parameters
25.7.32 TOID_NOVALIDATE
Default: none
When you import a table that references a type, but a type of that name already exists
in the database, Import attempts to verify that the preexisting type is, in fact, the type
used by the table (rather than a different type that just happens to have the same
name).
To do this, Import compares the type's unique identifier (TOID) with the identifier
stored in the export file. Import will not import the table rows if the TOIDs do not match.
In some situations, you may not want this validation to occur on specified types (for
example, if the types were created by a cartridge installation). You can use the
TOID_NOVALIDATE parameter to specify types to exclude from TOID comparison.
For example:
imp scott TABLES=jobs TOID_NOVALIDATE=typ1
imp scott TABLES=salaries TOID_NOVALIDATE=(fred.typ0,sally.typ2,typ3)
If you do not specify a schema name for the type, then it defaults to the schema of the
importing user. For example, in the first preceding example, the type typ1 defaults to
scott.typ1 and in the second example, the type typ3 defaults to scott.typ3.
Note that TOID_NOVALIDATE deals only with table column types. It has no effect on table
types.
The output of a typical import with excluded types would contain entries similar to the
following:
[...]
. importing IMP3's objects into IMP3
. . skipping TOID validation on type IMP2.TOIDTYP0
. . importing table "TOIDTAB3"
[...]
Note:
When you inhibit validation of the type identifier, it is your responsibility to
ensure that the attribute list of the imported type matches the attribute list of the
existing type. If these attribute lists do not match, then results are
unpredictable.
25.7.33 TOUSER
Default: none
Specifies a list of user names whose schemas will be targets for Import. The user
names must exist before the import operation; otherwise an error is returned. The
25-27
Chapter 25
Import Parameters
If multiple schemas are specified, then the schema names are paired. The following
example imports scott's objects into joe's schema, and fred's objects into ted's
schema:
imp FROMUSER=scott,fred TOUSER=joe,ted
If the FROMUSER list is longer than the TOUSER list, then the remaining schemas will be
imported into either the FROMUSER schema, or into the importer's schema, based on
normal defaulting rules. You can use the following syntax to ensure that any extra
objects go into the TOUSER schema:
imp FROMUSER=scott,adams TOUSER=ted,ted
See Also:
"FROMUSER" for information about restrictions when using FROMUSER and
TOUSER
25.7.34 TRANSPORT_TABLESPACE
Default: n
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
25.7.35 TTS_OWNERS
Default: none
When TRANSPORT_TABLESPACE is specified as y, use this parameter to list the users who
own the data in the transportable tablespace set.
See "TRANSPORT_TABLESPACE".
25-28
Chapter 25
Example Import Sessions
See Also:
• The user's guide for your Oracle Net protocol for information about
specifying a connect string for Oracle Net
25.7.37 VOLSIZE
Default: none
Specifies the maximum number of bytes in a dump file on each volume of tape.
The VOLSIZE parameter has a maximum value equal to the maximum value that can be
stored in 64 bits on your platform.
The VOLSIZE value can be specified as number followed by KB (number of kilobytes).
For example, VOLSIZE=2KB is the same as VOLSIZE=2048. Similarly, MB specifies
megabytes (1024 * 1024) and GB specifies gigabytes (1024**3). The shorthand for
bytes remains B; the number is not multiplied to get the final file size (VOLSIZE=2048B is
the same as VOLSIZE=2048).
25-29
Chapter 25
Example Import Sessions
Command-Line Method
> imp FILE=dba.dmp FROMUSER=scott TABLES=(dept,emp)
Import Messages
Information is displayed about the release of Import you are using and the release of
Oracle Database that you are connected to. Status messages are also displayed.
Command-Line Method
> imp FROMUSER=blake TOUSER=scott FILE=blake.dmp TABLES=(unit,manager)
Import Messages
Information is displayed about the release of Import you are using and the release of
Oracle Database that you are connected to. Status messages are also displayed.
25-30
Chapter 25
Example Import Sessions
Command-Line Method
> imp FILE=scott.dmp FROMUSER=scott TOUSER=blake TABLES=(*)
Import Messages
Information is displayed about the release of Import you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
Warning: the objects were exported by SCOTT, not by you
import done in WE8DEC character set and AL16UTF16 NCHAR character set
. importing SCOTT's objects into BLAKE
. . importing table "BONUS" 0 rows imported
. . importing table "DEPT" 4 rows imported
. . importing table "EMP" 14 rows imported
. . importing table "SALGRADE" 5 rows imported
Import terminated successfully without warnings.
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
25-31
Chapter 25
Example Import Sessions
.
.
.
About to export specified tables via Conventional Path ...
. . exporting table EMP
. . exporting partition P1 7 rows exported
. . exporting partition P2 12 rows exported
. . exporting partition P3 3 rows exported
Export terminated successfully without warnings.
In a partition-level Import you can specify the specific partitions of an exported table
that you want to import. In this example, these are P1 and P3 of table emp:
> imp scott TABLES=(emp:p1,emp:p3) FILE=exmpexp.dat ROWS=y
Import Messages
Information is displayed about the release of Import you are using and the release of
Oracle Database that you are connected to. Status messages are also displayed.
Export Messages
Information is displayed about the release of Export you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
When the command executes, the following Export messages are displayed:
.
.
.
About to export specified tables via Conventional Path ...
. . exporting table EMP
. . exporting composite partition P1
. . exporting subpartition P1_SP1 2 rows exported
. . exporting subpartition P1_SP2 10 rows exported
. . exporting subpartition P1_SP3 7 rows exported
. . exporting composite partition P2
. . exporting subpartition P2_SP1 4 rows exported
. . exporting subpartition P2_SP2 2 rows exported
Export terminated successfully without warnings.
The following Import command results in the importing of subpartition P1_SP2 and
P1_SP3 of composite partition P1 in table emp and all subpartitions of composite partition
P2 in table emp.
25-32
Chapter 25
Example Import Sessions
Import Messages
Information is displayed about the release of Import you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
. importing SCOTT's objects into SCOTT
. . importing subpartition "EMP":"P1_SP2" 10 rows imported
. . importing subpartition "EMP":"P1_SP3" 7 rows imported
. . importing subpartition "EMP":"P2_SP1" 4 rows imported
. . importing subpartition "EMP":"P2_SP2" 2 rows imported
Import terminated successfully without warnings.
25-33
Chapter 25
Example Import Sessions
The following SQL SELECT statements show that the data is partitioned on the deptno
column:
SQL> connect scott
Connected.
SQL> select empno, deptno from emp partition (dept_low);
EMPNO DEPTNO
---------- ----------
7782 10
7839 10
7934 10
3 rows selected.
SQL> select empno, deptno from emp partition (dept_mid);
EMPNO DEPTNO
---------- ----------
7369 20
7566 20
7788 20
7876 20
7902 20
5 rows selected.
SQL> select empno, deptno from emp partition (dept_high);
EMPNO DEPTNO
---------- ----------
7499 30
7521 30
7654 30
7698 30
7844 30
7900 30
6 rows selected.
SQL> exit;
25-34
Chapter 25
Exit Codes for Inspection and Display
Command-Line Method
imp FROMUSER=scott FILE=scott.dmp TABLES=(%d%,b%s)
Import Messages
Information is displayed about the release of Import you are using and the release of
Oracle Database that you are connected to. Then, status messages similar to the
following are shown:
.
.
.
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses JA16SJIS character set (possible charset conversion)
. importing SCOTT's objects into SCOTT
. . importing table "BONUS" 0 rows imported
. . importing table "DEPT" 4 rows imported
. . importing table "SALGRADE" 5 rows imported
Import terminated successfully without warnings.
25-35
Chapter 25
Error Handling During an Import
• Uniqueness constraints
• Primary key (not null and unique) constraints
• Referential integrity constraints
• Check constraints
See Also:
25-36
Chapter 25
Error Handling During an Import
Note:
Specifying IGNORE=y can cause duplicate rows to be entered into a table unless
one or more columns of the table are specified with the UNIQUE integrity
constraint. This could occur, for example, if Import were run twice.
25.10.2.2 Sequences
If sequence numbers need to be reset to the value in an export file as part of an
import, then you should drop sequences. If a sequence is not dropped before the
import, then it is not set to the value captured in the export file, because Import does
not drop and re-create a sequence that already exists. If the sequence already exists,
then the export file's CREATE SEQUENCE statement fails and the sequence is not imported.
25-37
Chapter 25
Table-Level and Partition-Level Import
Import commits the partial import of the current table. If not, then a rollback of the
current table occurs before Import continues. See the description of "COMMIT".
25-38
Chapter 25
Table-Level and Partition-Level Import
• If the target table is partitioned, then partition-level Import rejects any rows that fall
above the highest partition of the target table.
• Partition-level Import cannot import a nonpartitioned exported table. However, a
partitioned table can be imported from a nonpartitioned exported table using table-
level Import.
• Partition-level Import is legal only if the source table (that is, the table called
tablename at export time) was partitioned and exists in the export file.
• If the partition or subpartition name is not a valid partition in the export file, then
Import generates a warning.
• The partition or subpartition name in the parameter refers to only the partition or
subpartition in the export file, which may not contain all of the data of the table on
the export source system.
• If ROWS=y (default), and the table does not exist in the import target system, then the
table is created and all rows from the source partition or subpartition are inserted
into the partition or subpartition of the target table.
• If ROWS=y (default) and IGNORE=y, but the table already existed before import, then all
rows for the specified partition or subpartition in the table are inserted into the
table. The rows are stored according to the existing partitioning scheme of the
target table.
• If ROWS=n, then Import does not insert data into the target table and continues to
process other objects associated with the specified table and partition or
subpartition in the file.
• If the target table is nonpartitioned, then the partitions and subpartitions are
imported into the entire table. Import requires IGNORE=y to import one or more
partitions or subpartitions from the export file into a nonpartitioned table on the
import target system.
The following example causes row data of partitions qc and qd of table scott.e to be
imported into the table scott.e:
imp scott FILE=expdat.dmp TABLES=(e:qc, e:qd) IGNORE=y
If table e does not exist in the import target database, then it is created and data is
inserted into the same partitions. If table e existed on the target system before import,
then the row data is inserted into the partitions whose range allows insertion. The row
data can end up in partitions of names other than qc and qd.
25-39
Chapter 25
Controlling Index Creation and Maintenance
Note:
With partition-level Import to an existing table, you must set up the target
partitions or subpartitions properly and use IGNORE=y.
25-40
Chapter 25
Network Considerations
in the existing table t, compared with the amount of data to be inserted by the export
file (expdat.dmp). Assume that the reverse is true for p2.
Consequently, performing index updates for p1_ind during table data insertion time is
more efficient than at partition index rebuild time. The opposite is true for p2_ind.
Users can postpone local index maintenance for p2_ind during import by using the
following steps:
1. Issue the following SQL statement before import:
ALTER TABLE t MODIFY PARTITION p2 UNUSABLE LOCAL INDEXES;
2. Issue the following Import command:
imp scott FILE=expdat.dmp TABLES = (t:p1, t:p2) IGNORE=y
SKIP_UNUSABLE_INDEXES=y
See Also:
25-41
Chapter 25
Character Set and Globalization Support Considerations
This partitioning scheme makes sense because z comes after Z in ASCII character
sets.
When this table is imported into a database based upon an EBCDIC character set, all
of the rows in the part_mid partition will migrate to the part_low partition because z
comes before Z in EBCDIC character sets. To obtain the desired results, the owner of
partlist must repartition the table following the import.
See Also:
Oracle Database Globalization Support Guide for more information about
character sets
25-42
Chapter 25
Using Instance Affinity
2. If the export file's character set is different than the import user session character
set, then Import converts the character set to its user session character set. Import
can only perform this conversion for single-byte character sets. This means that
for multibyte character sets, the import file's character set must be identical to the
export file's character set.
3. A final character set conversion may be performed if the target database's
character set is different from the character set used by the import user session.
To minimize data loss due to character set conversions, ensure that the export
database, the export user session, the import user session, and the import database
all use the same character set.
Note:
When the character set width differs between the Export server and the Import
server, truncation of data can occur if conversion causes expansion of data. If
truncation occurs, then Import displays a warning message.
See Also:
25-43
Chapter 25
Considerations When Importing Database Objects
25-44
Chapter 25
Considerations When Importing Database Objects
Note:
Be very careful about using TOID_NOVALIDATE, because type validation provides
an important capability that helps avoid data corruption. Be sure you are
confident of your knowledge of type validation and how it works before
attempting to perform an import operation with this feature disabled.
Import uses the following criteria to decide how to handle object types, object tables,
and rows in object tables:
• For object types, if IGNORE=y, the object type already exists, and the object
identifiers, hashcodes, and type descriptors match, then no error is reported. If the
object identifiers or hashcodes do not match and the parameter TOID_NOVALIDATE
has not been set to ignore the object type, then an error is reported and any tables
using the object type are not imported.
• For object types, if IGNORE=n and the object type already exists, then an error is
reported. If the object identifiers, hashcodes, or type descriptors do not match and
the parameter TOID_NOVALIDATE has not been set to ignore the object type, then any
tables using the object type are not imported.
• For object tables, if IGNORE=y, then the table already exists, and the object
identifiers, hashcodes, and type descriptors match, no error is reported. Rows are
imported into the object table. Import of rows may fail if rows with the same object
identifier already exist in the object table. If the object identifiers, hashcodes, or
type descriptors do not match, and the parameter TOID_NOVALIDATE has not been
set to ignore the object type, then an error is reported and the table is not
imported.
• For object tables, if IGNORE=n and the table already exists, then an error is reported
and the table is not imported.
Because Import preserves object identifiers of object types and object tables, consider
the following when you import objects from one schema into another schema using the
FROMUSER and TOUSER parameters:
• If the FROMUSER object types and object tables already exist on the target system,
then errors occur because the object identifiers of the TOUSER object types and
object tables are already in use. The FROMUSER object types and object tables must
be dropped from the system before the import is started.
• If an object table was created using the OID AS option to assign it the same object
identifier as another table, then both tables cannot be imported. You can import
one of the tables, but the second table receives an error because the object
identifier is already in use.
25-45
Chapter 25
Considerations When Importing Database Objects
For object tables and for tables containing columns of objects, each object the table
references has its name, structure, and version information written out to the export
file. Export also includes object type information from different schemas, as needed.
Import verifies the existence of each object type required by a table before importing
the table data. This verification consists of a check of the object type's name followed
by a comparison of the object type's structure and version from the import system with
that found in the export file.
If an object type name is found on the import system, but the structure or version do
not match that from the export file, then an error message is generated and the table
data is not imported.
The Import parameter TOID_NOVALIDATE can be used to disable the verification of the
object type's structure and version for specific objects.
25-46
Chapter 25
Considerations When Importing Database Objects
See Also:
Oracle Database SQL Language Reference for more information about the
ANALYZE statement
For directory aliases, if the operating system directory syntax used in the export
system is not valid on the import system, then no error is reported at import time. The
error occurs when the user seeks subsequent access to the file data. It is the
responsibility of the DBA or user to ensure the directory alias is valid on the import
system.
When a local stored procedure, function, or package is imported and COMPILE=y, the
procedure, function, or package is recompiled upon import and retains its original
timestamp specification. If the compilation is successful, then it can be accessed by
remote procedures without error.
If COMPILE=n, then the procedure, function, or package is still imported, but the original
timestamp is lost. The compilation takes place the next time the procedure, function, or
package is used.
25-47
Chapter 25
Considerations When Importing Database Objects
See Also:
"COMPILE"
See Also:
Oracle Database Advanced Queuing User's Guide
25-48
Chapter 25
Considerations When Importing Database Objects
Note:
Oracle recommends that you convert existing LONG columns to LOB columns.
LOB columns are subject to far fewer restrictions than LONG columns. Further,
LOB functionality is enhanced in every release, whereas LONG functionality has
been static for several releases.
It is important to note that once the import is performed, there is no way to distinguish
between LOB columns that are NULL versus those that are empty. Therefore, if that
information is important to the integrity of your data, then be sure you know which LOB
columns are NULL and which are empty before you perform the import.
25-49
Chapter 25
Support for Fine-Grained Access Control
Unless SKIP_UNUSABLE_INDEXES=y,inserting the exported data into the target table fails if
Import cannot update a nonpartitioned index or index partition that is marked Indexes
Unusable or is otherwise not suitable.
Note:
In certain situations, particularly those involving data warehousing, snapshots
may be referred to as materialized views. This section retains the term
snapshot.
• Snapshot Log
• Snapshots
25-50
Chapter 25
Transportable Tablespaces
25.18.2 Snapshots
A snapshot that has been restored from an export file has reverted to a previous state.
On import, the time of the last refresh is imported as part of the snapshot table
definition. The function that calculates the next refresh time is also imported.
Each refresh leaves a signature. A fast refresh uses the log entries that date from the
time of that signature to bring the snapshot up to date. When the fast refresh is
complete, the signature is deleted and a new signature is created. Any log entries that
are not needed to refresh other snapshots are also deleted (all log entries with times
before the earliest remaining signature).
• Importing a Snapshot
• Importing a Snapshot into a Different Schema
Note:
Schema names that appear inside function-based indexes, functions,
procedures, triggers, type bodies, views, and so on, are not affected by
FROMUSER or TOUSER processing. Only the name of the object is affected. After the
import has completed, items in any TOUSER schema should be manually checked
for references to old (FROMUSER) schemas, and corrected if necessary.
25-51
Chapter 25
Storage Parameters
Note:
You cannot export transportable tablespaces and then import them into a
database at a lower release level. The target database must be at the same or
later release level as the source database.
To move or copy a set of tablespaces, you must make the tablespaces read-only,
manually copy the data files of these tablespaces to the target database, and use
Export and Import to move the database information (metadata) stored in the data
dictionary over to the target database. The transport of the data files can be done
using any facility for copying flat binary files, such as the operating system copying
facility, binary-mode FTP, or publishing on CD-ROMs.
After copying the data files and exporting the metadata, you can optionally put the
tablespaces in read/write mode.
Export and Import provide the following parameters to enable movement of
transportable tablespace metadata.
• TABLESPACES
• TRANSPORT_TABLESPACE
See Also:
25-52
Chapter 25
Read-Only Tablespaces
Note that LOB data might not reside in the same tablespace as the containing table.
The tablespace for that data must be read/write at the time of import or the table will
not be imported.
If LOB data resides in a tablespace that does not exist at the time of import, or the
user does not have the necessary quota in that tablespace, then the table will not be
imported. Because there can be multiple tablespace clauses, including one for the
table, Import cannot determine which tablespace clause caused the error.
In many cases, you can drop a tablespace by doing a full database export, then
creating a zero-block tablespace with the same name (before logging off) as the
tablespace you want to drop. During import, with IGNORE=y, the relevant CREATE
TABLESPACE statement will fail and prevent the creation of the unwanted tablespace.
25-53
Chapter 25
Reorganizing Tablespaces
All objects from that tablespace will be imported into their owner's default tablespace
except for partitioned tables, type tables, and tables that contain LOB or VARRAY
columns or index-only tables with overflow segments. Import cannot determine which
tablespace caused the error. Instead, you must first create a table and then import the
table again, specifying IGNORE=y.
Objects are not imported into the default tablespace if the tablespace does not exist, or
you do not have the necessary quotas for your default tablespace.
25-54
Chapter 25
Using Export and Import to Partition a Database Migration
Note:
Specifying ROWS=n will not prevent the use of precalculated statistics. This
feature allows plan generation for queries to be tuned in a nonproduction
database using statistics from a production database. In these cases, the
import should specify STATISTICS=SAFE.
In certain situations, the importer might want to always use ANALYZE statements rather
than precalculated statistics. For example, the statistics gathered from a fragmented
database may not be relevant when the data is imported in a compressed form. In
these cases, the importer should specify STATISTICS=RECALCULATE to force the
recalculation of statistics.
If you do not want any statistics to be established by Import, then you should specify
STATISTICS=NONE.
25-55
Chapter 25
Tuning Considerations for Import Operations
All exports can be done in parallel. When the import of full.dmp completes, all
remaining imports can also be done in parallel.
Note:
Oracle recommends that you use automatic undo management instead of
rollback segments.
• Put the database in NOARCHIVELOG mode until the import is complete. This will
reduce the overhead of creating and managing archive logs.
• Create several large redo files and take any small redo log files offline. This will
result in fewer log switches being made.
25-56
Chapter 25
Tuning Considerations for Import Operations
• If possible, have the rollback segment, table data, and redo log files all on
separate disks. This will reduce I/O contention and increase throughput.
• If possible, do not run any other jobs at the same time that may compete with the
import operation for system resources.
• Ensure that there are no statistics on dictionary tables.
• Set TRACE_LEVEL_CLIENT=OFF in the sqlnet.ora file.
• If possible, increase the value of DB_BLOCK_SIZE when you re-create the database.
The larger the block size, the smaller the number of I/O cycles needed. This
change is permanent, so be sure to carefully consider all effects it will have before
making it.
25-57
Chapter 25
Using Different Releases of Export and Import
Eliminating indexes significantly reduces total import time. This is because LOB data
requires special consideration during an import because the LOB locator has a primary
key that cannot be explicitly dropped or ignored during an import.
Ensure that there is enough space available in large contiguous chunks to complete
the data load.
See Also:
"Importing LONG Columns"
25-58
Chapter 25
Using Different Releases of Export and Import
• Any export dump file can be imported into a later release of the Oracle database.
• The Import utility cannot read export dump files created by the Export utility of a
later maintenance release or version. For example, a release 9.2 export dump file
cannot be imported by a release 9.0.1 Import utility.
• Whenever a lower version of the Export utility runs with a later version of the
Oracle database, categories of database objects that did not exist in the earlier
version are excluded from the export.
• Export files generated by Oracle9i Export, either direct path or conventional path,
are incompatible with earlier releases of Import and can be imported only with
Oracle9i Import. When backward compatibility is an issue, use the earlier release
or version of the Export utility against the Oracle9i database.
Table 25-5 covers moving data only between the original Export and Import utilities.
For Oracle Database 10g release 1 (10.1) or later, Oracle recommends the Data
Pump Export and Import utilities in most cases because these utilities provide greatly
enhanced performance compared to the original Export and Import utilities.
See Also:
Oracle Database Upgrade Guide for more information about exporting and
importing data between different releases, including releases later than 10.1
25-59
Part V
Appendixes
This section contains the following topics:
• SQL*Loader Syntax Diagrams
This appendix describes SQL*Loader syntax in graphic form (sometimes called
railroad diagrams or DDL diagrams).
• Instant Client for SQL*Loader, Export, and Import
Oracle Instant Client allows you to run your applications without installing the
standard Oracle client or having an Oracle home.
A
SQL*Loader Syntax Diagrams
This appendix describes SQL*Loader syntax in graphic form (sometimes called
railroad diagrams or DDL diagrams).
For information about the syntax notation used, see the Oracle Database SQL
Language Reference
The following diagrams are shown with certain clauses collapsed (such as pos_spec).
These diagrams are expanded and explained further along in the appendix.
A-1
Appendix A
Options Clause
BINDSIZE =n
OPTIONS (
COLUMNARRAYROWS =n
DATE_CACHE =n
IGNORE
EVALUATE_ONCE
DEFAULTS = EVALUATE_EVERY_ROW
IGNORE_UNSUPPORTED_EVALUATE_ONCE
IGNORE_UNSUPPORTED_EVALUATE_EVERY_ROW
degree_num
DEFAULT
DEGREE_OF_PARALLELISM =
AUTO
NONE
TRUE
DIRECT =
FALSE
TRUE
DIRECT_PATH_LOCK_WAIT =
FALSE
TRUE
EMPTY_LOBS_ARE_NULL =
FALSE
ERRORS =n
NOT_USED
EXTERNAL_TABLE = GENERATE_ONLY
EXECUTE
LOAD =n
TRUE
MULTITHREADING =
FALSE
TRUE
PARALLEL =
FALSE
)
A-2
Appendix A
Options_Cont
READSIZE =n
TRUE
RESUMABLE =
FALSE
RESUMABLE_TIMEOUT =n
ROWS =n
HEADER
FEEDBACK
ERRORS
SILENT =
DISCARDS
PARTITIONS
ALL
SKIP =n
TRUE
SKIP_INDEX_MAINTENANCE =
FALSE
TRUE
SKIP_UNUSABLE_INDEXES =
FALSE
STREAMSIZE =n
LRTRIM
NOTRIM
TRIM = TRIM
RTRIM
LDRTRIM
)
A-3
Appendix A
Load Statement
UNRECOVERABLE
CONTINUE_LOAD
BYTE
SEMANTICS
LENGTH CHAR
IGNORE
FIRST FILE
IGNORE
FIELD NAMES
ALL FILES
NONE
INSERT
APPEND
, REPLACE
,
concatenate_clause PRESERVE BLANKS BEGINDATA
into_table_clause
A-4
Appendix A
infile_clause
* os_file_proc_clause
INFILE
input_filename
directory_path filename
BADFILE
directory_path filename
DISCARDFILE
var
fix
’string’
" "
X’hex_string’
str
integer
Note:
On the BADFILE and DISCARDFILE clauses, you must specify either a directory
path, or a filename, or both.
concatenate_clause
integer
CONCATENATE
( integer )
THIS
NEXT PRESERVE (
pos_spec )
str
CONTINUEIF PRESERVE ( operator
X’hex_str’
LAST
A-5
Appendix A
into_table_clause
,
INDEXES
SORTED ( name )
INTO TABLE name
PARTITION name
( )
SINGLEROW SUBPARTITION name
YES
REPLACE
NO
RESUME
INSERT
DELETE
USING
TRUNCATE
REPLACE
TRUNCATE
APPEND
A-6
Appendix A
into_table_clause_continued
WHEN field_condition
OID_spec
SID_spec
XMLTYPE_spec
WITH
EMBEDDED
WITHOUT
CSV delim_spec NULLCOLS
FIELDS TRAILING
DATE
TIMESTAMP
FORMAT mask
= X’hexstr’
!= BLANKS
NULLIF
SKIP n
field_list
field_condition
AND
’char_string’
( full_fieldname )
operator X’hex_string’
pos_spec
BLANKS
A-7
Appendix A
delim_spec
enclosure_spec
OPTIONALLY
enclosure_spec
termination_spec
full_fieldname
full_fieldname
termination_spec
WHITESPACE
BY X’hexstr’
TERMINATED
’string’
EOF
enclosure_spec
’string’ ’string’
AND
BY X’hexstr’ X’hexstr’
ENCLOSED
oid_spec
OID ( fieldname )
sid_spec
fieldname
SID ( )
CONSTANT SID_val
A-8
Appendix A
xmltype_spec
XMLTYPE ( fieldname )
field_list
dgen_fld_spec
scalar_fld_spec
( column_name col_obj_fld_spec )
collection_fld_spec
filler_fld_spec
dgen_fld_spec
RECNUM
SYSDATE
CONSTANT val
COUNT
, incr
SEQUENCE ( MAX )
integer
REF_spec
SID_spec init_spec
BFILE_spec
ref_spec
fieldname
REF ( )
CONSTANT val
A-9
Appendix A
init_spec
NULLIF
field_condition
DEFAULTIF
bfile_spec
fieldname fieldname
BFILE ( , )
CONSTANT val CONSTANT val
filler_fld_spec
BOUNDFILLER
scalar_fld_spec
LOBFILE_spec
datatype_spec PIECED
POSITION pos_spec
lobfile_spec
BYTE
SEMANTICS
LENGTH CHAR BIG ENDIAN
BYTEORDER
CHARACTER LITTLE
CHECK
BYTEORDERMARK
NOCHECK
)
A-10
Appendix A
lls_field_spec
pos_spec
:
end
start –
( +integer )
*
datatype_spec
delim_spec
SIGNED
( length ) UNSIGNED
( length ) delim_spec
INTEGER
EXTERNAL
( length ) delim_spec
EXTERNAL
FLOAT
( length ) delim_spec
EXTERNAL
DECIMAL
, scale
ZONED ( precision )
DOUBLE
BYTEINT
SIGNED
UNSIGNED
SMALLINT
( length )
RAW
EXTERNAL ( graphic_char_length )
GRAPHIC
VARGRAPHIC ( max_length )
VARCHAR
datatype_spec_cont
A-11
Appendix A
datatype_spec_cont
( length ) delim_spec
CHAR
, max_size_bytes
VARCHARC ( length_of_length )
, max_size_bytes
VARRAWC ( length_of_length )
LONG ( max_bytes )
VARRAW
LOCAL
TIME fractional_second_precision WITH TIME ZONE "mask"
TIMESTAMP
year_precision
YEAR TO MONTH
day_precision fractional_second_precision
DAY TO SECOND
INTERVAL
col_obj_fld_spec
collection_fld_spec
nested_table_spec
BOUNDFILLER
varray_spec
nested_table_spec
delim_spec
A-12
Appendix A
varray_spec
delim_spec
sdf_spec
field_name
BYTE
SEMANTICS
LENGTH CHAR
count_spec
fieldname
COUNT ( )
CONSTANT positive_integer
A-13
B
Instant Client for SQL*Loader, Export, and
Import
Oracle Instant Client allows you to run your applications without installing the standard
Oracle client or having an Oracle home.
The following topics are discussed:
• What is the Tools Instant Client?
• Choosing the Instant Client to Install
Before you install the Tools Instant Client Tools package, you must first choose
either Basic Instant Client or Instant Client Light.
• Installing Tools Instant Client by Downloading from OTN
The OTN downloads for Linux are RPM packages. The OTN downloads for UNIX
and Windows are zip files.
• Installing Tools Instant Client from the 12c Client Release Media
The Tools Instant Client package can be installed from client release media.
• Configuring Tools Instant Client Package
The Tools Instant Client package executable should only be used with the
matching version of the OCI Instant Client. No ORACLE_HOME or ORACLE_SID
environment variables need to be set.
• Connecting to a Database with the Tools Instant Client Package
After the Tools Instant Client package is installed and configured, you can connect
to a database.
• Uninstalling Instant Client
B-1
Appendix B
Choosing the Instant Client to Install
The basic steps required to use the Tools Instant Client are as follows. Each of these
steps is described in this appendix.
1. Choose which OCI Package (Basic or Light) you want to use, and also select the
directory in which to install the Instant Client files.
2. Copy the Tools Instant Client Package, and the OCI Instant Client package of your
choice, from an installed Oracle instance or download them from OTN.
3. Install (unpack) the Tools Instant Client package and the OCI package. A new
directory instantclient_12_2 is created as part of the installation.
4. Configure the Instant Client.
5. Connect to a remote instance with the utility you want to run.
Both the Tools package and OCI package must be from Oracle Database version
12.2.0.0.0, or higher, and the versions for both must be the same.
B-2
Appendix B
Installing Tools Instant Client by Downloading from OTN
3. Unzip the two packages into the new directory. Install the OCI Package first.
4. Configure Instant Client. See Configuring Tools Instant Client Package
B-3
Appendix B
Installing Tools Instant Client from the 12c Client Release Media
To install the Tools Instant Client using the Instant Client Light package on UNIX and
Linux, copy the following files:
$ORACLE_HOME/instantclient/light/libociicus.so
$ORACLE_HOME/lib/libnfsodm12.so
$ORACLE_HOME/bin/exp
$ORACLE_HOME/bin/imp
$ORACLE_HOME/bin/expdp
$ORACLE_HOME/bin/impdp
$ORACLE_HOME/bin/sqlldr
B-4
Appendix B
Configuring Tools Instant Client Package
To install the Tools Instant Client using the Instant Client Light package on Windows,
copy the following files:
ORACLE_HOME%\instantclient\light\oraociicus12.dll
%ORACLE_HOME%\bin\exp.exe
%ORACLE_HOME%\bin\imp.exe
%ORACLE_HOME%\bin\expdp.exe
%ORACLE_HOME%\bin\impdp.exe
%ORACLE_HOME%\bin\sqlldr.exe
For example, to set LD_LIBRARY_PATH in the Bourne or Korn shells, use the following
syntax:
LD_LIBRARY_PATH=/usr/lib/oracle/12.2.0.1/client/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
B-5
Appendix B
Connecting to a Database with the Tools Instant Client Package
NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_LANG
Configuring Tools Instant Client Package (from Client Media or Zip File) on Linux
and UNIX
1. Add the name of the directory containing the Instant Client files to the appropriate
shared library path LD_LIBRARY_PATH, LIBPATH or SHLIB_PATH. Remove any other
Oracle directories.
For example on Solaris in the Bourne or Korn shells:
LD_LIBRARY_PATH=/home/instantclient12_2:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
2. Add the directory containing the Instant Client files to the PATH environment
variable. If it is not set, then an absolute or relative path must be used to start the
utilities provided in the Tools package. Remove any other Oracle directories from
PATH. For example:
PATH=/home/instantclient12_2:${PATH}
export PATH
3. Set Oracle globalization variables required for your locale. A default locale will be
assumed if no variables are set. For example:
NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_LANG
B-6
Appendix B
Uninstalling Instant Client
To connect to a database you must specify the database using an Oracle Net
connection identifier. The following information uses the SQL*Loader (sqlldr) utility, but
the information applies to other utilities supplied in the Tools Instant Client package as
well.
An example using an Easy Connection identifier to connect to the HR schema in the
MYDB database running on mymachine is:
sqlldr hr/your_password@\"//mymachine.mydomain:port/MYDB\"
Net Service Names can be stored in a number of places, including LDAP. The use of
LDAP is recommended to take advantage of the new features of Oracle Database 12c
To use Net Service Names configured in a local Oracle Net tnsnames.ora file, set the
environment variable TNS_ADMIN to the directory containing the tnsnames.ora file. For
example, on UNIX, if your tnsnames.ora file is in /home/user1 and it defines the Net
Service Name MYDB2:
TNS_ADMIN=/home/user1
export TNS_ADMIN
sqlldr hr@MYDB2
sqlldr hr@MYDB3
The TWO_TASK (on UNIX) or LOCAL (on Windows) environment variable can be set to a
connection identifier. This removes the need to explicitly enter the connection identifier
whenever a connection is made in SQL*Loader or SQL*Loader Instant Client. This
UNIX example connects to the database known as MYDB4:
TNS_ADMIN=/home/user1
export TNS_ADMIN
TWO_TASK=MYDB4
export TWO_TASK
sqlldr hr
B-7
Appendix B
Uninstalling Instant Client
B-8
Index
A append to table
SQL*Loader, 9-38
ABORT_STEP parameter archive logging
Data Pump Export utility, 2-13 disabling in Data Pump jobs, 3-61
Data Pump Import utility, 3-13 enabling in Data Pump jobs, 3-61
ACCESS PARAMETERS clause archived LOBs
special characters, 17-2 restrictions on export, 2-62
access privileges archiving
Export and Import, 24-3 disabling
ACCESS_METHOD parameter effect on direct path loads, 12-17
Data Pump Export utility, 2-14 array overflows, 17-12
Data Pump Import utility, 3-14 arrays
ADD_FILE parameter committing after insert, 25-14
Data Pump Export utility atomic null, 11-6
interactive-command mode, 2-66 ATTACH parameter
ADR Data Pump Export utility, 2-14
See automatic diagnostic repository Data Pump Import utility, 3-15
ADR base attaching to an existing job
in ADRCI utility, 19-4 Data Pump Export utility, 2-14
ADR home attribute-value constructors
in ADRCI utility, 19-3 overriding, 11-7
ADRCI attributes
troubleshooting, 19-70 null, 11-5
ADRCI utility, 19-1 auditing Data Pump jobs
ADR base, 19-4 unified auditing
ADR home, 19-3 Data Pump, 1-24
batch mode, 19-6 auditing direct path loads
commands, 19-15 when using SQL*Loader, 12-13
getting help, 19-4 automatic diagnostic repository, 19-2
homepath, 19-4
interactive mode, 19-5
starting, 19-4 B
Advanced Queuing, 24-39 backslash escape character, 9-7
exporting advanced queue tables, 24-39 backups
importing advanced queue tables, 25-48 restoring dropped snapshots
aliases Import, 25-51
directory bad files
exporting, 24-38 specifying for SQL*Loader, 9-14
importing, 25-47 BAD parameter
analyzer statistics, 25-54 SQL*Loader command line, 8-4
analyzing redo log files, 22-1 SQL*Loader express mode, 13-5
ANYDATA type BADFILE parameter
using SQL strings to load, 10-54 SQL*Loader utility, 9-14
APPEND parameter BEGINDATA parameter
SQL*Loader utility, 9-43 SQL*Loader control file, 9-13
Index-1
Index
BFILEs C
in original Export, 24-38
in original Import, 25-47 cached sequence numbers
loading with SQL*Loader, 11-16 Export, 24-37
big-endian data catalog.sql script
external tables, 15-16 preparing database for Export and Import,
binary overflows, 17-12 24-2, 25-2
bind arrays catexp.sql script
determining size of for SQL*Loader, 9-50 preparing database for Export and Import,
minimizing SQL*Loader memory 24-2, 25-2
requirements, 9-53 CDBs
minimum requirements, 9-49 Oracle Data Pump support, 1-8
size with multiple SQL*Loader INTO TABLE using Data Pump to move data into, 1-8
statements, 9-54 changing a database ID, 21-3
specifying maximum size, 8-6 changing a database name, 21-6
specifying number of rows, 8-27 CHAR data type
SQL*Loader performance implications, 9-49 delimited form and SQL*Loader, 10-23
BINDSIZE parameter character fields
SQL*Loader command line, 8-6, 9-49 delimiters and SQL*Loader, 10-14, 10-23
blanks determining length for SQL*Loader, 10-28
loading fields consisting of blanks, 10-41 SQL*Loader data types, 10-14
SQL*Loader BLANKS parameter for field character overflows, 17-12
comparison, 10-31 character sets
trailing, 10-26 conversion
trimming, 10-41 during Export and Import, 24-34, 25-42
external tables, 8-32, 13-20, 15-31 eight-bit to seven-bit conversions
whitespace, 10-41 Export/Import, 24-36, 25-43
BLANKS parameter identifying for external tables, 15-9
SQL*Loader utility, 10-31 multibyte
BLOBs Export/Import, 24-36
loading with SQL*Loader, 11-16 SQL*Loader, 9-21
buffer cache size single-byte
and Data Pump operations involving Export/Import, 24-36, 25-43
Streams, 5-4 SQL*Loader control file, 9-25
BUFFER parameter SQL*Loader conversion between, 9-21
Export utility, 24-10 Unicode, 9-21
Import utility, 25-14 character strings
buffers external tables
calculating for export, 24-10 specifying bytes or characters, 15-17
specifying with SQL*Loader BINDSIZE SQL*Loader, 10-32
parameter, 9-50 character-length semantics, 9-26
byte order, 10-37 CHARACTERSET parameter
big-endian, 10-37 SQL*Loader express mode, 13-6
little-endian, 10-37 SQL*Loader utility, 9-25, 13-6
specifying in SQL*Loader control file, 10-38 check constraints
byte order marks, 10-38 overriding disabling of, 12-22
precedence CLOBs
for first primary datafile, 10-38 loading with SQL*Loader, 11-16
for LOBFILEs and SDFs, 10-39 CLUSTER parameter
suppressing checks for, 10-40 Data Pump Export utility, 2-15
BYTEORDER parameter Data Pump Import utility, 3-16
SQL*Loader utility, 10-38 collection types supported by SQL*Loader, 7-16
BYTEORDERMARK parameter collections, 7-15
SQL*Loader utility, 10-40 loading, 11-29
column array rows
Index-2
Index
3
Index
Index-4
Index
Data Pump Export utility (continued) Data Pump Export utility (continued)
FILESIZE command TRANSPORT_FULL_CHECK parameter,
interactive-command mode, 2-67 2-58
FILESIZE parameter, 2-33 TRANSPORT_TABLESPACES parameter,
filtering data that is exported 2-58
using EXCLUDE parameter, 2-31 TRANSPORTABLE parameter, 2-60
using INCLUDE parameter, 2-37 VERSION parameter, 2-62
FLASHBACK_SCN parameter, 2-33 versioning, 1-21
FLASHBACK_TIME parameter, 2-34 VIEWS_AS_TABLES parameter, 2-63
FULL parameter, 2-35 Data Pump Import utility
HELP parameter ABORT_STEP parameter, 3-13
interactive-command mode, 2-67 ACCESS_METHOD parameter, 3-14
INCLUDE parameter, 2-37 ATTACH parameter, 3-15
interactive-command mode, 2-65 attaching to an existing job, 3-15
ADD_FILE parameter, 2-66 changing name of source datafile, 3-44
CONTINUE_CLIENT parameter, 2-66 CLUSTER parameter, 3-16
EXIT_CLIENT parameter, 2-67 CONTENT parameter, 3-17
FILESIZE, 2-67 controlling resource consumption, 5-2
HELP parameter, 2-67 DATA_OPTIONS parameter, 3-17
KILL_JOB parameter, 2-68 DIRECTORY parameter, 3-19
PARALLEL parameter, 2-68 DUMPFILE parameter, 3-20
START_JOB parameter, 2-69 ENCRYPTION_PASSWORD parameter,
STATUS parameter, 2-69, 3-79 3-21
STOP_JOB parameter, 2-70, 3-80 ENCRYPTION_PWD_PROMPT parameter,
interfaces, 2-2 3-23
invoking ESTIMATE parameter, 3-24
as SYSDBA, 2-2, 3-2 estimating size of job, 3-24
job names EXCLUDE parameter, 3-24
specifying, 2-39 filtering data that is imported
JOB_NAME parameter, 2-39 using EXCLUDE parameter, 3-24
KEEP_MASTER parameter, 2-39 using INCLUDE parameter, 3-30
LOGFILE parameter, 2-40 FLASHBACK_SCN parameter, 3-26
LOGTIME parameter, 2-41 FLASHBACK_TIME parameter, 3-28
METRICS parameter, 2-42 full import mode, 3-4
NETWORK_LINK parameter, 2-43 FULL parameter, 3-29
NOLOGFILE parameter, 2-45 HELP parameter
PARALLEL parameter command-line mode, 3-30
command-line mode, 2-45 interactive-command mode, 3-77
interactive-command mode, 2-68 INCLUDE parameter, 3-30
PARFILE parameter, 2-46 interactive-command mode, 3-76
QUERY parameter, 2-47 CONTINUE_CLIENT parameter, 3-77
REMAP_DATA parameter, 2-49 EXIT_CLIENT parameter, 3-77
REUSE_DUMPFILES parameter, 2-50 HELP parameter, 3-77
SAMPLE parameter, 2-51 KILL_JOB parameter, 3-78
SCHEMAS parameter, 2-51 PARALLEL parameter, 3-78
SecureFiles LOB considerations, 1-23 START_JOB parameter, 3-79
SERVICE_NAME parameter, 2-52 STATUS, 3-79
SOURCE_EDITION parameter, 2-53 STOP_JOB parameter, 3-80
specifying a job name, 2-39 interfaces, 3-3
STATUS parameter, 2-54 JOB_NAME parameter, 3-31
syntax diagrams, 2-73 KEEP_MASTER parameter, 3-32
TABLES parameter, 2-54 LOGFILE parameter, 3-32
TABLESPACES parameter, 2-57 LOGTIME parameter, 3-33
transparent data encryption, 2-26 MASTER_ONLY parameter, 3-34
METRICS parameter, 3-34
5
Index
Index-6
Index
7
Index
Index-8
Index
9
Index
Index-10
Index
11
Index
Index-12
Index
13
Index
Index-14
Index
15
Index
Index-16
Index
17
Index
Index-18
Index
19
Index
Index-20
Index
21
Index
Index-22
Index
23
Index
Index-24