SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
C-124
Considerations—COPY
The display includes the file name, the ordinal number of each row or record, the
length of each record (in decimal bytes), and the ASCII representation of each line.
If you use COPY to write to an audited file or table, the write always takes place
within a TMF transaction. COPY starts a transaction if a user-defined transaction is
not in progress. Because copying large amounts of data results in large amounts of
TMF audit information, you might want to use ALTER TABLE to turn off the AUDIT
attribute of the target file before the COPY and reset it after the COPY.
If you use COPY to write to a nonaudited file or table within a user-defined
transaction, COPY issues a warning but performs the COPY anyway.
You can press the Break key to interrupt COPY. If the target file or table is audited,
the COPY is rolled back and all the work is undone. If the target is nonaudited, all
the work done by COPY up to the point of the break is committed.
If COPY fails and the target table is audited, TMF performs the recovery operation.
If the target table is nonaudited, the data might be partially copied.
COPY does not overwrite existing data. If out-file has key-sequenced file
organization, COPY inserts data at the appropriate locations in the table or file, as
determined by the key. COPY reports an error if a record already exists that has
the same key as a record to be inserted. If out-file has entry-sequenced,
relative, or unstructured file organization, COPY appends data to the end of the
file.
When you enter a COPY command without the SHARE option, COPY opens the
input file in read-only access mode and protected exclusion mode (unless the
source file is a terminal, which is always opened with shared exclusion mode). If,
however, you include the SHARE option in the command when copying a disk file,
COPY opens the file with shared exclusion mode.
By default, COPY opens the output file with protected exclusion mode unless the
file is a terminal.
If you copy a table or file that contains data records and zero-length (empty)
records to a table or file with relative file organization, all records are written with
this exception: if the in-file also has relative file organization, the empty records
are skipped unless you specify NO COMPACT.
For example, when you copy a table or file with relative file organization that
contains a combination of eight data records and two empty records, out-file
file has eight records instead of ten. Thus, if you copy empty records from a table
or file with relative file organization to another table or file with relative file
organization, you lose the empty records. To transfer empty records from a table or
file with relative file organization, include the NO COMPACT option.
If the target is a table, using the COPY command is equivalent to using a set of
INSERT commands with STABLE ACCESS and APPEND options. Values are
inserted in the indexes of the table automatically. All the conditions that must be
satisfied for an INSERT must be satisfied for each target row.