ltldr

ltldr — Compatible with ORACLE, loads data from external files into tables of an LightDB database。

Synopsis

ltldr [connection-option...] [option...]

描述

ltldr is a small and flexible tool that loads data from external files into tables of an LightDB database。

ltldr can specify the format of the data file. This includes the separator of field and field, row and row.

ltldr including txt and csv, and also fixed length of record.

ltldr supports writing logs to specified files.

Options

The following command-line options control the content and format of the load.

user=

Specify the user who loads the table.

dbname=

Specify the dbname who loads the table.

host=

Specify the host who loads the table.

port=

Specify the port who loads the table.

password=

Specify the password who loads the table.

control=

Specifies the path to a control file that describes how to load data.

log=

Specifies the path to the log file where log information about the loading process is stored.

示例

Connect to the database according to the control file LTLDR000003.ctl loads data from external files into tables of an testdb database:

      $ ltldr control=/home/lightdb/ltldrtest/LTLDR000003.ctl host=127.0.0.1 port=5432 userid=lightdb password=111111 dbname=testdb
    

Control file syntax

[ OPTIONS  ( option [ , ... ] )  ]
LOAD DATA
[ CHARACTERSET  charset ]
INFILE  'filename' [ "STR 'char'" ] [ "FIX count" ]
[ APPEND  |  INSERT  |  REPLACE ]
INTO TABLE tablename
[ WHEN  condition ]
[ FIELDS [CSV] TERMINATED  BY 'char' ]
[ [ OPTIONALLY ]  ENCLOSED  BY 'char' ]
[ TRAILING NULLCOLS ]
(
   column1  constant '321',
   column2  position(5:10),
   column3  position(12:14),
   ignore1  FILLER
   column4  FILLER
   [ ... ]
)
OPTIONS

The supported options are skip and load. Skip indicates how many rows to skip, and load indicates how many rows to import at most.

CHARACTERSET

For the character set of the data file, you need to ensure that the character set of the control file (obtaining the character set from the environment) and the data file are consistent.

INFILE

Specify the path to the imported data file

STR

Specify the line separator, the default is '\n', supports multi-byte and hexadecimal, optional

FIX

Specify a fixed length of data to be processed as one row, optional;

APPEND | INSERT | REPLACE

APPEND appends; INSERT inserts, can only be imported into an empty table; REPLACE replaces, clears the table before importing

INTO TABLE

Specify the imported table name

WHEN

Determine whether a certain row can be imported, supports equal and not equal operations, optional. Support column name or character range judgment;

CSV

Indicates using CSV format to parse data files, optional;

TERMINATED BY

Specify the column separator, the default is '\t', supports multi-byte and hexadecimal, optional

ENCLOSED BY

When CSV is specified, ENCLOSED BY represents the field bracket, only supports one byte, and is optional;

TRAILING NULLCOLS

When the number of data file columns is not enough, the remaining columns in the table are null and optional;

constant

Indicates that the field uses a fixed value and uses single quotes to quote constants, optional;

position

Indicates filling the field with a character range, optional;

FILLER

Indicates that the column value is skipped and no data is filled, optional;