Previous Topic

Next Topic

Binary Copying

The binary copy is designed for reloading data into tables that have exactly the same record layout as those from which the data was unloaded. Those tables must be on a machine with the same architecture as that from which they were unloaded.

The utilities designed for quick unloading and reloading of tables or databases—copydb and unloaddb (and their VDBA equivalent features)—both use the binary form of copy by default. They automate the process so you can easily recreate and reload tables of identical layout. For information on copydb and unloaddb, see the Command Reference Guide.

Previous Topic

Next Topic

Copy Data into a Binary File

The quickest form of the copy statement to code and execute for unloading data into a file is a binary copy. A binary copy always creates a file of type binary. This statement has the following format:

copy [table] [schema.]tablename () into 'output_filename'
  [standard-with-clauses]

You omit the column list from the copy statement. For example, the following statement copies the entire dept table into the dept_file file in binary format:

copy dept () into 'dept_file';

The binary copy into statement copies all rows of a table to the output file in a proprietary binary format, using the order and format of the columns in the table. It places no delimiters between fields or between records. It performs no type conversions; all data items retain the type they had in the table.

Unloading data in binary format for backup can be inconvenient if you need to inspect the file data later.

Note: If any columns have a type other than character, they are not readable as characters in the output file.

If you unload a table in binary format, the data must subsequently be reloaded in binary format. You cannot use unloaded binary data to later load tables that have a different column order, number of columns, data types, or table structure. To perform these functions, use formatted copy statements.

Previous Topic

Next Topic

Reload a Table in Binary Format

Use the following form of the copy statement to reload a table from a file containing data in binary format:

copy [table] [schema.]tablename () from 'output_filename'
  [standard-with-clauses]
  [bulk-copy-with-clauses]

This form of the copy from statement must be used to reload from a binary file (that is, one created with an empty column list in the copy into statement).

For example, the following statement copies the binary data from the dept_file file into the new_dept_table table:

copy new_dept_table () from 'dept_file'

The table is recreated with the same column and data type format specifications as in the original table. If the table characteristics allow, include bulk copy with clauses.


© 2007 Ingres Corporation. All rights reserved.