NZLoad Working Examples
NZLoad Working Examples
[Translate] nzload is the utility used by Netezza to load data into tables. Heres some working examples.nzload options. Option Information -u -pw -db -t -df -cf Username to access the database Password for the username supplied to get into the database Name of the database into which you want to load the data. Table name into which the data is to be loaded. The datafile containing the data to be loaded. The file which contains the formatting and option for nvload. Useful if you are going to repeat the command often.
-delim The delimiter for the data in the file being loaded.
nzload alone is powerful enough to load most required data into netezza. for example, for a file containing tab delimited data, use the following options. To load into database prod, using user fred, password barney and table wilma from a tab delimited file called loadme.data, you would use the following: nzload -u fred -pw barney -db prod -t wilma -delim t -df loadme.data. If your file is delimited by a | symbol, you could then use the following to load into table piped table from file datafile.dat nzload -u admin -pw password -db thedatabase -delim | -df datafile.dat
Using Named Pipes If you are loading a lot of data, and do not have space to keep the data on the system, you can feed it to a named pipe, and feed the command from that. This will not exit until the end of file indicator is given. First, create the pipe file.
mkfifo pipefile
Now you can pipe the data from a supplied file and place it on the pipe.
Now you specify the pipe file with the -df option to load the data in.
Datafile loadme.dat { Database mydatabase TableName datatable. } Now you can run that with the following:
Load session of table DATATABLE completed successfully When you use the nzload command, note that you cannot specify both the -cf and -df options in the same command. You can load from a specified data file, or load from a control file, but not both in one command. This is because the control file requires a datafile definition, so you cannot specify the file from outside of the controlfile. The following control file options define two data sets to load. Note that the options can vary for each data set. Datafile /home/operation/data/customer.dat { Database dev TableName customer Delimiter | Logfile operation.log Badfile customer.bad } Datafile /home/imports/data/inventory.dat { Database dev TableName inventory Delimiter # Logfile importload.log
Badfile inventory.bad } If you save these control file contents as a text file (named import_def.txt in this example) you can specify it using the nzload command as follows: nzload -cf /home/nz/sample/import_def.txt Load session of table CUSTOMER completed successfully Load session of table INVENTORY completed successfully