smorgasbord of topics… scott forstie …€¢ ibm db2 for z/os • ibm db2 for linux, unix and...

35
1 DB2 for IBM i Smorgasbord of topics… Scott Forstie DB2 for i – Business Architect [email protected] For…

Upload: vokhanh

Post on 21-May-2018

244 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

1

DB2 for IBM i

Smorgasbord of topics…

Scott ForstieDB2 for i – Business [email protected]

For…

Page 2: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation2

Global Variables

Page 3: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation3 Intro to SQL

CREATE OR REPLACE – Easier (re)deployment of DDL

� When you use OR REPLACE, the CREATE will handle the case where the same named object already exists.

� When replacing an existing object, authorizations f or the existing object are moved to the new object

� Views are special. Dependent views are managed and rebuilt as part of the replace!

� Select the “OR REPLACE” option on Generate SQL to ea sily build re-deployable scripts

� CREATE OR REPLACE ALIAS

� CREATE OR REPLACE FUNCTION

� CREATE OR REPLACE PROCEDURE

� CREATE OR REPLACE MASK

� CREATE OR REPLACE PERMISSION

� CREATE OR REPLACE SEQUENCE

� CREATE OR REPLACE TRIGGER

� CREATE OR REPLACE VARIABLE

� CREATE OR REPLACE VIEW

Article: Use SQL CREATE OR REPLACE to Improve DB2 for i Obje ct Management

http://iprodeveloper.com/database/use-sql-create-or-replace-improve-db2-i-object-management

Page 4: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation4

Implicit Remote database access

Page 5: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation5

DRDA Interoperability

Oracle and SQL Server do not support DRDA as a

Application Server

Server and Client

DDM/DRDA Protocols

DDM/DRDA Protocols

• IBM DB2 for i

• IBM DB2 for z/OS

• IBM DB2 for Linux, UNIX and Windows (LUW)

• Other DB2® database products

• IBM Informix• Other databases (check your database vendor for their DRDA support statement)

Application Requestor (AR)

• IBM DB2 for i

• IBM DB2 for z/OS

• IBM DB2 for Linux, UNIX and Windows (LUW)

• Other DB2® database products

• Other databases (check your database vendor for their DRDA support statement)

Application Server (AS)

Page 6: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation6

CREATE TABLE with remote SUBSELECT

• CREATE TABLE AS and DECLARE GLOBAL TEMPORARY TABLE are enhanced to allow the select to reference a single remote database which is different than the current server connection• An implicit remote connection is established and used by DB2 for i• The remote query can reference a single remote homogeneous or heterogeneous table

Example:CREATE TABLE DATALIB.MY_TEMP_TABLE AS (SELECT CURRENT_SERVER CONCAT ' is the Server Name', IBMREQD

FROM X1423P2.SYSIBM.SYSDUMMY1) WITH DATA

SELECT * FROM DATALIB.MY_TEMP_TABLE� 7.1 Base – 3-part name support� TR4 – INSERT WITH

remote SUBSELECT� TR5 – CREATE TABLE WITH

remote SUBSELECT

Page 7: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation7

CREATE TABLE with remote SUBSELECT� The copy-options clause controls how “special” colum ns are processed

(excluding is the default)– Identity columns

– Defaults on columns

– Implicitly hidden columns

– Row change timestamp columns

CREATE TABLE DATALIB.MY_TEMP_TABLE AS (SELECT Column_....

FROM Alias… )

WITH NO DATA INCLUDING DEFAULTSINCLUDING IDENTITY

Limitations:

� For DB2 for i , DB2 for z/OS, and DB2 for LUW remote servers

– The materialized query table clauses are not allowed.

– A column with a FIELDPROC cannot be listed in the select list.

� DB2 for z/OS and DB2 for LUW

– Copy-options cannot be specified on the create table statement.

DRDA Server choices:DB2 for i (V5R4, 6.1 or 7.1)DB2 for z/OSDB2 for WindowsDB2 for AIXDB2 for HP-UXDB2 for Sun SolarisDB2 for LinuxDB2 for VM and VSE

Page 8: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation8

CREATE TABLE with remote SUBSELECT

