SQL/MP Installation and Management Guide
Reorganizing Tables and Maintaining Data
HP NonStop SQL/MP Installation and Management Guide—523353-004
8-14
Examples of Copying Tables and Files
•
You can copy within a user-defined TMF transaction or, if the table is audited,
COPY initiates the transaction. If you are copying large amounts of data, you must
plan to ensure that the TMF audit trail space is large enough to handle the copied
rows.
•
For an audited table, you can alter the AUDIT attribute of the table to NO AUDIT
before the COPY operation. After the COPY operation completes, alter the
attribute to AUDIT again; then make a TMF online dump, because any previous
dump of the table is no longer valid.
•
If the COPY operation fails or is stopped during the data loading, the state of the
target table or file depends on whether it is audited or nonaudited. If the target is
audited, the TMF transaction terminates abnormally, and the work is undone by the
TMF subsystem. If the target is nonaudited, all the inserted rows are committed.
•
The rules for valid field compatibility are the same as those described for the
CONVERT utility in the SQL/MP Reference Manual.
Examples of Copying Tables and Files
Several examples of copying tables and files follow.
The first example copies data into a table from an Enscribe file. The COPY command
maps the fields with MOVEBYORDER and specifies truncation if necessary. The fields
involved in the transfer from the source file must be compatible with the data type and
order of the receiving columns in the target table.
>> COPY $ENSC.SALES.ORDERS, $VOL1.SALES.ORDERS,
+> MOVEBYORDER ON
+> TRUNCATION ON
+> SOURCEDICT $ENSC.SALES SOURCEREC ORDERREC;
The next example copies data from one table into another table, with only those rows
in which EMPNUM is greater than or equal to 4000 copied to the target table. The
tables have identical definitions.
>> COPY \SYS1.$VOL1.PERSNL.EMPLOYEE,
+> \SYS1.$VOL1.SPECIAL.EMPLOYEE,
+> FIRST KEY 4000
+> MOVEBYNAME;
This command copies data into a table from a tape file:
>> COPY $TAPE, $VOL1.SALES.CUSTOMERS;
This example copies data from a table to a terminal in hexadecimal format:
>> COPY $VOL1.SALES.CUSTOMERS, \SYS1.$TERM1,
+> HEX;
This example copies 100 rows from a table to a terminal in ASCII format:
>> COPY $VOL1.SALES.CUSTOMERS, \SYS1.$TERM1,
+> ASCII COUNT 100;