SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
P-27
Primary Keys
+> & "FROM PERSNL.EMPLOYEE WHERE DEPTNUM = 1500)";
--- SQL command prepared.
>> DISPLAY STATISTICS;
This SQLCI example prepares an INSERT statement with parameters, then
supplies parameter values with the EXECUTE:
>> PREPARE EMPIN FROM "INSERT INTO PERSNL.EMPLOYEE"
+> &" VALUES (?, ?, ?, ?, ?, ?);
---SQL command prepared.
>> EXECUTE EMPIN USING 66, "AMY", "RYAN", 3100, 300, 50500;
WHERE DEPTNUM = 1500) ";
This SQLCI example uses a string literal within a string literal because the
prepared statement includes a string literal itself. (Double quotes delimit the outer
string, and two quotation marks represent one quotation mark within the string.)
>> PREPARE ADDSUP FROM "INSERT INTO INVENT.SUPPLIER"
+> &" VALUES (?, ?, ?, ""BEND"", ""OREGON"", ""97709"" )";
---SQL command prepared.
>> EXECUTE ADDSUP USING 572, "ULTRA-TECH",
+> &"240 INDUSTRIAL WAY";
--- 1 row(s) inserted.
Primary Keys
A primary key is a column or a group of columns whose values uniquely identify the
rows in a table and (along with file organization and any collations associated with the
file) determine the order in which the rows are stored. Each base table and each index
has a primary key.
The primary key of a table stored in a key-sequenced file can be defined by the user
(PRIMARY KEY clause of the CREATE TABLE statement), defined by the file system
(SYSKEY column), or defined by both the user and the file system (CLUSTERING
KEY clause of CREATE TABLE, plus the SYSKEY column).
The primary key of a table stored in a relative or entry-sequenced file is always defined
by the file system.
The primary key of an index includes the keytag column, the indexed columns, and—
for nonunique indexes—the primary key of the underlying table.
Primary key values affect the order in which rows are stored and retrieved. The length
of the primary key is a factor in determining the maximum number of partitions for a
table or index. The number of columns in a primary key is a factor in determining the
number of columns that can be indexed and the maximum number of indexes possible
on a table.
A primary key is sometimes called a physical primary key.
For more information, see these entries:
Clustering Keys