NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-124
Correlation Names
The following example demonstrates the MOVE option. The command copies data
from the table $VOL1.SALES.PARTS to the Enscribe file
$TESTVOL.SALES.PARTS, copying only the PARTNUM column to the
PARTNUMR field and the PARTDESC column to the PARTD field:
>> COPY $VOL1.SALES.PARTS, $TESTVOL.SALES.PARTS,
+> TARGETDICT $TESTVOL.SALES, TARGETREC DFORMAT,
+> MOVE (PARTNUM TO PARTNUMR, PARTDESC TO PARTD);
A target column that does not have a source column mapped to it receives its default
value, unless no default value is defined for it, in which case COPY returns an error.
Because the target is an Enscribe file, the command includes a TARGETREC option
to identify the DDL record definition for the Enscribe file.
The following example demonstrates the FIRST KEY option, provided that a table
with a two-column key as described by the following CREATE TABLE statement
exists:
>> CREATE TABLE EMP (
+> EMPNUM SMALLINT, EMPNAME VARCHAR (20),
+> SALARY SMALLINT, PRIMARY KEY (EMPNUM, EMPNAME) );
The COPY command displays rows of table EMP at your terminal in hexadecimal
format, starting with the row for the employee whose employee number is 100 and
whose name is Martin Smith:
>> COPY EMP,,HEX,FIRST KEY (0, 100, "MARTIN SMITH ");
The EMPNUM column is defined as a SMALLINT, which uses two bytes of
storage. For an employee number of 100, the first byte of the EMPNUM column
contains 0 and the second byte contains 100. The second byte contains 100 because
the data is shifted to the right. For the EMPNAME column, the key-value must be
fully padded to 20 characters, which is the maximum length of the VARCHAR used
to define the column.
Correlation Names
A correlation name is a name associated with a table or view in an SQL statement for
one or more of the following reasons:
To distinguish the table or view from another table or view referred to in the
statement
To qualify an ambiguous column reference
To distinguish different uses of the same table
To make the query shorter
A correlation name can be explicit or implicit.