• Use of an ALIAS is the best practice for remote 3-part names because it shields the application. (database transparency)• Notice how the text of the query does not change

Example:

CREATE OR REPLACE ALIAS DATALIB.TARGET_TABLE FOR X1 423P2.SYSIBM.SYSDUMMY1

CREATE TABLE DATALIB.MY_TEMP_TABLE(Server_Name) AS (SELECT CURRENT_SERVER CONCAT ' is the Server Name' FROM DATALIB.TARGET_TABLE) WITH DATA

CREATE OR REPLACE ALIAS DATALIB.TARGET_TABLE FOR LP 01UT18.SYSIBM.SYSDUMMY1

INSERT INTO DATALIB.MY_TEMP_TABLE(SELECT CURRENT_SERVER CONCAT ' is the Server Name' FROM DATALIB.TARGET_TABLE)

SELECT * FROM DATALIB.MY_TEMP_TABLE

Page 9: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation9

RDB alias support for 3-part SQL statements

� Instead of using CREATE ALIAS (SQL) to deploy database transparency, the Relational Database Directory Entry Alias name can be used.

ADDRDBDIRE RDB(X1423P2 MYALIAS) RMTLOCNAME(X1423P2 *IP) INSERT INTO WORKTABLE SELECT * FROM MYALIAS.SALESLI B.DAILY_SALES

CHGRDBDIRE RDB(LP13UT16 MYALIAS) RMTLOCNAME(LP13UT1 6 *IP) INSERT INTO WORKTABLE SELECT * FROM MYALIAS.SALESLI B.DAILY_SALES

WorkTable

X1423P2

LP13UT16

Note:

The SQL statement text does not change

Articles: Improve Your Data Center with Three-part Name Alias es

http://iprodeveloper.com/database/improve-your-data -center-three-part-name-aliases

Achieve improved database interoperability with SQL and RDB aliases

http://www.ibm.com/developerworks/ibmi/library/i-im proved-database-interoperability-sql-rdb/index.html

Page 10: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation10

SQL & Control Language Commands

Page 11: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation11

SQL – CL related enhancements

2012 2014

7.2 – GA

RUNSQLSTM command - OPTION parameter added to control listing

CPYTOIMPF and CPYFRMIMPF commands – Include column headings

ADD ORDERBY parameter to CPYTOIMPF command

Run SQL (RUNSQL) - new command

Infosphere Guardium V9 – target DB2 for i as a data source

Dynamic Compound statement

Additional Free form RPG & Embedded SQL

www.ibm.com/developerworks/ibmi/techupdates/db2

RUNSQL control of output listing

2013

7.2 – TR17.1 – TR97.1 – TR77.1 – TR67.1 – TR5

Page 12: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation12

SQL and CL - Programming Options

� Run SQL Statements (RUNSQLSTM)– Execute 1-Many statements in order

– SQL Statement text comes from:• Source physical file member• IFS stream file• Error Level (tolerance) control

� Run SQL (RUNSQL)– Execute a single statement

– SQL Statement text is part of the command string

� SQL Precompilers for host languages– Interleave SQL and host language logic

