26
IBM System i 8 Copyright IBM Corporation, 2006. All Rights Reserved. This publication may refer to products that are not currently available in your country. IBM makes no commitment to make available any products referred to herein. i want skilled IT professionals. i want control. i want an i. Sail Through Database Tasks with iSeries Navigator Jim Flanagan IBM Rochester, MN USA IBM System i © 2006 IBM Corporation i want an i. Database Manager Configuration

Sail Through Database Tasks with iSeries Navigator · • Parallel Data load (Import)– Wizard based on CPYFRMIMPF and CPYTOIMPF CL commands – Show Command displays command syntax

  • Upload
    vanmien

  • View
    231

  • Download
    2

Embed Size (px)

Citation preview

1

IBM System i™

8 Copyright IBM Corporation, 2006. All Rights Reserved.This publication may refer to products that are not currently available in your country. IBM makes no commitment to make available any products referred to herein.

i want skilled IT professionals.i want control.

i want an i.

Sail Through Database Tasks with iSeries Navigator

Jim FlanaganIBM Rochester, MN USA

IBM System i

© 2006 IBM Corporationi want an i.

Database Manager Configuration

2

IBM System i

© 2006 IBM Corporationi want an i.

How do I install the database?

• It’s simple! i5/OS already has it in there

• Not only that, but integrated too!

• Ok, but what about release upgrades?

– Database automatically upgrades during the operating system upgrade

IBM System i

© 2006 IBM Corporationi want an i.

How do I get Database Fixes?

• Fixes are provided via PTFs just like other operating system fixes

• There is a special package for database group PTFs– Can be used as part of your preventative maintenance– Convenient packaging of database fixes– Every group PTF is thoroughly tested as a set to ensure quality

• Fix information and PTFs can be found on – http://ibm.com/servers/eserver/support/iseries/fixes/index.html

• PTFs can be managed using Management Central– included with iSeries Navigator for Windows

3

IBM System i

© 2006 IBM Corporationi want an i.

User Interface to the Database

IBM System i

© 2006 IBM Corporationi want an i.

About iSeries Navigator

iSeries Navigator ships with iSeries Access for Windows

– The database graphical user interface is a component of iSeries Navigator– iSeries Navigator comes with the base operating system for no extra charge

• None of the database GUI support requires an iSeries Access License

– When installing iSeries Access on your PC

• Database is not selected by default. Select “Custom" install

For general information on iSeries Access Express for Windows check our web site at:– http://www-1.ibm.com/servers/eserver/iseries/clientaccess/

• (PTFs are available from a link off the above page)

For a self-study iSeries Navigator database lab go tohttp://ibm.com/servers/enable/site/education/ibo/view.html?oc#db2

– Click on the "Piloting DB2 UDB for iSeries with iSeries Navigator in V5R3 “– Click on the "Register" link

4

IBM System i

© 2006 IBM Corporationi want an i.

How Do I Start the Database?

• It’s simple! If the system is up, the system database is up

• Support for multiple database instances per server (since V5R2)

– Requires special setup of Independent Auxiliary Storage Pools (IASPs)

• Allows you to work on multiple databases on a single system

– Expand each database to work at that level– No need to "switch" back and forth when

working with multiple databases on a specific system

• See Relational Database Directory entries

IBM System i

© 2006 IBM Corporationi want an i.

Explorer-like Interface

Folders under each Schema (Library), for each object type.

5

IBM System i

© 2006 IBM Corporationi want an i.

Managing the Schema – Seeing is believing

A list of database objects in the schema is nice, but...

