databaseinformixdbimport

Need to understand dbimport utility in Informix DB


Can anyone help me to understand the command below? I have a confusion about hw and hwdbs01 and the function of the dbimport utility.

dbimport hw -c -q -d hwdbs01

Solution

  • DB-Import is the second part of the DB-Export/DB-Import duo. You can find the documentation on them in the IBM Informix Knowledge Center (The dbexport and dbimport utilities).

    DB-Export creates a copy of an Informix database with the SQL statements needed to recreate it written to standard output, and the unloaded data stored and a copy of the SQL needed put in a directory that the command creates.

    For example, to export a database stores:

     dbexport stores
    

    This creates a directory stores.exp containing the schema in a file stores.exp/stores.sql and a set of unload-format files with names based on the table name and 'tabid' number such as stores.exp/isoto00305.unl. (This database has a table isotopes which has tabid of 305 in the system catalog; the number simply ensures the data file names are unique, of course, and the 14-character limit is a relic of the days of yore when file systems didn't allow longer names).

    When it comes time to import, you use DB-Import. In theory, you've changed servers or something. If you reimport to the same server, you'll need to drop the original database or rename the original database or tweak the export files. The basic form of import is:

    dbimport newdb
    

    This will look for newdb.exp/newdb.sql and expects the unload data files in newdb.exp. I used the following to be able to use the exported results for importing newdb.

    mv stores.exp newdb.exp
    mv newdb.exp/stores.sql newdb.exp/newdb.sql
    

    Your version of the dbimport command was:

    dbimport hw -c -q -d hwdbs01
    

    This imports schema and data from directory hw.exp into a database hw. The -d hwdbs01 option specifies that the database should be stored in dbspace hwdbs01. The -q option means 'be quiet'. The -c options means 'continue on error' (if possible). So, this does the best job it can as quietly as it can; if there are errors, they are reported, but other reporting is suppressed.

    I'm blithely assuming you know enough about Informix databases to know what a dbspace is — if you're not sure, then you need to do some reading on the subject; it is mostly tangential to this question. Very succinctly, though, the storage space used by an Informix server is split into disjoint areas called 'dbspaces'. Each dbspace has a name and a set of one or more chunks (areas of disk space, each identified by file path, starting offset and size). You can place databases, tables and indexes in dbspaces as you require. The initial default dbspace is normally called rootdbs; on this system, there is, presumably, at least one other dbspace called hwdbs01.