Table of Contents
This chapter describes the tbImport utility and its usage.
tbImport is the Import utility provided by Tibero. It can import the schema object, which is saved in an external file, into the Tibero database. Along with tbExport utility, this utility is useful when processing a database backup and transmitting a database between different machines. The tbImportutility has functions similar or symmetrical to the tbExport utility.
When you import one schema object using the tbImport utility, related schema objects will also be imported automatically. If necessary, it is possible to block some of the related schema objects from being imported.
Just like the tbExport utility, tbImport has three modes: full database mode, user mode, and table mode. They can only be used by a DBA. If DBA privilege cannot be granted, it is recommended to grant the SELECT ANY DICTIONARY privilege.
Specify the log, which is created while importing, by using the LOG parameter.
The following table describes the Complete, Alert, and Error messages created as a result of executing the tbImportutility .
Item | Description |
---|---|
Complete Message | Displayed when the import has been successfully processed. |
Alert Message | Displayed when the import has been finished, but something is wrong. |
Error Message | Displayed when an error occurs during import and the import cannot continue. |
The tbImport utility will be installed or removed when Tibero is installed or removed. Also, the tbImport utility is implemented in the Java language and it can be run on any platform in which JVM (Java Virtual Machine) is installed.
Check the following requirements are met before executing the utility.
If JRE 1.4.2 or higher is installed.
Should be installed on the same platform as Tibero database server or be connected through a network.
Necessary class libraries (the default location: $TB_HOME/client/lib/jar directory) for execution.
tbImport class: expimp.jar
Common library of the utilities: toolcom.jar
Common Logger library of the utilities: msllogger-14.jar
JDBC driver: internal-jdbc-14.jar
The Class libraries required for execution will be installed automatically when installing Tibero. Therefore, there are no additional tasks required for this.
Import mode has three modes: full database mode, user mode, and table mode. Exported files are the source for the import. Import the data according to the features of each mode. Each mode can be specified by using a parameter.
The following figure shows the relationship of schema objects, which are to be imported, in each mode.
Full database mode imports the entire Tibero database from the exported files. It imports objects of all users except the SYS user.
To use the full database mode, specify Y for the FULL parameter.
FULL=Y
User mode imports all schema objects of the specified users, except the SYS user, from the exported files. A DBA can allow more than one users to use this mode.
To use the user mode, specify the userlist for the USER parameter. (USER=userlist format).
USER=SCOTT, USER1, …
Table mode specifies one or more tables and imports all of their schema objects, such as index, from the exported files.
To use table mode, specify the tablelist for the TABLE parameter. (TABLE=tablelist format). Make sure to enter the user who owns the table like SCOTT.EMP as shown below.
TABLE=SCOTT.EMP, USER1.TABLE1, …
From User To User mode imports the schema objects from the exported files after changing their owner from FROMUSER parameter to TOUSER parameter. A DBA can allow more than one user to use this mode. This mode is part of the user mode.
To use the From User To User mode, specify the parameter as in the format below.
FROMUSER=SCOTT,USER1 TOUSER=USER2,USER3…
To execute the tbImport utility, enter the tbimport command in the $TB_HOME/client/bin directory.
The following is an example of how to execute tbImport in full database mode.
[Example 4.1] Executing the tbImport Utility
$ tbimport username=tibero password=tmax sid=tibero file=export.dat full=y $ tbimport cfgfile=import.cfg
If there are constraints specified to the table, the rows that violate these constraints will not be saved.
The proper process order is to save the table data first and then save table constraints. However, if you save the table constraints before saving table data, certain rows that violate the saved constraints will not be saved. For example, if you save the child table data before saving the parent table data in two tables that have referential integrity constraint specified, not even the first row will be saved in the child table.
Therefore, when importing a table that has constraints, import all the table data first, and then specify the table constraints.
Before executing the tbImport utility, a user can define a table in the target database, in advance. This newly defined table does not have to be exactly the same as the table that is to be imported, but has to be compatible.
To maintain compatibility between tables, pay extra attention to the following conditions.
Table to be imported
Should include all the columns the table contains.
Data type
Should have mutual compatibility. Do not change the default values.
When adding a new column
Do not specify a primary key constraint or NOT NULL.
It is possible to import data into a table that already exists in a database. The two tables should be compatible, as mentioned in the previous section.
If a user defines the same table name or a table that already exists in the database, before processing the tbImport utility, there may be some rows that cannot be saved in the tbImport utility due to the constraints specified in the table.
Use the following two methods when importing data into a table that already exists.
Holding the constraints
Hold the constraints while processing the tbImport utility.
Controlling the execution order
Control the execution order while processing the tbImport utility.
For example, if the two tables have referential integrity constraint specified, save the parent tables first and then save the child tables.
If the table size is large, using the controlling execution order method is better in terms of performance. The method of holding constraints is not good for performance. When you hold and then allow constraints again, all rows in the table will be checked to see whether they match the constraints.
If a user executes the tbImport without specifying any values for the parameters, the user will see a list of parameters and their usage, which can be entered at the command prompt, as shown below.
tbImport 6.0 101902 TmaxData Corporation Copyright (c) 2008-. All rights reserved. Usage: tbimport [PARAMETER1=VALUE] [PARAMETER2=VALUE] ... Parameters: BIND_BUF_SIZE Specify the buffer size of DPL stream, default: 1M(1048576) CFGFILE Config file name COMMIT Commit after the insertion, default: N CONSTRAINT Import Constraint: Y/N, default: Y DBLINK Import DB Link: Y/N, default: Y DPL Use Direct Path Load: Y/N, default: N EXP_SERVER_VER Specify the exported server version, default: 8 FILE Import dump file name, default: default.dat FROMUSER FromUser toUser Mode: user name list (must be used with TOUSER parameter) FULL Full Mode: Y/N, default: N GRANT Import Grant: Y/N, default: Y GEOM_ASBYTES Import the data to the geometry columns as bytes, default: N IGNORE Ignore create error due to object existence: Y/N, default: N INDEX Import Index: Y/N, default: Y IO_BUF_SIZE Specify the buffer size of file I/O, default: 16M(16777216) IP IP address, default: localhost LOG Import script log file name LOGDIR Import log directory NATIONAL_CHARSET Specify the exported national character set, default is the exported character set NO_PACK_DIR Import unpacked dump files from specified directory. If this option is specified, FILE parameter will be ignored. PASSWORD User password ROLE Import Role: Y/N, default: Y PORT PORT number, default: 8629 PSM Import PSM: Y/N, default: Y P_DPL Use Parallel DPL: Y/N, default: N ROWS Import Table Rows: Y/N, default: Y SAVE_CREDENTIAL Save your username and password to specified file SCRIPT LOG THE DDL SCRIPT: Y/N, default: N SEQUENCE Import Sequence: Y/N, default: Y SID Database name SYNONYM Import Synonym: Y/N, default: Y TABLE Table Mode: table name list TEMP_DIR Directory for the temporary raw dump files. THREAD_CNT Thread Count, default: 4 TOUSER FromUser toUser Mode: user name list (must be used with FROMUSER parameter) TRIGGER Import Trigger: Y/N, default: Y USER User Mode: user name list USERNAME Database user name
Parameter values do not have to be entered in order. Among the parameter values, CFGFILE can only be entered at the command prompt. Other parameter values can be specified in the configuration file. Parameter names specified in the configuration file must be in uppercase.
The parameters used in command prompt can be saved in the configuration file in the following two ways. The second type is used when specifying two or more parameter values.
PARAMETER=value PARAMETER=value1, ...
The following is an example of how to specify a number of parameters.
FULL=Y
FILE=TBEXPORT.DAT
GRANT=Y
INDEX=Y
CONSTRAINT=Y
The following table describes the tbImport utility parameters, that can be entered at the command prompt.
Item | Description |
---|---|
BIND_BUF_SIZE | Size of the bind buffer that is used in stream when importing data in the DPL mode. (Default value: 1MB (1048576)) |
CFGFILE | Configuration file name. |
COMMIT | Commits after an insert operation. (Default value: N) Units of an insert operation:
|
CONSTRAINT | Option to import the constraint.
|
DPL | Option to import in the DPL method.
|
DBLINK | Option to import the DBLink.
|
EXP_SERVER_VER | Server version that data is exported to.
|
FILE | Name of the dump file that is created while importing. (Default value: default.dat) It is created in the operating system in the type of binary file. If the name is not given, default value will be used. |
FROMUSER | Used in the From to User mode. Specifies the original owner of the objects used during export. Usage (number of mapping items must equal those in the TOUSER parameter): FROMUSER=userlist Detailed rules for use:
|
FULL | Option to import in full database mode.
|
GRANT | Option to import permissions.
|
GEOM_ASBYTES | Option to input a geometry column as WKB or bytes. (Default value: Y)
|
IGNORE | Option to ignore an error, caused by an existing schema object, when processing the import.
|
INDEX | Option to import the index information.
|
IO_BUF_SIZE | Controls the size of the buffer that is used to input/output files when processing the import. (Default value: 16MB (16777216)) |
IP | IP address of theTibero server, that is to be imported. (Default value: localhost) |
LOG | Name of the file to record object scripts. |
LOGDIR | Name of the directory that contains the file that records import execution logs. |
NATIONAL_CHARSET | Character set that was exported. (Default value: Exported character set) |
NO_PACK_DIR | Directory which stores the unpacked dump file to run the import. If this option is specified, the value set in FILE parameter is ignored. |
PASSWORD | Password of the user, who performs the import. |
ROLE | Option to import the ROLE.
|
PORT | Port number of Tibero that is to be imported. (The default value: 8629) |
PSM | Option to import the PSM object.
|
P_DPL | Option to use the parallel DPL method to import.
|
ROWS | Option to import the table data.
|
SAVE_CREDENTIAL | Option to save encrypted username and password.
|
SCRIPT | Option to show the DDL script that creates a schema object during import.
|
SEQUENCE | Option to import the sequence.
|
SID | SID of the Tibero server to be imported. |
SYNONYM | Option to import the synonym.
|
TABLE | Name of the table to import in table mode. Usage: TABLE=tablelist |
TEMP_DIR | Directory that stores temporary dump files when importing data. |
THREAD_CNT | Number of threads, which are used to import the table data. (The default value: 4) |
TOUSER | List of users (owners) whose objects will be imported. Used in the From to User mode. Usage: TOUSER=userlist |
TRIGGER | Option to import the trigger.
|
USER | Owner of the object to be imported in the user mode. Usage: USER=userlist |
USERNAME | User account to perform the import. |
The following is the process order for importing using tbImport utility.
Table definition
Table data
Table index
Table constraint, view, procedure, etc.
The following is an example of importing using the tbImport utility.
[Example 4.2] Executing Import using the tbImport utility
tbImport 6.0 97819 TmaxData Corporation Copyright (c) 2008-. All rights reserved. Unpacking the file... the entire database: Mon Jul 14 01:07:43 KST 2014 Import character set: MS949 The version of this tbExport dump file is 5.0. importing schema: "TIBERO" importing tables [M] importing table BONUS no rows imported. [0] importing table DEPT 4 rows imported. [0] importing table SALGRADE 5 rows imported. [1] importing table EMP 10 rows imported. importing index importing sequences importing views importing synonyms Import completed successfully: Mon Jul 14 01:07:55 KST 2014