• Now I understand this App(no wonder we didn't understand it!)

• Easily see how decisions could affect the schema

– I already have five indexes over that table?

– Should I remove one?– That view is really over seven tables?– I didn't know we had RI defined over

those• e.g. application designer creates a

test database using the picture and brings it to me for sign off

• Maps stored on i5/OS• Advanced, graphical version of

DSPDBR

IBM System i

© 2006 IBM Corporationi want an i.

Database Navigator

Can easily see relationships for existing schemas, including:

Referential ConstraintsIndexesViewsJournalsPrimary/Unique KeysAliasesCheck ConstraintsTriggersUDRsTable PartitionsMQTS

6

IBM System i

© 2006 IBM Corporationi want an i.

Database Navigator - UDRs

User-Defined Relationshipscan be defined to documentlinks

• Not SQL constructs

• A way to depict application-specific relationships

IBM System i

© 2006 IBM Corporationi want an i.

DBA Functions Available from Web Browser!

• Able to view database object lists over the web

• Many new lists and actions are available on the web in V5R4

New V5R4

7

IBM System i

© 2006 IBM Corporationi want an i.

DB Management / Operations

IBM System i

© 2006 IBM Corporationi want an i.

Creating a Schema (called Library pre-V5R3)

• CREATE SCHEMA MYSCHEMA;– Organizational construct– Library/Folder

• A stored procedure is shipped with i5/OS that can create sample schemas– CALL CREATE_SQL_SAMPLE(‘CORPDATA’);– Contains tables (including sample data), views, aliases, indexes, and RI– CORPDATA is used in the SQL manuals and labs

8

IBM System i

© 2006 IBM Corporationi want an i.

Database Object creation

• Create database objects with no storage considerations (including tables!)

• Browse function for reusing existing column definitions

• Robust Alter Table support

– No need for special utilities

How do I rebalance indexes?- it’s simple! The database does it for me.

New index create options for specifying parallel degree and page size New

V5R4

IBM System i

© 2006 IBM Corporationi want an i.

Run SQL Scripts• Create/save scripts for repetitive tasks

• Both SQL statements and CL commands

• See output for SQL queries

• Call stored procedures with result sets and/or OUTput parameters and launch iSeries System Debugger

• Do Visual Explain on queries, for performance analysis and tuning

• Syntax error highlighting and font chooser

• SQL Assistant for building SQL statements

• SQL state errors in message box, including second level text

• Prompting of CL commands

• Ignore drop error messages

New V5R4

9

IBM System i

© 2006 IBM Corporationi want an i.

Show SQL statement from create dialogs

• SQL statement is recorded as you fill in dialog

• Option to show the SQL statement being built

• Great for learning SQL syntax

• Allows for statement customization

IBM System i

© 2006 IBM Corporationi want an i.

Generate the SQL – Regenerate SQL CREATE/ALTER statements directly from the existing objects

• Helpful for when the original statements are no longer available• Teach programmers about SQL syntax of objects

New in V5R4:

Include generating short names of objects

Do not generate RI and triggers for tables

Include SET OPTIONS statement

See what the SQL form of my DDS-created files would be like

New V5R4

10

IBM System i

© 2006 IBM Corporationi want an i.

Data Dictionaries

• DDS File Field Reference Files

• SQL CREATE TABLE AS (subselect)Ex: CREATE TABLE SalesByRegion AS

(SELECT region, SUM(to_sales) FROM sales GROUP BY region) WITH NO DATA

• User-defined types

IBM System i

© 2006 IBM Corporationi want an i.

Journaling• Default journal automatically created

and started when creating a schema• Journal receivers contain journal

entries for recovery

11

IBM System i

© 2006 IBM Corporationi want an i.

Table Description

Answers questions like: How big is this table/file getting anyway?

– Works for indexes and views too!

IBM System i

© 2006 IBM Corporationi want an i.

How do I synch up my DB and OS userids?

It’s Simple! Group and user authorizations aremanaged by operating system

• SQL syntax maps to i5/OS security types

• Column level security

• Program vs. object level security

• Views

• Exits

• Auditing

12

IBM System i

© 2006 IBM Corporationi want an i.

Database Loading• Parallel Data load (Import)– Wizard based on CPYFRMIMPF and CPYTOIMPF CL commands

– Show Command displays command syntax in Run SQL Scripts

New V5R4

IBM System i

© 2006 IBM Corporationi want an i.

Constraint Repair

• Works for both check constraints and referential integrity constraints

• Show problem rows in table

• Able to update column values or delete entire rows

• Quick access to check constraint definition for check constraint repair

• Quick access to parent table rows for RI constraint repair

13

IBM System i

© 2006 IBM Corporationi want an i.

Reorganize Table Progress Monitoring

• New reorganize table options:

– Allow suspend (cancel)

– Allow online access

– Allow changes

– Influence when to rebuild access paths

• Allow reorganize to be suspended and resumed later

IBM System i

© 2006 IBM Corporationi want an i.

Reorganize Table --- Monitoring the Progress

• Show percent complete of reorganize and status of indexes as they are reorganized

• Attach to an already-running reorganization to see progress

• Ability to Suspend an ongoing reorg – even after disconnect of client

New V5R4

14

IBM System i

© 2006 IBM Corporationi want an i.

Manage Index Rebuilds

• Manage index re-creation after Reorgs, Database Restores, etc

• Priority Adjusting• Monitor Progress

• GUI version of EDTRBDAP system command

New V5R4

IBM System i

© 2006 IBM Corporationi want an i.

Health Center

• Overview to see database object counts by category

• View database wide or schemaspecific

– % wildcards can be used

• Capture to history file

• View history of counts for trending

New V5R4

15

IBM System i

© 2006 IBM Corporationi want an i.

Health Center • Size and Design Limits views

– Size limits are things that change by normal operations

– Design limits are things that change by application design

• View database wide, schema specific or by object name

– % wildcards can be used• Categorized by limit type, includes

system limit!• Status indicator for “within percent of

limit”– Changeable threshold

• Capture to history file• View history of limits for trending

New V5R4

IBM System i

© 2006 IBM Corporationi want an i.

Current SQL for a Job• Launched from Databases folder

• Find a job for which someone is reporting problems

• All columns are sortable

• Shows schema name and program name, service program name, or package name

• Edit SQL launches SQL statement into Run SQL Scripts window, or can go directly to Visual Explain

• Can view the job log and end the job

• Refresh allows for monitoring

• Statement & cursor information

New V5R4

16

IBM System i

© 2006 IBM Corporationi want an i.

Work Management for Database Jobs• Work with jobs

– Find a job for which someone is reporting problems– Customize list by user, job information, and column filtering– Find last SQL statement run by the job

IBM System i

© 2006 IBM Corporationi want an i.

Who’s Got Those Table Rows Locked?See what jobs have which rows locked for a given table • Shows the row number locked• Current User column shows “real” userid if from a client• Job information provided• Viewing of row locks also available in Work Management folder for jobs and

threads

17

IBM System i

© 2006 IBM Corporationi want an i.

Database Performance Monitoring and Tuning

IBM System i

© 2006 IBM Corporationi want an i.

Live Analysis – Index Advisor

Want DB2 to help with your Indexing Strategy?• New system-wide repository of DB2 Advised Indexes

– System view makes it easier to create index with biggest impact – Gauge benefits of index creation based on frequency, last occurrence, common keys– Available at the database, schema, or individual table level

• Enhanced Index Advice (SQE-Only)

• Ability to view SQL statements that caused index advice (SQE-Only)

New V5R4

18

IBM System i

© 2006 IBM Corporationi want an i.

Live Analysis – SQL Plan Cache

Easy analysis of current SQL workloads …

• Without overhead of database monitor

• Advanced filtering to quickly narrow focus to the most interesting SQL

– By number of executions– By DB2 object– …

• Easy access to Visual Explain for detailed analysis

• Archive capability into snapshot for future comparisons

• SQE-Only

New V5R4

IBM System i

© 2006 IBM Corporationi want an i.

SQL Performance Monitor Toolset

Have an existing application and want tocapture the SQL activity and analyze it?

• Start / Stop database monitor– Pre & Post-Filtering– Summary or Detailed– Import data from other systems

• Areas to watch:– Index advised– Full opens vs. pseudo opens– Access plan rebuilds– Index creates

• Recommended during application tuning & problem determination

• Keep a baseline monitor run for comparison

19

IBM System i

© 2006 IBM Corporationi want an i.

SQL Performance Monitor Filtering

• Minimize system-impact by reducing amount of data collected – Collect data for a specific user– Collect data for a collection of jobs (QZDASO*)– Collect data for longer-running SQL requests

• Enables quicker analysis & identification of SQL performance bottlenecks• Post-Filtering available for Visual Explain interface

New V5R4

IBM System i

© 2006 IBM Corporationi want an i.

SQL Performance Monitor Analysis

Drill-Thru Analysis

Dashboard Summary

Summary view to more simply decide, if the monitor has attributes that require deeper analysis

Integrated analysis with ability to launch other performance tools from current analysis view

New V5R4

20

IBM System i

© 2006 IBM Corporationi want an i.

SQL Performance Monitor Comparison

Want to know if an application change, system change or PTF altered your DB2 performance?

Compare current SQL performance “profile” with archived monitor data

See if the optimizer’s implementation of an SQL statement has changed

Can be long-running operation for large database monitor collections

New V5R4

IBM System i

© 2006 IBM Corporationi want an i.

Analyze SQL Performance Monitors with Visual Explain • Select existing

detailed SQL Performance Monitor

• Show list of SQL statements captured by the monitor

• Can import monitor data from other systems

• Can narrow down analysis with post-filters

New V5R4

21

IBM System i

© 2006 IBM Corporationi want an i.

Visual Explain• Active window - Look at DB

objects (indexes, constraints, etc.) involved

• Attributes show all the settings that impact query optimizer

– Labels include optimizer’s estimates

– SQE plans show decomposed SQL statement for each operation

• Icon Highlighting to speed analysis

– Expensive nodes– Index Advised nodes

• Debug messages help bridge to picture

IBM System i

© 2006 IBM Corporationi want an i.

Index Advisor• Advisor shows indexes that

would help specific query (if any)

• Use advice along with Index Analyzer for the table to determine if index would be helpful

• Create button prompts Create Index dialog with recommended columns pre-filled

22

IBM System i

© 2006 IBM Corporationi want an i.

Statistics

• Advisor in Visual Explain shows statistics that would help specific query

• How do I run statistics?– It’s simple! Statistics

automatically created/maintained by database

• Cardinality, Most common values

IBM System i

© 2006 IBM Corporationi want an i.

Evaluating your Indexes & MQTs

Is an Index or MQT providing value?• Launch Evaluators by right-clicking on table and select Show Index or MQT• Scroll Right to find the interesting query optimizer usage statistics

– Stats updated for all query interfaces – MQTs are SQL-only– Includes all objects the optimizer evaluates whether created by DDS or SQL

• Index Evaluator available on V5R2 & V5R3 via PTF – statistics not updated until the PTFs are applied

New V5R4

23

IBM System i

© 2006 IBM Corporationi want an i.

Analyze Performance of SQL Programs & Packages

• Explain SQL is equivalent to PRTSQLINF CL command

• Can Explain SQL for functions, procedures, triggers, and packages

• Can Explain SQL for programs by going down the File System folder

• How do I rebind my application packages?– It’s simple! The database does it for you

automatically.

IBM System i

© 2006 IBM Corporationi want an i.

Database Application Design

24

IBM System i

© 2006 IBM Corporationi want an i.

SQL and External Triggers

• Easily create External and SQL Triggers with new wizard in V5R4 (ADDPFTRG)• Also added Instead of triggers over views

IBM System i

© 2006 IBM Corporationi want an i.

Stored Procedures

• Easily create External (including Java) and SQL stored procedures• A List of example SQL statements makes creating SQL procedures easier

25

IBM System i

© 2006 IBM Corporationi want an i.

SQL Graphical Debug

• Starts with SQL *SOURCE Debug View– Specifying DBGVIEW=*SOURCE on the SET OPTION clause in your SQL

procedure, function, or trigger– Specify a *SOURCE value for DBGVIEW parameter on the RUNSQLSTM

(Run SQL Statements) CL command

• Graphical iSeries System Debugger– Part of the Toolbox for Java– Typical debugger capabilities– Can debug SQL procedures, functions, and triggers that run on System i5

family

IBM System i

© 2006 IBM Corporationi want an i.

iSeries System Debugger - example

26

IBM System i

© 2006 IBM Corporationi want an i.

Ease of Database Management

Multiple IBM & 3rd Party ProductsData Replication & Consolidation

iSeries Navigator3rd Party Tools

Advanced DB Performance Analysis & Tuning

3rd Party ToolsAutomated DB Performance Profiling

iSeries Navigator& 3rd Party Tools

Create and Maintain DB Schema

iSeries NavigatorPerformance Analysis & Tuning (DB & System)

iSeries Navigator / Automated Index AdvisorCreate & Review Indexes for Tables

iSeries NavigatorBuild and Manage DB Backup & Recovery

iSeries NavigatorLoad Data into Database

AutomatedReload Data for Hardware & Software Upgrades

AutomatedSynchronized OS & DB User Security

AutomatedUpdate Database Statistics

AutomatedMaintain Database Integrity

AutomatedApplication Rebinding

AutomatedReview & Balance Indexes

AutomatedReview Table Space Allocations & Extents

AutomatedManage DASD Space Allocation

DB2 UDB for iSeriesTypical DBA Tasks

IBM System i

© 2006 IBM Corporationi want an i.

Additional Information• DB2 UDB for iSeries home page - ibm.com/iseries/db2• Newsgroups

– USENET: comp.sys.ibm.as400.misc, comp.databases.ibm-db2– iSeries Network SQL & DB2 Forum -

http://www.iseriesnetwork.com/Forums/main.cfm?CFApp=59• Education Resources - Classroom & Online

– http://www.iseries.ibm.com/db2/gettingstarted.html– http://ibm.com/servers/enable/site/education/ibo/view.html?oc#db2

• DB2 UDB for iSeries Publications– White Papers: ibm.com/servers/enable/site/education/ibo/view.html?wp#db2– Online Manuals: http://www-3.ibm.com/servers/eserver/iseries/db2/books.html– Porting Help: http://ibm.com/servers/enable/site/db2/porting.html– DB2 UDB for iSeries Redbooks (http://ibm.com/redbooks)

• Stored Procedures, Triggers, and UDFs on DB2 UDB for iSeries (SG24-6503)• Preparing for the V5R2 SQL Query Engine (SG24-6598)• Modernizing iSeries Application Data Access (SG24-6393)