– Build and deploy a *PGM/*SRVPGM object

Page 13: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation13

RUNSQLSTM vs RUNSQL – compare & contrast

NoYesSyntax Checking option

(PROCESS)

NoYesStandards Flagging options(SAAFLAG & FLAGSTD)

Statement participates in transaction of the caller. No implied COMMIT/ROLLBACK.

Implied COMMIT/ROLLBACK

Must be at a commit boundary. (SQL7941)

Transaction Management(COMMIT)

NoneYes, with several command parameters for control

Spool File Output(OUTPUT)

5,0002,097,152Maximum Statement text length

Single1-manyStatement execution

RUNSQLRUNSQLSTMCommand Comparison

Page 14: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation14

RUNSQLSTM vs RUNSQL – compare & contast

NoYesCL Command execution from within script (CL: <command-string>;)

NoYesCommand parameters to control SQL “build” of Procedures, Functions and Triggers

(OPTION, OUTPUT, TGTRLS, DBGVIEW, CLOSQLCSR, DLYPRP,USRPRF,DYNUSRPRF)

No

(use RUNSQLSTM or developerWorks or Knowledge Center for help)

YesCommand Help text on IBM i 6.1 & 7.1

RUNSQLRUNSQLSTMCommand Comparison

Page 15: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation15

RUNSQL Command -Examples

� SQL parameter for entering of SQL statement– RUNSQL SQL(‘Create Table SAMPLE ( +

Class Char(5), Status Numeric(1,0), EffDate Date’) COMMIT(*NONE)

– RUNSQL SQL(‘Insert into SAMPLE +

Values(‘’FIRST’’, 1, ‘’2013-04-10’’)’) COMMIT(*NONE)

– RUNSQL SQL(‘Update SAMPLE +

Set EffDate = EffDate + 10 Days +

Where Status = 1 and EffDate = ‘’2013-04-10’’’) COMMIT(*NONE)

EffDate is now 2013-04-20– RUNSQL SQL(‘Delete from SAMPLE’) COMMIT(*NONE)

� No query output– SQL Select statements must insert results into intermediate file/table

– Results can then be read (e.g using RCVF command) and processed

Page 16: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation16

RUNSQL Command – Using CL variables

RUNSQL1: PGM PARM(&LIB) DCL &LIB TYPE(*CHAR) LEN(10) DCL &SQLSTMT TYPE(*CHAR) LEN(1000) CHGVAR VAR(&SQLSTMT) +

VALUE('DELETE FROM QTEMP.WorkTable1 + WHERE table_schema = ''' CONCAT &LIB CONCAT ''' ')

RUNSQL SQL(&SQLSTMT) COMMIT(*NONE) NAMING(*SQL) ENDSQL1: ENDPGM

You can build a pretty complex SQL statement using existing and new CL built-in functions

Page 17: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation17

RUNSQLSTM & Dynamic Compound statementsCREATE OR REPLACE VARIABLE QGPL.HANDOFF

VARCHAR(8) DEFAULT 'CONTINUE';

BEGIN

DECLARE Dynamic_STATEMENT VARCHAR(1000) CCSID 37;

DECLARE LOCAL_SQLCODE INTEGER;

DECLARE LOCAL_SQLSTATE CHAR(5);

DECLARE V_Message_text VARCHAR(70) CCSID 37;

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION

BEGIN

GET CURRENT DIAGNOSTICS CONDITION 1

LOCAL_SQLCODE = DB2_RETURNED_SQLCODE,

LOCAL_SQLSTATE = RETURNED_SQLSTATE;

IF (LOCAL_SQLCODE <> -601) THEN

SET QGPL.HANDOFF = 'EXIT';

SET V_Message_text =

'Create Table failed with: ' CONCAT LOCAL_SQLCODE CONCAT

' AND ' CONCAT LOCAL_SQLSTATE;

SIGNAL SQLSTATE 'QPC01' SET MESSAGE_TEXT = V_Message_text ;

END IF;

END;

SET Dynamic_STATEMENT =

' Create Table TOYSTORE6/SAMPLE (Class Char(5),

Status Numeric(1,0), EffDate Date) ';

EXECUTE IMMEDIATE Dynamic_STATEMENT;

END;

BEGIN

DECLARE Dynamic_STATEMENT VARCHAR(1000) CCSID 37;

DECLARE LOCAL_SQLCODE INTEGER;

DECLARE LOCAL_SQLSTATE CHAR(5);

DECLARE V_Message_text VARCHAR(70) CCSID 37;

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION

BEGIN

GET CURRENT DIAGNOSTICS CONDITION 1

LOCAL_SQLCODE = DB2_RETURNED_SQLCODE,

LOCAL_SQLSTATE = RETURNED_SQLSTATE;

IF (LOCAL_SQLCODE <> -204) THEN

SET QGPL.HANDOFF = 'EXIT';

SET V_Message_text =

‘Unexpected failure: ' CONCAT

LOCAL_SQLCODE CONCAT ' AND ' CONCAT

LOCAL_SQLSTATE;

SIGNAL SQLSTATE 'QPC02'

SET MESSAGE_TEXT = V_Message_text ;

END IF;

END;

IF (QGPL.HANDOFF = 'CONTINUE') THEN

SET Dynamic_STATEMENT =

'Insert into TOYSTORE6/SAMPLE Values(''FIRST'', 1, ''2013-04-10'' ';

EXECUTE IMMEDIATE Dynamic_STATEMENT;

END IF;

END;

RUNSQLSTM SRCFILE(SCOTTF/QCSRC) SRCMBR(SAMPLE1)

COMMIT(*NONE) NAMING(*SYS)

Page 18: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation18

RUNSQL & Dynamic Compound statementRUNSQL SQL(‘ BEGIN

DECLARE LOCAL_SQLCODE INTEGER;

DECLARE LOCAL_SQLSTATE CHAR(5);

DECLARE V_Message_text VARCHAR(70) CCSID 37;

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION

BEGIN

GET CURRENT DIAGNOSTICS CONDITION 1 LOCAL_SQLCODE = DB2_RETURNED_SQLCODE, LOCAL_SQLSTATE = RETURNED_SQLSTATE;

IF (LOCAL_SQLCODE <> -204) THEN

SET V_Message_text = ''INSERT failed with: '' CONCAT LOCAL_SQLCODE CONCAT '' AND '' CONCAT LOCAL_SQLSTATE;

SIGNAL SQLSTATE ''QPC41'' SET MESSAGE_TEXT = V_Message_text ;

ELSE

CREATE TABLE QGPL.LARGE_TABLE_TRACKER AS (SELECT LAST_CHANGE_TIMESTAMP, SIZING_NAME, SYSTEM_SCHEMA_NAME, SYSTEM_OBJECT_NAME, SYSTEM_TABLE_MEMBER, CURRENT_VALUE FROM QSYS2.SYSLIMITS WHERE LIMIT_CATEGORY = ''DATABASE'' AND LIMIT_TYPE = ''OBJECT'' AND SIZING_NAME LIKE ''%ROWS%'') WITH DATA;

END IF;

END;

INSERT INTO QGPL.LARGE_TABLE_TRACKER SELECT LAST_CHANGE_TIMESTAMP, SIZING_NAME, SYSTEM_SCHEMA_NAME, SYSTEM_OBJECT_NAME, SYSTEM_TABLE_MEMBER, CURRENT_VALUE FROM QSYS2.SYSLIMITS WHERE LIMIT_CATEGORY = ''DATABASE'' AND LIMIT_TYPE = ''OBJECT'' AND SIZING_NAME LIKE ''%ROWS%'';

END') COMMIT(*NONE) NAMING(*SQL);

Page 19: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation19

Database CL Commands - instrumented for Client Speci al Registers

• RUNSQLSTM, RUNSQL, STRSQL, WRKQRY, RUNQRY, STRQRY & STRQMQRYcommands are instrumented to utilize default values for the Client Special Registers.• Use these registers to identify workloads, track usage, and more.• Surfaces in SQL Details for Jobs, STRDBMON, Visual Explain, Health Center, etc.

• STRQMQRY Client Special Register values:� CURRENT CLIENT_APPLNAME - “ START QUERY MANAGEMENT QUERY”� CURRENT CLIENT_PROGRAMID – “STRQMQRY”� CURRENT CLIENT_USERID - <Caller of the command> � CURRENT CLIENT_WRKSTNNAME-<database name>� CURRENT CLIENT_ACCTNG - <Accounting code (ACGCDE) of caller>

• Database Monitor pre-filtering:STRDBMON OUTFILE(DBMONLIB/QMQRYMON1) JOB(*ALL/*ALL/*ALL) FTRCLTPGM(STRQMQRY)

Article: SOX Auditing of STRSQL and RUNSQLSTM Commandswww.ibmsystemsmag.com/ibmi/administrator/db2/SOX-Au diting-of-STRSQL-and-RUNSQLSTM-Commands

Page 20: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation20

Database CL Commands - instrumented for Client Speci al Registers

RUNQRY

STRSQL

STRQMQRY

RUNSQLSTM

RUNSQL

Filter by program name(FTRCLTPGM - QVC3006)

RUN QUERY

START SQL INTERACTIVE SESSION

START QUERY MANAGEMENT QUERY

RUN SQL STATEMENTS

RUN SQL STATEMENTS

Filter by application name(FTRCLTAPP - QVC3001)

STRQRY, WRKQRY & RUNQRY

STRSQL

STRQMQRY

RUNSQLSTM

RUNSQL

Command

Page 21: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation21

The new (optional) ORDERBY parameter can be used to control how rows are identified for the copy operation.

ORDERBY parameter values:

1) *NONE - No specific order requested. This is the default value for the command.

2) *ARRIVAL - The records will be inserted in Relative Record Number order.

3) character-value - Specifies an SQL ORDER BY clause that will be used for ordering the records in the to file.

Example:

CPYTOIMPF FROMFILE(CORPDB1/DEPARTMENT) TOSTMF('/dept.file') RCDDLM(*LF) ORDERBY('*ARRIVAL')

CPYTOIMPF FROMFILE(CORPDB1/DEPARTMENT) TOSTMF('/dept.file') RCDDLM(*LF) ORDERBY(' DEPTNO ASC FETCH FIRST 5 ROWS ONLY ')

After the ORDER BY detail, the user can tack on the following:

FETCH FIRST n ROWS OPTIMIZE FOR n ROWS

FOR UPDATE FOR READ ONLY

WITH <isolation-level> SKIP LOCKED DATA

USE CURRENTLY COMMITTED WAIT FOR OUTCOME

ADD ORDERBY parameter to CPYTOIMPF command

Page 22: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation22

CPYTOIMPF and CPYFRMIMPF commands – Include column headings

Copy To Import File (CPYTOIMPF) – a new (optional) parameter indicates whether the column names should be included as the first row in the target file.

ADDCOLNAM (*NONE or *SQL or *SYS)*NONE – (default) don’t include the columns names

*SQL – The column SQL names will be used to populate the first row

*SYS – The column System names will be used to populate the first row

Copy From Import File (CPYFRMIMPF) – a new (optional) parameter indicates whether the first row should be skipped when processing the import file.

RMVCOLNAM (*NO or *YES)*NO – (default) don’t skip the first row

*YES – remove the columns names from the file being imported byskipping the first row of data

Page 23: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation2323

Both QAUDJRN and SQL information is streamed to the Guardium collector

� Global SQL Monitor using a view and instead of trigger captures SQL information and puts them on a Unix queue

� Audit server job • Runs in QBATCH (or your choice of subsystem) • Receives QAUDJRN audit entries and puts them on a Unix queue• Runs a Guardium UNIX executable in PASE to receive entries from the queue

and send them to the collector• On an IPL it will restart automatically (you may have to start the subsystem)

Guardium STAP for IBM i

Secure logging

Secure logging

ibm.biz/GuardiumDAMonIBMi

Page 24: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation24

Navigator

Page 25: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation25

Windows Installed Client - Best Practices

1. Use the latest version of Navigator release/service pack regardless of your IBM i OS release

2. Use the Columns… control to customize & order detail

3. Create Navigator shortcuts on the desktop

Page 26: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation26

Windows Installed Client - Best Practices4. Direct Launch of Run SQL Scripts from a Shortcut"C:\Program Files (x86)\IBM\Client Access\Shared\cw bundbs.exe" /s=< machine> <optional-RSS-filename>Example:

"C:\Program Files (x86)\IBM\Client Access\Shared\cwbundbs.exe" /s=rchaptf3.rch.stglabs.ibm.com "C:\Users\IBM_ADMIN\Documents\ODBC tests\dump plan cache today.sql"

Page 27: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation27

Generate SQL options

• SQL Privileges (GRANT statements to match authorizations on the object)

• Schema qualify names for objects (easily cleansed)

• Column CCSID values (easily cleansed)

• OR REPLACE clause• Obfuscate (treat SQL logic as

a corporate asset)• Generate index options

(modernize DDS�SQL)

Page 28: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation28

DB2 for i – Function Usage IDs

Database Function Usage Identifiers:� QIBM_DB_DDMDRDA (ability to lock down

DRDA and DDM application server access)

� QIBM_DB_SQLADM (enable use of OnDemand Performance Center tools and more)

� QIBM_DB_SYSMON (SQL Details for jobs)

� QIBM_DB_ZDA (restrict ODBC and JDBC Toolbox from the server side, including Run SQL Scripts, System i Navigator and others)

� QIBM_DB_SECADM (7.2 only)Alternative to *SECOFR, administer security

Articles:

Improved Security Controls Open Door to DB2 for i T ool Usage

http://iprodeveloper.com/database/improved-security-controls-open-door-db2-i-tool-usage

Granular security control with function usage

https://www.ibm.com/developerworks/ibmi/library/i-granular-security/

Page 29: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation29

Database Maintenance and Navigator

• Significantly easier for a user to see long running operations in 7.1• The information is there when you need it, for active or completed operations

Page 30: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation30

Database Maintenance and Navigator

Reorganize

� Is the only interactive option in Database Maintenance… because you can cancel the reorganize

� A cancelled reorganize can be resumed later

� If still in the preparation phase, we have to start from scratch… let this phase finish!

� Ability to review table activity that occurred during the reorganization

� Status file is more sophisticated... history of the number of cancels

� The entire reorganize statement is saved

� Parallel degree is locked in at the start, but each step may use a different value

Number deleted rows eliminated

Starting recordAmount of storage recovered

Page 31: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation31

Database Maintenance and Navigator

� Alter Table

� Index builds

Alters with unique index(es)

Reorganize

New index create

� Index rebuilds

Restored base table without restoring the index

Alters with non-unique index(es)

� See the progress…ETA is a guess

� If an anomaly occurred... check the status file before repeating

Page 32: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation32

Q&A?

Thank you!

Page 33: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation33

This document was developed for IBM offerings in the United States as of the date of publication. IBM may not make these offerings available in other countries, and the information is subject to change without notice. Consult your local IBM business contact for information on the IBM offerings available in your area.

Information in this document concerning non-IBM products was obtained from the suppliers of these products or other public sources. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.

IBM may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. Send license inquires, in writing, to IBM Director of Licensing, IBM Corporation, New Castle Drive, Armonk, NY 10504-1785 USA.

All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.

The information contained in this document has not been submitted to any formal IBM test and is provided "AS IS" with no warranties or guarantees either expressed or implied.

All examples cited or described in this document are presented as illustrations of the manner in which some IBM products can be used and the results that may be achieved. Actual environmental costs and performance characteristics will vary depending on individual client configurations and conditions.

IBM Global Financing offerings are provided through IBM Credit Corporation in the United States and other IBM subsidiaries and divisions worldwide to qualified commercial and government clients. Rates are based on a client's credit rating, financing terms, offering type, equipment type and options, and may vary by country. Other restrictions may apply. Rates and offerings are subject to change, extension or withdrawal without notice.

IBM is not responsible for printing errors in this document that result in pricing or information inaccuracies.

All prices shown are IBM's United States suggested list prices and are subject to change without notice; reseller prices may vary.

IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless, our warranty terms apply.

Any performance data contained in this document was determined in a controlled environment. Actual results may vary significantly and are dependent on many factors including system hardware configuration and software design and configuration. Some measurements quoted in this document may have been made on development-level systems. There is no guarantee these measurements will be the same on generally-available systems. Some measurements quoted in this document may have been estimated through extrapolation. Users of this document should verify the applicable data for their specific environment.

Revised September 26, 2006

Special notices

IBM Corporation 2014 33

Page 34: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation34

IBM, the IBM logo, ibm.com AIX, AIX (logo), AIX 5L, AIX 6 (logo), AS/400, BladeCenter, Blue Gene, ClusterProven, DB2, ESCON, i5/OS, i5/OS (logo), IBM Business Partner (logo), IntelliStation, LoadLeveler, Lotus, Lotus Notes, Notes, Operating System/400, OS/400, PartnerLink, PartnerWorld, PowerPC, pSeries, Rational, RISC System/6000, RS/6000, THINK, Tivoli, Tivoli (logo), Tivoli Management Environment, WebSphere, xSeries, z/OS, zSeries, Active Memory, Balanced Warehouse, CacheFlow, Cool Blue, IBM Systems Director VMControl, pureScale, TurboCore, Chiphopper, Cloudscape, DB2 Universal Database, DS4000, DS6000, DS8000, EnergyScale, Enterprise Workload Manager, General Parallel File System, , GPFS, HACMP, HACMP/6000, HASM, IBM Systems Director Active Energy Manager, iSeries, Micro-Partitioning, POWER, PowerExecutive, PowerVM, PowerVM (logo), PowerHA, Power Architecture, Power Everywhere, Power Family, POWER Hypervisor, Power Systems, Power Systems (logo), Power Systems Software, Power Systems Software (logo), POWER2, POWER3, POWER4, POWER4+, POWER5, POWER5+, POWER6, POWER6+, POWER7, System i, System p, System p5, System Storage, System z, TME 10, Workload Partitions Manager and X-Architecture are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (® or ™), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries.

A full list of U.S. trademarks owned by IBM may be found at: http://www.ibm.com /legal/copytrade.shtml.

Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other countries.AltiVec is a trademark of Freescale Semiconductor, Inc.AMD Opteron is a trademark of Advanced Micro Devices, Inc.InfiniBand, InfiniBand Trade Association and the InfiniBand design marks are trademarks and/or service marks of the InfiniBand Trade Association. Intel, Intel logo, Intel Inside, Intel Inside logo, Intel Centrino, Intel Centrino logo, Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.IT Infrastructure Library is a registered trademark of the Central Computer and Telecommunications Agency which is now part of the Office of Government Commerce.Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates.Linear Tape-Open, LTO, the LTO Logo, Ultrium, and the Ultrium logo are trademarks of HP, IBM Corp. and Quantum in the U.S. and other countries.Linux is a registered trademark of Linus Torvalds in the United States, other countries or both.Microsoft, Windows and the Windows logo are registered trademarks of Microsoft Corporation in the United States, other countries or both.NetBench is a registered trademark of Ziff Davis Media in the United States, other countries or both.SPECint, SPECfp, SPECjbb, SPECweb, SPECjAppServer, SPEC OMP, SPECviewperf, SPECapc, SPEChpc, SPECjvm, SPECmail, SPECimap and SPECsfs are trademarks of the Standard Performance Evaluation Corp (SPEC).The Power Architecture and Power.org wordmarks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org.TPC-C and TPC-H are trademarks of the Transaction Performance Processing Council (TPPC).UNIX is a registered trademark of The Open Group in the United States, other countries or both.

Other company, product and service names may be trademarks or service marks of others. Revised December 2, 2010

Special notices (cont.)

IBM Corporation 2014 34

Page 35: Smorgasbord of topics… Scott Forstie …€¢ IBM DB2 for z/OS • IBM DB2 for Linux, UNIX and Windows (LUW) • Other DB2® database products • IBM Informix • Other databases

© 2014 IBM Corporation35

Revised April 2, 2007

Notes on performance estimates

rPerf for AIX

rPerf (Relative Performance) is an estimate of commercial processing performance relative to other IBM UNIX systems. It is derived from an IBM analytical model which uses characteristics from IBM internal workloads, TPC and SPEC benchmarks. The rPerf model is not intended to represent any specific public benchmark results and should not be reasonably used in that way. The model simulates some of the system operations such as CPU, cache and memory. However, the model does not simulate disk or network I/O operations.

• rPerf estimates are calculated based on systems with the latest levels of AIX and other pertinent software at the time of system announcement. Actual performance will vary based on application and configuration specifics. The IBM eServer pSeries 640 is the baseline reference system and has a value of 1.0. Although rPerf may be used to approximate relative IBM UNIX commercial processing performance, actual system performance may vary and is dependent upon many factors including system hardware configuration and software design and configuration. Note that the rPerf methodology used for the POWER6 systems is identical to that used for the POWER5 systems. Variations in incremental system performance may be observed in commercial workloads due to changes in the underlying system architecture.

All performance estimates are provided "AS IS" and no warranties or guarantees are expressed or implied by IBM. Buyers should consult other sources of information, including system benchmarks, and application sizing guides to evaluate the performance of a system they are considering buying. For additional information about rPerf, contact your local IBM office or IBM authorized reseller.

========================================================================

CPW for IBM i

Commercial Processing Workload (CPW) is a relative measure of performance of processors running the IBM i operating system. Performance in customer environments may vary. The value is based on maximum configurations. More performance information is available in the Performance Capabilities Reference at: www.ibm.com/systems/i/solutions/perfmgmt/resource.html

IBM Corporation 2014 35