nzload command examples

These examples show how to specify nzload parameters and sample ways of using the nzload command.

The following examples illustrate how to specify parameters for the nzload command:

  • The table repeat_cust is delimited by using the vertical bar character (|) and is in the input file clickstream.dat. To load this table, enter the following command:
    nzload -t repeat_cust -delim '|' -df clickstream.dat

    This example does not specify the -u, -pw, or -db options, so defaults are used. These defaults are described in Table 1.

  • The admin user has the password production. The table areacode in the database dev is delimited by tabs and is in the input file phone-prefix.dat. To load this table, enter the following command:
    nzload -u admin -pw production -db dev -t areacode
      -delim '\t' -df  phone-prefix.dat
  • The following command specifies the name of a load file:
    nzload -u admin -pw password -host nzhost -db emp -t name 
     -df /tmp/daily/Import.bad
  • The following command enables load continuation:
    nzload -u admin -pw password -host nzhost -db emp -t name -allowReplay
  • The following command specifies the boolean style:
    nzload -u admin -pw password -host nzhost -db emp -t name -df /tmp 
     -boolStyle yes_no
  • The following command specifies the name of a control file:
    nzload -u admin -pw password -host nzhost -db emp -t name 
     -cf /tmp/daily/control.file
  • The following command allows unescaped carriage returns in char() and varchar() fields:
    nzload -u admin -pw password -host nzhost -db emp -t name -df /tmp -crinString
  • The following command allows an ASCII value of 1 - 31 in char() and varchar() fields:
    nzload -u admin -pw password -host nzhost -db emp -t name -ctrlChars
  • The following command specifies the field delimiter:
    nzload -u admin -pw password -host nzhost -db emp -t name -delim ','
  • The following command specifies the use of an escape character:
    nzload -u admin -pw password -host nzhost -db emp -t name -df /tmp 
     -escapeChar '\\''
  • The following command specifies an input line with fewer columns than that of the table definition:
    nzload -u admin -pw password -host nzhost -db emp -t name -fillRecord
  • The following command specifies discarding of the byte value zero in the char() and varchar() fields:
    nzload -u admin -pw password -host nzhost -db emp -t name -ignoreZero no
  • The following command specifies that an embedded newline value that is also the record delimiter is treated as real data:
    nzload -u admin -pw password -host nzhost -db emp -t name -df /tmp -lfinString
  • The following command specifies a log file name:
    nzload -u admin -pw password -host nzhost -db emp -t name 
     -lf /tmp/daily/import.log
  • The following command specifies the maximum number of errors:
    nzload -u admin -pw password -host nzhost -db emp -t name -maxErrors 100
  • The following command specifies to stop processing when the specified number of records are in the database:
    nzload -u admin -pw password -host nzhost -db emp -t name -maxRows 100
  • The following command specifies the string to use for the null value:
    nzload -u admin -pw password -host nzhost -db emp -t name -nullValue 'none'
  • The following command specifies the output directory for the log files:
    nzload -u admin -pw password -host nzhost -db emp -t name -outputDir /tmp/daily
  • The following command specifies that quotation marks are mandatory, except for null values:
    nzload -u admin -pw password -host nzhost -db emp -t name -requireQuotes 
     quoted value YES
  • The following command specifies truncating a string and inserting it into the declared string:
    nzload -u admin -pw password -host nzhost -db emp -t name -truncString
  • The following commands show the use of options that are related to date and time:
    • The following command specifies how to interpret the date format:
      nzload -u admin -pw password -host nzhost -db emp -t name -dateDelim '/' 
       -dateStyle MDY'
    • The following command specifies the delimiter to use with the -dateStyle option:
      nzload -u admin -pw password -host nzhost -db emp -t name -dateDelim '/' 
       -dateStyle MDY
    • The following command changes the default delimiter of a space (' ') between the date and time components of a timestamp value:
      nzload -u admin -pw password -host nzhost -db emp -t name -dateTimeDelim '_' 
       
    • The following command changes the default delimiter of a space (' ') between the seconds component and the AM or PM token of a time value:
      nzload -u admin -pw password -host nzhost -db emp -t name -meridianDelim '_' 
       
    • The following command specifies the delimiter to use for time formats:
      nzload -u admin -pw password -host nzhost -db emp -t name -timeDelim '.'
    • The following command specifies allowing but rounding non-zero digits with smaller than microsecond resolution:
      nzload -u admin -pw password -host nzhost -db emp -t name -timeRoundNanos
    • The following command specifies the time style value in the data file:
      nzload -u admin -pw password -host nzhost -db emp -t name -timeStyle 12hour
    • The following command specifies the first year in the YY format:
      nzload -u admin -pw password -host nzhost -y2Base 2000
  • The following commands merge records in a data file into target table t1. The data file and target table each contain three columns: col1, col2, and col3.
    • The following command inserts new rows into table t1 and updates existing rows in table t1. To determine which rows to insert or update, the values of the col1 column in the data file and the col1 column in the table are used as a match condition.
      nzload -t t1 -df /tmp/data.txt -delim '|' -merge INSERTUPDATE 
      -mergeschema "col1 int primary_key,col2 int,col3 int" 
    • The following command inserts new rows into table t1 and updates existing rows in table t1. To determine which rows to insert or update, the values of the col1 column in the data file and the col1 column in the table are used as a match condition. In addition, only the records in the data file whose col1 value is greater than 3 are considered.
      nzload -t t1 -df /tmp/data.txt -delim '|' -merge INSERTUPDATE 
      -mergeschema "col1 int,col2 int,col3 int" 
      -mergeon "src.col1 > 3 AND src.col1 = t1.col1" 
    • The following command updates existing rows in table t1. To determine which rows to update, the values of the col1 column in the data file and the col1 column in the table are used as a match condition. In addition, only the records in the data file whose col1 value is greater than 3 are considered.
      nzload -t t1 -df /tmp/data.txt -delim '|' -merge UPDATE 
      -mergeschema "col1 int,col2 int,col3 int" 
      -mergeon "src.col1 > 3 AND src.col1 = t1.col1" 
    • The following command inserts new rows into table t1. To determine which rows to insert, the values of the col1 column in the data file and the col1 column in the table are used as a match condition. In addition, only the records in the data file whose col1 value is greater than 3 are considered.
      nzload -t t1 -df /tmp/data.txt -delim '|' -merge INSERT 
      -mergeschema "col1 int,col2 int,col3 int" 
      -mergeon "src.col1 > 3 AND src.col1 = t1.col1"