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 Specifying a COPY Parser. Vertica recommends that you load the smaller tables before the largest tables. To check data formats before loading, see Checking Data Format Before or After Loading.

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:

  1. Create a vsql variable containing your Linux current directory.

    \set t_pwd `pwd`
  2. 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\''
  3. Use the second variable in the COPY statement:

    => COPY Date_Dimension FROM :input_file DELIMITER '|';
  4. 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.

  1. Change your Linux working directory to the location of the data files.

    $ cd /opt/vertica/doc/retail_example_database
  2. Run the Administration Tools.

    $ /opt/vertica/bin/admintools
  3. Connect to the database.
  4. Run the load script.