rdm-import

Data Import Utility

Synopsis

rdm-import [OPTION]… db_namespec

Description

rdm-import is a command-line utility that creates an RDM database from a backup created by rdm-export or another data source in SQL, CSV or XML file format.

Options

-h, --help Display this usage information
--version Display the version information
-q, --quiet Quiet mode. No information will be displayed
--key=key Specify the encryption key for the database ([algorithm:]passcode). The valid algorithms are xor, aes128, aes192 and aes256. The AES algorithms are only available for packages that have strong encryption support. If an algorithm is not specified, the default is aes128 for strong encryption packages and xor otherwise.
--docroot=path The location of the docroot directory. (See Document Root (DOCROOT))
-c, --commit=count Commit per this number of rows
--dateformat=format Date format in the import file
--timeformat=format Time format in the import file
-f, --force Overwrite an existing export database
-L, --locale=locale The string collation locale the database will use. (See locale)
--alter Existing database will be altered for DDL
-o, --output=db_namespec Name of the database to be created
-t, --table=table_name Name of the table to import data into
--triggers-off Turn off trigger execution on existing database
filename Name of the file to be imported. Filename must have one of the following file extensions: sql, csv or xml. For CSV and XML import files, filename is assumed to be in dbname_tablename.[csv|xml] format where dbname is the name of the target database and table_name is the name of the target table, unless--output is used to specify the database name and/or--table is used to specify the table name. For an SQL import file, filename is assumed to be in dbname.sql format where dbname is the name of the target database, unless--outputis used to specify the database name.

Comments

rdm-import imports data stored n files in comma-separated (CSV), XML or SQL format into an existing database. If the --force option is specified, all the existing data of the database will be removed before the new data are imported.

Each CSV or XML file must contain data for one table only. If the database name is specified with the --output option, the filename will be interpreted as the table name. Otherwise, the filename should be databasename_tablename[.csv|.xml]. Each SQL import file may contain data for multiple tables since each INSERT statement includes the name of the target table.

The SQL import file may include a schema definition, stored procedures and triggers. If it does, rdm-import attempts to create a new database and stored procedures / triggers based on the definition before processing the INSERT statements. If the remote TFS location is specified with the --output option, the database will be created on that TFS.

If the --force option is specified without --alter, an existing database will be dropped. This action is irreversible, even if the subsequent operation fails.

When importing the data into a new database using rdm-import, the user must make sure they process the CSV / XML files in the correct order. For instance, if Table A has a foreign key that references Table B, then the file that contains data for B must be imported before the file for A.

Importing Stored Procedures and Triggers

rdm-import included in the RDM 14.1 Enterprise package provides the capability to parse the stored procedure and trigger statements included in the SQL import file and report any syntax errors. This feature may be useful if there is a need to create a new SQL import file with your own stored procedure and/or trigger definitions or edit existing stored procedure and/or trigger definitions.

rdm-import included in the RDM 14.1 Core Cursor package does not have this capability built-in. It will simply read in the stored procedure/trigger definitions and store them in the target database.

Usage Examples

The usage examples assume that P.sql contains the following table and procedure definitions:

CREATE TABLE p0
(
    a integer
);

CREATE TABLE p1
(
    b smallint
);
COMMIT;

INSERT INTO p0 VALUES 1;
INSERT INTO p1 VALUES 11;

CREATE TRIGGER p.trigger_insert_after_p0
        AFTER INSERT ON p0
    REFERENCING NEW ROW AS new_p0
    FOR EACH ROW
BEGIN ATOMIC
    INSERT INTO p1 VALUES new_p0.a + 10;
END;
;
COMMIT;

Creating and importing an RDM database

rdm-import can be used to create a new RDM database and populate it. Execute rdm-import as follows.

$ rdm-import P.sql

The "--output" command-line option can be used to create and populate a database on a remote TFS as follows.

$ rdm-import --output tfs//localhost/REMOTE_P P.sql

A new database will be created under the TFS running on localhost.