Adding columns to the Db2 PLAN_TABLE table by importing DML
Use the following procedure to import DML to upgrade Db2 PLAN_TABLE tables with columns that were added by a later version of Db2.
Before you begin
Create a temporary table, as shown in the following figure that contains the new columns that were added by subsequent versions of Db2 for the PLAN_TABLE table, using Change Manager or SPUFI.
CREATE DATABASE DEMPLAN;
CREATE TABLESPACE TS1 IN DEMPLAN;
CREATE TABLE DEM.TESTPLAN
(WHEN_OPTIMIZE CHAR(1) NOT NULL,
QBLOCK_TYPE CHAR(6) NOT NULL,
BIND_TIME TIMESTAMP NOT NULL,
OPTHINT CHAR(8) NOT NULL WITH DEFAULT,
HINT_USED CHAR(8) NOT NULL WITH DEFAULT,
PRIMARY_ACCESS CHAR(1) NOT NULL WITH DEFAULT)
IN DEMPLAN.TS1
;
CREATE TABLESPACE TS1 IN DEMPLAN;
CREATE TABLE DEM.TESTPLAN
(WHEN_OPTIMIZE CHAR(1) NOT NULL,
QBLOCK_TYPE CHAR(6) NOT NULL,
BIND_TIME TIMESTAMP NOT NULL,
OPTHINT CHAR(8) NOT NULL WITH DEFAULT,
HINT_USED CHAR(8) NOT NULL WITH DEFAULT,
PRIMARY_ACCESS CHAR(1) NOT NULL WITH DEFAULT)
IN DEMPLAN.TS1
;
To create and import the DML statement
In an ISPF editor, type the DML statement to match the one shown in the following figure and provide the information that is unique to your site.For information about DML syntax, see CM-PILOT-Data-Manipulation-Language-DML.
-- EXAMPLE DML TO ADD PLAN TABLE COLUMNS
LIKE COLUMNS
JOIN SYSIBM.SYSCOLUMNS DEM
SET NAME = DEM.NAME,
COLNO = 200 + DEM.COLNO,
COLTYPE = DEM.COLTYPE,
LENGTH = DEM.LENGTH,
NULLS = DEM.NULLS,
DEFAULT = DEM.DEFAULT
WHERE
SYSIBM.SYSCOLUMNS.TBNAME = 'PLAN_TABLE'
--EXCLUDE THE SYSTEM PLAN TABLE FOR DB2
AND SYSIBM.SYSCOLUMNS.TBCREATOR <> 'SYSIBM'
AND SYSIBM.SYSCOLUMNS.COLNO = 1
--CHANGE TO WHATEVER YOU CALLED THE TEMP TABLE ABOVE
AND DEM.TBNAME = 'PLAN_TABLE'
--CHANGE TO WHATEVER YOU USED TO CREATE TEMP TABLE
AND DEM.TBCREATOR = 'DEM'
--FIND PLAN TABLES THAT DO NOT CONTAIN NEW COLUMNS
AND NOT EXISTS
(SELECT * FROM SYSIBM.SYSCOLUMNS X
WHERE
X.TBNAME = SYSIBM.SYSCOLUMNS.TBNAME
AND X.TBCREATOR = SYSIBM.SYSCOLUMNS.TBCREATOR
AND X.NAME = DEM.NAME)
;Import the DML file.Now that the DML file has been imported, you can analyze a work ID and execute a worklist.
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*