SQL/MX Programming Manual for Java
SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java—523726-003
4-37
Automatic Hash Partitioning From an SQLJ Program
information about maintaining a network-distributed SQL/MX database environment,
see the SQL/MX Installation and Management Guide.
Automatic Hash Partitioning From an SQLJ Program
The Partition Overlay Specification (POS) enables you to create hash partitioned tables
automatically from an SQLJ program without using partition syntax in the CREATE
TABLE statement. To specify the number and locations of the partitions, use the
POS_NUM_OF_PARTNS and POS_LOCATIONS default attributes in CONTROL
QUERY DEFAULT statements.
For example, this SQLJ program creates a JOB table that is automatically hash
partitioned with non-primary partitions on three disk volumes, $vol2, $vol3, $vol4:
try {
try {
#sql [ctx] {CONTROL QUERY DEFAULT
POS_NUM_OF_PARTNS '4'};
#sql [ctx] {CONTROL QUERY DEFAULT
POS_LOCATIONS '$vol2,$vol3,$vol4'};
#sql [ctx] { /* SQL statement */ };
#sql [ctx] {CREATE TABLE samdbcat.persnl.job
( jobcode NUMERIC (4) UNSIGNED
NO DEFAULT
NOT NULL NOT DROPPABLE
HEADING 'Job/Code'
,jobdesc VARCHAR (18)
DEFAULT 0
HEADING 'Job Description'
,PRIMARY KEY (jobcode) NOT DROPPABLE
)
LOCATION \local.$vol1
};
System.out.println("Successful operation");
}
finally {
#sql [ctx] {CONTROL QUERY DEFAULT * RESET};
}
}
catch (SQLException se) {
System.out.println("Exception: " + se.getMessage());
}
For more information about the POS default attributes, see the SQL/MX Reference
Manual.