The COPY
command can only be used by a superuser. The COPY
command provides the flexibility to load and manage data with the help of the following optional parameters:
Format and arrangement of the incoming data
Metadata about the data load
Data transformation
Error handling
The encoding of the data to be loaded should be in the UTF-8
format. It is advisable to check the encoding of the file before loading the data. If the data present is not in the UTF-8
format, then we can convert it using the following Linux/UNIX iconv
command:
iconv -f encoding-of-old-file -t encoding-of-new-file old-file.txt > newfile.txt
This can be illustrated with the help of the following example:
> iconv –f WINDOWS-1251 –t UTF-8 data.txt > data_new.txt
You can also check for the various formats supported by iconv
using iconv -l
.
It should also be noted that data should be segregated with proper delimiter characters. Before loading the data, it should also be checked that no CHAR(N)
or...