Book Contents

Book Index

Next Topic

Home

Using Load Scripts

This section describes how to write and run a load script using the COPY command.

Writing a Load Script

The COPY command requires an absolute pathname for a data file. It does not accept relative pathnames. However, you can specify the locations of your data files relative to your Linux working directory using vsql variables.

  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 for all data files. Load the dimension tables before the fact table.

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.