Documente Academic
Documente Profesional
Documente Cultură
IBM DB2 10.1 Administration for the Experienced SQL Server DBA
Lab Exercises
Version 6.1 August 25, 2012 Burt Vialpando & Vikram Khatri
Copyright IBM Corporation, 2006, 2012 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Contents
LAB 01. INSTANCE EXPLORATION ............................................................................................................................... 8 A. DB2 OPERATING SYSTEM DIRECTORIES AND FILES .............................................................................................. 8 B. START AND STOP A DB2 INSTANCE................................................................................................................... 12 C. CLP INTRODUCTION........................................................................................................................................ 13 D. DB2 WINDOWS REGISTRY ............................................................................................................................... 16 E. CREATE A NEW DB2 INSTANCE ........................................................................................................................ 17 F. CATALOG A NEW DB2 INSTANCE ...................................................................................................................... 19 G. EXTRA EXERCISES.......................................................................................................................................... 22 DATABASE CREATION AND EXPLORATION ............................................................................................... 24 A. GENERAL DB2 DATABASE COMMANDS ............................................................................................................. 24 B. THE DB2 SYSTEM AND LOCAL DATABASE DIRECTORIES ..................................................................................... 26 C. CREATING A DATABASE ................................................................................................................................... 27 D. EXPLORING VARIOUS DB2 DATABASE FUNCTIONALITY FEATURES ......................................................................... 30 E. ALTERING A TABLE .......................................................................................................................................... 31 DATA STUDIO.................................................................................................................................................. 32 A. LAUNCHING DATA STUDIO ................................................................................................................................ 32 B. CONNECTING TO AND MANAGING A DATABASE .................................................................................................... 33 CLPPLUS AND ORACLE COMPATIBILITY.................................................................................................... 55 A. LOGGING ON TO CLPPLUS............................................................................................................................... 55 B. INTERACTIVE CLPPLUS COMMANDS .................................................................................................................. 57 C. RUNNING A SCRIPT FILE IN BATCH MODE ............................................................................................................ 63 D. ORACLE COMPATIBILITY .................................................................................................................................. 66 SECURITY ........................................................................................................................................................ 77 A. INSTANCE LEVEL SECURITY.............................................................................................................................. 77 B. DATABASE LEVEL SECURITY ............................................................................................................................ 80 B. DATABASE LEVEL SECURITY ............................................................................................................................ 80 D. USING THE SYSTEM CATALOG SECURITY VIEWS ................................................................................................ 86 E. USER AND GROUP OVERVIEW .......................................................................................................................... 89 F. SCHEMAS ....................................................................................................................................................... 90 G. VIEWING DATABASE AUTHORITIES ...................................................................................................................... 91 H. COLUMN AND ROW LEVEL SECURITY .................................................................................................................. 92 I. EXTRA EXERCISE: DB2AUDIT AND AUDIT POLICY............................................................................................ 94 J. EXTRA EXERCISE: A QUICK LOOK INTO LABEL BASED ACCESS CONTROL ............................................................... 96 K. CLEANUP ....................................................................................................................................................... 96 AUTONOMIC COMPUTING ............................................................................................................................. 97 A. SELF TUNING MEMORY MANAGER (STMM)....................................................................................................... 97 B. AUTOMATIC STORAGE ................................................................................................................................... 101 C. RUN AUTOCONFIGURE (COMMAND LINE FOR CONFIGURATION ADVISOR)............................................................ 102 D. EXTRA EXERCISE: AUTOMATIC MAINTENANCE ................................................................................................. 103 E. EXTRA EXERCISE: STATISTIC PROFILING ......................................................................................................... 109 F. EXTRA EXCERCISE: SYSTOOLS SETUP ......................................................................................................... 110 G. CLEANUP ..................................................................................................................................................... 110 DEEP COMPRESSION .................................................................................................................................. 111 A. TABLE DEEP COMPRESSION........................................................................................................................... 111 C. CLEAN UP .................................................................................................................................................... 115 EXPLAIN FACILITIES AND THE OPTIMIZER............................................................................................... 116 A. CREATE EXPLAIN TABLES .............................................................................................................................. 116 B. UNION ALL VIEW EXAMPLE SETUP .................................................................................................................. 117 C. VISUAL EXPLAIN IN DATA STUDIO ................................................................................................................... 119 D. VISUAL EXPLAIN TUNING A QUERY ............................................................................................................... 123 E. USING DB2EXFMT EXPLAIN MULTIPLE QUERIES AT ONCE.................................................................................. 128 F. EXTRA EXERCISE USING DB2EXPLN ............................................................................................................. 129 H. EXTRA EXERCISES: REBIND AND ROW MOVEMENT ................................................................................... 131 WORKLOAD MANAGEMENT (WLM)............................................................................................................ 132 A. SETTING UP A CUSTOM WORKLOAD MANAGER ENVIRONMENT ............................................................................. 132 B. SETTING UP TO SIMULATE A WORKLOAD ........................................................................................................... 136 C. RUNNING A WORKLOAD AS USER DB2USER1 .................................................................................................... 138 D. RUNNING A SECOND WORKLOAD AS DB2COBRA ................................................................................................ 140 E. RUNNING A THIRD WORKLOAD AS USER DB2DEFAULT ........................................................................................ 142 F. WORKING WITH WLM EVENT MONITORS .......................................................................................................... 144
LAB 02.
LAB 03.
LAB 04.
LAB 05.
LAB 06.
LAB 07.
LAB 08.
LAB 09.
G. EXTRA EXERCISE: MISCELLANEOUS WLM LESSONS ........................................................................................ 145 H. CLEAN UP .................................................................................................................................................... 145 LAB 10. HIGH AVAILABILITY DISASTER RECOVERY (HADR)................................................................................ 146 A. HADR LAB OVERVIEW ............................................................................................................................... 146 B. SET UP HADR.............................................................................................................................................. 147 C. CREATE OBJECTS IN PRIMARY DATABASE AND MONITOR HADR ....................................................................... 148 CREATE SOME TABLES TO WORK WITH .................................................................................................................. 151 D. MONITOR HADR OUTSIDE THE GUI ................................................................................................................ 157 E. SWITCH ROLE OF DATABASES ........................................................................................................................ 158 F. CLEANUP...................................................................................................................................................... 160 LAB 11. IBM DB2 PUREXML....................................................................................................................................... 161 A. CREATE A SUPPORTING DATABASE AND AN XML READY TABLE ........................................................................ 161 B. INSERTING AND EXPLORING XML DATA ........................................................................................................... 163 C. IMPORTING AND EXPORTING XML DATA .......................................................................................................... 166 D. CREATING INDEXES ON XML DATA ................................................................................................................. 168 E. EXTRA EXERCISE: REGISTERING AN XSR........................................................................................................ 169 F. EXTRA EXERCISE: VALIDATING WITH THE XSR ................................................................................................. 170 G. CLEANUP ..................................................................................................................................................... 170 LAB 12. MULTIDIMENSIONAL CLUSTERS (MDCS) .................................................................................................. 171 A. CARS TABLES EXAMPLE SETUP .................................................................................................................... 171 B. EXPLORE MDC SPACE USAGE ....................................................................................................................... 172 C. EXPLORE MDC TABLE ORGANIZATION ............................................................................................................ 174 D. USING THE DB2BATCH BENCHMARKING UTILITY ................................................................................................ 176 E. EXTRA EXERCISE - MDC PERFORMANCE TIMING TEST ..................................................................................... 177 F. CLEANUP...................................................................................................................................................... 181 LAB 13. DATA MOVEMENT UTILITIES....................................................................................................................... 182 A. DB2RELOCATEDB (A TRANSPORTABLE DATABASE UTILITY) .............................................................................. 182 B. CONVERTING NON-UNICODE DATABASE TO UNICODE DATABASE ....................................................................... 187 C. SYSPROC.ADMIN_MOVE_TABLE ........................................................................................................... 191 C. DATA INGESTION........................................................................................................................................... 192 D. CLEANUP ..................................................................................................................................................... 193 LAB 14. BACKUP, RESTORE & RECOVERY............................................................................................................. 194 A. OFFLINE BACKUP .......................................................................................................................................... 194 B. OFFLINE RESTORE ........................................................................................................................................ 195 C. OFFLINE REDIRECTED RESTORE USING DATA STUDIO ...................................................................................... 197 D. CONFIGURE DATABASE LOGGING ................................................................................................................... 201 E. ONLINE DATABASE BACKUP ........................................................................................................................... 202 F. DATABASE RECOVER AND RESTORE / ROLL FORWARD TECHNIQUES .................................................................. 203 G. RECOVER A DROPPED TABLE......................................................................................................................... 204 H. RESTORE A HISTORY FILE ............................................................................................................................. 204 I. MOVING TABLE SPACE LOCATIONS WITH A SCRIPT (REDIRECTED RESTORE) ........................................................ 205 J. ONLINE TABLE SPACE BACKUP / RESTORE / RECOVERY .................................................................................... 207 K. INCREMENTAL BACKUP / RESTORE / RECOVERY ............................................................................................... 207 L. DELTA BACKUP / RESTORE / RECOVERY .......................................................................................................... 208 N. CLEANUP ..................................................................................................................................................... 208 LAB 15. MONITORING................................................................................................................................................. 209 A. SNAPSHOT MONITORING ................................................................................................................................ 209 B. EVENT MONITORING ...................................................................................................................................... 210 C. DATA STUDIO STORED PROCEDURE PROFILING ............................................................................................... 213 D. LIGHT WEIGHT MONITORING SQL FUNCTIONS AND DB2PD ............................................................................. 215 E. IBM DATA STUDIO WEB CONSOLE ................................................................................................................. 216 E. CLEANUP ..................................................................................................................................................... 221 LAB 16. ADDITIONAL MISC. TOPICS......................................................................................................................... 222 A. TEMPORAL DATA MANAGEMENT & TIME TRAVEL QUERY ................................................................................... 222 B. FEDERATION SIMPLE DB2 TO DB2 EXAMPLE ................................................................................................. 225 C. CLEANUP ..................................................................................................................................................... 227 OPTIONAL TOPICS VOTING SHEET ........................................................................................................................................ 231
IBM Software
Lab Instructions
Setting up this Proof of Technology (PoT) if you are not using an IBM VMware approach
If you are not doing this lab in an IBM hosted Proof of Technology session on IBM prepared VM imaged computers, you can prepare for this PoT yourself by doing the following:
Create userid dbapot with password dbapot123. Log on as this user to complete these steps. Install IBM DB2 10.1 Enterprise Server Edition on a Windows XP Enterprise machine (as user dbapot) Use all the defaults while installing DB2 Copy the PoT scripts to your computer (if you did not get these, ask for them from your IBM rep) Run the setup script in a DB2 Command Line Processor (CLP) Command Window. Script is located at: C:\POT_DB2\00SETUP\Setup01.BAT. Install the free DB2 Data Studio product, using the defaults. http://www.ibm.com/developerworks/spaces/optim?pageid=649 Make sure your Windows Explorer can see hidden files and folders. From the Windows Explorer choose: Organize Folder and Search Options. Then choose the tab: View and check the button: Show Hidden Files and Folders.
Helpful icons:
You might want to create the following desktop icons to make your PoT experience easier: IBM Data Studio DB2 CLP Command Window Windows Command Prompt Windows Explorer Services
Windows users:
The Setup01.BAT script creates the following users: db2cobra, db2user1, db2user2 and db2default, each of these have passwords that match the names. Important note #1: YOU must first create a user dbapot yourself with password dbapot123. After you create this user, you should log on with this user to do the product install and setup. This is the user you should do the PoT lab exercises with. The other users will be invoked as needed by the scripts. Important note #2: You should also make sure all the users do not have an expiring password. To see this, at a Windows Command Prompt type: NET USER [username]. If any are expiring, change the password to not expire, or reset the password using the Windows Control Panel.
Page 6
Lab Instructions
IBM Software
Script file names use this convention: TTTTNN.EXT TTTTT NN EXT = Topic lesson (like Instance) = Number of script within that lab section = File extension that best describes the contents: CMD, BAT, DB2, SQL, DML, DCL, etc. For example: CMD files are the scripts that run other scripts.
Lab Instructions
Page 7
IBM Software
___2.
To check where to find code is installed, type: db2set all (Note the location of DB2INSTPROF and DB2PATH )
The following are the kinds of DB2 profile registry variables and are parsed by DB2 in this order: Environment variables - denoted by [e] Node level registry Global level registry - denoted by [n] - denoted by [g] Instance level registry - denoted by [i]
The DB2INSTPROF may differ for you depending upon your operating system type. For example, in Windows XP, it is at: C:\Documents and Settings\All Users\Application Data\IBM\DB2\DB2COPY1\
Page 8
IBM Software
DB2 install path ___3. Using the Windows Explorer, find that DB2PATH location: Windows Explorer Program Files IBM SQLLIB Explore this directory and the BIN directory under it to see all the DB2 binaries
Instance default metadata path ___4. Using the Windows Explorer, find the DB2INSTPROF location by using: Windows Explorer ProgramData IBM DB2 DB2COPY1 DB2 and explore this directory. (Note, this will be different for Windows XP)
If not using the PoT VM image, to see this normally hidden directory, in the Windows Explorer use: Organize Folder and search options Show hidden files & folders.
Page 9
IBM Software
___5.
Find the folder for instance called DB2: Find db2systm - this is the DBM config binary file. (Please, do not try to edit this.) Find db2diag.log in the DIAG000 directory - this is the diagnostic log file. (You can edit this.)
Database default metadata path ___6. ___7. Now lets explore the database files managed by instance DB2 Using the Windows Explorer, find: ___8. My Computer C: DB2 NODE0000 SQL0001
Look at directory SQL0001 This is the metadata folder for the SAMPLE database. Even though we are exploring instances in this lab, we still need to see how databases relate to instances and how each are placed on your operating system. Well show you later how you know which SQL subdirectory goes with which database
SQL0001 is the directory for the metadata for the SAMPLE database. This is different that the SAMPLE directory which is where the automatic storage containers are kept for the SAMPLE database.
Page 10
IBM Software
___9.
___10. Browse the various directories and files. What do you suppose SQLOGSTREAM0000 is? (Hint: its a default directory) SQLOGSTREAM0000 is where your active log path defaults to unless you change the location ___11. SQLDBDIR, which is on the same level as SQL0001, is the location of the "local database directory" for all databases created under instance DB2. We will be learning about what a local database directory is later.
Page 11
IBM Software
___13. To see the environment variable that shows the current instance, type: set db2instance ___14. To stop an instance, type: db2stop force This command works against the current instance only db2 stop dbm is an alternative using the CLP (try later when we use the CLP)
___15. To start an instance, type: db2start A DB2 instance always takes only a few seconds to start
Find DB2 DB2COPY1 - DB2-0 right click on it stop Windows service naming convention starts all DB2 services with DB2, then it uses the copy of DB2 you are using (usually DB2COPY1).
___17. Start the service by using right click start or use db2start at the command line ___18. You can make Windows automatically start your instance using this screen, right click and choose properties ___19. Minimize your Services window for now; dont close it yet. UNIX notes on instances: The default instance created on a UNIX system is usually called db2inst1. To automatically start a DB2 instance upon server startup, use the db2iauto command.
Page 12
IBM Software
C. CLP Introduction
___20. This section is to demonstrate a command line interface for DB2. ___21. Here are terms used throughout these Proof of Technology lab workbooks: Windows Command Prompt Windows Explorer DB2 CLP Command Window DB2 CLP Interactive Windows Operating System command shell Windows Operating System GUI DB2 command window running in the OS shell DB2 command window running in its own shell
___22. To start the DB2 CLP Command Window, from the Windows Command Prompt, type: db2cmd This starts the DB2 shell over the OS shell often called the DB2 CLP Command Window This is one mode of the Command Line Processor (CLP)
___23. Close the Windows Command Prompt you opened first as we won't be needing it for now. ___24. From the new DB2 CLP Command Window you just opened, type: db2 get dbm cfg Notice the use of dbm (data base manager = instance) These are the instance configuration parameters
___25. To see what is in the instance memory, hit your up arrow key, then finish typing: db2 get dbm cfg show detail You will get an error stating you are attached to the instance, so you cannot get detailed information from it. The detail will show temporary changes to the cfg settings (if any) so you need to be attached to the instance to find this information The cfg it is referencing is simply information in a binary file and saved changes are persistent.
Page 13
IBM Software
___26. To attach to a DB2 instance, type: db2 attach to db2 ___27. Try the previous command again (hint: hit your up arrow key): db2 get dbm cfg show detail ___28. To see the DB2 Administration Server (DAS) settings, type: db2 get admin cfg DAS is a special process that helps administrate communication between instances and databases, locally and remotely which has its own configuration settings For UNIX systems, a special DAS user needs to be created, normally called dasusr1
___29. Try the DB2 CLP in the interactive mode, type: db2 This is sometimes called the DB2 Command Line Processor or CLP, however, it really is just another mode of the DB2 CLP
___30. To verify your instance location, type: get instance Notice this time we did not need to preface the command with db2
___31. Run run a Windows command or launch a .bat file, preface it with a !, type: !dir ___32. To understand connections and applications, in the DB2 CLP interactive window type: connect to gsdb
Page 14
IBM Software
___33. Now, type: list active databases Active databases have at least one connection to them by at least one application This database is active because we connected to it
___34. Type: list applications Notice that GSDB has a db2bp.exe application name (the CLP)
___35. Type: list applications show detail This demonstrates there are other applications to the database started on our behalf when the database was activated
___36. Type: terminate This command does the following: resets the connection to GSDB, refreshes the directory cache, stops the background process and leaves the CLP interactive session
___37. We are no longer in the interactive mode, but we can still run DB2 commands. Try listing the active databases. What happens and why?
Page 15
IBM Software
___40. In this window, go to HKEY_LOCAL_MACHINE\SOFTWARE\IBM\DB2\PROFILES\ DB2 is the instance GLOBAL_PROFILE is for all DB2 instances on server Just note for now the various registers that are kept for DB2
Minimize this Registry Editor window for now, dont close it yet.
Page 16
IBM Software
DB2 Instance creation on UNIX: 1. Sets environment variables DB2INSTANCE and PATH Creates /SQLLIB subdirectory in $HOME of the SYSADM (e.g. /home/[inst-name] /sqllib) Configures communication based on servers available protocol
2. Creates files db2profile for main environment variable settings (bourne, bash, ksh) userprofile for upgrade and additional environment variable settings
3. Requires user id to: Run with root authority this is because it needs to access the db2icrt command in the DB2 install directory /opt/IBM/db2/[version]/instance/db2icrt on most UNIX platforms /opt/ibm/db2/[version]/instance/db2icrt on Linux Specifies an instance name that is tied to a particular user id which has its own home file system and home directory; this user id should also have the SYSADM authority
Create a DB2 instance and then verify it in Windows: ___41. In the DB2 CLP Command Window, change directories to C:\POT_DB2\01INSTANCE ___42. Type: db2icrt db2bkp
The instance is created. For details on this command see file: Instance_DB2ICRT_Command.txt
___43. Services window check: Go to Services window and click Action refresh Find new service db2bkp (its name is: DB2 - DB2copy1 - db2bkp) Start this instance (Hint: right click on it) Close the Services window now.
Page 17
IBM Software
___44. Registry Editor check: In your Registry Editor window click: View refresh Find the new folder created for db2bkp Close the Registry Editor window Windows Explorer View refresh Find the instance metadata folder in: C:\Program Data\IBM\DB2\DB2COPY1 folder You should see your new instance folder DB2BKP
___46. Perform other checks in a DB2 CLP Command Window to see you new instance, type: db2set l db2ilist db2 get instance (shows available instance profiles) (shows same thing, but with some options) (what is your default instance?)
set db2instance=db2bkp (change your current instance) db2 get instance (you should be pointing to DB2BKP instance now)
___47. Now lets explore dropping instances: db2icrt db2jnk db2idrop db2jnk (check to see if it created another instance) (gets rid of this instance thats it!)
This command only has one flag that it so force applications off before dropping, see: Instance DB2IDROP_Command.txt Creating and dropping instances in DB2 is just that easy
Page 18
IBM Software
___50. From the DB2 CLP Command Window type: db2 list node directory
___51. Notice the instance DB2 now knows about, or has cataloged, the DB2BKP instance. This means they can now communicate with each other and that any GUI tools launched can see both of them locally or remotely.
You can use the utilities db2cfexp AND db2cfimp to export and import all of your clients configuration settings. This allows you to easily share all of the catalog information without doing individual catalog commands. These commands also allow you to exchange protocol, registry, dbm cfg and ODBC/CLI settings. (ODBC is Open Database Connectivity.) Usage of this tool is demonstrated in the extra exercises of this lab.
Page 19
IBM Software
___52. Let's set up the communication for our instance to make sure it is available for use by any TCPIP client: 1. Set up the DB2 Communication Protocol set db2instance=db2bkp db2 get instance db2start db2set db2comm=tcpip db2set -all
2. Set up the Instance Service Name (the TCPIP listening port) db2 update dbm cfg using svcename 50001 db2 get dbm cfg | findstr SVCE db2stop force db2start
Page 20
IBM Software
3. Attach to the instance db2 attach to db2bkp db2 get dbm cfg
On the DB2 server, we set the registry variable DB2COMM to the protocol(s) used for listening. TCP/IP is commonly used, while SSL is another option. Example: db2set DB2COMM=TCPIP If the protocol at the DB2 server instance is TCP/IP, then we can set the DBM configuration parameter SVCENAME too. Example Unix: update dbm cfg using svcename db2c_db2inst1 servicename | portnumber matches the entry in: etc/services
Example Windows: update dbm cfg using svcename 50000 db2c_db2 | 50000/tcp can match the entry in: %SystemRoot%\system32\drivers\etc\services After this, we should recycle the instance with db2stop, then db2start in order for it to take effect.
Page 21
IBM Software
G. Extra Exercises
DB2CFEXP (Connectivity Configuration Export Tool) usage example ___53. Review and execute script: Instance02.CMD Review files Instance02_OUTPUT.TXT DBMCFG, DBCFG and REG_VARIABLES Administration views usage example ___54. Review and execute script: Instance03.CMD which executes Instance04.SQL
DB2DIAG (diagnostic log tool) usage example ___55. Review and execute script: Instance05.CMD Review files Instance05a_OUTPUT.TXT and Instance05b_OUTPUT.TXT INSPECT and DB2INSPF usage example ___56. Review and execute script: Instance06.CMD Review files Instance06_OUTPUT.TXT DB2PD (Problem Determination) usage example ___57. Review and execute script: Instance07.CMD Review files Instance07_OUTPUT.TXT DB2GCF (Generic Control Facility) usage example ___58. Review and execute script: Instance08.CMD Review files Instance08_OUTPUT.TXT DB2SUPPORT usage example ___59. Review script and execute it: Instance09.CMD Executes problem analysis support tool, db2support, in a full mode Review file instance09_out.zip and then launch db2support.html
Page 22
IBM Software
CLP exercises ___60. How do you change your CLP interactive prompt to: Your next wish master? db2set db2_clpprompt=Your wish master? When this is done, change it back to the default with: db2set db2_clpprompt= ___61. Execute these commands from the CLP interactive mode: connect to sample select current date from sysibm.dummy ___62. When you get an error code, check it out by using the following: DB2 ? SQL0204N ___63. Fix this command by executing this: select current date from sysibm.sysdummy1
Page 23
IBM Software
___2. ___3.
Change directory to C:\POT_DB2\02DATABASE In this window type: set db2instance=db2 db2 get instance
___4.
To make sure the instance is in an Oracle compatibility mode, do the following: db2set db2_compatibility_vector=ORA db2set all db2stop force db2start (sets the compatibility) (make sure the setting was done correctly) (stops the instance) (starts the instance)
___5.
___6.
To see the database configuration parameters, type: get db cfg for sample
Page 24
IBM Software
___7.
Connect to the SAMPLE database: connect to sample The complete syntax for the CONNECT would be: connect to sample user dbapot using dbapot123
___8.
To explore further, type these and hit [Enter] after each line: get db cfg get connection state list tables for schema dbapot
The default schema for a userid is usually the userid itself. Well explore in more detail later in the Security lab the differences between a user and a schema in DB2.
___9.
Continue exploring your database, type the following using [Enter] after each line: describe table department describe indexes for table department select * from employee describe output select * from employee values user select user from dual values current date select sysdate from dual runstats on table dbapot.employee reorgchk update statistics on schema dbapot quit
The above commands that used DUAL will only work when the registry variable is set to make our instance Oracle compatible. Well learn more about Oracle compatibility in a later lab.
Page 25
IBM Software
___11. Connect to the GSDB database to prove that you can access it, type: db2 connect to gsdb ___12. Connect back to the SAMPLE database using the same background process: db2 connect to sample ___13. Uncatalog the GSDB database in the current instance: db2 uncatalog database gsdb ___14. Refresh the directory cache (and terminate the background process as well): db2 terminate ___15. List the system database directory again. Notice GSDB is not there: db2 list database directory ___16. List the local database directory db2 list database directory on c: ___17. Try to connect to the GSDB directory (notice you cannot): db2 connect to gsdb ___18. Recatalog database GSDB to make it available again: db2 catalog db gsdb ___19. Refresh the directory cache (and terminate the background process as well): db2 terminate ___20. Try to connect to the GSDB directory (notice now you can!): db2 connect to gsdb
Page 26
IBM Software
C. Creating a Database
Creating a database managed by the instance DB2 ___21. To create a database in the instance DB2, try these commands: set db2instance=db2 db2 get instance db2 terminate db2 create database sample2 This will take a few minuteswhile this command is executing, see the explanation in the box below for what the CREATE DATABASE command is doing. Also, review the file Database_CREATE_DATABASE_Command.txt
The DB2 CREATE DATABASE command does the following: 1. 2. 3. 4. 5. 6. 7. Creates a subdirectory to hold the database metadata information Creates SYCATSPACE, TEMPSPACE1 and USERSPACE1 table spaces Creates system catalog tables in the SYSCATSPACE table space Creates SQLJ, SYSCAT, SYSFUN, SYSIBM, SYSIBMADM, SYSIBMINTERNAL, SYSIBMTS, SYSPROC, SYSPUBLIC and SYSSTAT schemas Grants SECADM, DBADM, DATAACCESS and ACCESSCTRL authorities to the database creator Grants selected database privileges to PUBLIC (unless specified as restricted) Defaults many things for you, but you can control these if you wish: Partition number Install path Database alias name Collating characteristics Codeset and territory Table space characteristics (types, sizes, containers, etc.) Database configuration parameters (using feature called autoconfigure which well go through later) Set up Automatic Storage and Automatic Resize defaults Many other things (see: Database CREATE_DATABASE_Command.txt)
___22. When the CREATE DATABASE command finishes, run this command next: db2 list db directory
Page 27
IBM Software
Creating a database managed by the instance DB2BKP ___23. Now lets create a database called BACKDB in a different instance: DB2BKP ___24. Review and run these scripts: Database01.CMD which executes Database02.DB2 Remember, it takes a few minutes to finish... while this is running.
___25. Execute these commands: db2 get instance db2 list db directory ___26. Notice database BACKDB is not in the directory for our instance DB2. This is because we have not yet cataloged it to instance DB2. (It is however cataloged to the instance DB2BKP which manages / owns it.) ___27. Lets catalog database BACKDB to instance DB2: db2 catalog db backdb at node db2bkp with 'my first db catalog' db2 terminate
___28. Review if it is in the system catalog of our instance DB2: db2 list db directory
Page 28
IBM Software
db2 terminate
Page 29
IBM Software
___31. To learn about db2mtrk Memory Tracking: Review and run script: Database04.CMD Review files: Database04_OUTPUT.TXT & Database_DB2MTRK_Command.txt
___32. To learn about Event Monitoring: Review and run script: Database05.CMD Review file: Database05_OUTPUT.TXT & Database_DB2EVMON_Commant.txt
Page 30
IBM Software
E. Altering a Table
DB2 allows you to alter a table in many different ways. Here is an example of how DB2 can alter a table: ___33. Review scripts Database15.CMD which executes Database16.DDL. Notice what this last script is doing: 1) renaming a column, 2) changing a column data type from SMALLINT to CHAR, 3) dropping a column:
DB2 ALTER TABLE actually has much more power than this. For example, you can alter a column from CHAR to BIGINT for example, provided your data can be cast that way. So, if your CHAR column had 1,2,3 data in it, DB2 would scan your column to make sure your CHAR data can be cast into and BIGINT column, and if it can do that, it will! DB2 can alter a table to change any column data type to any other, provided the data can be cast that way. For an extra exercise, try these commands: db2 describe table alter_table_tb db2 alter table alter_table_tb alter column dept set data type bigint db2 describe table alter_table_tb
*** End of Database Creation and Exploration Lab by Burt Vialpando ***
Page 31
IBM Software
ORYou can open Data Studio by choosing: Start All Programs IBM Data Studio Data Studio 3.1.1 Full client ___2. At the Workspace Launcher window, make sure your workspace is pointed to the following folder: C:\POT_DB2\03DATASTUDIO\WORKSPACE
___3. ___4.
Check the box: Use this as the default and do not ask again After the perspective opens, close the Task Launcher view
___5.
The top right portion of your screen shows that you are now in the Database Administration perspective.
Page 32
IBM Software
___7. ___8.
You are now in a Properties for GSDB screen. Fill in the following (case sensitive!) User name: dbapot Password: dbapot123 Save password: [check]
___9.
Page 33
IBM Software
___10. In this same Properties for GSDB screen, click on the Common setting ___11. Check box: Connect every time the workbench is started [OK]
___12. You are now connected to the GSDB database. After you leave Data Studio, upon return, you will automatically reconnect. Notice you see GSDB database in the Administration Explorer below the instance DB2.
Instance management
___13. Maximize your Data Studio screen in order to best take advantage of the entire Database Administration perspective. ___14. Right click on the instance DB2. Notice the functionality that is available to you for the instance that manages GSDB. We wont be using any of these yet so dont choose any of them. (Note: Configure means changing the DBM cfg parameters; we will explore this in a later exercise.)
Page 34
IBM Software
Database management
___15. Right click on the GSDB database connection to see what database management activities you can perform with the UI. ___16. Choose: Set Up and Configure Configure. This will allow you to change database (DB) configuration parameters.
___17. An Editor view opens up in the middle pane of your perspective. Double click on the view name to expand it to full screen. Dont change any parameters just now, but notice how you could if you wanted to. Close this screen when done by clicking on the X in the view tab.
___18. Right click on GSDB and choose: Manage Database List or Force Applications Just browse through the applications screen to see how you can force (kill) an application with it. Do not force any applications! Close this screen when done. ___19. Now review: Manage Database Manage Storage to be able to add automatic storage paths to your database. ___20. Expand GSDB database and notice you can click on database level objects like buffer pools or table space to manage these as well. Expand table space for example and right click on one to see what you can do.
___21. Close all Editor views (top middle screens in your Database Admin perspective) when done.
Page 35
IBM Software
___23. Expand the Data Source Explorer GSDB database connection as shown below. Notice the first GSDB entry is the connection property, the second is the database itself
___24. Right click on the GSDB database and choose: New SQL Script
___25. Choose the appropriate instance and database connection that this script will run in
The Editor view will be open with a blank SQL editor session.
Page 36
IBM Software
___26. In the Script1.sql editor view, copy and paste the two SQL statements shown below found in the file : C:\POT_DB2\03DATASTUDIO\DataStudio01.SQL.
(Alternately, you can drag and drop the script from the Windows Explorer into the editor view or you can use a technique: File Open File...) ___27. The first SQL statement will use a proprietary Oracle syntax (reference to DUAL) and the second a proprietary DB2 syntax (reference to FETCH) select sysdate from dual; select * from gosales.product fetch first 5 rows only; ___28. Highlight both statements, right click, then choose: Format SQL
___29. Highlight the first SQL statement and hit [F5] SQL statement and then choose: Run SQL)
___30. Find the output in the bottom right pane of your Data perspective in the SQL Results view. (You may have to expand it a bit to see the results better.)
Notice that Data studio will use whatever Oracle compatibility features you have enabled for your database. (We enabled this earlier.)
Page 37
IBM Software
___32. Look at the SQL Results section closely. Notice you can now click on either query you have run before. Both result sets are available to you.
You can right click in the SQL Results pane and remove or save any of these results. ___33. Highlight the first query, then right click on it, then choose: Toggle Comment (or [Ctrl] /)
___34. Position your cursor after the asterisk in the second query. Use [Ctrl][Space] to get context assist for this SQL. Notice here it gives the column names and data types from the table referenced. This helps you build or edit the query without having to go to another window to look these things up. You can double click on any column name to put it into the query. Try it.
. ___35. Remove the keyword ONLY from the second query. Notice you get a syntax warning with the red X mark on the line and a red underline near the syntax problem. (Note: you can turn these off if you don't want to see them.)
___36. Put the keyword "ONLY" back into the SQL statement to fix the syntax error.
Page 38
IBM Software
___37. Right click in the editor window anywhere, choose: Validate Database Object References
___38. Now change your query to reference a fake column name (like XXX) that does not exist in your table in the query (as shown below) and notice you get an error warning.
___39. Change the editor settings back to how it was in the beginning of this Editor lesson ___40. Close this Editor view and dont save the script.
Page 39
IBM Software
C. Exploring Tables
Overview diagrams
___41. Expand the top and side of your Data Source Explorer to see more of it ___42. Expand the objects in this view by clicking on the + signs by: 1) GSDB database, 2) Schemas & 3) GOSALES under schema.
___43. Notice each database object type is represented for you to manipulate with the UI. Data Studio is powerful as you can right click on any object or any level of object and it will show you what things you can do. ___44. Expand the Tables under schema GOSALES. ___45. Select table PRODUCT Hold [SHIFT] Click PRODUCT_TYPE Right Click Add to Overview Diagram
Page 40
IBM Software
___46. At the Overview Diagram Selection screen, check the Infer implicit relationships box. This is a powerful Data Studio capability that can go beyond defined foreign keys on tables. It will match up column names and data types to make relationships in the diagram. Click: [OK]
___47. Data Studio will take a couple of seconds to calculate the inferred relationships and return a diagram of these tables in the Editor view. ___48. Double click on the diagram views tab. This will maximize this view in your Data perspective.
___49. Review the diagram. Move the tables and lines around to get a sense for how this can be redrawn if you dont like the default diagram.
Page 41
IBM Software
___50. Double click the diagram view tab again to shrink it. Select the Properties view and notice you can manipulate the diagram using this view if you want to by selecting anything on the diagram.
This is just a basic functionality of Data Studio. If you want the full power of a data modeling tool, please ask about IBM InfoSphere Optim Data Architect which integrates fully with other Eclipse based tools. ___51. Close the diagram view when you are done with this review.
Page 42
IBM Software
___53. In the editing screen find the last row <new row>. Right click on it Insert Row ___54. Add values 2104 and Burts Beeswax to the row. Update another row by changing a value in it like shown below. Click Save or [CTRL]+S
___55. Notice the SQL Results view message that reflects what you just did.
___56. Close the Edit view. Save your work as you exit. ___57. Right click on the table PRODUCT_LINE again. This time try: Data Sample Contents ___58. Look in the SQL Results view, your changes should be there.
Page 43
IBM Software
Generating DDL
___59. Select all tables in schema: GOSALES (hint: hold [Shift]). ___60. Right click then choose: Generate DDL
___61. Choose all the defaults [Next] then [Next]. ___62. In the Save and Run DDL screen, check the box: Edit and run DDL in the SQL Editor.
___64. Close the script Editor view when done reviewing the DDL.
You have a great amount of flexibility in generating DDL like creating DROP statements, fully qualifying object names, including DDL for related objects, etc., but we just chose defaults for this example to keep it simple.
Page 44
IBM Software
___67. Find table PRODUCT under the tables view in the Administration Explorer. Right click and choose: Manage Reorg Table
___68. In the Reorg editor choose the options shown below then: Preview Command.
Page 45
IBM Software
___70. At the top of your Data Studio menu choose: File New Data Development Project
___72. Make sure you associate the GSDB database connection property with this project. Click [Next].
___73. Change the Default schema to be GOSALESCT which happens to be where the stored procedure is we want to debug.
Your project will be created with the properties you just chose.
Page 46
IBM Software
___75. In the top left view in your Data perspective, find and expand your project MyFirstProject in the Data Project Explorer. Notice the types of projects we can do in this view. We will be working on a Stored Procedures project in this view.
___76. Now go to the Data Source Explorer, and find and expand Schemas to find schema GOSALESCT. Find Stored Procedures. Click on GET_CUSTOMER_NAME then drag and drop it into the Stored Procedures section of the project MyFirstProject as shown below.
Page 47
IBM Software
___77. Choose the stored procedure code for GOSALES.GET_CUSTOMER_NAME, right click on it then: Open
___78. Notice the Editor view has this code loaded and ready for you to start working with.
Debugging the stored procedure ___79. Right click on the stored procedure, then choose: Deploy
Page 48
IBM Software
___81. On the Routine Options screen, make sure to click: Enable debugging Then: [Finish]
___83. Now right click on the stored procedure, then choose: Debug
___84. In the Specify Parameter Values screen, set CUSTOMERID to 101. Then: [Debug]
Page 49
IBM Software
___85. Data Studio will now warn you that it is about to change perspectives on you. Check the Remember my decision box and then: [Yes]
___86. Look in the upper right hand corner of the screen and notice you now have both a Debug and a Data perspective opened. You can switch between them now if you want to. Stay in the Debug perspective for now.
___87. In this Debug Perspective, set breakpoints anywhere in your code by double clicking in the shaded area next to the code. Set breakpoints on all the SELECT statements as shown below.
Page 50
IBM Software
___88. Now either press [F5] to go from line to line or use the icon shown below to Step Into the code. Learn to use [F6] and [F7] for Step Return and Step Over.
___89. As you step through this simple stored procedure, notice the output parameters (variables) change. The code we are using here is purposefully simple to demonstrate how strategically placed breakpoints will help you find what your code is doing and what it is returning.
___90. If you run all the way through the code and the session is terminated, then just right click on the terminated session itself and choose: Relaunch. This will let you start your debugging all over again.
Page 51
IBM Software
___91. Close the Debug perspective when you are done by right clicking on it and then: Close.
___92. Back in the Data perspective, close all the editor views.
Page 52
IBM Software
___94. In the Run screen, click on the Run and Performance Options tab
___95. Check the Performance data box that says: Gather performance information from the database Then: [Run]
Page 53
IBM Software
___96. In the SQL Results view, find the Profiling Data tab. Review all the performance information and imagine a large complex procedure with lots of loops and branches. This information can tell you where the code is going and what it is doing line by line. Right click on any line of code to switch to the InfoSphere Optim Query Workload Tuner to begin a tuning session. (Note: this product has not been installed for this lab and is outside the scope of this topic. Ask about our other PoTs on various IBM tooling for more details.)
___97. In the SQL Results view, right click and choose: Remove All
___98. Close your editors and exit from the Data Studio by using the tool bar: File Exit
Page 54
IBM Software
___3.
CD \POT_DB2\04CLPPLUS
CLPPlus does not require a DB2 CLP Command Window to execute in. We will show that in the next few exercises by only using a Windows Command Prompt. ___4. ___5. For our CLPPlus session, we will be using the following parameters: User: Password: Host: Port: Database: dbapot dbapot123 localhost 50000 sample
There are several ways to start up CLPPlus. The first method we will use is to connect directly to the database upon start up. In the terminal window, type in the following command:
CLPPLUS dbapot/dbapot123@localhost:50000/sample
Page 55
IBM Software
___6.
You are now in an interactive CLPPlus window with a default prompt: SQL>
We could have started CLPPlus without a new window staying in the Windows Command Prompt window instead. To do this use the -nw option, as shown below. For these exercises, we'll just use the default window.
Page 56
IBM Software
DESCRIBE employee
CLPPlus commands are not case sensitive. In this lab, CLPPlus commands are capitalized in order to distinguish the command from the keywords. ___8. Use the HOST command to run any operating system command. For example, try this:
HOST dir
___9. Using the Windows Explorer, review script file: CLPPlus01.SQL. ___10. To execute this script in CLPPlus, use the command:
START CLPPlus01.SQL
___11. Any DB2 commands in the script will be loaded to the SQL buffer and executed.
Page 57
IBM Software
The GET command will load the script into the SQL buffer without executing it.
LIST
Use CLPPlus SQL buffer line commands to manipulate a query ___13. We would like to sort the entries by salary in ascending order instead of descending. To do this, we can use the CHANGE command that will do a pattern matching and replace the old token with the new one. Be aware that the pattern string you provide is case-sensitive.
LIST
___15. Use the RUN command to execute the query contained in the SQL Buffer. You can also use / as an alias to the RUN command.
RUN
Page 58
IBM Software
Using the editor ___16. Use the EDIT command to invoke the default editor to make changes to the SQL buffer.
EDIT
___17. In the editor, change the NOT LIKE value from E% to A%
___18. Save to the buffer with: File Save ___19. Exit the editing session with : Exit ___20. Your buffer has changed and lists the code again for you automatically. Use the / key to run this new change (or use the RUN command)
Page 59
IBM Software
Writing results to a file (SPOOL) ___21. Use the SPOOL command to save the results of our SQL output to a file in order to make a report. SPOOL requires an output file name and optionally a complete path. Type in the command:
SPOOL employee_report.txt
___22. Now execute the following commands to create your report file:
___24. Use the SHOW command to check the value of a particular CLPPlus setting. Try this to see if your spool is on or not:
SHOW spool
___25. Try this to see all of your command control settings:
SHOW
Page 60
IBM Software
___26. Notice your timing command control setting is off. To see timing of your executed SQL try this:
Page 61
IBM Software
Save and clear the SQL buffer content ___27. Use the SAVE command to save the contents of the SQL buffer to a file:
SAVE employee_changed_report.sql
___28. Now find and review this file using the Windows Explorer
With SAVE, you could hard code a complete path where you want the saved file to go, otherwise CLPPlus will put the file in the path where you invoked SAVE from.
___29. Use the CLEAR command to empty your SQL buffer in order to start fresh.
QUIT
Page 62
IBM Software
___32. Notice in this script we invoke the CLPPlus with a SQL script file all in one command line:
___33. Using the Windows Explorer, find the SQL script file CLPPlus03.SQL. Open it and review it. Take time to review the control setting commands like SET or COLUMN. ___34. Run the command file to see how it creates a report automatically for you using all of these techniques weve seen so far:
CLPPlus02.CMD
___35. Notice the output report is spooled to a file CLPPlus02_OUTPUT_REPORT.TXT. Use the Windows Explorer to open this report to see the formatting.
Page 63
IBM Software
Using substitution variables ___36. Lets explore using substitution variables in a script. Use the Windows Explorer to open command file CLPPlus04.SQL. ___37. Notice this script has two ACCEPT commands. The first is for the OWNER_NAME_STRING variable which is accepted, defined and used later in the query.
___38. Run this SQL script the way shown below. (This is typed all in one line and there is a space after the database name and before the @SQL script file name.)
These answers are strings that our query uses to find any owner with pot in the name and any table with emp in its name because the query uses a LIKE syntax in the WHERE clause.
Page 64
IBM Software
___40. Review output report CLPPlus04_OUTPUT_REPORT.TXT. Notice our query has used the substitution variables to customize the report. (Owner only has pot in the name and the table_name only has ones with emp in the name. Try running this script again, but this time use different values for the variables, or, just hit [ENTER] when prompted for the variable and let it default and see what happens. (Hint: use the up arrow key to bring back your old command at the Windows Command Prompt.)
Substitution variables can be used in your SQL in any way you can dream up in any part of the SQL statement, not just in the WHERE clause. These make a single query more flexible. ___41. Run this SQL script again, but use the way shown below to see that you can provide substitution variables with the execution of the script (without having to do it interactively.) Use the variables dba and mdc as shown below:
Page 65
IBM Software
D. Oracle Compatibility
Now lets see some more native Oracle functionality using the CLPPlus. This functionality works in the DB2 CLP Command Window too by the way, or in any programming interface for that matter. We will be mixing CLP with CLPPlus command examples in this lab exercise, so do the following: Checking your Oracle compatibility environment ___43. First, lets look at our registry variables to see if we are in an Oracle compatible mode. Type the following:
db2set -all
Notice the registry variable DB2_COMPATIBILITY_VECTOR. Setting this to ORA turns on all Oracle compatibility features. (It is possible to set this to choose only some compatibility features, but we have set it for all Oracle related features.) To activate this registry variable for your instance, you would start and stop the instance with two commands: DB2STOP then DB2START. (We did these things already in the first command script in this lab.) Once this registry variable is set for your instance, you would next create your database. Creating a database with the compatibility vector set will enable it to use Oracle native data types and also creates an Oracle data dictionary compatible set of views in the DB2 system catalog. (We have already done that for the SAMPLE database in our setup script for this PoT.) ___44. To see the Oracle dictionary views in the DB2 database, review and run script CLPPlus05.CMD:
CLPPlus05.CMD
___45. Review CLPPLUS05_OUTPUT_REPORT.TXT. Seeing these views and the compatibility vector as above tells us we are ready to use all Oracle native PL/SQL syntax.
Page 66
IBM Software
Using Oracle proprietary syntax in a DB2 database with CLPPlus ___46. Review and run script CLPPlus05.CMD and CLPPlus06.SQL to see SQL using Oracle proprietary syntax used in a DB2 database. Notice now you will be able to run these kinds of commands in DB2 because you are in a compatibility mode. You can run these in the CLP, in CLPPlus, in a Java program, in any way that you may want.
CLPPlus06.CMD
___47. Review the output file CLPPlus05_OUTPUT_REPORT.TXT to see how DB2 can use: DECODE, SYSDATE, DUAL, ROWNUM and NVL. Using Oracle proprietary syntax in a DB2 database with the CLP ___48. Close your Windows Command Prompt window ___49. Open a DB2 CLP Command Window and change to directory C:\POT_DB2\04CLPPLUS
___50. We can run Oracle syntax in the DB2 CLP Command Window too. However, the CLP does not by default recognize the / as a delimiter in scripts the way CLPPlus does. So, in order to get the CLP to use this / delimiter we use a SET SQLCOMPAT command. ___51. Review script CLPPlus08.CMD
___52. Review the script it calls: CLPPlus09.SQL. Notice this is just regular Oracle PL/SQL syntax that creates a procedure.
Page 67
IBM Software
CLPPlus08.CMD
___54. Notice that the creation of the procedure is successful and the call to that procedure works. Review file CLPPlus08_OUTPUT_REPORT.TXT for details.
Automatic Revalidation ___55. There is a database parameter called AUTO_REVAL. This parameter controls how revalidation of objects is enforced in DB2. The most powerful option of this parameter is called deferred_force. Lets see how this works: ___56. From the DB2 CLP Command Window, type the following: db2 connect to sample db2 update db cfg using auto_reval deferred_force ___57. To make sure this has taken affect, type this next (this is case sensitive): db2 get db cfg | findstr AUTO_REVAL ___58. You should see this if your commands worked properly:
Page 68
IBM Software
First, notice DB2 will perform the CREATE OR REPLACE functionality on the view. This capability is very important for online schema change. It means that we can avoid using DROP in order to recreate a view which preserves grants to the view. Second, notice also that the view references a function not yet created, and then the function references a table not yet created. Wont this DDL fail if it is attempted to be run in this order? Normally, yes, but with AUTO_REVAL to deferred_force set as we did earlier, it will work just fine. We will see this in action soon. Third, the table is created and data inserted into it. Finally, the view is used in a SELECT. Results are displayed because the view and function will automatically revalidate upon reference. Since everything is there for them to validate, the view works just fine!
___60. Run script CLPPlus10.CMD. ___61. Notice that the view and function are created, but are marked as invalid and an error code is produced
Page 69
IBM Software
___62. Notice though that at the end of the script, the SELECT from the view works just fine! This is because the view and functions are automatically revalidated upon access.
DB2 has another online schema change ability called soft invalidation. This allows for you to drop or alter an object, even while transactions are using that object. For example, you could have a long running query going against a view. DB2 allows you to alter or drop the view without killing the transaction. The running transaction simply uses the copy of the view until it completes. This is the default setting for DB2. If you want to turn this off, do the following registry variable change: db2set DB2_DDL_SOFT_INVAL=OFF
Page 70
IBM Software
Migrating a schema from Oracle to DB2 ___63. We have taken some DDL from an Oracle database, and separated it by object type as shown below. Lets see if we can create these objects in DB2. ___64. Using your Windows Explorer, review this source DDL in the 04CLPPLUS directory. Pay special attention to the PL/SQL types of objects like packages, procedures, functions and triggers. Notice all of these files use the proprietary Oracle syntax. This would represent all the source code from your source Oracle database that you wish to migrate to DB2.
___65. Review script CLPPlus20.CMD. Note the following things about the script:
(so, the target objects will end up in that schema) (so, we can create objects in any order) (so, the source DDL can have / delimiters)
Page 71
IBM Software
___66. It then calls each .sql file using the DB2 CLP Batch Command Processor
CLPPlus20.CMD
___68. You can review file CLPPlus20_OUTPUT.RPT to see the details on this. (Please make sure you use WordPad and not Notepad to review this file. WordPad formats this for better viewing.) ___69. Run script CLPPlus21.CMD to see a report of all the objects in the DB2 database under schema db2user1. Review CLPPlus21_OUTPUT.TXT for that report.
CLPPlus21.CMD
Page 72
IBM Software
Currently Committed ___70. We can easily see how the Currently Committed behavior works in DB2. ___71. Review and run CLPPlus30.CMD to set up a session that is updating a table
CLPPlus30.CMD
___72. This script does the following:
CONNECT as user dbapot Display CUR_COMMIT database configuration parameter setting SELECT all records from table INVENTORY Begins an UPDATE of the first record in the INVENTORY table, but does not commit it
___74. Again, please note: user dbapot is in the middle of a non-committed update to this table. ___75. Now, this is important: OPEN A SECOND DB2 CLP Command Window ___76. In this second CLP window, simulate another DB2 application by typing:
Page 73
IBM Software
___79. If you want to see what the data looks like that hasnt been committed, you can use a dirty read of the data in memory using isolation level UR (Uncommitted Read). Try this:
Page 74
IBM Software
___81. If you want to use the classic behavior of isolation level CS that does not use Currently Committed, try this:
___82. Notice the screen stays in a locked mode. The query is waiting for the other transaction to commit or rollback ___83. Return to the FIRST CLP window to commit the update to the table, type:
db2 commit
___84. Notice now that both transactions complete.
Page 75
IBM Software
Extra Exercise: Anonymous Block and DBMS package use ___86. To see an example of anonymous block PL/SQL in DB2 as well as support of DBMS_OUTPUT: ___87. In a Windows Command window, logon into the SAMPLE database using CLPPlus:
*** End of CLPPlus and Oracle Compatibility lab by Burt Vialpando ***
Page 76
Lab 05 Security
IBM Software
___2.
In the Administration Explorer, connect to the SAMPLE database. (Hint: right click on the database).
Use dbapot, dbapot123 as the User name and Password to connect with as shown below
___3.
Lab 05 Security
Page 77
IBM Software
___4.
___5.
This section of DBM cfg parameters controls security at the instance level A section of DBM cfg parameters is a UI concept only as this arrangement is to help you find similar parameters within the Data Studio UI interface.
___6.
Click on parameter: AUTHENTICATION. Then click in the Pending Value box to find a drop down option.
___7.
Page 78
Lab 05 Security
IBM Software
___8.
This authority grant is very important on UNIX systems as it is the highest authority level you can have
Notice the other instance level authorities that are granted through a DBM cfg parameter to a group: SYSADM_GROUP, SYSCTRL_GROUP, SYSMAINT_GROUP, and SYSMON_GROUP. These parameters are all set to null on Windows systems due to the way Windows handles administrator capabilities: a user is either an administrator or not. But these are important on the UNIX systems to separate the duties of different users. Review parameters: SVRCON_PW_PLUGIN and CLNT_PW_PLUGIN
___9.
Remember, a plug-in is a DB2 method of controlling database authentication. The default plug-in that uses the OS to authenticate comes with DB2, all others are optional purchases from vendors or they can be custom built by your IT shop. You can pretend to put a plug-in name here called myplugin to see how to set this. Do not save this parameter setting however.
___10. Close the Configure Parameters editor without executing any changes.
Lab 05 Security
Page 79
IBM Software
___12. Type the following one at a time in the DB2 CLP Command Window: db2 terminate db2 connect to sample db2 connect to sample user dbapot using dbapot123 db2 get connection state db2 connect to sample in exclusive mode ___13. NOTE: If you get an error here, go back to the Data Studio tool and right click on SAMPLE then choose: disconnect. You cannot get exclusive lock on the database while it is in use and the Data Studio connection you had kept it in use. ___14. Now, try this again. db2 connect to sample in exclusive mode db2 get connection state (You should now show exclusive connection mode.) db2 terminate Exclusive mode connections lock out everybody else. If you were to open another DB2 CLP Command Window and try to connect as a different user (like user db2user1 password db2user1) you would not connect and receive a message: The database is currently in use.
Page 80
Lab 05 Security
IBM Software
___15. Return to Data Studio and connect to SAMPLE again. ___16. Right click the database SAMPLE Manage Privileges
___17. Review the Properties section of this perspective. Notice that you can use the icons shown below to grant to new or existing users, groups or roles any database level authority. We will do this on the next step.
___18. Click on the yellow diamond to make database level grants to a new user.
___19. Fill in the Grantee as GUEST. Check off CONNECT and CREATETAB grant boxes, then: [OK]
Lab 05 Security
Page 81
IBM Software
You did NOT just create a user GUEST. You simply are performing a grant to a user called GUEST so that, if properly authenticated, that user is allowed to connect to the SAMPLE database and then create a table in it. You dont care at this point how GUEST authenticates, you have just made sure that if they do authenticate, they will have these database authorities. ___20. Try this again, but this time use Group and name the new group NEWGROUP.
DB2 does not have concept of creating nor maintaining users as does some other databases like SQL Server. Only the grants to users, groups and roles are maintained in DB2. We will show how this looks in the system catalog later in this lab. ___21. You will now harden these changes to the database by performing the following: ___22. Make sure to click on the database SAMPLE in the Administration Explorer
___23. Find the Review and Deploy Changes icon in the top right corner of the editor view which looks like the one below. Hover on it first to make sure it is the correct one, then click on it.
Page 82
Lab 05 Security
IBM Software
___24. The very first time this is done in a Data Studio session, it can take a few seconds to complete, so please be patient. ___25. Review the changes then click [Run].
___26. The SQL Results view will tell you if you did this properly.
Lab 05 Security
Page 83
IBM Software
___29. Notice the Properties view for the table becomes available. Click on all the privileges for the user DB2COBRA so it looks like the image below:
___30. Notice that an icon symbolizing a delta change now shows next to this table. That means this object is being altered in some way in Data Studio.
___31. Find the icon on this editor view at the top right that symbolizes Review and deploy changes shown below. Hover on it first to see what it is, then click on it when you are sure you have found it.
Note: If you get a warning, you can inspect the [Details] to see that it is telling you a related view might need changes as well as the table. Go ahead with the changes anyway for now.
Page 84
Lab 05 Security
IBM Software
___32. Review the changes. Notice that your earlier double clicking of a grant box adds the WITH GRANT OPTION to the grant. Click [Run].
___33. Security for most other database objects works similarly, take a look at a couple of different object types as the exact kind of privileges vary from object type to object type, for example: Table spaces have only one privilege: USE. Indexes only have one: CONTROL
Other objects, like triggers and buffer pools, dont have any specific privileges associated with them directly at all. Review these kind of objects too.
___34. Close any editors you may have open. Don't worry about saving changes.
Lab 05 Security
Page 85
IBM Software
___37. Notice you are now only showing views with names that have AUTH in them
Page 86
Lab 05 Security
IBM Software
___39. You will see all the database authority grants in this database. Notice the last entries were the ones we made earlier in this lab to user NEWGROUP and group GUEST.
___40. Close this view. ___41. Find view SYSCAT.TABAUTH. Right click on it then Browse Data
___42. Find and click on the filter icon on the top right of this editor (browse) session
___43. First click the [Add All] button to select all columns to display in the filter.
___44. Next, in the Row Selection Condition section, fill in the column, operator and value as shown below with TABNAME, =, ACT. ACT doesnt have to be entered with quotes, Data Studio will add the quotes. This will filter all data in the browse session to only see grants on table ACT.
Lab 05 Security
Page 87
IBM Software
___45. Click [OK] to see the results of this filter for the data in this view. You will notice we can see the grants we made earlier in this lab for table ACT for user DB2COBRA.
___46. Right click on the filtered Views in the Administration Explorer again Database Catalog Filter
Page 88
Lab 05 Security
IBM Software
___51. Notice in the Properties view you can manage all database and object privileges for this single user here in one editor session!
___52. Review group NEWGROUP the same way. So, you can see that these Data Studio views allow you to change all the privileges for a user, group or role in one editor session.
Lab 05 Security
Page 89
IBM Software
F. Schemas
This exercise will show you how schemas work in DB2 in your CLP Command Window, change directory to C:\POT_DB2\05SECURITY ___53. Review & run script Security01.CMD. Review output file Security01_OUTPUT.TXT. ___54. The script sets up the example by creating a schema called TSCHEM. Then it creates a table fully qualified with the schema name. It is called TSCHEM.TSCHEM_TABLE
___55. The script next does a simple select from this table, but the first time it fully qualifies the table name with the schema:
___56. The second time it does a select from this table, but uses a SET SCHEMA method:
___57. Notice the results work fine this way too. ___58. Extra exercise: You can explore the schema and table we just created in Data Studio.
IMPLICITSCHEMA is a database authority that lets users create a schema on the fly if it doesnt exist. So, if you issued a CREATE TABLE schema1.table1 command and schema1 did not yet exist and the user had IMPLICITSCHEMA authority, then that schema would be created along with the table.
Page 90
Lab 05 Security
IBM Software
Lab 05 Security
Page 91
IBM Software
___63. After Row and Column Access Control is implemented by the security administrator (user DB2SECADM) and rerunning the exact same query produces a limited result set for rows and columns:
Page 92
Lab 05 Security
IBM Software
___64. Use Data Studio to Return All Rows from this table connected as user dbapot.
___65. Notice that any access method obeys these RCAC rules, even the Data Studio UI. They cannot be overridden by any access method. They can only be changed by the security administrator.
___66. Review the properties for this table to see how RCAC is enabled. (Note: we could have added RCAC to our table with Data Studio if we wanted to.)
Lab 05 Security
Page 93
IBM Software
DB2 passive auditing is controlled in following 2 ways: SYSADM is in control of instance level security through the use of the db2audit tool. SECADM is in control of database level security through the use of AUDIT POLICY and AUDIT commands. ___67. A user with SYSADM grants SECADM authority to user secpot which creates 2 audit policies. Review and run script Security04.CMD. Explore output file Security04_OUTPUT.TXT; Notice that secpot with SECADM creates 2 audit policies: CHECK_POLICY to determine what DBAs are doing SENSITIVE_DATA_POLICY to determine who is accessing a given table.
___68. The audit facility controlled by SYSADM is demonstrated by the script Security05.CMD. Review and run scripts: Security05.CMD that executes Security07.SQL and Security08.SQL Explore output file Security05_OUTPUT.TXT. The last part of the output shows the output of SQL reports run against AUDIT tables. This shows that user dbapot using SYSADM: Did see instance level auditing information, in this case, connection audits Did not see database level audit results from SAMPLE database at all
Page 94
Lab 05 Security
IBM Software
Hint: You can also use Data Studio to browse table AUDIT.VALIDATE
___69. The script Security06.CMD shows the audit capabilities exercised by SECADM at the database level. Review and run scripts Security06.CMD that executes Security07.SQL and Security08.SQL Explore output file Security06_OUTPUT.TXT. The last part of the output shows the output of SQL reports run against AUDIT tables. This shows that user secpot using SECADM: Did see database level auditing information, in this case, who was creating or accessing tables Did not see instance level audit results from instance DB2 at all
Lab 05 Security
Page 95
IBM Software
___71. Review and run exercise Security09.CMD. Review the output file Security09_OUTPUT.TXT. ___72. All users issue the identical query: SELECT SALES_DATE, SALES_PERSON, REGION, SALES FROM ACCOUNT.SALES (This query does not have a WHERE clause, so it runs against every row in the table) ___73. Notice that the user CEO sees all 4 rows of the table:
K. Cleanup
After you are done with the above exercises, you can run the following command to clean up the resources: Security50.BAT *** End of Security Lab - by Burt Vialpando and Vikram Khatri ***
Page 96
IBM Software
___3.
Review and then execute Autonom01.CMD which executes Atonom02.DB2 and Autonom03.DB2. This will set up our lab. Notice that these scripts create a database AUTONMDB, a buffer pool, a table space and a table for our lab exercises. The script takes about 2 minutes to complete. Wait for the script to finish before going on to the next step. After the script is finished, restart Data Studio by choosing: File Restart
___4.
___5.
The restart should have automatically added a new database connection attribute for AUTONMDB in Data Studio. If it did not, then you can add a new connection manually by right clicking on the All Databases folder in the Administration Explorer view and choosing: New Connection to a database
Page 97
IBM Software
___6.
Then fill out the connection attributes as shown below. Test the connection before finishing. You will now be ready to work with your new database AUTONMDB in Data Studio.
___7.
Next run Autonom04.CMD which creates output files Autonom04_OUTPUT1.TXT and Autonom04_OUTPUT2.TXT. This file shows all the STMM related database configuration parameters for AUTONMDB:
___8.
___9.
This file shows the buffer pools that are STMM configurable for our database:
Page 98
IBM Software
___10. Now run Autonom05.CMD which executes Autonom06a.DML and Autonom06b.SQL multiple times. Youll see a window for each session of this running script simulating many users doing work against the STMM_TABLE table in our database. ___11. Let all the sessions run for a couple of minutes or so... After a few minutes, use your Windows Task Bar to find and kill all the CLP sessions except for your original DB2 CLP Command Window (the others have scripts running in them).
If you accidently close them all, that's OK, just open up a new CLP window for your next exercise and make sure to return to the appropriate directory. ___12. In your remaining CLP window, execute this script: Autonom07.CMD which creates output files Autonom07_OUTPUT1.TXT and Autonom07_OUTPUT2.TXT. ___13. Review and compare files Autonom04_OUTPUT1.TXT with Autonom07_OUTPUT1.TXT to see that STMM changed the DATABASE_MEMORY automatically:
Page 99
IBM Software
___14. Review and compare files Autonom04_OUTPUT2.TXT with Autonom07_OUTPUT2.TXT to see that STMM changed two buffer pool sizes automatically:
Page 100
IBM Software
B. Automatic Storage
Note when this lab was first set up, we created the database with the AUTOMATIC STORAGE YES ON C:\ parameter. This is all you need to do in order to get DB2 to handle automatic storage for you from now on in this database.
If you did not create the database with automatic storage, you can always add this later with: CREATE STORAGE GROUP [NAME] ON PATH [PATH] ___15. Review and execute the command Autonom08.CMD that executes Autonom09.DDL (which contains our ready-made table space DDL) and Autonom10.SQL (which uses administration views to show us information about all the table spaces in this database) ___16. Notice how the container paths look different for automatic and non-automatic storage table spaces. All automatic storage table spaces are under directory C:\DB2\AUTONMDB
Page 101
IBM Software
___19. Review the output in Autonom20_OUTPUT.TXT file ___20. You can modify the Autonom21.DB2 to change APPLY NONE parameter to APPLY DB AND DBM to apply changes in database manager and database configuration parameters.
Page 102
IBM Software
___22. To see what statistics look like for these tables, review and run these scripts: Autonom33.CMD which executes Autonom34.SQL Review output file: Autonom33_OUTPUT.RPT (HINT: Use WordPad for best formatting of this output)
Page 103
IBM Software
___23. Run script Autonom35.CMD which executes Autonom36.DDL. This script will reset the statistics for the table cardinality and NPAGES. ___24. Autonom33.CMD which executes Autonom34.SQL (yes, run this again) Now review this file again: Autonom33_OUTPUT.RPT (Use WordPad)
So, now you know what these tables look like with and without statistics We will set up the automatic maintenance facility to update these statistics for us from now on.
Page 104
IBM Software
___27. Options screen: Review defaults and leave as-is, click: Online Maintenance Window
___28. Online Maintenance Window screen: Maintenance Window ___29. Offline Maintenance Window screen: Policy
Page 105
IBM Software
___30. Runstats Policy screen: Check off: Create or update the runstats policy. Click on: Selected tables Fill in simple condition as shown below which will only run statistics on tables with names that start AUTOMAINT%
___32. Review the commands that will perform the automatic maintenance set up tasks in your database, then click: [Run]
___33. Wait for the command to finish and make sure it is successful. Close the task assistant editor.
Page 106
IBM Software
Checking the UI usage ___34. Now lets see what weve done in the database when setting the automatic maintenance ON for RUNSTATS on all tables. ___35. In your Data Studio view, right click on database AUTONMDB: Set Up and Configure Configure ___36. Find section called Maintenance and find the keyword parameters called AUTO_MAINT, AUTO_TBL_MAINT and AUTO_RUNSTATS.
If these three are set to ON, then DB2 will automatically run statistics in your database. Close this editor window after reviewing. ___37. Find the table called SYSTOOLS.POLICY in Data Studio and browse the data. This is the table that keeps all the automatic maintenance settings you gave it during the UI usage as well as any it determines for itself. Close the editor window when done.
You are now all set up for automatic table maintenance, RUNSTATS on all tables, during your specified maintenance window. DB2 will automatically detect that statistics are required in those AUTOMAINT% tables and run statistics on them. This happens at the discretion of DB2.
Page 107
IBM Software
Remember, the desired final outcome is for the automatic maintenance feature to produce statistics for your tables without you having to do so manually. The final outcome should look like this:
Page 108
IBM Software
___42. To use a previously set profile, run this command: DB2 RUNSTATS ON TABLE DBAPOT.AUTOMAINT_TAB4 USE PROFILE
Page 109
IBM Software
DB2 normally creates this table for you when you first invoke the Automatic Maintenance UI in Data Studio, but we went ahead and did this manually to see what is involved for purposes of understanding it better in this lab, or this could be done if you every want to start from scratch in your database.
G. Cleanup
After you are done with the above exercises, you can run the following command to clean up the resources: Autonom50.BAT *** End of Autonomic Computing Lab by Burt Vialpando ***
Page 110
IBM Software
___4. ___5.
Open the SQL Script Editor by right clicking on database SAMPLE New SQL Script Run the following SQL in the SQL Script Editor to check the cardinality of this table: SELECT COUNT(*) FROM COMP1.ORDERS
Page 111
IBM Software
Estimating Compression
___6. Review and run script Compress05.CMD This script runs a DB2 INSPECT command to estimate the compression and percentage of saving in the data pages if compression is enabled. Review the output file Compress05_OUTPUT.TXT and check the output from INSPECT command to notice the percentage saving it estimates will happen for this table. You will see an output as shown below.
The INSPECT command estimates compression on the table before you actually do it. In this way you can determine whether or not you think it is worthwhile to do compression before actually doing it.
___7.
In the SQL Script Editor, run the SQL statement in script Compress16.SQL
___8.
So, reviewing the view SYSSTAT.TABLES, this table uses 27,287 pages (of 4096 bytes each because that is the table space page size). This means the table usage is 111,767,552 bytes (a little over 110 MB) uncompressed. We should expect a 56% compression savings out of that (according to the INSPECT command used above) or 62 MB of savings for this table.
Page 112
IBM Software
___14. When this completes, use the SQL Editor to run script Compress16.SQL for a third time. ___15. Notice now that the table that had the entire REORG (the exercise we just did previously) had slightly better compression than the table with a partial REORG and subsequent LOAD after the compression dictionary was built on the sample data. However, the compression results are an impressive 55% even using the partial LOAD/REORG and subsequent LOAD method.
Page 113
IBM Software
___18. Notice that automatic dictionary creation (ADC) doesnt compress all the rows in the table because it takes a certain amount of sampling to build the dictionary first. After that, the dictionary is built and compression of the remaining rows occurs. We still ended up with fairly impressive results with very little work on our part to get this mainly because adaptive compression will kick into to do page level compression as well.
DB2 automatic dictionary creation means that after you ALTER a table to turn compression on, you do not have to REORG the table for a dictionary to be built. DB2 will build the dictionary for you once it determines enough new records have been INSERTED or LOADED to determine a valid compression result. This makes it easy to use, yet shows impressive results.
___19. In Data Studio, find tables COMP2.ORDERS and COMP3.ORDERS and review their properties. Notice what kind of compression gets turned on when using keywords COMPRESS YES.
Page 114
IBM Software
Compressing indexes
___20. Review and run script Compress18.CMD. ___21. This script uses the COMPRESS YES for a CREATE INDEX statement. Thats all you need to do in order to compress an index. (If the index already exists, then you can do an ALTER INDEX COMPRESS YES followed by a REORG INDEX command)
___22. The script next uses a table function to help show compression for indexes. We could have used a table function for showing compression on our tables too.
___23. This is the output results from this compression on our index:
C. Clean up
In Data Studio, close your editors. Run Compress50.Bat to clean up resources after above lab exercises.
*** End of Deep Compression Lab - by Vikram Khatri and Burt Vialpando ***
Page 115
IBM Software
___4.
Connect to GSDB database. Verify that the explain tables were created in schema DBAPOT. These tables are named: EXPLAIN_%
The script also created the ADVISE_% tables. The presentation material mentioned how these tables can be used, but we will not be working with these tables in this lab.
Page 116
IBM Software
___7.
___8.
Expand Tables again, and find the 4 individual tables named Q?_2012. Sample the contents of one of them to make sure it has data and to see what it looks like. (Hint: use Data Sample Contents)
Page 117
IBM Software
___9.
___10. Find the view called YEAR_2012 and right click on it. Sample contents from it too. ___11. Right click on view YEAR_2012 again and choose Generate DDL.
___12. Choose the defaults using [Next] until you see the Preview DDL screen. Use this to double check your union all view DDL. You can open the DDL for editing here by checking the appropriate box. Then [Finish].
___13. Review the DDL in the editor. You can reformat it here if you want to be able to better understand what it is doing.
___14. Close this editor view and dont bother to save this edited script. ___15. Clean out your SQL Results cache too. (Right click, Remove All)
We are now ready to run SQL against this union all view to see how the DB2 explain facility works.
Page 118
IBM Software
___17. Using the Windows Explorer, navigate and find directory C:\POT_DB2\08EXPLAIN and double click on file: Explain05.SQL
___18. Copy and paste the contents of this file into your editor view in Data Studio
___19. Notice this script will count all records from the view YEAR_2012 that have a month of value 3 (March). ___20. Highlight and run this script with [F5] to see the results. Your results may vary from the one shown here, but the key thing is that throughout this exercise, your results should not change if we do things to tune this query using explain. Note your query results here: _______
___21. To see this query explained visually in Data Studio, right click anywhere on that query (or you can highlight it) and choose: Open Visual Explain
Page 119
IBM Software
If we had not built the explain tables through the script as we did previously, the Data Studio UI would build them for us anyway at this time by merely invoking the Visual Explain. ___23. Double click on the Access Plan Diagram that was generated to expand it to fill the perspective.
___24. Click on the Scale to Fit icon shown below to make your visual explain fill your screen.
___25. Right click on one of the table icons on the bottom of the diagram and choose: Show Description.
___26. Notice you have details on this explain node regarding the details of the table, its statistics creation time, number of rows, and so on. You even can drill down into its table space, columns, frequent values, and so on.
Page 120
IBM Software
___28. Find the section on the left side of the Access Plan Diagram called Canvas. Click on it to expand it or to contract it. The click on the tab called Description of Selected Node
___29. Click on the top node called RETURN in your Visual Explain diagram. Notice this node is described in the canvas. Find and expand Environment to see things like the overall parallelism, CPU speed, buffer pool size, etc. used in this query.
___30. Now, notice the total timeron cost from this query shown in the node: RETURN. (To see this, hover over the top RETURN node.) Make note of this result here: __________________
___31. In the Access Plan Diagram, notice that the query is using table scans and these are pretty costly. Review the table scan predicate detail to see which column this is occurring on. Can we reduce the cost of this query somehow to avoid these table scans? (Answer: Yes and we will do this later.)
Page 121
IBM Software
___32. In the Canvas, find the tab called Overview Diagram. Click on the icons shown below to see what they do.
___33. Close this Access Plan Diagram when you are finished.
Page 122
IBM Software
___36. You will have a new editor session opened with the DDL from that script in it. ___37. Fist make a connection to the GSDB database by clicking on: No Connection GSDB [Finish]
___38. Now highlight all the statements in the script and then [F5] to run the DDL together. Note: alternatively, if you don't highlight anything, Data Studio runs all SQL together by default.
Page 123
IBM Software
___39. Review the SQL Results view to see if these were created. Make sure all 4 indexes were created.
___40. If the DDL ran successfully, close the editor for this DDL script. You are done with it. ___41. Find table Q1_2012 in the Data Source Explorer and verify it has an index by expanding as shown below: (note: you may have to refresh the view to see it.)
___42. Highlight the original query in your editor, right click on it and choose: Open Visual Explain again. Choose the same defaults again. Review the Access Plan Diagram now that we have made a design change to the database by adding indexes. Notice the reduced timeron count.
Page 124
IBM Software
___43. Notice that even though we were performing a function in the query on the indexed column, DB2 was able to use the index. In other databases, this would require a functional index. The DB2 optimizer is aware of many of its built-in functions and does not require functional indexes for this kind of situation.
This script provides two solutions, both of which work. DB2 can parse the second query, with its function usage on an indexed column, and still return the correct answer quickly without a functional index.
Page 125
IBM Software
___45. Highlight the first query and Open Visual Explain for it to see the solution work. Notice the total timeron count has fallen even more and that the query is looking through only one table in the union all view.
___46. Why does the SQL work? Because we also provided the YEAR and not the just MONTH in the query. Our union all view was based on the table constraints for each table and those constraints contained both YEAR and MONTH. Just providing a month alone in the query was not enough for the optimizer to prune the other tables out. This is true for partitioned tables in SQL Server, DB2, etc. You must provide the entire partition key in the WHERE predicate for partition pruning to work. ___47. Run this query to make sure the final answer is not changed from our original answer.
___48. Highlight the second query solution (the one using functions) and run it with [F5]. The answer should be the same as when we first ran it at the beginning of this lab. So, adding indexes should not change the result of the query, and writing our query more efficiently should not change the result answer either. ___49. Do a visual explain on the second query too. Notice it also gives an efficient plan.
Page 126
IBM Software
___50. But, what about the query rewrite that DB2 does. What does that mean? ___51. In the Access Plan Diagram, find and click on the Canvas section on the left edge as shown here, then make sure you are on the tab Overview of Diagram
___52. On View the SQL Statements (to the left of the diagram) click on the second tab: Compare the Original tab with the Optimized tab
___53. This tab contains the query rewritten by DB2 and is shown the way the DB2 optimizer sees the query. Notice the function calls have been replaced with what looks like a BETWEEN clause. Notice that DB2 has rewritten this query to not use functions. ___54. As a final comparison, find the original "bad" query we ran at the very beginning in file Explain05.sql. Run a visual explain on it and look at the Original vs. Optimized SQL Statements
___55. Close all editor sessions and Access Plan Diagrams. Dont bother saving any scripts.
Page 127
IBM Software
___59. Review the data in the explain tables EXPLAIN_INSTANCE and EXPLAIN_PREDICATE. Notice what the EXPLAIN ALL FOR command produces in these tables.
___60. Review Explain_DB2EXFMT_Command.txt for full command syntax ___61. Use Data Studio to explore the data in EXPLAIN_INSTANCE and EXPLAIN_STATEMENT tables.
Page 128
IBM Software
___63. To demonstrate how the db2expln utility works in its static mode, review and run this script: Explain11.CMD [package_name] Dont forget to use the package_name parameter when executing this script!
___64. Explore output file Explain11_OUTPUT_PLAN.TXT Notice packages are broken into sections. Each section is for each SQL statement in the package. So, each SQL statement in any DB2 package can be explained this way.
___65. Close any editor session you may have open in Data Studio. Dont bother to save the scripts.
Page 129
IBM Software
Page 130
IBM Software
Question: Why would you think you would ever need to do this? Answer: For stored procedures, the package is bound when it is created. Statistics and the data model can change over time and affect the access path. A rebind will make sure this path is up-to-date.
Row movement ___70. Single out the first record in table Q1_2012 and note the TX_NUMBER here ________
Through the union all view YEAR_2012 update that record with the date: 2012-12-30. Use script Explain15.DB2 which has the solution and looks something like this: UPDATE YEAR_2012 SET TX_DATE=DATE(2012-12-30) WHERE TX_NUMBER=1; COMMIT;
Question: What happens to the record in the individual tables and why? Can you find it in table Q1_2012? Answer: The data moves from table Q1_2012 to Q4_2012. Note that this is NOT the DB2 default behavior. When this view was created, the syntax used to make this happen was: WITH ROW MOVEMENT. Find the moved record: SELECT * FROM Q4_2012 WHERE TX_NUMBER=1;
In lieu of the above query, you can also right click on the Q4_2012 table and choose: Return all rows. Then, in the SQL Results, scroll down to the last record. Notice this moved record is there. Try the same in table Q1_2012. You'll see the record is gone.
___71. Close all editors and exit from Data Studio. *** End of Explain Facilities and the Optimizer Lab by Burt Vialpando***
Page 131
IBM Software
___2.
Review and run WLM01.CMD. This script will execute SQL against the system catalog of the SAMPLE database showing how the WLM environment looks. This first run of this script shows the default workloads and no defined service classes, which is the way a DB2 database looks just after creation. Review WLM01_OUTPUT.TXT to see how a default WLM database environment looks.
___3.
Review scripts WLM03.CMD and WLM04.DB2. This will customize the WLM environment. Notice it creates workloads, services classes, thresholds, work class sets, work action sets, etc. This script does these things in a particular order since the WLM objects are hierarchically dependant upon one another.
Page 132
IBM Software
___4.
When reviewing the script, there are two workload / service class configurations you should pay attention to: WORKLOAD #1: Name: Identify by: Service Class: (higher resource usage) CLP_Workload_Admin Client userid db2cobra CLP_Serv_Admin
Let prefetch, agent and buffer pool priority default
Admin_Actions
Map WRITE work to the high sub service class Map READ work to the medium sub service class
___5. ___6.
Run script WLM03.CMD to create these WLM customizations. Run script WLM01.CMD again and review WLM01_OUTPUT.TXT again to see how the WLM environment has changed. Study this for all WLM objects created.
Page 133
IBM Software
___7.
The service superclass called CLP_Serv_User does not have a defined service subclass, but it still uses one: SYSDEFAULTSUBCLASS. Workload IPADDR does not have any defined service classes, so it will use a default. Notice the thresholds and event monitors the script created too.
Setting up Priority Aging ___8. ___9. Review script WLM05.CMD. Notice it calls a script wlmtiersdefault.db2 which is supplied in the DB2 sample scripts directory in the DB2 install path. Review script wlmtiersdefault.db2. This script is useful for instructing you how to set up a WLM priority aging environment, where service subclasses can remap activities to other service subclasses, while those activities are running. The key to how this works is shown below in excerpts from this script:
Page 134
IBM Software
___10. Run script WLM05.CMD. Then run WLM01.CMD a third time. Review WLM01_OUTPUT.TXT a third time to see your WLM environment now set up with priority aging. Notice the script altered the SYSDEFAULTUSERWORKLOAD to map to the WLM_TIERS service superclass.
___11. Notice too that in our earlier script we created some event monitors that write to a DB2 table. We will be using these later.
___12. Review and run WLM10.CMD to see this WLM using the db2pd utility. WLM10_OUTPUT.TXT contains the db2pd report. This report has zeros in the activity counts because we havent started running an active workload on the database yet.
Page 135
IBM Software
___14. This script takes a few minutes to run, so while it is running go on to the next steps to save time in this lab. ___15. In Data Studio, we will connect to the SAMPLE database as user db2cobra, password db2cobra. Right click on SAMPLE then: Properties ___16. In the Driver Properties screen, fill in the new credentials as below, then [OK]. Answer "yes" to reconnect.
Note: if the reconnect fails, just connect as usual. ___17. Start the Data Studio SQL Script Editor for the SAMPLE database.
___18. Copy and paste into the editor the contents of script file: WLM30.SQL Hint: it is located at: C:\POT_DB2\09WLM\
Page 136
IBM Software
___19. You should now have a session that looks like this:
___20. Scroll down to find the very first SQL SELECT statement in the script. It is labeled #1 Workload -> service class occurrences. Highlight it and run it. (note: you can also use [F5] to run it.)
___21. The db2bp.exe application name is the background process of our CLP session that we used to create the WLM environment in. It is still connected so it is using a default for now. The db2jcc_applicat application names are for the Data Studio tool itself.
___22. Go to your DB2 CLP Command Window that you ran the script in and type this: db2 terminate ___23. Return to the SQL Script Editor session and run script #1 again to see the CLP workload gone.
Page 137
IBM Software
___25. Notice also the script runs batch file WLM28.BAT 200 times.
___26. Notice WLM28.BAT runs WLM29.DML (which will be done 200 times):
___27. WLM29.DML is a collection of SELECT, INSERT, UPDATE, DELETE and other DB2 workload:
Page 138
IBM Software
___28. Execute WLM22.CMD to see it begins its 200 cycles of workload as user db2user1
___29. Return to the SQL Script Editor and run script #1 again. You will now see a new db2bp.exe application running user db2user1. This user is NOT using the default workload. It is using workload CLP_Workload_User1 which in turn uses the service superclass CLP_Serv_User.
___30. db2user1 mapped to this workload because of this statement we used when we created it:
___31. In the SQL Script Editor, find and run query #2 Service class activity counts. Youll see the service class CLP_Serv_User has been busy completing many activities.
Please keep the first CLP window open and running the WLM22.CMD script for the remainder of this lab. Do not close it! If it should complete before you are done with this lab, just start it again in its window.
Page 139
IBM Software
___33. Review and run WLM23.CMD. Notice this script connects as user db2cobra and it sets the client information to set our client_userid as db2cobra. ___34. This script will run the same exact workload 200 times just as the previous script did, but it will use a different client userid. ___35. Notice that script WLM22.CMD is started first and so it is further ahead of the 200 cycles of workload than script WLM23.CMD. (your results will vary.)
___36. Return to the SQL Script Editor and run script #1 again. ___37. Notice that now db2cobra is running under a different workload CLP_Workload_Admin and this uses a different service superclass CLP_Serv_Admin.
___38. If you recall, this service class runs with much higher resource allocation than the one db2user1 is using. We should expect to see it finishing more activities faster.
Page 140
IBM Software
___39. Run script #2 again to see the activities it has done so far. The total number of activities is behind the other service class right now. But, we should expect it to catch up at some point and pass the number of activities in the lesser service class.
Please keep this second CLP window open and running the WLM23.CMD script for the remainder of this lab. Do not close it!
Page 141
IBM Software
___41. Review and run WLM24.CMD. Notice this script connects as user db2default and it sets the client information to set our client_userid as db2default. ___42. Run script #1 and #2 again in the SQL Script Editor.
___43. Run script #3 Work Action Set Activity Count. Remember, script wlmtiersdefault.db2 used work action sets to do initial mapping into the service subclasses depending upon what type of activity it was.
We can also use work action sets to map to subclasses based on data tags in table spaces or storage groups. We don't show that in this exercise, but it works in the same way.
Page 142
IBM Software
___44. Run script #4 Long query to test activity remapping. This script will run longer than the subclass threshold allows and will remap the query activity to another subclass. (Dont forget to select and run the FLUSH PACKAGE CACHE DYNAMIC statement with the query!) This might take a while to run, so be patient. If it doesn't finish in a few minutes, you can terminate it like this:
___45. When it finishes, run script #2 again and look at the ACTIVITIES_REMAPPED_IN and ACTIVITIES_REMAPPED_OUT columns. (You may have more than one remap shown.) Notice the subclasses these remaps belong to. WLM_SHORT will remap to WLM_MEDIUM. WLM_MEDIUM will remap to WLM_LONG This is an example of priority aging.
We can also use thresholds to remap based on data tags in table spaces or storage groups. We don't show that in this exercise, but it works in the same way.
Page 143
IBM Software
___48. Notice the in-memory statistics have been set back to zero. But, fortunately, they have been collected in our event monitors. Since our event monitors were created as tables, we can easily select from them. ___49. Run scripts #5, #6, #7 and #8. These seem familiar as they are like the in-memory statistics queries we were using earlier, only now we are using our event monitor tables. These persist after a database is deactivated, in-memory statistics dont. ___50. Now, lets look at a very special event monitor called Threshold Violations. This contains information we cannot get from in-memory statistics. Run script #9. Threshold violations event monitor summary table select
___51. Notice we show two threshold violated, one resulting in a Continue and another in Remap we discussed earlier. ___52. If you are not doing the extra exercises in the next section, you can close all the DB2 CLP Command Windows now.
Page 144
IBM Software
Revisiting db2pd: ___54. Open yet another DB2 CLP window and run script WLM10.CMD. This is the db2pd script. This time you will have in-memory statistics from running workloads to review this utility with. ___55. Close all DB2 CLP Command Windows now.
H. Clean up
___56. Run WLM50.BAT to clean up resources after above lab exercises. *** End of Workload Manager (WLM) Lab by Burt Vialpando ***
Page 145
IBM Software
Client Application Machine Instance Name = DB2 Make a connection to the HADB database
In this lab exercise, we set up HADR manually with a script. However, back in your own IT environment, you probably should set up HADR for the first time using the Data Studio HADR wizard, as it is very easy to use and will walk you through the required steps.
Page 146
Lab 10 HADR
IBM Software
B. Set up HADR
___1. ___2. ___3. ___4. Close Data Studio if it is open. Open a DB2 CLP Command Window and change the directory to: C:\POT_DB2\10HADR Run the script HADR01.CMD. While it is running, review the script which does the following steps: ___a. ___b. ___c. ___d. ___e. ___f. ___g. ___h. ___i. ___j. ___k. ___l. ___m. ___5.
Create a DB2_P instance (assume this to be an instance on the primary database server). Create an HADB database in the DB2_P instance. Turn on archival logging for this database. Take a backup of the HADB database. Create a DB2_S instance (assume this to be an instance on the secondary database server). Restore HADB database in the DB2_S instance from the backup taken in the previous step d. Catalog the DB2_S instance in the DB2_P instance and the DB2_P instance in the DB2_S instance On the DB2_P instance, catalog the local HADB database as HADBP and the remote HADB database on DB2_S as HADBS. On the DB2_S instance, catalog the local HADB database as HADBS and the remote HADB database on DB2_P as HADBP. Configure client re-route on DB2_P and DB2_S instances for HADBS and HADBP databases respectively. Configure HADR on DB2_P and DB2_S instances for HADB database. Start HADR on DB2_S database server in STANDBY mode Start HADR on DB2_P database server in PRIMARY mode.
Please note the following TCPIP ports used in this HADR lab. Type DB2 default instance DB2_P Primary HADR instance DB2_S Standby HADR instance HADR Port on Primary HADR Port on Standby Port Number 50000 51600 51700 51800 51900
Lab 10 HADR
Page 147
IBM Software
___7.
___8.
In Administration Explorer, expand localhost 51600 and select HADBP. Right click and click Connect.
___9.
Specify user name dbapot and password dbapot123. Check Save Password. Click OK.
Page 148
Lab 10 HADR
IBM Software
___10. Notice that 51600 changes to DB2_P after establishing the connection.
___11. Expand 51700 and select HADBS. Right click and click Connect.
___12. Specify user name dbapot and password dbapot123. Check Save Password. Click OK.
Lab 10 HADR
Page 149
IBM Software
___14. You will see Manage HADR view open in the workspace. Scroll down to the standby database section. Select HADBS from the dropdown of the Connection profile.
Page 150
Lab 10 HADR
IBM Software
___16. Go back to your DB2 command prompt and run the command HADR02.CMD. This command will create a HATABLE and HALOAD table in HADB database on the primary server. Run the command HADR02.CMD now. ___17. After starting the above command, go back to the Data Studio Manage HADR view (you can use [Alt][Tab] to do this) ___18. Observe the Log position and Log page after creation of the two tables.
Lab 10 HADR
Page 151
IBM Software
___19. Expand HADBP and select Tables. Notice that these two new tables show in the view.
Page 152
Lab 10 HADR
IBM Software
___22. Expand HADBS and select Tables. Right click HALOAD table and select Browse Data.
___23. Notice the error thrown for the STANDBY database. Click OK.
Note: The standby database is available for READ only operations due to registry variable DB2_HADR_ROS=ON but only uncommitted read (UR) isolation level is allowed. Since Data Studio did not use UR, we see above error. To avoid the above error, we have to use isolation level to UR in the select statement or set DB2 registry variable DB2_STANDBY_ISO to UR. When standby database becomes primary, this variable has no effect and only applies to the database as a standby.
Lab 10 HADR
Page 153
IBM Software
___24. Click down arrow next to the Task Navigator and select SQL and Routine Development. [By doing so, the perspective will change from Database Administrator to the IBM SQL and Routine Development.]
___26. Change directory to C:\POT_DB2\10HADR. Select script HADR06.SQL and hit [Open]. Hit OK to accept semicolon as the statement terminator.
Page 154
Lab 10 HADR
IBM Software
___29. Highlight first SQL statement, and click the Run SQL icon.
___30. From the Status tab of the SQL Results view, notice that the SQL runs successfully since we used UR isolation level. Review the Results tab as well to see it returned the data.
Lab 10 HADR
Page 155
IBM Software
___31. Highlight second SQL statement and click Run SQL icon. Notice the error in the SQL Results view since we tried to do an update on a read only database.
Page 156
Lab 10 HADR
IBM Software
___33. The output from the above command shows the status of HADR on primary and standby databases.
Lab 10 HADR
Page 157
IBM Software
___37. Go to the Manage HADR view in the Data Studio. Notice that the Primary Database role has changed to Standby now.
Page 158
Lab 10 HADR
IBM Software
___38. Expand DB2_P HADBP from the Administration Explorer view. Select Tables. Right click on HALOAD table and click Browse Data. The error statement confirms that the database role is now standby after we executed the TAKEOVER command in the previous section.
___39. Expand DB2_S HADBS from the Administration Explorer view. Select Tables. Right click on HALOAD table and click Browse Data.
Lab 10 HADR
Page 159
IBM Software
___40. Notice that you can see the data in the HALOAD table, which was populated using the DB2 LOAD utility on the primary database.
Note: The LOAD operation is not a logged operation but COPY YES option allows HADR to apply LOAD on the Standby database. ___41. Use the Windows Explorer to review the following directories you have created with script HADR01.CMD. Make sure your REFRESH your screen to see the new directories. Note: These are shown from the C:\ root directory:
F. Cleanup
After you are done with the above exercises, you can run the following command to clean up resources. Run: HADR50.BAT *** End of HADR Lab by Vikram Khatri and Burt Vialpando ***
Page 160
Lab 11 pureXML
IBM Software
___4. ___5.
Review these scripts while they are running. Wait for the scripts to complete. Launch Data Studio when the scripts are finished.
___6.
In the Database Admin perspective, find database XMLDB that was just created and right click on it. Connect with the user name dbapot and password dbapot123
Lab 11 pureXML
Page 161
IBM Software
___7.
By the way, you can manage all your database user names and passwords in one screen easily by right clicking on the database and choosing: Change User Names and Passwords
___8.
Close from that screen after reviewing what it can do for you.
___9.
Next, lets create a table that will support XML. All this means is that it has at least one column with a DB2 data type called XML
___10. Review and run scripts: pureXML03.CMD which executes pureXML04.DB2 Open the Data perspective in the Data Source Explorer
Find new table DBAPOT.XML_BOOKS in Data Studio. Click on it and then review the columns in its properties view. Notice the XML column called BOOK_DOC.
Page 162
Lab 11 pureXML
IBM Software
Notice three new records in the table. Review the XML documents by clicking on the BOOK_DOC fields in any row. Ellipses will appear. Click on the ellipses.
In the XML Cell Editor, find the XML Tree tab. Expand the tree and review.
Explore other XML documents and see if you can tell how they are different from each other. Notice how they have different element structures. For example, the XML document for the record BOOK_ID=34567 has an element called extras that the other XML documents do not have. This shows the flexibility of XML. Notice you can edit this data if you wanted to. We won't be doing that for this lab . Click [Cancel] when done reviewing.
Lab 11 pureXML
Page 163
IBM Software
___13. In your Window Explorer, find and open the file: pureXML07.SQL ___14. Copy and paste all the queries in this file into the SQL Script Editor window
___15. Run the first query only by highlighting it and then: [F5] Note: alternately, you can use the RUN icon to run the query:
Page 164
Lab 11 pureXML
IBM Software
___16. Do this for each query and explore the result sets from these queries to learn more about exploiting the power of XML in your DB2 hybrid pure native XML database! Notice below one that uses a complex xQuery FLWOR expression:
___17. Close the SQL Script Editor when finished. ___18. Close all editor view sessions. ___19. Clean out your SQL Results view too.
Lab 11 pureXML
Page 165
IBM Software
___22. The data file itself has pointers to the exact file, and offset within that file, where the XML data is located for each row of data.
___23. Use Data Studio to view the newly imported data. (Hint: use Edit)
Page 166
Lab 11 pureXML
IBM Software
___25. Fill in the output file name, like below. Leave the delimiters as-is:
Lab 11 pureXML
Page 167
IBM Software
___28. Review and run script: pureXML11.CMD which executes pureXML12.DDL Note: there are MANY ways to create supporting indexes on a DB2 XML column. You must find out from your application developers how they are using their XML data to best create these. The Data Studio task assistant UI can help you do this.
___29. Refresh your index listing. Notice the new indexes you have just created. Click on each and explore them in the Properties view.
Page 168
Lab 11 pureXML
IBM Software
Lab 11 pureXML
Page 169
IBM Software
___35. Edit your INSERT statement and take out the element called <nonxsdelement> that is not registered in your XSR and rerun the INSERT statement. Your INSERT statement should now validate against your XSR and succeed.
G. Cleanup
After you are done with the above exercises, you can run the following command to clean up the resources: pureXML50.BAT *** End of pureXML Lab by Burt Vialpando ***
Page 170
IBM Software
___2.
To set up this lab, run these scripts right away without reviewing them:
MDC01.CMD which executes these 3 scripts: MDC02.DB2 & MDC03.DB2 & MDC04.BAT
This should take about 4 to 5 minutes to complete. While these scripts run, take this time review what the scripts are doing. Here is an overview of what these scripts do: Overview of what the setup scripts create in database GSDB:
Table: CARS Table: CARS_MDC Table: CARS_TIMING_CHECK Table space: CARS_DATA Table space: CARS_INDEX Table space: CARS_MDC_DATA Table space: CARS_MDC_INDEX Buffer pool: CARS_BP_DATA Buffer pool: CARS_BP_INDEX Buffer pool: CARS_MDC_BP_DATA Buffer pool: CARS_MDC_BP_INDEX Procedure: CARS_INSERT_ALL Procedure: CARS_FETCH_CHK Procedure: CARS_INSERT_CHK Procedure: CARS_UPDATE_CHK Procedure: CARS_DELETE_CHK Regular table w/clustered index and regular indexes MDC table, with dimensions CARNAME, COLOR & YEAR Repository table used to collect timing statistics Each table and indexes for each table has its own table space which has its own buffer pool. (the timing table is put in the userspace1 table space)
Buffer pool for non-MDC data Buffer pool for non-MDC indexes Buffer pool for MDC data Buffer pool for MDC indexes Used to populate CARS & CARS_MDC with generated data Used to perform fetches on both tables and time the results Used to perform inserts on both tables and time the results Used to perform updates on both tables and time the results Used to perform deletes on both tables and time the results
Page 171
IBM Software
___5.
Run the SQL and review the output from the system catalog on table space usage
___6.
Since the data and indexes are in their own table space for the CARS and CARS MDC tables, we can easily see the usage in pages of each of these solutions. Notice that the total for CARS_DATA + CARS_INDEX table spaces take up over 4,000 pages. Notice that the total for CARS_MDC_DATA + CARS_MDC_INDEX table spaces take up less than 3,000 pages. Notice the CARS_MDC_DATA alone however, is greater than the CARS_DATA Notice it is the savings in index space that makes the CARS MDC solution smaller overall
Note: IBM does not claim to save space with MDCs in every scenario. But the very small index size required to support MDCs is helpful in offsetting the space used up by the data.
Page 172
IBM Software
The tables Now let's explore this at the table level from the system catalog. ___7. ___8. ___9. In the SQL Script Editor window and cut and paste the SQL from file MDC11.SQL. Run the script. Notice that in fact the MDC table uses up more data pages, even though it has the exact same data and number of rows. Why? Because some extents are allocated, but not used up. (Remember the presentation?)
The indexes Now let's explore the indexes from the system catalog. ___10. In the SQL Script Editor window and cut and paste the SQL from file MDC12.SQL. ___11. Run the script. ___12. Notice the indexes for the MDC tables are significantly smaller and less complex ___13. Notice the indexes for the MDC tables are generated names, created during table creation time
Page 173
IBM Software
___15. Notice what the first 10 rows looks like unfiltered and unsorted (your solution may vary as the data is randomly generated)
___16. Now browse the CARS_MDC table next (again Return all rows) ___17. Notice what the first 10 rows of this table looks like unfiltered and unsorted (your solution may vary)
___18. Notice that the CARS data look randomly put into the table. Actually, it is randomly put into the table. (Only sorting or indexing on it will give it order.)
Page 174
IBM Software
___19. Notice the CARS_MDC data is grouped together. This is because it is not randomly put into the table. It is organized by the CAR, COLOR and YEAR block. ___20. Scroll down in the CARS_MDC table until you see the CARNAME change. This is the very next block of data. From this example, we can conclude we were able to fit 169 records into one MDC block. That is GREAT record co-location!
___21. Is the data really identical in the data groupings between the two tables? Let's check this out by running the SQL from file MDC13.SQL. You'll notice that the results for both tables are identical meaning there are the same numbers of each car dimension. You can change the query to see the color or year dimensions too if you want to and see these too are identical.
Page 175
IBM Software
A final note: this is a very small table compared to a typical data warehousing fact table. You can expect even much better performance from MDCs in most real-world situations.
Page 176
IBM Software
For reference, here are the different colors used in our CARS tables: RED, BLUE, GREEN, YELLOW, BROWN, BLACK, PURPLE, SILVER, GREY, ORANGE, PINK, WHITE, CLEAR
Page 177
IBM Software
___26. From Data Studio browse the table: CARS_TIMING_CHECK. This is the table the stored procedure puts the results in. Review the TOTAL_MICROSCNDS column for time spent on each fetch activity; which seems to run faster fetches, MDC or non-MDC? Answer: MDCs are faster at fetching data when using any dimensional column Note: values not found (like our example below "RRRR") is equally fast for both tables
Use the Data Studio SQL Script Editor to run script MDC30.SQL to get summary totals from the CARS_TIMING_CHECK table:
Generally speaking, MDC tables can be very efficient for fetching data. Though both tables are highly indexed, MDC indexes are smaller and thus more efficient. Further, you have automatic prefetching advantages for MDC tables due to collocation of like rows. The non MDC clustered table may degrade over time. Run a test of more colors to see the numbers begin to really add up and imagine warehouses with tables with millions of rows and thousands of queries.
Page 178
IBM Software
Inserting into MDC tables has a different free space search algorithm than for non MDC tables so random inserts into MDC tables can take a bit more time. Sometimes it does and sometimes it doesn't. You can improve on inserts by sorting them first. INSERT into MDCs utilizes partially filled blocks before creating new ones. The LOAD utility has been enhanced to work with MDCs at a block level so it is more efficient than INSERT. Presorting data for a LOAD helps improve performance and space usage, but it is not necessary. LOAD does not use partially filled blocks though.
Page 179
IBM Software
DELETE from an MDC table can also be quite fast. If you delete on a dimension column, MDCs know already all the blocks that qualify and can delete a block at a time. Also, it has less bid indexing to maintain. Non MDC tables must both find each record, wherever they are, and then delete them and update the rid indexes each time, thus being slower. Your test should have shown an advantage here over the non MDC table. ___29. Run script MDC30.SQL to get final totals from the CARS_TIMING_CHECK table How did your MDC table do? Your run might look like this below. Notice that MDC tables are faster on bulk fetches and deletes.
Page 180
IBM Software
UPDATE of MDC tables can be faster or slower depending upon what is being updated. In this exercise, we updated on one of the dimension columns which can make the MDC UPDATE fast because it changes every record in the block quickly as it reads all records together and writes it back in bulk. If our test were to only update one record on a dimension column however, it would have to relocate the data to a new or different block making it slower. How did your test do?
F. Cleanup
After you are done with the above exercises, you can run the following command to clean up the resources: MDC50.BAT *** End of MDC Lab by Burt Vialpando ***
Page 181
IBM Software
___5. ___6.
Connect to the DATA database in the DB2 instance. (Hint: remember to connect with user dbapot, using password dbapot123.) Expand Data Table Spaces. Verify that it has two DMS user table spaces.
Page 182
IBM Software
___7.
Select Data table space. Click Containers from the Properties view and check for the container name.
___8.
___9.
___10. Using the Windows Explorer, check for the table spaces data files that we created in the script. We will be copying these two table space containers to the instance DB2PROD manually later.
Page 183
IBM Software
___11. From the DB2 CLP Command Window run this command: C:\POT_DB2\13DATA\>db2 list db directory on c:
___12. We will copy this database from the instance DB2 to a new instance called DB2PROD using the db2relocatedb utility. ___13. Using your Windows Explorer, find the files that are under the metadata directory space for the DATA database. These are the ones that will be copied by the next copy script along with the table space data files.
___14. Review and run command Data04.CMD which will copy database metadata files and DMS table space files using an OS copy command. The above command deactivates the DATA database to allow an OS copy. It copies the DATA database metadata files from C:\DB2 directory to C:\DB2PROD directory. It copies DMS table space data files from C:\DB2 to C:\DB2PROD. After execution of the above command, please open the Windows Explorer. Check the C:\DB2PROD folder for files that this script copied from the C:\DB2 folder.
Page 184
IBM Software
___15. Go to the Windows Explorer and refresh. Check for the copied table space containers under C:\DB2PROD directory and the database metadata files under its SQL0000X directory.
___16. After copying the database files, you are now ready to make them be a new database using the db2relocatedb command. ___17. Review and run command Data06.CMD to execute db2relocatedb command and CFG file.
The db2relocatedb command uses configuration file Data07.CFG to read the parameters to move a database DATAPROD into the instance DB2PROD. ___18. Restart your Data Studio session:
Page 185
IBM Software
___20. Expand the database to find the new table RELO_TB and browse the data to see that the utility worked as desired. Find the table spaces and their data files as well.
db2relocatedb also allows you to move or rename data files for a table space in a DB2 database. To do this, you do an OS rename of the data file(s) and run the db2relocatedb command making the source and target database and instance the same.
Page 186
IBM Software
This exercise also demonstrates how you can convert one database from one codepage to another from one platform to another by a mass move of all the objects out of one database into another database. ___21. From a DB2 CLP Window, enter the following command: C:\POT_DB2\13DATA\>db2 get db cfg for data | findstr code
Notice the code page and code set for this database which is NOT unicode ___22. Step #1. Review and run Data10.CMD. This script exports the DATA database using the db2move command. It puts the data in a directory called DUMP under your current lab directory:
Page 187
IBM Software
___24. Step #2. Review and run Data11.CMD. This generates a DDL script using the db2look command. The breakdown of this command is as follows: db2look -d data -e -o db2look_dump.ddl -l -x -f The -d option indicates the database name to be reengineered The -e option extracts all objects (entire database) The -o option indicates the output file name for the generated DDL script The -l option generates DDL for user defined table spaces, database partition groups and buffer pools, The -x option generates authorization DDL The-f option generates an update command for database configuration parameters The -m option generates statistics statements.
___25. This creates a DDL dump file DB2LOOK_DUMP.ddl. Review it to see the entire database. (note: it is located in the DUMP directory)
Page 188
IBM Software
___26. Note: Make sure to change the two CONNECT commands in this file to database DATA2 as shown below. (We we are actually creating a different database called DATA2.)
___27. Step #3. Review and run Data12.CMD. This creates a new target database DATA2 that is in Unicode. This database could actually be on any platform in any codepage as this technique can relocate a database from any platform to any platform.
It then recreates the database structures using the db2look_dump.ddl file. It then imports all the data using the db2move data2 import command.
db2move accepts two loading options, IMPORT and LOAD. If we use the IMPORT option, the table definition can be recreated from IXF files. But in case of the LOAD option, the table must be present in target database. The db2look utility should be used to generate other objects like triggers, UDFs event monitors, any DB2 object, in the target database.
Page 189
IBM Software
___28. Check results in database DATA2 in Data Studio. (Hint: you can either add a new connection for it manually or restart Data Studio again.)
___29. Check out the database parameter CODESET to see the database has changed to UTF-8 (Hint: this is in the database configuration parameter listing)
Page 190
IBM Software
C. SYSPROC.ADMIN_MOVE_TABLE
___30. Review and run Data20.CMD. This will move a table from one table space to another. This only begins to show the many options of this powerful stored procedure. ___31. Review terminal output message (shown below) as well as file Data20_OUTPUT.TXT
Page 191
IBM Software
C. Data Ingestion
The INGEST utility can be run continuously to pump data into DB2 tables using SQL array inserts, updates, and deletes until data sources are exhausted. Ingest command is restartable from the last commit point. Ingest utility also works for DB2 DPF (Warehouse) and DB2 pureScale (OLTP) environments.
This exercise demonstrates the use of the INGEST utility. ___32. IMPORTANT: Close Data Studio for this exercise. The INGEST utility may need the memory used by Data Studio in your VMWare image, so to avoid a memory problem, close it now. ___33. Review and run Data30.CMD. This script creates an INGEST_SAMPLE table with 10 rows.
___34. Review data file Data31.TXT. This file has 7 rows of data having 3 new rows, updated information for 3 existing rows and indication to delete one row. Action New Update Delete Description HULU, FACEBOOK, LINKEDIN WAL MART, JC PENNY, IBM KODAK
Page 192
IBM Software
___35. Review script Data33.SQL which has the INGEST command to merge the data.
___36. Review and run script Data32.CMD. This script will run the INGEST command against data file Data31.TXT and merge the data in INGEST_SAMPLE table.
Note: 3 new rows are inserted, 3 rows are updated and 1 row is deleted. We have only shown one capability of the INGEST utility and there are others like continuous data ingestion, reading from pipe etc.
D. Cleanup
Run the following command to clean up DATA database from DB2 instance and drop DB2PROD instance: Data50.BAT *** End of Data Movement Utilities Lab by Vikram Khatri and Burt Vialpando ***
Page 193
IBM Software
___6.
Find the backup in the directory C:\DB2Backup. Notice the file name of that backup incorporates the timestamp taken from the backup. This is how DB2 names all its backups so it is impossible to accidentally write over a DB2 backup in the operating system.
Page 194
IBM Software
B. Offline Restore
___7. We need the timestamp of the BKPTEST database backup in order to restore it. There are three methods to locate the timestamp of the last backup. The first is to manually write it down from the backup script output. The second is to find the backup file itself and get the timestamp from that. The third way is to review the history file. To do this last way, we use the command db2 list history backup all for bkptest ___8. This command lists all the timestamps of all the previous backups taken on BKPTEST database. Review and execute: Backup02.CMD
___9.
Page 195
IBM Software
___10. You can also use following SQL command to find most recent timestamp from history file for full backup using the view SYSIBMADM.DB_HISTORY db2 connect to bkptest db2 x SELECT max(START_TIME) FROM SYSIBMADM.DB_HISTORY where operation = 'B' and operationtype = 'F'
The value of operation and operation type can be looked from following table:
Operation B Description Backup Operation Type F Offline backup N Online Backup I Incremental offline O Incremental online D Delta offline E Delta online None E End of logs P Point in time F Offline I Incremental offline N Online O Incremental online R Rebuild
D F R
___11. Review and run script Backup03.CMD to restore the BKPTEST database from a backup.
Error message SQL2540W, warning 2539 is normal for restoring over an already existing database, which is what we did in this exercise.
Page 196
IBM Software
___13. After the Database Administration perspective opens, close the Task Launcher view
___14. In Administration Explorer, under instance DB2, select BKPTEST. Right click and click Connect.
___15. Specify user name dbapot and password dbapot123. Check Save Password. Click OK.
Page 197
IBM Software
___17. The Restore Database view will open. Select Restore Objects and click to select the backup image.
___18. Select Restore Containers. Click the drop down of Table space with containers to be redirected and select HDATA16.
Page 198
IBM Software
___19. Click Add. Enter container path C:\DB2NewLoc\BackupData1601.dat and size as 10000 pages.
___20. Select HIDX16 from the drop down. Click Add. Specify container path C:\DB2NewLoc\BackupIndex1601.dat and size as 5000 pages.
___21. Expand the Command section and review the generated RESTORE command. Click Run.
___22. The redirected restore commands run and you will be able to see the output.
Page 199
IBM Software
___23. When this finishes, use the Windows Explorer to review the contents of the DB2NewLoc folder. The two table spaces have been moved from C:\DB2 to C:\DB2NewLoc folder during this redirected restore.
___24. Verify this by looking at the table space containers in the database BKPTEST in Data Studio as well:
Page 200
IBM Software
___26. We built this lab's logging script that updates the db config parameters using the Configure Database Logging task assistant in Data Studio. We will not be using this task assistant in the lab, but you should know it is available and that it simplifies the first-time logging setup for your databases. To use it, right click on database then Set Up and Configure Configure Database. (We are not going to finish using this GUI here in this lab, but you should know about it.)
Page 201
IBM Software
___29. Run: Backup05.CMD. Notice that two different CLP windows are doing work. One is doing the online backup while the other is doing INSERT and LOAD operations.
___31. Close one of the CLP windows in order to continue with the rest of the lab exercises
Page 202
IBM Software
___33. Next, the RESTORE database and ROLLFORWARD commands are demonstrated. (This is for greater control.) Next, review and run: Backup07.CMD
Check the count in BACKUPTEST and BKPLOAD tables and it should be 50,000 rows. The BACKUPTEST table gets 25,000 rows from the LOGS whereas table BKPLOAD gets its data using the RECOVERABLE load operation from C:\DB2LoadData location.
Page 203
IBM Software
Page 204
IBM Software
___39. When you run the above script, the RESTORE command generates the redirected restore script to a file called redirect.CLP. Find this file and right click on it. Choose: Edit
Page 205
IBM Software
___40. Modify the table space container names for HDATA16 and HIDX16 as shown below. (Note: there are TWO changes you need to make!)
___41. After modifying the generated script to change container names, run this script as follows: db2 tvf redirect.clp (Please disconnect the Data Studio connection if it is open. You may get Database is in use error if applications are connected with it. The redirected restore can be performed only in offline mode with the above command.) ___42. The output from above script is kept is BKPTEST_NODE0000.out. Please verify this file and if it was executed correctly, you will see the new table space container names. Use the Windows Explorer and check the new table space containers locations. ___43. After running above script, you cannot connect to the database as it is in roll forward pending mode. Run the roll forward command as shown below. db2 rollforward db bkptest to end of logs and complete
Page 206
IBM Software
Page 207
IBM Software
N. Cleanup
After you are done with the above exercises, you can run the following command to clean up resources. Run: Backup60.BAT
*** End of Backup, Restore and Recovery Lab by Vikram Khatri and Burt Vialpando ***
Page 208
Lab 15 Monitoring
IBM Software
A. Snapshot Monitoring
The snapshot monitoring requires turning on switches either at an instance level or at a session level. The following lab exercise shows how to turn on and off monitoring switches. ___1. Open a DB2 CLP Command Window and change your directory to C:\POT_DB2\15MONITOR
___2.
Review and run Monitor01.CMD. Review output in file Monitor01_OUTPUT.TXT to see the monitor switches set at the instance and session levels. Notice that the global monitoring switches are set using UPDATE DBM command at the DB2 Instance level and session specific monitoring switches is set using UPDATE MONITOR command.
The snapshot monitor is a classic monitoring approach accomplished by the use of the GET SNAPSHOT CLP command. ___3. Review and run the script: Monitor02.CMD to see the output from the GET SNAPSHOT command. Review output in file Monitor02_OUTPUT.TXT.
The snapshot monitoring is the technology of yesteryear. While it is going to stay around, the current preference is to use light weigh monitoring functions and the db2pd command line tool which we will demonstrate later in this lab.
Lab 15 Monitoring
Page 209
IBM Software
B. Event Monitoring
An event monitor differs from other monitor types due to the fact that information is collected at the time when that event is detected or completes. The following lab exercise is an example of event monitoring where we will capture elapsed time used by the SQL statements inside a stored procedure. ___4. Review and run the command: Monitor03.CMD which runs Monitor04.SQL that has DDL to create a table MONITOR_TAB and a stored procedure MONITOR_SP to insert and update data in that table. Review Monitor03_OUTPUT.TXT to see the results of running the stored procedure.
___5.
Review and run the command: Monitor05.CMD which runs Monitor06.SQL that creates an event monitor POT_EVEMON and a stored procedure MONITOR_RS which we will use to see the elapsed time for each SQL statements used inside MONITOR_SP procedure. The db2evtbl command line tool can help you generate event monitor command scripts to store data in target DB2 tables. In the DB2 install path, under the folder MISC, there is an example script for building DB2 Workload Manager event monitors called: wlmevmon.ddl Notice that this script turns on the statement event monitor POT_EVEMON and then runs the procedure MONITOR_SP. The statement event monitor captures the data from this procedure and populates three event monitor tables: POT_EVEMON_HEAD, POT_EVEMON_STMT and POT_EVEMON_CTRL
Now we will run the MONITOR_RS procedure in Data Studio to see the elapsed time for each SQL statement that was inside the procedure MONITOR_SP. ___6. Open the IBM Data Studio by clicking on this icon on your desktop or in your task bar:
Page 210
Lab 15 Monitoring
IBM Software
___7.
___8.
In the Database Administration perspective, find the Administration Explorer and expand localhost DB2 and select SAMPLE. Right click and click Connect. Navigate to schema DBAPOT and expand node Stored Procedures.
___9.
___10. You should see MONITOR_SP and MONITOR_RS stored procedures. (If not, refresh this view so they will appear.) We will run MONITOR_RS procedure to pull information from event monitor tables in which we captured data from the MONITOR_SP procedure.
___11. Right click on stored procedure MONITOR_RS and open click on Run.
Lab 15 Monitoring
Page 211
IBM Software
___12. In the dialog box, specify MONITOR_SP as the argument to the procedure so that it will pull the information from event tables for each SQL statement. Click Run to continue
___13. You will see results from the stored procedure in SQL Results window as shown below. Double click on SQL Results to maximize the screen.
___14.
Click Result1 tab. Expand the TEXT column width to see the statements text and review results:
Page 212
Lab 15 Monitoring
IBM Software
___16. Check Gather performance information from the database. Click Run.
___17. When the run is completed, double click SQL Results tab.
Lab 15 Monitoring
Page 213
IBM Software
___18. Click tab Profile Data. Adjust the width of the SQL column. Double click User CPU Time to sort in the descending order.
This view shows the Stored Procedure body and you have options to sort in different fashion to arrive at the SQL which are expensive and needs attention.
Page 214
Lab 15 Monitoring
IBM Software
___21. Review the output in Monitor07_OUTPUT.TXT file. Notice that we did monitoring of MONITOR_TAB table by running a work load and monitoring the table, table space containers and logs using these lightweight monitoring techniques.
Lab 15 Monitoring
Page 215
IBM Software
___25. From the Getting Started section, click Select a repository database.
Page 216
Lab 15 Monitoring
IBM Software
___27. Specify database DSWC, host name localhost, port number 50010, user id dbapot and password dbapot123. Click Test Connection and if it succeeds, click OK.
By following the above steps, we have chosen DSWC as repository for the Data Studio Web Console. Now we will add databases to do the health monitoring. ___28. Click x to close Configuration Repository.
Lab 15 Monitoring
Page 217
IBM Software
___31. Specify database connection name SAMPLE, database name SAMPLE, host name localhost, port number 50000, user id dbapot, password dbapot123. Click Test Connection and if it succeeds, click OK.
Page 218
Lab 15 Monitoring
IBM Software
___36. The Health Summary view shows the health related alerts encountered for the monitored database.
___37. Click on the down arrow icon next for SAMPLE, select Current Application Connections.
Lab 15 Monitoring
Page 219
IBM Software
Note: The HEALTH_MON database manager parameter must be turned on for the health related alerts to show up in the Health Summary view. So, if nothing is showing up do the following: db2 get dbm cfg | findstr HEALTH db2 update dbm cfg using HEALTH_MON ON db2stop force db2start Now connect to SAMPLE again through Data Studio
Page 220
Lab 15 Monitoring
IBM Software
___43. The table spaces used by the monitored database are shown. Explore the containers too.
E. Cleanup
Please run the following script to clean up objects that we created in this lab: Monitor50.BAT *** End of Monitoring Lab by Vikram Khatri and Burt Vialpando ***
Lab 15 Monitoring
Page 221
IBM Software
___3.
___4.
Run script Temporal03.cmd to see the data in the tables. At first, the tables are empty.
Page 222
IBM Software
___5. ___6.
Find the script file Temporal04.DML and bring it into a SQL Script Editor session in Data Studio. (Hint: New SQL Script) Highlight and run each DML statement one at a time.
___7.
After each DML execution in the SQL Script Editor, run script Temporal03.CMD to see what the tables look like:
___8.
After you finish the INSERTS, find script Temporal05.DML and do the same, running the three UPDATES, one at a time and reviewing the output. Notice on the UPDATE, a new history record is generated.
Page 223
IBM Software
___9.
Finally, run the last DELETE DML operation and review the output, which should look like this:
___10. Study how the start and end times relate to each other. For example, the last history record for POLICY_ID 'A001' ends when the current record for it starts. Time Travel Query ___11. Copy and paste script file Temporal06.SQL into the SQL Script Editor. ___12. Review your own output from the Temporal03.CMD file in your CLP (shown above) to notice the timestamps of your data. Your examples will be run with later and different timestamps than the examples shown here in this lab document, so you have to adjust your timestamps in the query in order to get them to work.
___13. Examples of how this output looks when run with appropriate dates is shown below:
Page 224
IBM Software
___18. At end of the script, notice it runs a query using the nickname EMP_NICK which is in the SAMPLE2 database federated from the table EMP in the SAMPLE database
Federation is enabled ___19. In Data Studio connect to database SAMPLE2. ___20. In the Database Administration perspective, right click on Instance DB2 and choose: Configure
Page 225
IBM Software
___21. Find the section called Environment, then the parameter FEDERATED and notice the script has changed this to YES. This allows for federation to be done in any database in this instance.
___22. Close this parameter edit session when done reviewing. Review federated objects ___23. From Data Studio, go to the Data perspective. ___24. In the Data Source Explorer, find and expand the entire tree for Federated Objects under SAMPLE2 database
___25. First notice the Wrappers and the one called DRDA This wrapper library is found in the BIN subdirectory of your DB2 install path, so on Windows by default this should be in C:\Program Files\IBM\SQLLIB\BIN. If we had other wrapper DLL for Oracle or SQL Server, this is where we would put them to create a wrapper. ___26. Next notice the Defined Remote Servers. We have defined one called SAMPLE for the SAMPLE database ___27. Next notice the User Mappings. We have defined one called DBAPOT for server SAMPLE.
Page 226
IBM Software
___28. Finally, expand EMP_NICK under Nicknames and explore all the attributes of this object.
C. Cleanup
After you are done with the above exercises, you can run the following command to clean up the resources: Misc50.BAT *** End of Misc Additional Topics Lab by Burt Vialpando ***
Page 227
IBM Software
Appendix A. Notices
This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service. IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not grant you any license to these patents. You can send license inquiries, in writing, to: IBM Director of Licensing IBM Corporation North Castle Drive Armonk, NY 10504-1785 U.S.A. For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual Property Department in your country or send inquiries, in writing, to: IBM World Trade Asia Corporation Licensing 2-31 Roppongi 3-chome, Minato-ku Tokyo 106-0032, Japan The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice. Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk. IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. Any performance data contained herein was determined in a controlled environment. Therefore, the results obtained in other operating environments may vary significantly. Some measurements may have been made on development-level systems and there is no guarantee that these measurements will be the same on generally available systems. Furthermore, some measurements may have been estimated through extrapolation. Actual results may vary. Users of this document should verify the applicable data for their specific environment.
Page 228
IBM Software
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. All statements regarding IBM's future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.
Appendix
Page 229
IBM Software
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. Other company, product and service names may be trademarks or service marks of others.
Page 230
IBM Software
Name: (optional)
_____________________________________________________________
Rules and guidelines for voting: You can talk with others on your team about how they want to vote, so you can vote similarly You can only vote once for yourself You can refrain from voting if you want to TOPIC or LAB DB2 Compression DB2 Compression LAB Explain Facilities Explain Facilities LAB DB2 Workload Manager (WLM) DB2 Workload Manager (WLM) LAB DB2 HADR DB2 HADR LAB DB2 pureXML DB2 pureXML LAB DB2 Multidimensional Clusters DB2 Multidimensional Clusters LAB DB2 Data Movement DB2 Data Movement LAB DB2 Backup, Restore & Recovery DB2 Backup, Restore & Recovery LAB DB2 Monitoring DB2 Monitoring LAB Misc Additional Topics & LABs
* Ranking
Time to complete 20 minutes 20 minutes 60 minutes 45 minutes 60 minutes 40 minutes 40 minutes 30 minutes 30 minutes 30 minutes 30 minutes 30 minutes 60 minutes 30 minutes 45 minutes 75 minutes 30 minutes 30 minutes 40+ minutes
Ranking *
Give 10 to your highest, 9 to your next highest and so on down to your lowest with a ranking of 1 If you want to do a lab for a topic, rank the lab for a topic the same as the topic The time to complete is listed to remind you of how much time each topic usually takes We will tally up the rankings of each, and the ones with the highest go first, and so on, until we run out of time for our PoT session
Copyright IBM Corporation 2012. The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBMs sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at Copyright and trademark information at www.ibm.com/legal/copytrade.shtml.