Using load scripts
You can write and run a load script for the COPY statement using a simple text-delimited file format. For information about other load formats see Data formats. Vertica recommends that you load the smaller tables before the largest tables. To check data formats before loading, see Handling Non-UTF-8 input.
Using absolute paths in a load script
Unless you are using the COPY FROM LOCAL
statement, using COPY
on a remote client requires an absolute path for a data file. You cannot use relative paths on a remote client. For a load script, you can use vsql variables to specify the locations of data files relative to your Linux working directory.
To use vsql variables to specify data file locations:
-
Create a vsql variable containing your Linux current directory.
\set t_pwd `pwd`
-
Create another vsql variable that uses a path relative to the Linux current directory variable for a specific data file.
\set input_file '\'':t_pwd'/Date_Dimension.tbl\''
-
Use the second variable in the COPY statement:
=> COPY Date_Dimension FROM :input_file DELIMITER '|';
-
Repeat steps 2 and 3 to load all data files.
Note
COPY FROM LOCAL
does not require an absolute path for data files. You can use paths that are relative to the client's directory system.
Running a load script
You can run a load script on any host, as long as the data files are on that host.
-
Change your Linux working directory to the location of the data files.
$ cd /opt/vertica/doc/retail_example_database
-
Run the Administration Tools.
$ /opt/vertica/bin/admintools
-
Connect to the database.
-
Run the load script.