Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

How to Write Files to Load Database

You can add mass data to the database more rapidly by writing the object input file used in the cubrid loaddb utility. An object input file is a text file in simple table form that consists of comments and command/data lines.


In CUBRID, a comment is represented by two hyphens (--).

-- This is a comment!

Command Line

A command line begins with a percent character (%) and consists of %class and %id commands; the former defines classes, and the latter defines aliases and identifiers used for class identification.

Assigning an Identifier to a Class

You can assign an identifier to class reference relationships by using the %id command.


%id class_name class_id





The class_name specified by the %id command is the class name defined in the database, and class_id is the numeric identifier which is assigned for object reference.

Example 1

%id employee 2

%id office 22

%id project 23

%id phone 24

Specifying the Class and Attribute

You can specify the classes (tables) and attributes (columns) upon loading data by using the %class command. The data line should be written based on the order of attributes specified. When a class name is provided by using the -t option while executing the cubrid loadd utility, you don't have to specify the class and attribute in the data file. However, the order of writing data must comply with the order of the attribute defined when creating a class.


%class class_name ( attr name [attr name... ] )

The schema must be pre-defined in the database to be loaded.

The class_name specified by the %class command is the class name defined in the database and the attr_name is the name of the attribute defined.

Example 2

The following example shows how to specify a class and three attributes by using the %class command to enter data into a class named employee. Three pieces of data should be entered on the data lines after the %class command. For this, see Example 3 in the "Configuring Reference Relationship" section.

%class employee (name age department)

Data Line

A data line comes after the %class command line. Data loaded must have the same type as the class attributes specified by the %class command. The data loading operation stops if these two types are different.

Data for each attribute must be separated by at least one space and be basically written as a single line. However, if the data to be loaded takes more than one line, you should specify the plus sign (+) at the end of the first data line to enter data continuously on the following line. Note that no space is allowed between the last character of the data and the plus sign.

Loading an Instance

As shown below, you can load an instance that has the same type as the specified class attribute. Each piece of data is separated by at least one space.

Example 1

%class employee (name)





Assigning an Instance Number

You can assign a number to a given instance at the beginning of the data line. An instance number is a unique positive number in the specified class. Spaces are not allowed between the number and the colon (:). Assigning an instance number is used to configure the reference relationship for later.

Example 2

%class employee (name)

1: 'jordan'

2: 'james'

3: 'garnett'

4: 'malone'

Configuring Reference Relationship

You can configure the object reference relationship by specifying the reference class after an "at sign (@)" and the instance number after the "vertical line (|)."


@class_ref | instance_no




Specify a class name or a class id after the @ sign, and an instance number after a vertical line (|). Spaces are not allowed before and after a vertical line (|).

Example 3

The following example shows how to load class instances into the paycheck class. The name attribute references an instance of the employee class. As in the last line, data is loaded as NULL if you configure the reference relationship by using an instance number not specified earlier.

%class paycheck(name department salary)

@employee|1   'planning'   8000000   

@employee|2   'planning'   6000000  

@employee|3   'sales'   5000000  

@employee|4   'development'   4000000

@employee|5   'development'   5000000

Example 4

Since the id 21 was assigned to the employee class by using the %id command in the Assigning an Identifier to a Class section, Example 3 can be written as follows:

%class paycheck(name department salary)

@21|1   'planning'   8000000   

@21|2   'planning'   6000000  

@21|3   'sales'   5000000  

@21|4   'development'   4000000

@21|5   'development'   5000000