Sunday, November 8, 2015

1.5 COPY and COPY LOCAL

COPY and COPY LOCAL:

1
The COPY statement bulk loads data into an HP Vertica database.
 
Using COPY we can initiate loading one or more files or pipes on a cluster host.

2
To load directly from the remote client system we should use COPY LOCAL.

 
For example, to copy a GZIP file from your local client, use a command such as this:

=> COPY store.store_dimension FROM LOCAL '/usr/files/my_data/input_file' GZIP;

We can use a comma-separated list to load multiple files of the same compression type. 
COPY LOCAL then concatenates the files into a single file, so you cannot combine files with different compression types in the list. When listing multiple files, be sure to specify the type of every input file, such as BZIP, as shown:

=>COPY simple_table FROM LOCAL 'input_file.bz' BZIP, 'input_file.bz' BZIP;
3
You can load data from a local client from STDIN, as follows:

 
=> COPY simple_table FROM LOCAL STDIN;

Remember that just saying "FROM STDIN" means input is read from initiator node.
Using LOCAL STDIN to read from a client.

BOTTOM Line: Use COPY when the files to be loaded are on the HOST systems OR on a storage area shared by all Nodes.

                      Use COPY LOCAL when the file to be loaded in on remote machine.

No comments:

Post a Comment