Keys; Clustering Keys; Syskey - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Keys

Neoview SQL supports these types of keys:

"Clustering Keys"

SYSKEYs
"Hash Partition Keys"
"Index Keys"
"Primary Keys"
Clustering Keys
Every table has a clustering key, which is the set of columns that determine the order of the rows
on disk. Neoview SQL organizes records of a table or index by using a b-tree based on this
clustering key. Therefore, the values of the clustering key act as logical row-ids.

SYSKEY

When the STORE BY clause is specified with the key-column-list clause, an additional column
is added to the key-column-list called the SYSKEY.
A SYSKEY (or system-defined clustering key) is a clustering key column which is defined by
Neoview SQL rather than by the user. Its type is LARGEINT SIGNED. When you insert a record
in a table, Neoview SQL automatically generates a value for the SYSKEY column. You cannot
supply the value.
Because the SYSKEY is a part of the clustering key, its ordinal location with other columns
depends on whether a HASH PARTITION BY clause is specified.
If a table is created specifying a STORE BY (key-column-list) clause but does not include
HASH PARTITION BY (partition-column-list), the SYSKEY is the last column of the
clustering key.
CREATE TABLE mytable (col1 INT NOT NULL, col2 CHAR(10) NOT NULL)
STORE BY (col1);
Key column order is col1, SYSKEY.
If the table is created specifying a STORE BY (key-column-list) and does include a HASH
PARTITION (partition-column-list), the SYSKEY is placed between the clustering
key columns and the additional partitioning columns. The algorithm generates the clustering
key by starting with the columns defined in the key-column-list, adding the SYSKEY,
and then including columns in the partition-column-list not already included in the
key-column-list.
CREATE TABLE t4 (col1 INT NOT NULL, col2 CHAR(10) NOT NULL)
HASH PARTITION BY (col2)
STORE BY (col1);
Key column order is (col1, SYSKEY, col2).
CREATE TABLE T4 (col1 INT NOT NULL, col2 INT NOT NULL, col3 INT NOT NULL)
HASH PARTITION BY (col1)
STORE BY (col1);
Key column order is (col1, SYSKEY).
CREATE TABLE t4 (col1 INT NOT NULL, col2 INT NOT NULL, col3 INT NOT NULL)
HASH PARTITION BY (col1, col3)
STORE BY (col1);
Key column order is (col1, SYSKEY, col3).
You cannot specify a SYSKEY at insert time and you cannot update it after it has been generated.
To see the value of the generated SYSKEY, include the SYSKEY column in the select list:
SELECT *, SYSKEY FROM t4;
272
SQL Language Elements

Advertisement

Table of Contents
loading

Table of Contents