Netezza Data Loading Guide
Netezza Data Loading Guide
3
IBM Netezza Data Loading Guide
Revised: June 16, 2011
20525 Rev. 2
Note: Before using this information and the product that it supports, read the information in Notices and Trademarks on
page D-1.
Copyright IBM Corporation 2011.
US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM
Corp.
iii
Table of Contents
Preface
1 Overview
Data Loading Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
Data Loading Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
New Decimal Delimiter Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
2 External Tables
About External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
Privileges Required . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Displaying External Table Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Log Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Parsing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
Backing Up and Restoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Transient External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Explicit Schema Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Implicit Schema Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Exporting Data Using Transient External Tables . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Remote Transient External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Supported Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Integer Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Fixed-Point Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Floating-Point Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Character Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Time Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Best Practices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
Transient External Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
Fixed-Length Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Standard Unloading and Reloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
iv
Back up and Restore a User Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
3 External Table Options
Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
Option Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
BoolStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Compress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
CRinString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
CtrlChars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
DataObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
DateDelim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
DateStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
DecimalDelim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Delimiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
EscapeChar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
FillRecord. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
IgnoreZero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
IncludeZeroSeconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
LogDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
MaxErrors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
MaxRows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
NullValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
QuotedValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
RecordDelim. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
RecordLength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
RemoteSource. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
RequireQuotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
SkipRows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
SocketBufSize. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
TimeDelim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
TimeRoundNanos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
TimeStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
TruncString. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Y2Base. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
v
Option Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Counting Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Handling Bad Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Delineating Input Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Matching Input Fields to Table Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Using String and Non-string Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Handling the Absence of a Value. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14
Enabling Load Continuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Handling Legal Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Session Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
4 Using nzload
How the nzload Command Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
Protection and Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
Concurrency and Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Program Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Using the nzload Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Additional Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Using a Control File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
Configuration File Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
5 Unloading Data
Unloading Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
Unloading Data to a Remote Client System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
6 Using Fixed-Length Format
Formatting Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
Fixed-Length Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
Data Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Format Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
New Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Changed Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Unsupported Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Default Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Layout Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
vi
Building the Fixed-Length Format Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
End-of-Record. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Record Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Skipping Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Temporal Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Numeric Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
Logical Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Null Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Appendix A: Examples and Grammar
The nzload Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
Specifying nzload Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
Using Named Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
Sample nzload Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
Reference Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
Decimal Delimiter Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
SQL Grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5
Fixed-Length Format Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7
Appendix B: Troubleshooting
Tips for Successful Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1
Create Your Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1
Determine Your Data Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1
Consider the Load Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
Run the Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
Troubleshoot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
Handle Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
Validate the Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
Generate Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
Test Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
nzload Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
Reporting Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
Understanding nzload Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
Appendix C: Option Names
Specifying Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1
Appendix D: Notices and Trademarks
Notices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-1
Rev. -vii
Trademarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-3
Open Source Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-4
Regulatory and Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-6
Index
-viii Rev.
ix
Preface
The IBM Netezza Data Loading Guide describes the functionality for data loading.
Audience for This Guide
The IBM Netezza Data Loading Guide is written for administrators using data loading
features.
Purpose of This Guide
This guide contains the following information:
Symbols and Conventions
This guide uses the following typographical conventions:
Italics for emphasis on terms and user-defined values such as user input
Upper case for SQL commands; for example INSERT, DELETE
Bold for command line input; for example, nzsystem stop
Topics See the following
Introduction to Data Loading Concepts and Terms Chapter 1, Overview
How to use External Tables Chapter 2, External Tables
External Table options to use, and how the sys-
tem processes them
Chapter 3, External Table Options
Details on the nzload command Chapter 4, Using nzload
Details on unloading data Chapter 5, Unloading Data
Details on the Fixed-Length format Chapter 6, Using Fixed-Length
Format
Examples of commands, format, and usage Appendix A, Examples and
Grammar
Command and Task Tips Appendix B, Troubleshooting
How to enter external table options on the com-
mand line, in a control file, or in a SQL command
Appendix C, Option Names
x
If You Need Help
If you are having trouble using the IBM Netezza appliance, you should:
1. Retry the action, carefully following the instructions given for that task in the
documentation.
2. Go to the IBM Netezza Knowledge Base at https://knowledge.netezza.com. Enter your
support username and password. You can search the knowledge base or the latest
updates to the product documentation. Click Netezza HelpDesk to submit a support
request.
3. If you are unable to access the Netezza Knowledge Base, you can also contact Netezza
Support at the following telephone numbers:
North American Toll-Free: +1.877.810.4441
United Kingdom Free-Phone: +0.800.032.8382
International Direct: +1.508.620.2281
Refer to your Netezza maintenance agreement for details about your support plan choices
and coverage.
Comments on the Documentation
We welcome any questions, comments, or suggestions that you have for the IBM Netezza
documentation. Please send us an e-mail message at netezza-doc@wwpdl.vnet.ibm.com
and include the following information:
The name and version of the manual that you are using
Any comments that you have about the manual
Your name, address, and phone number
We appreciate your comments on the documentation.
1-1
C H A P T E R 1
Overview
Whats in this chapter
Data Loading Components
Data Loading Formats
New Decimal Delimiter Option
This chapter provides general information about the data loading methods now available.
Note that loading data takes a significant allocation of system resources, which may affect
performance.
Data Loading Components
Within the IBM
Netezza
environment, data loading means simply to transfer data to the
IBM
Netezza
appliance. Within this framework, there are a number of components:
External Tables These are tables stored as flat files on the host or client systems and
not in the Netezza appliance database. These tables can be used to load data into the
Netezza appliance. For more information, see Chapter 2, External Tables.
nzload This is a command that provides an easy method for using external tables and
getting data into the Netezza appliance. For more information, see Chapter 4, Using
nzload.
Format Options These are options for formatting the data load to and from external
tables. Since data comes in different forms, Netezza provides different ways of setting
up the load. For more information, see Chapter 4, Using nzload, and Chapter 6,
Using Fixed-Length Format.
Backup and Restore There are different methods for doing backups and restores to
transfer data between systems. One method is to create external tables and use nzload,
described in Chapter 2, External Tables, and Chapter 4, Using nzload. For more
information on backups and restores, see Backing Up and Restoring Databases in
the IBM Netezza System Administrators Guide.
nz_migrate This is a separate tool, not part of the Netezza software package. This
utility is a script that can migrate (copy) a database/table from one Netezza appliance
to another, or make a copy of a database/table on the same server. Run the following
command to see the help explanation text for the command, showing syntax and usage:
nz_migrate -?
1-2 20525 Rev. 2
Netezza Data Loading Guide
Data Loading Formats
In the database environment, there is always the need to load data from external sources
such as files, pipes, or sockets into a table. These external sources have a variety of formats
to represent each of the data types individually, and together as records or rows.
When you load data from database-like applications, such as an RDBMS, a Web-server, or
some other structured data-store, they may export data into files or streams in different for-
mats. The following formats are used with the Netezza environment:
Text-Delimited The method commonly used for data loading is Text-Delimited format,
where every value of a field or column ends with a delimiter, and each set of these val-
ues of rows or records has an end-of-record delimiter, typically a new-line character.
Previously, this has been the preferred method used for loading data into external
tables.
Fixed-Length The new format, which allows for a more expressive form of external
table definition, thus increasing the kinds of data formats and layouts that can be
loaded.
Compressed Binary This Netezza proprietary format compresses the data before a
backup or restore to benefit performance. It typically yields smaller data files, retains
information about the Netezza appliance topology, and thus is often faster to backup
and restore. Compress the data before loading, and uncompress before unloading. For
more information, see the IBM Netezza System Administrators Guide.
New Decimal Delimiter Option
In the 6.0 release, a new option allows you to specify a comma as a decimal separator, in
addition to the period (the default value). This new option is available for external tables
and for nzload, to help you to directly load data without extra pre-load conversion.
For the text-delimited format, and for unloading data, this option is available only at
the table level.
For the fixed-length format, you can specify this option at the column level, making it
possible to have a mix of comma and decimal separators.
The option is available for the following data types, for both text-delimited and fixed-length
formats:
Numeric
Float
Double
Time
Timetz
Timestamp
Option usage for each data type is explained in each particular section describing that data
type. For examples of how to use this new option, see Appendix A, Examples and
Grammar.
2-1
C H A P T E R 2
External Tables
Whats in this chapter
About External Tables
Command Syntax
Transient External Tables
Supported Data Types
Restrictions
Best Practices
Examples
This chapter describes external tables, as well as best practices and restrictions for using
them. For options for using external table, see Chapter 3, External Table Options. For
examples of how to use external tables, see Appendix A, Examples and Grammar.
In the Netezza environment, there are the following types of tables:
System tables Stored on the host
User tables Stored on the SPUs
External tables Stored as flat files on the host or client systems
About External Tables
An external table allows Netezza to treat an external file as a database table. An external
table has a definition (a table schema), but the actual data exists outside of the Netezza
appliance database. External tables can be used to access files which are stored on the
Netezza host server or, in the case of a remote external table, Netezza can treat a file on a
client system as an external table (see REMOTESOURCE option).
After you have created the external table definition, you can use INSERT INTO statements
to load data from the external file into a database table, or SELECT FROM statements to
query the external table.
2-2 20525 Rev. 2
Netezza Data Loading Guide
Privileges Required
To create an external table, you must have LIST privilege on the database and CREATE
EXTERNAL TABLE administration privilege. The database user who issues the CREATE
EXTERNAL TABLE command owns the resultant table. The operating system user must
have proper permission on the data object (READ permission for loading, WRITE permis-
sion for unloading).
Displaying External Table Information
To display information about external tables, use the \d command from the nzsql prompt.
To list all external tables found in the current database, use the \dx command. For
example:
dev(admin)=> \dx
List of relations
Name | Type | Owner
-------------+-----------+-------
extlineitem | ext table | admin
xlineitem | ext table | admin
(2 rows)
To list the options defined in an external table, use the \d <external_tablename> com-
mand. For example:
dev(admin)=>\d extlineitem
Log Files
By default, loading errors go into the following log files:
nzbad <tablename>.<dbname>.nzbad
nzlog <tablename>.<dbname>.nzlog
You can override the default by specifying a file for errors to go by using the following with
a filename:
bf <filename> for nzbad
lf <filename> for nzlog
Usage
Use external tables to do the following:
Load data into the Netezza appliance from an external table and structure the loading
operation to manipulate the data by using casts, joins, dropping columns, and so on.
Store data outside the Netezza appliance, either to transfer to another application, or
as a table backup. See Backing Up and Restoring on page 2-4.
Create an external table and use data from an external table as part of a SQL query.
The power of external tables is that the entire Extraction-Transformation-Loading (ETL) pro-
cess is mapped to plain SQL. Since a SQL-based ETL process can be initiated/executed
from any SQL client that can talk to the Netezza appliance, it reduces or avoids the require-
ment of specialized ETL tools.
20525 Rev. 2 2-3
About External Tables
To load an external data file into the Netezza appliance as an external table, you can do
either of the following:
Use a FROM clause of a SELECT SQL statement/command, like any normal table.
Use a WHERE clause of an UPDATE or DELETE SQL statement.
To unload an external table into an external data file, use the table as the target table in
any of the following SQL statements:
INSERT SQL
SELECT INTO SQL
CREATE TABLE AS SELECT SQL
All references to columns in the external table can be complex SQL expressions used for
the transformation of external data during a load/unload process. For more information, see
Restrictions on page 2-13.
Parsing
For loads, the sequence of rows are parsed one-by-one from the external data file, and con-
verted into internal records of the external table. There could be errors during the parsing of
each row, or each column. For example, there could be errors in identifying the column
value itself, as in the case of a missing delimiter. Or there could be errors during the con-
version from external format to internal records of the external table, such as alphabets
mentioned for an integer column in Text-Delimited format.
Each error is logged in detail in an nzlog file, and bad rows are logged in an nzbad file.
These files help user to identify bad rows in the external data file and correct them for
reloading. Depending on the load options of the external table in use, each bad row would
either cause the row to be skipped, or the entire load to be aborted. Similarly, each bad col-
umn of a bad row could cause the rest of the row to be ignored, or if possible to recover, the
load could continue to parse subsequent columns of the same row.
Note that if there is an error in the project-expression on the external table columns, then
the entire load is aborted and the transaction rolled back. Errors of this nature are not
logged in nzbad or nzlog files, as they are outside of the scope of the external table load
mechanism. Once the processing reaches the normal SQL engine, the external table is
treated as if it is a normal table.
Unlike an external table that has external rows in an ordered sequence, normal user tables
have no implicit row order other than hidden rowid columns. So there is no way for a user
not using rowids to identify the bad row in a SQL engine. In this case, the Netezza system
just returns an error that a particular column caused an error, without identifying the bad
row. It is as if the query was selecting from a normal table and inserting into another nor-
mal table, with some row that caused the error during insertion.
2-4 20525 Rev. 2
Netezza Data Loading Guide
Backing Up and Restoring
You can use external tables to back up a table in the system database. While the Netezza
appliance database backup utility, nzbackup, enables you to create backups of the entire
database, the external table backup method allows you to create a backup of a single table,
with the ability to later restore it to the database as needed.
To back up table data using an external table, create external table definitions for each
user table and then use SQL to insert into the external table.
When you restore table data, create a table definition (if it does not exist) and then use
SQL to insert into the table from an external table.
Command Syntax
The CREATE EXTERNAL TABLE command has the following syntax.
To create an external table based on another table:
CREATE EXTERNAL TABLE table_name
SAMEAS table_name
USING external_table_options
To create an external table by defining columns:
CREATE EXTERNAL TABLE table_name
({ column_name type
[ column_constraint [ ... ] ]} [, ... ]
)
[USING external_table_options]
Note: Although you can specify column constraints, they are ignored, and must be defined
elsewhere. For more information, see Column Constraint Rules for Empty Strings on
page 2-10.
Transient External Tables
Transient external tables (TET) provide a way to define an external table that exists only for
the duration of a single query. Transient external tables have the same capabilities and lim-
itations as normal external tables. A special feature of a TET is that the schema does not
have to be defined when the TET is used to load data into a table or when the TET is cre-
ated as the target of a SELECT statement.
Syntax
The following is the syntax for a TET:
INSERT INTO <table> SELECT <column_list | *>
FROM EXTERNAL 'filename' [(schema_definition)]
[USING (external_table_options)];
CREATE EXTERNAL TABLE 'filename' [USING (external_table_options)]
AS select_statement;
20525 Rev. 2 2-5
Transient External Tables
SELECT <column_list | *> FROM EXTERNAL 'filename' (schema_definition)
[USING (external_table_options)];
Explicit Schema Definition
The schema of a transient external table can be explicitly defined in a query. When defined
this way, the schema definition is the same as is used when defining a schema using CRE-
ATE TABLE.
SELECT x, y, NVL(dt, current_date) AS dt FROM EXTERNAL '/tmp/test.txt'
( x integer, y numeric(18,4), dt date ) USING (DELIM ',');
The explicit schema definition feature can be used to specify fixed length formats.
SELECT * FROM EXTERNAL '/tmp/fixed.txt' ( x integer, y numeric(18,4),
dt date ) USING (FORMAT 'fixed' LAYOUT (bytes 4, bytes 20, bytes 10));
The SAMEAS keyword can also be used to specify that the schema of the external table is
identical to some other table that currently exists in the database.
SELECT * FROM EXTERNAL '/tmp/test.txt' SAMEAS test_table
USING (DELIM ',');
Implicit Schema Definition
If the schema is not explicitly defined, the schema for a transient external table is deter-
mined based on the query being executed. When a TET is used as a data source for an
INSERT statement, the external table will take on the schema of the target table.
The external table in this INSERT statement takes on the schema of the target table. The
columns in the external data file must be in the same order as the target table, and every
column in the target table must also exist in the external table data file.
INSERT INTO target SELECT * FROM external '/tmp/data.txt'
USING (DELIM '|');
Exporting Data Using Transient External Tables
A transient external table can also be used to export data out of the database. In this case
the schema of the external table is based on the query being executed.
Example:
CREATE EXTERNAL TABLE '/tmp/export.csv' USING (DELIM ',') AS
SELECT foo.x, bar.y, bar.dt FROM foo, bar WHERE foo.x = bar.x;
Remote Transient External Tables
A session connected to Netezza using ODBC, JDBC, or OLE DB from a client system can
import and export data using a remote transient external table, which is defined by using
the REMOTESOURCE option in the USING clause.
For example, the following SQL statement loads data from a file on a Windows system into
a TEMP table on Netezza, using an ODBC connection.
CREATE TEMP TABLE mydata AS SELECT cust_id, upper(cust_name) as name
from external 'c:\customer\data.csv' (cust_id integer, cust_name
varchar(100)) USING (DELIM ',' REMOTESOURCE 'ODBC');
2-6 20525 Rev. 2
Netezza Data Loading Guide
Remote external table loads work by sending the contents of a file from the client system to
the Netezza server where the data is then parsed. This method minimizes CPU usage on
the client system during a remote external table load.
Supported Data Types
Table 2-1 describes the Netezza supported data types for external tables. For more infor-
mation about the specific data types, see the IBM Netezza Database Users Guide.
Table 2-1: Supported Data Types
Data Type Example Description
byteint
smallint
integer
bigint
120
0
256
1290985
See Integer Data Types on page 2-7.
numeric
decimal
-99.56
123.679
See Fixed-Point Data Types on
page 2-7.
real
double precision
81293.35 See Floating-Point Data Types on
page 2-8.
char (n) salary See Character Strings on page 2-10
and Column Constraint Rules for Empty
Strings on page 2-10.
varchar (n) I am John See Character Strings on page 2-10
and Column Constraint Rules for Empty
Strings on page 2-10.
boolean true An ASCII string that contains any of the
following values:
[true|false]|[yes|no]|[1|0]|[t|f]|[y|n]
See BoolStyle on page 3-3.
date 2002-02-04 The date is an exact four-byte data type.
The system recognizes a range of dates
composed of year, month, and day. See
DateStyle on page 3-5.
time 01:59:45
23:00:01
See Time on page 2-11.
time with time zone 01:15:33 -05 See Time with time zone on
page 2-12.
timestamp 2002-02-04 01:15:33 See Timestamp on page 2-12.
20525 Rev. 2 2-7
Supported Data Types
Integer Data Types
Integer types are exact data types. The system generates an error if an input fields value
cannot be expressed without loss of accuracy in the target table.
Table 2-2 describes the integer syntax.
Table 2-3 describes the integer handling.
Fixed-Point Data Types
The fixed-point data types are exact data types. The system generates an error if an input
fields value cannot be expressed without loss of accuracy in the target table or database.
Table 2-4 lists and describes the fixed-point syntax.
Table 2-2: Integer Description
Syntax [+|-]<digit>
Description Optional leading sign
Unlimited leading zeros
At least one decimal digit
Limitation No thousands-separator commas
No support for exponential notation
Table 2-3: Integer Handling
SQL Alias Representation Values
byteint int1 1 byte, signed min value = -128
max value = 127
smallint int2 2 bytes, signed min value = -32768
max value = 32767
integer int or int4 4 bytes, signed min value = 2147483648
max value = 2147483647
bigint int8 8 bytes, signed min value = 9223372036854775808
max value = 9223372036854775807
Table 2-4: Fixed-Point Description
Syntax [+|-]<digit>[.[<digit>]]
[+|-].<digit>
[+|-]<digit>[,[<digit>]]
[+|-],<digit>
Description Optional leading sign
Unlimited leading zeros
At least one decimal digit
2-8 20525 Rev. 2
Netezza Data Loading Guide
The syntax of fixed-point values is the same as the syntax of integer values with the addi-
tion of an optional decimal digit that can occur anywhere from before the first decimal
digit to after the last decimal digit.
The optional decimal point can be followed by zero or more decimal digits, if there is at
least one decimal digit before the decimal point; followed by one or more decimal digits if
there are no decimal digits before the decimal point.
If there is no explicit decimal point, the system assumes a decimal point immediately fol-
lowing the last decimal digit.
You can also specify a comma as a separator, using it like the decimal digit. For examples
of how to do this, see Decimal Delimiter Examples on page A-4.
Table 2-5 describes the fixed-point precision and representation:
The following result in system errors:
Precision Having more decimal digits before the decimal point than the declaration
allows (P-S).
Scale Having more decimal digits following the decimal point than the declared scale
(S).
Note: Because fixed-point is an exact data type, when there are too many digits following
the decimal point, the system does not round the number.
Floating-Point Data Types
The floating-point data types are approximate data types. The system rounds the signifi-
cand if more precision is present that it can represent.
Table 2-6 lists the floating point syntax.
Limitation No thousands-separator commas
No support for exponential notation
Table 2-5: Fixed-Point Precision
Precision
Representation 4 bytes, signed 8 bytes, signed 16 bytes signed
Table 2-4: Fixed-Point Description
P 9 9 P 18 < 18 P 38 <
Table 2-6: Floating-Point Description
Syntax [ '+' | '-' ] <digit> [ '.' [ <digit> ] ] [( 'e' | 'E' ) [ '+' | '-' ] <digit> ]
[ '+' | '-' ] '.' <digit> [ ( 'e' | 'E' ) [ '+' | '-' ] <digit> ]
[ '+' | '-' ] <digit> [ ',' [ <digit> ] ] [( 'e' | 'E' ) [ '+' | '-' ] <digit> ]
[ '+' | '-' ] ',' <digit> [ ( 'e' | 'E' ) [ '+' | '-' ] <digit> ]
20525 Rev. 2 2-9
Supported Data Types
The syntax of fixed-point values is the same as the syntax of fixed-point values augmented
by an optional trailing exponent specification.
The optional decimal point can be followed by zero or more decimal digits, if there is at
least one decimal digit before the decimal point; followed by one or more decimal digits if
there are no decimal digits before the decimal point.
If there is no explicit decimal point, the system assumes a decimal point immediately fol-
lowing the last decimal digit.
You can also specify a comma as a separator, using it like the decimal digit. For examples
of how to do this, see Decimal Delimiter Examples on page A-4.
The optional power of ten exponent is e (lower or uppercase), with an optional sign,
non-empty sequence of decimal digits.
Table 2-7 describes the floating-point precision and representation:
The following result in system errors:
Overflow If the field exceeds the largest representable value (maximal exponent and
maximal significand)
Underflow If the number is too small to approximate in the denormalized range
Description Optional leading sign
Unlimited leading zeros
At least one decimal digit
Decimal point or comma, if needed
Optional e or E introducing an exponent followed by an optional sign
and one or more digits
Limitation No thousands commas
No support for loading exceptional values (Not a Number (NaNs) and
infinities)
Table 2-7: Floating-Point Precision
Type Real Double
Representation 4 byte IEEE floating
point
8 byte IEEE floating
point
Approx. largest normalized value 3.40e+38 1.79e+308
Approx. smallest normalized value 1.18e-38 3.40e-308
Approx. smallest denormalized
value
7.01e-46 2.50e-324
Table 2-6: Floating-Point Description
2-10 20525 Rev. 2
Netezza Data Loading Guide
Character Strings
Char(n)/nchar(n) are character strings of length n. Varchar(n)/nvarchar(n) are vari-
able-length character strings of maximum length n. A valid character is between the ASCII
values 32 to 255.
System Handling of Characters
Table 2-8 describes how the system handles char, nchar, varchar, and nvarchar characters.
Column Constraint Rules for Empty Strings
For all char(n) and varchar(n) data types, the result of inserting an empty string and filling
in missing data values depends upon whether the columns are declared null-able (default)
or not null-able (declared with constraint not null). Table 2-9 describes the different cases.
Table 2-8: Character Handling
Char, Nchar, Varchar,
and Nvarchar
How Handled
Padding Char/Nchar Padded to normal length with spaces
Varchar/Nvarchar Not padded
Truncation If the data is longer than the field:
The system writes the record to the nzbad file.
The system writes the records and column number to the nzlog
file.
Note that you can turn on automatic truncation with the -trunc-
String option.
Note: If you use this option for Unicode character data, it could
truncate combined NFC characters if they exceed the specified
column length. The switch does not attempt to keep any grapheme
clusters; it truncates data as necessary to fit in the specified
column size.
Table 2-9: Column Constraining Rule for Empty Strings
Data Type
Column
Constraint
Null Token Exists
Null Token
Does Not Exist
null token "" (empty string) "" (empty string)
Char/Nchar
Varchar/Nvarchar
NULL NULL char/nchar: space
filled.
varchar/nvarchar: zero
length string.
NULL
NOT NULL ERROR char/nchar:: space
filled.
varchar/nvarchar: zero
length string.
ERROR
20525 Rev. 2 2-11
Supported Data Types
If the record contains fewer data values than the actual columns defined in the tables
schema, the system writes an error to the nzlog file and discards the record. To override this
behavior, use the -fillRecord option, which applies to the entire load operation.
The -fillRecord option tells the system to use a null value in place of any missing fields.
You can use this option as long as the columns whose values are missing allow nulls. If
these columns are defined as not null, the system writes an error to the nzlog file and dis-
cards the record. You must resolve this conflict by changing the schema to allow null values
or modifying the data file to include a valid non-null value.
Time Data Types
The system supports time, timestamp, and time with time zone. These data types are exact
types, stored to the accuracy of (1/1,000,000 of a second).
You can also specify a comma as a separator in time data types, using it like the decimal
digit. For examples of how to do this, see Decimal Delimiter Examples on page A-4.
Time
The Netezza appliance time is an exact, eight-byte data type stored internally as a signed
integer representing the number of microseconds since midnight.
The system accepts both 24 hour and 12 hour AM/PM time values. You can specify the for-
mat with the -timeStyle option. The default is the 24-hour format.
The time format consists of five components: hour, minute, second, fraction of a second,
and AM/PM token. You must have hour and minute; second and fraction of second are
optional. The AM or PM token is required for 12 hour and not allowed for 24-hour format.
The time options have the following formats. Note that the delimited examples use the
default time delimiter, which is a colon (:).
12-hour delimited HH:MM:SS.FFF [AM | PM] (such as 10:12 PM, or 1:02:46.12345
AM)
12-hour undelimited HHMMSS.FFF [AM | PM] (such as 1012 PM or 010246.12345
PM)
24-hour delimited HH:MM:SS.FFF (such as 19:15 or 1:15:00.1234)
24-hour undelimited HHMMSS.FFF (such as 1915 or 10246.12345 PM)
In these formats, note the following:
Bool, Date,
Int (1,2,4,8),
Numeric(),
Float (4,8), Time,
Timestamp, Timetz
NULL NULL NULL NULL
NOT NULL ERROR ERROR ERROR
Table 2-9: Column Constraining Rule for Empty Strings
Data Type
Column
Constraint
Null Token Exists
Null Token
Does Not Exist
null token "" (empty string) "" (empty string)
1Sec
2-12 20525 Rev. 2
Netezza Data Loading Guide
HH is a one- or two-digit hour value from 112 in the 12-hour notation or 124 in the
24-hour notation. In undelimited format, you must specify two digits such as 01, 02,
and so on.
MM is a one- or two-digit minute value from 160. In undelimited format, you must
specify two digits such as 01, 02, and so on.
SS is a one- or two-digit seconds value from 160. In undelimited format, you must
specify two digits such as 01, 02, and so on.
FFF specifies a fraction of a second. If you specify a fractional value, you must precede
it with a decimal point. If the value can be stored without loss of precision, it is
accepted. If the value cannot be stored without loss of precision, it is rejected. You can
use the -timeRoundNanos option to allow rounding when the full precision of any frac-
tional digits cannot be preserved, as described in Using the -timeRoundNanos
Option on page 10-22.
Time with time zone
The Netezza time with time zone (timetz) is an exact data type stored in 12 bytes. Inter-
nally the Netezza appliance stores it as time and an offset. The stored offset has the same
resolution as time even though the input is restricted to a one-minute resolution.
Syntax The input format of time with time zone value is identical to that of simple time
followed by a trailing signed offset from Coordinated Universal Time (UTC formerly
Greenwich Mean Time GMT). The time section must conform to the -timeStyle and
-timeDelim in effect during the nzload job.
You must specify a signed, time-zone hour, whereas the time-zone minute is optional. If
you use the minute, separate it with a colon (the default timeDelim character).
Note: You cannot use named time zones, such as EST.
Table 2-10 lists the time with time zone syntax.
Errors The following are time and range errors:
Time The same errors as the time data type.
Range The time zone offset is restricted to -13:00 to +12:59.
Timestamp
The Netezza appliance timestamp is an exact data type stored as eight bytes. The stored
offset has the same resolution as the time data type.
Syntax The input format of a timestamp value is a date value followed by a time value.
You can have optional spaces between the date and the time. The date section must con-
form to the -dateStyle and -dateDelim in effect during the load job.
Table 2-10: Time With Time Zone Description
time with time zone <time> ( '+' | '-' ) <digit> [ <digit> [ ':' <digit> [ <digit> ] ] ]
1S
1S
20525 Rev. 2 2-13
Restrictions
Table 2-11 lists the timestamp syntax.
Errors The following are date and time errors:
Date The same errors as the date data type.
Time The same errors as the time data type.
Restrictions
The following are restrictions and considerations for use with external tables:
Always consider your source and target systems, and whether the data is properly for-
matted for loading.
To insert and drop an external table, use the INSERT and DROP commands.
You cannot delete, truncate, or update an external table. After creating an external
table, you can alter as well as drop the table definition. (Dropping an external table
deletes the table definition, but it does not delete the data file that is associated with
the table.) You can select the rows in the table, as well as insert rows into the table
(following a table truncation).
While you cannot select from more than one external table at a time in a query or sub-
query, you can move data from one external table to another, such as using SELECT
and INSERT. The system displays an error if you incorrectly specify multiple external
tables in a SQL query, or if you reference the same external table more than once in a
query:
*ERROR: Multiple external table references in a query not
allowed*
To specify more than two external tables, load the data in into a non-external table and
specify this table in the query.
You cannot perform a union operation involving two or more external tables.
You cannot back up external tables using the nzbackup command, and attempting to
do so displays a warning message.
You cannot use the limit clause with compressed external tables.
There is a maximum limit of 300 concurrent loads for multiple loads.
Best Practices
When specifying external tables, note the following:
An external table reference can appear as the source table of a SELECT FROM state-
ment. Note that a transient external table reference in a SELECT FROM clause infers
its shape from the preceding INSERT INTO clause.
Table 2-11: Timestamp Description
timestamp <date> <time>
2-14 20525 Rev. 2
Netezza Data Loading Guide
In Netezza Release 4.6 and later, the system catalog datatypes TEXT and NAME are
treated as NVARCHAR. If these types are used in the table that is referenced in the
select_clause, include the encoding option in the CREATE EXTERNAL TABLE com-
mand to specify internal encoding. Otherwise you could receive the error LATIN9
encoding cannot be specified with NCHAR/NVARCHAR column definitions. For
example:
create external table '/tmp/ext1' using (encoding 'internal') as
select username from _t_user;
The CREATE EXTERNAL TABLE AS statement supports an optional table name. If you
do not provide a table name, the table is transient, which means the external table def-
inition does not persist in the system catalog. If you supply a table name, the external
table becomes a named object in the system catalog.
The USING clause in the inline external statement is optional. If you omit it, the result-
ing external table has the default settings. Note that you must specify the USING
clause in the CREATE EXTERNAL TABLE SAMEAS statement, because the SAMEAS
table might be another external table.
When you insert data into an external table that references an existing data file, the
system truncates the file before inserting the external tables data.
You cannot use external tables in complex SQL statements. If the statement is not sup-
ported, the system displays an error.
Before you reload an external table, verify that the destination table in the database is
empty or that it does not already contain the rows in the external table that you are about to
reload. If the destination table already contains the rows contained in the external table,
unintended problems may occur. These problems could also occur if you accidentally
reload the external table more than once.
For example, loading a text-format external table into a destination table that already con-
tains the same data creates duplicate data in the database. The rows will have unique row
IDs, but the data will be duplicated. To fix this problem, you would have to delete the
duplicate rows or truncate the database table and reload the external table again (but only
once).
If you load a compressed binary format external table into a destination table that already
has the same rows, you will create duplicate rows with duplicate row IDs in the database
table. The system restores the rows using the same row IDs saved in the compressed binary
format file.
Duplicate row IDs can cause incorrect query results and could lead to problems in the data-
base. You can check for duplicate rowIDs using the rowid keyword as follows:
SELECT rowid FROM employee_table GROUP BY rowid HAVING count(rowid)
>1;
If the query returns multiple rows that share the same row ID, truncate the database table
and reload the external table (but only once).
After you load data from an external table into a user table, you should run GENERATE
STATISTICS to update the statistics for the user table. This improves the performance of
queries that run against that table.
20525 Rev. 2 2-15
Examples
Examples
The following examples show how to use the CREATE EXTERNAL TABLE command.
To create an external table, enter:
CREATE EXTERNAL TABLE ext_orders(ord_num INT, ord_dt
TIMESTAMP)USING(dataobject('/tmp/order.tbl') DELIMITER '|');
To create an external table that uses column definitions from an existing table, enter:
CREATE EXTERNAL TABLE demo_ext SAMEAS emp USING (dataobject
('/tmp/demo.out') DELIMITER '|');
To create an external table and specify the escape character (\), enter:
CREATE EXTERNAL TABLE extemp SAMEAS emp USING( dataobject
('/tmp/extemp.dat') DELIMITER '|' escapechar '\');
To unload data from your database into a file by using an insert statement, enter:
INSERT INTO demo_ext SELECT * FROM weather;
To drop an external table, enter:
DROP TABLE extemp
The system removes only the external tables schema information from the system cat-
alog. The file defined in the dataobject option remains unaffected in the filesystem.
To back up by creating an external table, enter:
CREATE EXTERNAL TABLE '/path/extfile' USING (FORMAT 'internal'
COMPRESS true) AS SELECT * FROM source_table;
To restore from an external table, enter:
INSERT INTO t_desttbl SELECT * FROM EXTERNAL'/path/extfile'
USING(FORMAT 'internal' COMPRESS true);
Transient External Table
The following examples show how to specify the shape of a transient external table:
To take on the schema of the target table:
insert into <table> select * from external '<file>' [USING(...)]
To take on the schema of the query:
create external table '<file>' [USING (...)] as <QUERY>
To take on the schema of <table>:
select * from external '<file>' sameas <table> [USING(...)]
To take on the schema as defined:
select * from external '<file>' (schema) [USING(...)]
To take on the schema as defined:
create external table '<file>' (schema) [USING(...)]
To make the source file FIXED format with the schema as defined:
select * from external '<file>' (schema) USING (FORMAT 'FIXED'
LAYOUT (...))
2-16 20525 Rev. 2
Netezza Data Loading Guide
To make the source file FIXED format and the table takes on the schema of the target
table:
insert into <table> select * from external '<file>' USING (FORMAT
'FIXED' LAYOUT (...))
The following example will not work, because you cannot unload data into a FIXED for-
mat external table:
create external table '<file>' [(schema)] USING (FORMAT 'FIXED'
LAYOUT ... )
Fixed-Length Format
The following examples show how to use Fixed-Length format with external tables:
To load data in fixed format, enter:
INSERT INTO t SELECT * FROM EXTERNAL /data/fixed USING ( FORMAT
FIXED LAYOUT (BYTES 20, REF BYTES 3, BYTES @2) )
To load data with different date/time delimiters for different zones, enter:
INSERT INTO t SELECT * FROM EXTERNAL /data/fixed USING ( FORMAT
FIXED LAYOUT ( YMD - BYTES 15, DMY / BYTES 15 ) )
To load spatial data (binary data into VARCHAR), enter:
INSERT INTO t SELECT * FROM EXTERNAL /data/fixed USING ( FORMAT
FIXED CTRLCHARS true LAYOUT ( BYTES 100, REF BYTES 4, BYTES @2) )
To load fixed format data with record-length and no record-delimiter, enter:
INSERT INTO t SELECT * FROM EXTERNAL /data/fixed USING ( FORMAT
FIXED RECORDDELIM RECORDLENGTH @1 LAYOUT( REF BYTES 2, BYTES
120, REF BYTES 2, BYTES @3) )
To load data with different NULLIF clauses for different zones, enter:
INSERT INTO t SELECT * FROM EXTERNAL /data/fixed USING ( FORMAT
FIXED LAYOUT ( BYTES 15 NULLIF 2000-10-10, BYTES 2 NULLIF & =
12) )
To load data with NULLIF clauses referring other zones, enter:
INSERT INTO t SELECT * FROM EXTERNAL /data/fixed USING ( FORMAT
FIXED LAYOUT ( REF BYTES 2, BYTES @1 NULLIF @1 = -1, REF BYTES 4,
BYTES 100 NULLIF &&3 = null ) )
Standard Unloading and Reloading
The following examples unload and load a user table to an external table in text-delimited
format. Unloading is not supported for Fixed-Length format.
To create a text-format external table, enter:
CREATE EXTERNAL TABLE extemp SAMEAS emp USING (DATAOBJECT
('/tmp/emp.dat'));
To unload data in user table EMP to the external table EXTEMP, enter:
INSERT INTO extemp SELECT * FROM emp;
To load data into user table EMP from external table EXTEMP, enter:
20525 Rev. 2 2-17
Examples
TRUNCATE TABLE emp;
INSERT INTO emp SELECT * FROM extemp;
Back up and Restore a User Table
The following examples show how to back up and restore the user table EMP to an external
table in binary compressed format.
To create a compressed binary format external table definition called emp_backup for
the table emp, enter:
CREATE EXTERNAL TABLE emp_backup SAMEAS emp USING (
DATAOBJECT ('/tmp/emp.bck')
COMPRESS true
FORMAT 'internal');
To back up the emp table data into emp_backup, enter:
INSERT INTO emp_backup SELECT * FROM emp;
To restore the emp table from emp_backup, make sure that the emp table is empty and
enter:
TRUNCATE TABLE emp;
INSERT INTO emp SELECT * FROM emp_backup;
2-18 20525 Rev. 2
Netezza Data Loading Guide
3-1
C H A P T E R 3
External Table Options
Whats in this chapter
Options
Option Details
Option Processing
Session Variables
This chapter describes the options used with external tables. For examples of how to use
external tables, see Appendix A, Examples and Grammar.
Options
When you create an external table definition, you can specify options. There are different
types of options: some are for records/rows, some are for fields, and some are for loads. Use
these options when loading from an external table or when using the external table directly
in a SQL query.
Note: The best method to verify that the load processing has been successful is to ensure
the system records any errors to the nzlog and nzbad files. Check these files occasionally.
Table 3-1 lists the external table options, and a description of each option follows. In the
Valid Formats column, Text refers to Text-Delimited format and Fixed refers to Fixed-Length
format. In the Data type column, enumeration refers to the system accepting a specified
set of quoted or unquoted string values.
Table 3-1: External Table Options
Option
Valid
Formats
Values Default
Unload
Y/N
Data Type
BoolStyle Text,
Fixed
1_0/T_F/Y_N NULL, 1_0 Y enumera-
tion
Compress Text,
Fixed
True/False False Y boolean
CRinString Text,
Fixed
True/False NULL, False Y boolean
3-2 20525 Rev. 2
Netezza Data Loading Guide
CtrlChars Text,
Fixed
True/False NULL, False N boolean
DataObject Text,
Fixed
Existing file path No default Y filename
DateDelim Text,
Fixed
1-byte NULL, "-" Y string
DateStyle Text,
Fixed
YMD/MDY/DMY NULL, YMD Y enumera-
tion
DecimalDelim Text,
Fixed
1-byte . Y string
Delimiter Text 1-byte NULL, "|" Y string
Encoding Text Inter-
nal/Latin9/Utf8
NULL,
Internal
Y enumera-
tion
EscapeChar Text 1-byte NULL Y string
FillRecord Text True/False NULL, False N boolean
Format Text,
Fixed
Text/Inter-
nal/Fixed
Text Y enumera-
tion
IgnoreZero Text True/False NULL, False N boolean
IncludeZero-
Seconds
Text True/False NULL, False Y boolean
Layout Text,
Fixed
Zone definitions NULL, Inherit N none
LogDir Text,
Fixed
existing dir path NULL, /tmp N string
MaxErrors Text,
Fixed
>=0 NULL,1 N integer
MaxRows Text,
Fixed
>=0 NULL, 0 N integer
NullValue Text,
Fixed
4-bytes NULL,
"NULL"
Y string
QuotedValue Text No/Yes/Sin-
gle/Double
NULL, No N enumera-
tion
Table 3-1: External Table Options
Option
Valid
Formats
Values Default
Unload
Y/N
Data Type
20525 Rev. 2 3-3
Option Details
Option Details
The following sections details the different options.
BoolStyle
Specifies the boolean style. During a load, the loader can handle only a specific style of
boolean values.
Table 3-2 lists the styles and their values.
RecordDelim Text,
Fixed
4-bytes NULL,
/newline
N string
RecordLength Fixed Integer/Zone-ref
expr
NULL N integer
RemoteSource Text,
Fixed
ODBC/JDBC NULL Y enumera-
tion
RequireQuotes Text True/False NULL, False N boolean
SkipRows Text,
Fixed
>=0 NULL, 0 N bigint
SocketBufSize Text,
Fixed
64KB-2GB 8MB Y integer
TimeDelim Text,
Fixed
1-byte NULL, ":" Y string
TimeRound
Nanos
TimeExtraZeros
Text True/False NULL, False N boolean
TimeStyle Text,
Fixed
24hour/12hour NULL,
24hour
Y enumera-
tion
TruncString Text True/False NULL, False N boolean
Y2Base Text,
Fixed
>=0 NULL, 0 N integer
Table 3-1: External Table Options
Option
Valid
Formats
Values Default
Unload
Y/N
Data Type
Table 3-2: Boolean Values
Style Name Value
1_0 1 or 0
3-4 20525 Rev. 2
Netezza Data Loading Guide
The default style is 1_0. The values can be expressed in mixed case, so true can be True
or TRUE or tRuE.
If you specify the YES_NO option on the command line, the system assumes that the data
in the Boolean field is in the form yes or no. If the data is any of the other values: true,
false, 1, 0, t, f, y, or n, the system discards the record to the nzbad file and logs an error
with the record number in the nzlog file.
Compress
Specifies whether the source datafile data is compressed or not. The valid values are true
or on, false or off. The default is false. This can only be true if the format is set to internal.
CRinString
Specifies whether to allow unescaped carriage returns in char/varchar and nchar/nvarchar
fields. Acceptable values are true or false, on or off. Do not put quotes around the value.
False Default, treats all cr or crlf as end-of-record.
True Accepts unescaped CR in char/varchar fields (LF becomes only end of row).
Note: This option is different for Fixed-Length format. For more information, see Changed
Options on page 6-3.
CtrlChars
Specifies whether to allow an ASCII value 1-31 in char/varchar and nchar/nvarchar fields.
You must escape NULL, CR, and LF characters. Acceptable values are: true or false, on or
off. The default is false. Do not insert quotes around the value.
Note: This option is different for Fixed-Length format. For more information, see Changed
Options on page 6-3.
DataObject
Specifies the OS-path to the source datafile (or any media that can be treated as a file).
There is no default, and this must be specified. When the remotesource option is not set (or
set to empty string), this path has to be an absolute path and not a relative path. The file-
name must be a valid UTF-8 string.
For loads, this file has to be an existing file with READ permission for the OS user ini-
tiating the load.
T_F T or F
Y_N Y or N
YES_NO YES or NO
TRUE_FALSE TRUE or FALSE
Table 3-2: Boolean Values
Style Name Value
20525 Rev. 2 3-5
Option Details
For unloads, the parent directory of this file has to have READ-WRITE permissions for
the OS user initiating the unload, and the data file is overwritten if it already exists.
DateDelim
Specifies the delimiter character that separates the date components, and used with the
dateStyle option. The default is - for all dateStyles except MONDY[2], where the default is
(space). This is a single-byte string.
If you specify the option as an empty string, which means that there is no delimiter
between the date components, you must specify days and months as two-digit num-
bers. Single-digit months and days are not supported.
With MonDY or MonDY2, the default dateDelim option is space.
With days and months less than 10, use either one or two digits, or a space followed by
a single digit.
With the dateDelim option as a space, the system allows a comma after the day.
With any component (day, month, year) as zero, or any day/month inconsistency, such
as August 32 or February 30, the system returns an error.
Table 3-3 lists dateDelim option examples.
Note: If not using delimiters, the date will be determined as in the following example for
June 12, 2009:
06122009
DateStyle
Specifies how to interpret the date format. The date style settings YMD, MDY, DMY,
DMONY, MONDY. The default is YMD.
Note: The two-digit year formats (Y2MD, MDY2, DMY2, DMONY2 and MONDY2) are not
supported for unloads.
The dateStyle options are shown in Table 3-4.
Table 3-3: The -dateDelim
No dateDelim -dateDelim , -dateDelim (space)
Jan 01 2003 Jan 01,2003 Jan 01, 2003
Jan 1 2003 Jan 1,2003 Jan 1, 2003
Jan 1 2003 Jan 1,2003 Jan 1, 2003
Table 3-4: DateStyle
Sequence of Date Components Four-digit Year Two-digit Year
Year Numeric-month Day YMD Y2MD
Day Numeric-month Year DMY DMY2
3-6 20525 Rev. 2
Netezza Data Loading Guide
Note: Two-digit year formats are not supported for unloads.
The default dateStyle is YMD, and the SQL standard stipulates that the legal years are
0001 to 9999. There is no provision in SQL for years prior to 0001 AD or later than 9999
AD.
Date example: In the data file jan-01.data, the data are specified as the following:
14255932|30/06/2002|20238|20127|40662|157|
Because the date value is using the DD/MM/YYYY format, specify the following dateStyle
and dateDelim options:
nzload -t agg_month -df jan-01.data -delim | -dateStyle DMY -datedelim '/'
DecimalDelim
Specifies the decimal delimiter for the following data types, for both text-delimited and
fixed-length formats: float, double, numeric, time, timetz, and timestamp. Default is ..
For examples of usage, see Decimal Delimiter Examples on page A-4.
Delimiter
Specifies the field delimiter. The default is the pipe character |. You can specify charac-
ters in the 7-bit ASCII range using either a quoted value (for example: delimiter '|') or
by its unquoted decimal number (delimiter 124) . To specify a byte value above 127,
use the decimal number. This is a single-byte string.
Note: For nzload, the default is \t(tab).
Note: This option is not supported for Fixed-Length format.
The system processes an input row by identifying the successive fields within that row. A
single character field delimiter separates adjacent fields. The lack of a field delimiter
between fields is an error. You can use a trailing field delimiter following the last field in a
row (but it is not required).
You can specify the following delimiters:
Numeric 0xNN or NN where NN is a number for either hexadecimal or decimal.
Control characters ^A -^Z (low-order 5 bits) and ^a -^z (low-order 5 bits).
Symbols \b backspace (8), \t horizontal tab (9), \n line feed (10), \f form feed (12), \r
carriage return (13), \\ backslash, \ single quote, \ double quote.
Literal Any character, such as c (the non-control character c).
Numeric-month Day Year MDY MDY2
Alphabetic-month Day Year MonDY MonDY2
Day Alpha-
betic-month
Year DMonY DMonY2
Table 3-4: DateStyle
Sequence of Date Components Four-digit Year Two-digit Year
20525 Rev. 2 3-7
Option Details
To use a character other than a 7-bit-ASCII character as a delimiter, make sure that you
specify it as a decimal or hex number. Do not specify a character literal, which could result
in errors from encoding transformation. For example, to use the hex value 0xe9 as a delim-
iter (which is in Latin9), use d 0xe9 as the value. Do not use d ''.
Although the system accepts alpha-numeric characters, to avoid ambiguity do not select a
delimiter that conflicts with the data in a field. Also if you use the dateDelim and timeDe-
lim options, select different delimiters for each type.
Note: When you are using the nzload wrapper you can enter escape characters on the com-
mand line, such a \b. If you use the CREATE EXTERNAL TABLE command, the only special
character you can specify is \t (\t).
Encoding
Specifies the encoding of the datafile for the character set. The default is internal.
You can also specify utf8 if the whole file is in UTF-8 encoding and has only nchar/nvar-
char data and no char/varchar data. Use internal if the file could have both Latin-9 and
UTF-8 data or either type using char, varchar, nchar, or nvarchar data.
The system supports single-byte characters in Latin9 encoding, and Unicode data in the
multi-byte UTF-8 encoding. Use the encoding option to specify the type of data in the file.
The encoding option has three values:
A value of latin9 indicates that the whole file is in Latin-9 char/varchar data and has
no nchar/nvarchar data. (If the file contains any nchar/nvarchar data, it will be rejected
by the load operation.)
A value of utf8 indicates the whole file is in UTF-8 encoding and has only nchar/nvar-
char data and no char/varchar data. (If the file contains any char/varchar data, it will be
rejected by the load operation.)
The value internal indicates that the file could have either or both Latin-9 and UTF-8
data using any or all of the char, varchar, nchar, or nvarchar data types. As a best prac-
tice, use internal if you are not certain of the data encoding.
For more information, see the Using International Character Sets chapter in the IBM
Netezza Database Users Guide.
Use the nzconvert command to convert character encoding before loading with external
tables. For the command options and examples, refer to Converting Legacy Formats in
the IBM Netezza Database Users Guide.
Note: This option is not supported for Fixed-Length format.
EscapeChar
Specifies the use of an escape character. The character immediately following the \ is
escaped. The only supported value is \, and the default is no escaping.
By default, the system expects fields to be delimited by a field-delimiter character or by an
end-of-row sequence. The system assumes all other characters are part of the fields value.
Although efficient, this representation has the drawback that string fields may not contain
instances of the field delimiters. In addition, one value typically becomes inexpressible
because you have used it to convey the absence of any value (that is, that column is null).
3-8 20525 Rev. 2
Netezza Data Loading Guide
One solution is to use an escape character for the delimiter. For example, the following
command line demonstrates using the escapeChar option.
nzload -escapeChar \ -nullValue NULL -delim |
|NULL| A null input field
|\NULL| A non-null input field containing the text NULL
|\|| A non-null input field containing the single character |
|\\| A non-null input field containing the single character \
Note: This option is not supported for Fixed-Length format.
FillRecord
Specifies whether to allow an input line with fewer columns than the table definition. Miss-
ing or trailing input fields should be treated as nulls if the columns are nullable. The
default is false.
The system expects one input field for every column in the target tables schema, and
rejects a row with fewer fields. If you specify the fillRecord option, the system allows omit-
ting one or more trailing (rightmost) fields, as long as all corresponding columns can be
null.
Note: This option is not supported for Fixed-Length format.
Format
Specifies the data format of the source file to load and unload. The valid values are as
follows:
text (default) Data in Text-Delimited format
fixed Data in new Fixed-Length format
internal Data in compressed binary format (to use this, the compress option must be
set to true)
IgnoreZero
Specifies discarding byte value zero in char() and varchar() fields. The default is false. If
true, the command accepts binary value zeroes in input fields and discards them.
Note: This option is not supported for Fixed-Length format.
IncludeZeroSeconds
Specifies that 00 seconds values will be unloaded to the external table. For example, a
time value such as 12:34:00 or 12:34 will be unloaded to the external table in the format
12:34:00. The default is false.
Note: This option is not supported for Fixed-Length format, and is only for unloading.
Layout
Specifies the zone definitions.
20525 Rev. 2 3-9
Option Details
Note: This option is used only with the Fixed-Length format. For more information, see
New Options on page 6-2.
LogDir
Specifies the directory to which nzlog and nzbad files are generated for loads. This is not
used for unloads. The default value is '/tmp'. Note that when doing remote loads from Win-
dows clients (through ODBC/JDBC), the default output directory is mapped to "C:\". The
directory name must be a valid UTF-8 string.
MaxErrors
Specifies the number of errors at which the system stops processing rows. If the count of
rejected rows reaches this threshold, the system immediately aborts and rolls back the
load.
The default value is 1. This default has the effect of committing a load only if it contains
no errors. A maxErrors value n (where n is greater than 1) allows the first n-1 row rejections
to be recoverable errors, not including the number of rows processed in the skipped row
range.
Use this option to specify a different value, from 0 (unlimited errors) up to 2,147,483,647
(the largest signed 32-bit integer).
Note: This option is different for Fixed-Length format. For more information, see Changed
Options on page 6-3.
MaxRows
Specifies to stop processing after this initial number of rows. Use a limit clause with the
select statement to limit loading data. The default is 0 (load all rows).
After processing a row (whether inserted, skipped or rejected), the system decides whether
to look for another input row:
If you did not specify the maxRows option, the system attempts to locate the next input
row.
If you specified the maxRows option and the input row counter is equal to the
maxRows count, the system ends the load and commits all inserted records, not
including the rows processed in the skipped row range. Otherwise, the system attempts
to locate the next input row.
NullValue
Specifies the string to use for the null value, with a maximum 4-byte UTF-8 string. The
default is NULL. You can specify a value such as a space (' ') or any string up to four char-
acters. Conceptually a field contains either a value or an indication that there is no value.
The system provides some flexibility in how you indicate that a field contains no value. For
more information about how the system handles nulls, see Column Constraint Rules for
Empty Strings on page 2-10.
The system determines a fields type and whether it is null by inspecting the corresponding
column declaration:
If there is no value, the system sets the corresponding value in the candidate binary
record to null.
3-10 20525 Rev. 2
Netezza Data Loading Guide
If you declared the target column not null, then an absence of a value is an error.
If a field does not indicate null, the system assumes it contains a value. The system
analyzes the contents of that field, converts its textual input representation to binary,
and sets the corresponding value in the candidate binary record to that value.
QuotedValue
Specifies whether data values are quoted or not. The default is false. Specify SINGLE or
YES to require single quotes or DOUBLE to require double quotation marks. You can pre-
cede the opening quote or follow the closing quote with spaces. You can use the actual
quote characters if you enclose them in double quotes. The system recognizes the end of
the field by a field-delimiter character or an end-of-row sequence.
The system recognizes a quoted value when the first non-space character is the quote char-
acter specified in the quotedValue option. If the first non-space character is not the
specified quote character, then the system handles it according to the normal rules. In par-
ticular, leading or trailing spaces in string fields are considered part of the strings value.
For example, the following command line demonstrates using the quotedValue option.
nzload -quotedValue SINGLE -nullValue NULL -delim |
|NULL| A null input field
|NULL| A null input field
| Im | A non-null input field containing the text Im
| Im | A non-null input field containing the text Im
| | | A non-null input filed containing the single character |
| | A non-null input field containing a single space
| | A non-null input field containing a single space
| | A non-null input field containing a zero-length string
|| A non-null input field containing a zero-length string
Note that unlike the escapeChar option, the quotedValue option is not able to force the sys-
tem to accept the nullValue token as a valid non-null input value. The system overhead for
processing quoted value syntax is much greater than the default unquoted syntax. In addi-
tion, except for strings containing three or more field delimiters that need to be escaped
and no embedded quotes, using the quotedValue option results in more bytes of input data
than the escapeChar option. When you have a choice, use unquoted syntax.
If you expect all values in all input fields (string or otherwise) to be uniformly enclosed in
quotes, then use the requireQuotes option to cause the system to enforce this usage. Using
the requireQuotes option improves the parsing overhead and provides extra robustness.
Note: This option is not supported for Fixed-Length format.
RecordDelim
Specifies that the row/record delimiter to be used is the string literal. Valid values must be
a maximum 8-byte UTF-8 string.
Note: This option is used only with the Fixed-Length format. For more information, see
New Options on page 6-2.
20525 Rev. 2 3-11
Option Details
RecordLength
Specifies the length of the entire record. Includes the length itself, but does not include
the RecordDelimiter.
Note: This option is used only with the Fixed-Length format. For more information, see
New Options on page 6-2.
RemoteSource
Specifies the source datafile is remote, and takes the following values: ODBC, JDBC or
empty string. External tables created with the remote source set to ODBC or JDBC are
usable only through ODBC or JDBC respectively. External tables created with the remote
source not set (or set to empty string) are usable from any client (the source datafile path is
assumed to be on the Netezza host, even if the load/unload is initiated remotely from a dif-
ferent host).
Note that nzsql does not support remote loads/unloads using external tables (you can only
create external tables remotely), though it does support loads/unloads locally on the host.
This option is automatically set to ODBC if the hostname option is set to anything but local-
host or the reserved IP address (127.0.0.1).
RequireQuotes
Specifies if quotes are mandatory. The default is false. If set to true, the quoted value must
be set to YES, SINGLE, or DOUBLE. See QuotedValue on page 3-10.
Note: This option is not supported for Fixed-Length format.
SkipRows
Specifies the number of initial rows to skip before loading the data. The default is 0 (none).
After the system has a candidate binary record from an input row, it determines whether to
insert that record into the target table:
If you did not specify this option, the system inserts every record.
If you specified this option and the input row counter is less than or equal to the
skipRows count, the system discards the candidate binary record (skipped). Otherwise,
the system inserts the record.
Note: If you use the skipRows option, the system skips that number of rows, and then
begins the count for the maxErrors and/or maxRows options (if you have specified them).
Note that this cannot be used for 'header' row processing in a datafile, as even the skipped
rows are processed first, so the data in the header rows should be valid with respect to the
external table definition.
This option can be used for doing a dry-run to validate the datafile is correct, before loading
into a user table, by setting a maximum value.
3-12 20525 Rev. 2
Netezza Data Loading Guide
SocketBufSize
Specifies the chunk size at which to read the data from the source file, expressed in bytes.
Valid values range from 64KB to 800MB, with a default value of 8MB. Values outside this
range result in a system notice that the value will be reset to the appropriate minimum or
maximum level. This is used to fine-tune the performance of loads, depending on the
speed at which the source data is available for loads.
TimeDelim
Specifies the single-byte character that separates the time components. The default is ':'.
If you specify the timeDelim option as an empty string, you must specify the hour, min-
utes, and optional seconds as two-digit numbers.
If you specify the 12-hour format, you can precede the AM or PM token with a single
space. Note that the tokens, AM and PM are case-insensitive.
The system checks syntax and range errors. If an error occurs, the system discards the
record to the nzbad file and logs an error with the record number in nzlog file.
TimeRoundNanos
Rounds the time value to six fractional seconds digits. You can use the timeRoundNanos
option to specify allowing but rounding non-zero digits with smaller than microsecond
precision.
If you do not use the timeRoundNanos option, a value is accepted, as long as it can be
stored without loss of precision.
If you specify this option, the value is accepted, even when full precision of any frac-
tional seconds cannot be preserved. In this case, the value is rounded.
For example, consider the following timestamps:
1999/12/31 23:59:59.9999994
1999/12/31 23:59:59.9999995
Both of these timestamps specify finer than microsecond resolution. Without the
option, each would be rejected. Using the option, the first sample timestamp would
round to:
1999/12/31 23:59:59.999999
The second sample would round to:
2000/01/01 00:00:00.0
Note: This option is not supported for Fixed-Length format, and is also referred to as the
TimeExtraZeros option.
TimeStyle
Specifies the time format (24HOUR, 12HOUR) used in the data file. The default is
24HOUR.
TruncString
Specifies truncating a string and inserting it into the declared storage.
False Default, the system reports an error when a string exceeds its declared storage.
20525 Rev. 2 3-13
Option Processing
True Truncate any string value that exceeds its declared char/varchar storage.
Note: This option is not supported for Fixed-Length format.
Y2Base
If you specify the Y2-style date, use the -y2Base option to specify the start of the 100-year
range. Table 3-5 provides some examples of date ranges and their corresponding input
values.
Option Processing
This section contains additional information on how the system processes the options.
Counting Rows
The system uses a line-oriented input format one line of text is an input row. It operates
by isolating successive rows in the input stream. Every time it finds a new row, it incre-
ments a row counter (starting with number 1) and analyzes the contents of the row.
During analysis two sorts of errors can occur:
The input text may not match the expected format.
A field value might fail to meet a requirement imposed by the target table schema.
If a row contains no errors, the system converts the row into a candidate binary record.
Table 3-5: The -y2Base Option
Desired Range 19001999 19232022 19762075 20002999
Option -y2Base 1900 -y2Base 1923 -y2Base 1976 -y2Base 2000
In Y2 input
00 1900 2000 2000 2000
01 1901 2001 2001 2001
02 1902 2002 2002 2002