db2 oracle

Upload: timsgreen

Post on 06-Apr-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Db2 Oracle

    1/39

    Leverage your Oracle 11g skills to learn DB2 9.7for Linux, UNIX and WindowsSkill Level: Introductory

    Suita Gupta ([email protected])GTS Information Management SupportIBM

    Allan Tham

    DB2 Presales Technical SupportIBM

    Raul Chong ([email protected])DB2 Express Community FacilitatorIBM

    Alain Fisher ([email protected])DB2 Technical Support SpecialistIBM

    17 Jul 2003

    Updated 24 Mar 2011

    If you're a database specialist interested in growing your DB2 9 skills, there's agood chance that you've already developed database skills with another relationaldatabase product somewhere along the way. Recently updated for the latest versionsof DB2 and Oracle, this article shows you how to use your current knowledge of

    Oracle 11g to quickly gain skills in IBM DB2 9.7 for Linux, UNIX, and Windows.

    Introduction

    IBM DB2 e-kit for Database ProfessionalsLearn how easy it is to get trained and certified for DB2 for Linux,UNIX, and Windows with the IBM DB2 e-kit for Database

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 1 of 39

    mailto:[email protected]:[email protected]:[email protected]://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/mailto:[email protected]:[email protected]:[email protected]
  • 8/3/2019 Db2 Oracle

    2/39

    Professionals. Register now, and expand your skills portfolio, orextend your DBMS vendor support to include DB2.

    An earlier developerWorks article talked about how to leverage your MS SQL Server2000 skills to learn DB2. Is your background in Oracle rather than SQL Server? If so,

    read on. In this article, we will show you how to use your current knowledge ofOracle 11g to quickly find your footing with DB2 9.7

    DB2 9.7 has been delivered with new capabilities to help manage costs and simplifyapplication development. There have been enhancements in several areas such ascompression, pureXML, manageability, and performance. This article focuses onmaking a comparison of DB2 and Oracle fundamental concepts, along withintroducing the new features available in DB2 9.7

    Note: For the remainder of this article, we will use the term "Oracle" to refer toOracle 11g and "DB2" to refer to DB2 9.7 for Linux, UNIX, and Windows.

    Overview of system structures

    To start out, we need to understand the architecture used by Oracle and how itcompares with DB2. Figure 1 shows the system structure of Oracle. Compare it withFigure 2, which shows the system structure of DB2. Refer back to these figures forunderstanding as you read the article.

    Figure 1. Oracle system structure on Linux, UNIX, and Windows

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 2 of 39

    http://www.ibm.com/developerworks/data/kits/dataprokit/index.htmlhttp://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/developerworks/data/kits/dataprokit/index.html
  • 8/3/2019 Db2 Oracle

    3/39

    Figure 2. DB2 on Linux, UNIX, and Windows system structure

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 3 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    4/39

    Instances

    The concept of an instanceis similar in both Oracle and DB2. In both cases aninstance is a combination of background processes and shared memory. The majordifference between the two is that in Oracle there can only be one database perinstance, while in DB2 multiple databases can share an instance.

    Because there is a one-to-one correspondence between database and instance, inOracle you create an instance implicitly by creating a database with the CREATEDATABASE command. Alternatively, to create an Oracle instance on your machineyou can use the Database Configuration Assistant, or you can use the ORADIMutility, available with Oracle 9i with the NEW option. You must also provide certaininformation including a System Identifier (SID) or a service name, instancepassword, maximum number of users, startup mode, and so on. Similarly, to deletethe instance the ORADIM utility can be used with the DELETE option. You wouldneed to pass in either the SID or the service name. There is no default instancecreated with a fresh install of Oracle unless you create a new database during theinstallation process.

    In DB2, after installing the product on the Windows platform, the instance "DB2" is

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 4 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    5/39

    created by default. In Linux and UNIX, the default instance name is called"db2inst1". To create another instance in the same machine, you simply execute thecommand db2icrt .

    Figure 3 shows one instance called DB2_01 created with the db2icrt command from

    the DB2 Control Center GUI.

    Figure 3. DB2 Control Center GUI showing DB2 instances

    To reference a given DB2 instance from a command line interface, use theenvironment variable DB2INSTANCE. This variable lets you specify the currentactive instance to which all commands would apply. For example, if DB2INSTANCEis set to PROD, and then you issue the command create database MYDB1, youwill create a database associated with instance PROD. If you wanted to create thisdatabase on instance DB2 instead, then you would first have to change the value ofthe DB2INSTANCE variable to DB2. This is similar to the ORACLE_SID (SystemIdentifier) which is also used when users want to switch between instances.

    Another easy way to identify the instance you want to work with is by using the DB2Control Center GUI as shown in Figure 3. To see an entry for the new instance inthis tool, you may have to add the instance to the GUI by right clicking on Instancesand choosing Add. To drop an instance in DB2, you can execute the commanddb2idrop .

    In summary, in Oracle the Database Configuration Assistant can be used to create,modify, start, stop and delete the instance, while in DB2 the Control Center GUI canbe used for a similar purpose. Also an Oracle instance can only have a one-to-onerelationship with a database, while in DB2 this is not the case. Multiple databases

    can exist and be concurrently used in a DB2 instance.

    Databases

    In Oracle, a database can either be created manually using the CREATEDATABASE command or by using the Database Configuration Assistant. Creating

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 5 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    6/39

    the database manually requires that a series of steps be followed, including settingOS variables, preparing the parameter file, and creating a password file before theCREATE DATABASE command can be executed.

    Metadata information is stored and managed by the Data Dictionary, which is

    composed of base tables, and corresponding views. The base tables are createdautomatically during database creation, and the views are constructed by runningthe catalog.sql and catproc.sql scripts.

    The Oracle database is therefore seen as a collection of three file types:

    Data File: Contains actual data, physical implementation of the database.(Similar to Containers in DB2)

    Redo File: This is equivalent to Transaction Logs in DB2.

    Control File: Contains information to maintain and verify database

    integrity.

    In DB2, an instance can contain several databases, as shown in Figure 2. Eachdatabase is a truly closed and independent unit. Each database has its own catalogtable space, temporary table space, and user table space which are created bydefault upon successful database creation. DB2 does contain a binary file known asthe system database directory that contains entries of all the databases you canconnect from your DB2 machine. This directory is kept at the instance level.

    When an instance is created, no databases are created by default. You need toexplicitly create a database using the create database command. You can also

    create a database using the Control Center as shown in Figures 4 and 5.

    Figure 4. Creating a DB2 database using the Control Center GUI

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 6 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    7/39

    Figure 5. Creating a DB2 database using the Control Center GUI (continued)

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 7 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    8/39

    In Figure 5, you can also see what happens when you click Show Command. AllDB2 Control Center GUI screens let you see the SQL statement or command that is

    actually executed in the background. These commands can be saved in scripts forexecution at a later time, or can be copied and executed from the Command LineProcessor (CLP) tool or Command Center GUI tool. These tools are equivalent toOracle's SQL*Plus and iSQL *Plus respectively.

    A DB2 database can be dropped by using the 'DROP DATABASE' command or fromthe DB2 Control Center GUI. In Oracle there is no such command; a database isdeleted by deleting all the associated datafiles.

    Databases within an instance normally don't interact with each other. However, ifyour application needs to interact with more than one database, this requirement can

    be supported by enabling federationsupport. See the resources section for an articleabout federation.

    Containers, table spaces, bufferpools and pages

    In Oracle, data is physically stored in files called Data Files. This is similar to DB2'scontainerswhere data is physically stored. Every Oracle database contains a table

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 8 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    9/39

  • 8/3/2019 Db2 Oracle

    10/39

    by adding a new table space.

    Table 2 below shows how Oracle databases or table spaces map to DB2 databasesor table spaces.

    Table 2. How Oracle databases map to DB2 databases and table spaces

    Oracle database or table space DB2 database or table space

    SYSTEM is the table space that holds thecatalog (Data Dictionary) information.

    SYSCATSPACE (catalog table space); as inOracle, this information is kept only at thedatabase level.

    Data Dictionary (contains metadata in form oftables and views) and resides inside theSYSTEM table space.

    System Catalog Tables (identified by theSYSIBM schema) and system views (identifiedby the SYSCAT OR SYSSTAT schema) andreside inside the SYSCATSPACE table space

    SCOTT database SAMPLE database

    TEMP table space System Temporary table space (By default it is

    called tempspace1)

    UNDO table space N/A

    USER table space User table space. By default, USERSPACE1 isnormally created after database creation

    As indicated earlier, Oracle's data buffer concept is equivalent to DB2's bufferpool;however, DB2 allows for multiple bufferpools to exist. There is no predefined numberof bufferpools that you can create, and they can have any name.

    The concept of an Oracle block is most similar to DB2's page. A DB2 page can have

    a size of 4k, 8k, 16k or 32k. A table row must fit in only one page; it cannot span toother pages as in Oracle.

    Object names

    An Oracle object name takes the following form:

    [Schema_name.]object_name[@database]

    In DB2, objects also have a two-part structure:

    Schema_name.object_name

    As in Oracle, the DB2 schema name is used to group objects logically. An importantdifference, however, is that in DB2, a schema name does not have to match to auser id. Any user with a privilege called IMPLICIT_SCHEMA can create an objectusing a non-existing schema. For example, suppose that "Peter" hasIMPLICIT_SCHEMA privilege and executes this command:

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 10 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    11/39

    CREATE TABLE WORLD.TABLEA (lastname char(10))

    In this case, the table WORLD.TABLEA is created, where WORLD is the newlycreated schema. If Peter had not explicitly indicated the schema, then the tablePETER.TABLEA would have been created, because the connection ID is used by

    default.

    In DB2 you always connect to a database before issuing database specificcommands; therefore, under this architecture, object names need not include thedatabase name.

    Tables, views, and indexes

    Tables, views, and indexes are basically the same in both Oracle and DB2.

    DB2 provides a utility called Design Advisor which you can use to recommendindexes for a particular query or workload. You can invoke the Design Advisor fromthe DB2 Control Center or from the DB2 CLP using the db2advis command. In DB2,indexes are directly tied to the table definition. For example, when using DMS tablespaces you can specify in which table space the indexes can reside as follows:

    CREATE TABLE mytable (col1 integer, col2 char(10)) in tbls1

    index in tbls2

    The above example shows that the data for the table will be stored in table space'tbls1', while the index pages will be stored in table space 'tbls2'. This is in contrast toOracle syntax where the CREATE INDEX statement provides an option to specify in

    which table space the index will reside.

    Also, once an index has been created in DB2, you cannot alter any clause of theindex definition. You would need to drop the index and create it again in order toimplement changes.

    As in Oracle, DB2 tables, views and indexes in different databases can have thesame names. Tables and views within the same database must have distinct names,but creating an index with the same name as either an existing table or view isallowed.

    Stored procedures, triggers and user-defined functions (UDFs)

    DB2 stored procedures can be written in any language supported by the DB2precompilers, including Java, C, C++, REXX, Fortran, and COBOL. However, therecommended language to use is the SQL Procedural Language (SQL PL), which isfairly similar to Oracle's PL/SQL. SQL PL stored procedures are easy to create and

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 11 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    12/39

    have good performance. DB2 stored procedure development also supports SQLJand Java using JDBC drivers type 2 and 4. Type 3 is discontinued.

    Development of triggers and functions can use inline SQL/PL, a subset of SQL PL.The Data Studio tool can be used to easily create, build, debug and deploy DB2

    stored procedures and user-defined functions.

    Configuration files

    Traditionally Oracle stores all session and system-related parameters in a text file,normally referred to as initSID.ora. However due to the non-persistent nature of thistext file, starting from Oracle 9i, Oracle introduced Server Parameter File (SPFILE),which is a binary parameter file stored on the server. This persists across instanceshutdown and startup. The initSID.ora file is still used, however, when an SPFILE isnot available. Prior to the introduction of SPFILE, any ALTER SYSTEM and ALTER

    SESSION commands that affected parameters would only persist during thatinstance or that session. The DBA would have had to manually modify theinitSID.ora text file whenever a rebound of a database instance was intended.Network access configurations are typically stored in listener.ora for listener andtnsnames.ora for client access.

    With DB2, configuration parameters are stored at the instance level, known as thedatabase manager configuration file, and at the database level, known as thedatabase configuration file. Most of these parameters can be changed dynamically,that is, there is no need to stop and restart the instance or force all connections froma database before the change to the parameter value takes effect. The files whereDB2 stores its configuration information cannot be edited directly.

    If you would like to manually change a specific database manager parameter fromthe CLP, use the command UPDATE DBM CFG USING .

    If you would like to manually change a specific database parameter from the CLP,use the command UPDATE DB CFG FOR USING .

    These commands would be the equivalent to Oracle's ALTER SYSTEM and ALTERSESSION. Alternatively, using the Control Center, you can review and change

    values for these parameters; if you right click on a given instance and chooseConfigure Parameters, you will see the window shown in Figure 6.

    Figure 6. DB2 Database Manager configuration parameters (instance level)

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 12 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    13/39

    At the database level, right clicking on a given database, and choosing ConfigureParameters displays the window shown in Figure 7.

    Figure 7. Database configuration parameters (database level)

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 13 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    14/39

    DB2 provides many parameters you can use to configure your system. However, ifyou would like an easy way to configure the system automatically, use the

    autoconfigure command (or the Configuration Advisor GUI) which sets thedatabase manager and database configuration parameters to optimal values basedon some information you provide. Figure 8 shows the Configuration Advisor.

    Figure 8. - DB2 Configuration Advisor

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 14 of 39

    http://a/#fig8http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/http://a/#fig8
  • 8/3/2019 Db2 Oracle

    15/39

    In addition to configuration files, DB2 also uses DB2 Registry variables normally forplatform-specific configurations. Note, the DB2 Registry variables have no

    relationship whatsoever to the Windows registry. Use the command db2set to reviewand change these variables.

    Connectivity (network access) information is stored in the system databasedirectory, local database directory and node directory. These are binary files and canonly be modified with the CATALOG and UNCATALOG commands.

    Memory architecture, background processes and threads

    Next we'll look at the memory architecture, background processes and threads, and

    will compare and contrast the way they are used in Oracle and DB2.

    Figure 9: Oracle memory architecture and background processes

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 15 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    16/39

    The System Global Area(SGA) in Oracle is a group of shared memory areas that

    stores information for the instance. Examples include statement cache, redo logbuffers, and data buffer cache. The Program Global Area(PGA) and the User GlobalArea(UGA) shared memory areas contain data and control information for serverprocesses and user sessions.

    Oracle supports multiple instances within the same machine but backgroundprocesses are not shared. For example, three instances in one machine will requirethree set of background processes. Therefore it is generally recommended to haveone database, one instance and multiple schemas within the same machine.

    Figure 10: DB2 Memory architecture and background processes and threads

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 16 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    17/39

    Both DB2 and Oracle use shared memory areas, but DB2's memory architecture isimplemented in a slightly different way than Oracle's. Since a DB2 instance cancontain more than one database, two levels of configuration exist. As we mentionedin the previous section, instance level configuration can be done in the DBM CFGfile while the database level configuration is done in the DB CFG file. Configurationparameters at both levels can be adjusted to tune memory usage. The section belowprovides a bit more detail on DB2's memory structures and different backgroundprocesses.

    Unlike Oracle where memory is allocated to both the instance and the databaseupon startup, DB2 allocates memory at different levels. This is primarily due to thefact that a DB2 instance can contain multiple databases. There are three mainmemory structures in DB2:

    Instance shared memory: This refers to the database manager globalshared memory, which is allocated when the instance is started using thedb2start command, and remains allocated until a db2stop commandis issued to stop the instance.

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 17 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    18/39

    Database shared memory: This refers to the database global memory,which is allocated when the database is activated or connected to for thefirst time. Memory allocated includes buffer pools, locklist, database heap,utility heap, package cache and catalog cache.

    Application shared memory: This refers to the memory allocated whenan application connects to a database and is used by agents that do thework requested by the connected clients. Each application connected tothe database has memory allocated to it; therefore accurate configurationof the parameters affecting the application shared memory becomescrucial.

    The DB2 database server must perform many different tasks, such as processingdatabase application requests or ensuring that log records are written out to disk.Each task is typically performed by a separate engine dispatchable unit (EDU). InDB2 for Windows, Linux and UNIX , server activities are conducted in the form ofthreads. DB2 threads and processes operate in the following levels. Note that this isa non-exhaustive list but we do highlight the important threads and processes:

    Instance Level: These are processes and threads that are initialized whenan instance is started:

    1. DB2 Daemon Spawner (db2gds): Global daemon processorstarted for each instance (only in UNIX)

    2. DB2 System Controller (db2sysc): Main DB2 process

    3. DB2 Watchdog (db2wdog): Parent process for all other processes

    4. DB2 Format Log (db2fmtlg): Similar to the ARCn process inOracle, pre-allocates log files in the log path

    5. Autonomic computing daemon (db2acd): Hosts the healthmonitor, automatic maintenance utilities, and the administrativetask scheduler. This process was formerly known as db2hmon.

    Database Level: These are processes that are initialized when aconnection is made to a database.

    1. DB2 Log Reader (db2loggr): Similar to the subset of Oracle'sPMON process. This process reads log files during rollback, restartrecovery and roll forward.

    2. DB2 Log Writer (db2loggw): Flushes log from log buffer to thetransaction log files on disk. Equivalent to LGWR process inOracle.

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 18 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    19/39

    3. DB2 Page Cleaner (db2pclnr): Equivalent to DBWR process inOracle, this process cleans the buffer pool before pages from thedisk are moved into the BP.

    4. DB2 Prefetcher (db2pfchr): Retrieves pages from disk and placesinto the buffer pool before it is needed.

    5. DB2 Deadlock Detector (db2dlock): Deadlock detector process.

    6. DB2 Self-Tuning Memory Manager (db2stmm): for the autonomicself-tuning memory management feature.

    Application Level: Each application connecting to the database wouldhave its own share of application-level background processes associatedwith it. These are as follows:

    1. DB2 Communication Manager (db2ipccm): Inter-processcommunication process for each locally connected client.

    2. DB2 TCP Manager (db2tcpcm): TCP communication managerprocess for remote clients connecting using TCP/IP.

    3. DB2 Coordinating Agent (db2agent): Thread that handles allrequests on behalf of an application.

    4. DB2 Pooled Gateway Agent (db2agntgp and db2agntgp): Anagent pooled on a remote database and local databaserespectively.

    For a comprehensive explanation of DB2's processes please refer to the article'Everything you wanted to know about DB2 processes'.

    Locking mechanisms

    Locking in Oracle can be either manual or automatic. The Oracle Lock Manager canimplicitly lock table data at the row level, or default locks can be overridden attransaction or session level using the following SQL statements:1. SET TRANSACTION ISOLATION LEVEL

    2. LOCK TABLE3. SELECT FOR UPDATE

    Oracle supports a mechanism called Multi-Version Read Consistency which isimplemented by undo data in the undo segments.

    DB2 implements ANSI standard Isolation levels such as Uncommitted Read, Cursor

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 19 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    20/39

    stability, Read stability and Repeatable Read. A user will only see committed dataunless the Uncommitted Read isolation level is used. Row locks are acquiredimplicitly according to the isolation level. Database objects that are lockable aretable spaces, tables and rows, however, only tables and table spaces can beexplicitly locked. The LOCK TABLE command can be used to lock a table instead of

    using the default row locking.

    Unlike Oracle, in DB2, locks are stored in the memory and not in data pages. TheLOCKLIST database configuration parameter can be used to configure the memoryavailable for locks, while the MAXLOCKS configuration parameter defines themaximum amount of memory for a particular application's locks.

    In DB2 9.7 lock event reporting has been enhanced. The new lock event monitorcollects information about lock timeouts, deadlocks, and lock waits that are morethan a specified duration. This data can be accessed from either a XML document,from database tables or using a java based tool (db2evmonfmt) to read from an xmlor text document.

    A new database configuration parameter cur_commit has been introduced whichbasically allows only committed data to be returned, as was the case previously, butnow readers do not wait for writers to release row locks. Instead, readers return datathat is based on the currently committed version; that is, data prior to the start of thewrite operation.

    Security

    Both Oracle and DB2 are secure databases with basic and advanced securityfeatures. In Oracle, there are 4 different user authentication methods, as follows:

    Database: The database performs both identification and authenticationof users.

    External: The operating system or network service performsauthentication

    Global authentication and authorization: The user is authenticatedglobally by SSL

    Proxy authentication and authorization: The middle-tier serverperforms authentication.

    The authentication method is specified when creating the user using the CREATEUSER command. There are several Data Dictionary views that contain informationabout these users.

    In DB2, users do not exist within the database, but are rather managed by the

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 20 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    21/39

    operating system. No database login information is kept in any database table. Anyoperating system user can potentially access DB2; however, unless they have beengranted a given DB2 authority or privilege, there is not much they can do. Grantingand revoking authorities and privileges can easily be handled through the ControlCenter GUI. You first may have to add a user or group to the Control Center from

    the available operating system users or groups.

    Also in DB2 the term "roles" is not used; instead, DB2 uses the term "authorities",which are similar to Oracle's database roles, whereby privileges are granted tocertain groups or users. The authorities supported with DB2 are: SYSADM,SYSCTRL, SYSMAINT, SYSMON, SECADM, DBADM and LOAD.

    The SYSADM, SYSCTRL and SYSMAINT authorities cannot be granted using theGRANT SQL statement. These special authorities can only be set by modifying thespecific database manager configuration parameters.

    DB2 also uses the term "privilege" which is similar to Oracle's system and schemaobject privileges. There are database privileges(connect, createtab, and so on) anddatabase object privileges(schema, table, view, and so on). Figure 11 shows DB2security information obtained from the Control Center GUI. Most of the tabs shownon the Change User window correspond to the privileges supported by DB2.

    Figure 11. DB2 security

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 21 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    22/39

    Authentication in DB2 does not only involve encrypting user names and passwordsbut also allows for encryption of data as it travels across the network between theclients and the server. The location of the authentication process is determined by

    the value of the database manager configuration parameter AUTHENTICATION.

    The following are the valid options for enabling authentication for DB2:

    SERVER_ENCRYPT - This value specifies that the authentication occurson the server. The user id and password specified during connection areencrypted and sent to the server where they are compared with the userand password on the server side. If the match is successful, the user isallowed to access the database.

    KRB_SERVER_ENCRYPT - This specifies that the server accepts

    KERBEROS authentication or encrypted SERVER authenticationschemes.

    DATA_ENCRYPT - This setting specifies that the server allows forSERVER authentication, and also that the data traveling over the networkbetween the client and server is encrypted.

    DATA_ENCRYPT_CMP - This specifies that the server accepts

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 22 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    23/39

    encrypted SERVER authentication schemes and the encryption of userdata. This authentication type allows for compatibility with down-levelproducts not supporting the DATA_ENCRYPT authentication type.

    GSS_SERVER_ENCRYPT - This specifies that the server accepts GSSAPI-based plug-in authentication or encrypted server authentication

    schemes.

    To update the AUTHENTICATION instance parameter, for example to a value ofDATA_ENCRYPT, use the commands shown below:

    Listing 1. Updating AUTHENTICATION instance parameter

    UPDATE DBM CFG USING AUTHENTICATION DATA_ENCRYPTdb2stopdb2start

    DB2 further extends security by offering a Label Based Access Control (LBAC)mechanism. The LBAC feature provides for greater granularity for controlling readand write access to individual rows and table columns. A security administrator role(SECADM) has been provided in DB2 which is needed to manipulate LBAC objects.Users attempting to access an object must have its security label granted to them.When there's a match, access is permitted; without a match, access is denied.

    There are other aspects of database security beyond privileges and authorities.Briefly, here are some of the differences and similarities between Oracle and DB2:

    User authentication and authorization

    Oracle uses an encrypted password stored in the dictionary once a user is created.DB2 supports passwords for user authentication and uses the underlying operatinguser for authentication. Both Oracle and DB2 support LDAP (Oracle InternetDirectory and IBM Directory Server). Both Oracle and DB2 support single sign on(SSO).

    Data encryption

    Oracle supports data encryption where sensitive data such as credit card numbersand some highly sensitive business data can be encrypted. You have the followingoptions for encrypting DB2 data in storage:

    You can use the encryption and decryption built-in functions ENCRYPT,DECRYPT_BIN, DECRYPT_CHAR, and GETHINT to encrypt your datawithin database tables.

    You can use IBM Database Encryption Expert to encrypt the underlyingoperating system data and backup files.

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 23 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    24/39

    If you are running a DB2 Enterprise Server Edition system on the AIoperating system, and you are interested in file-level encryption only, youcan use encrypted file system (EFS) to encrypt your operating systemdata and backup files.

    Network encryption

    Oracle provides network encryption with its Oracle Advanced Security. Oracle usesDES, 3DES and RC4 industry standard encryptions. To encrypt data in-transitbetween clients and DB2 databases, you can use the DATA_ENCRYPTauthentication type, or, the DB2 database system support of Secure Sockets Layer(SSL).

    Audit trail

    Oracle allows you to audit trail users and objects. Log miner can also be used for

    investigating and analyzing suspicious queries. DB2 provides a similar auditingfacility. The db2audit utility can be used for this purpose.

    XML support

    This section compares Oracle's support for XML to DB2's. Shipped with Oracle 9iRelease 2, Oracle XML DB feature provided a way to manage XML storage, retrievaland schema by defining XMLTYPE tables and columns which are stored as CLOBor shredded (decomposed) to small pieces into relational tables. Oracle 10g camewith some improvements to manage XML documents; for example, changes in

    schema can be dynamically reflected by mapping existing data without the need tore-import. In Oracle 11G, a third kind of XML support called binary XML wasintroduced. So Oracle now has the following ways of storing XML data:

    Unstructured storage using CLOBs (also know as schema-less storage)

    Structured storage which maps XML to object relational

    Binary XML storage

    DB2's pureXML technology, stores XML documents natively, that is, internally in treeformat. It also allows for the use of SQL with XML extensions, Xquery and Xpath to

    access relational and XML data. Storing XML documents natively is a betterapproach, and IBM's research indicates that there is a better performance for searchand retrieval of XML documents, and reduction in the lines of codes for certainprograms. Support for the DB2 XML data type is available in the DB2 ControlCenter, command line processor, IBM Data Studio, and IBM Database Add-Ins forMicrosoft Visual Studio.

    In order to use the pureXML feature in your database, create the database as

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 24 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    25/39

    UNICODE (for example using codeset UTF-8). Failure to create a UNICODEdatabase prior to creating a table will result in an error as shown below:

    SQL1239N XML features can only be used in a Unicode database with a single databasepartition. SQLSTATE=42997

    DB2 stores relational data as in previous versions. However, XML data is stored inhierarchical format (as a tree using the Xquery Data Model, XDM). There is tightintegration between both XML and relational services. To store XML documents, auser needs to create a table, and specify a column to use a new data type, XML, asshown in the example below.

    Listing 2. Create a DB2 table with XML datatype

    CREATE TABLE T(ID INT PRIMARY KEY NOT NULL, COMMENT VARCHAR(1000) NOT NULL, DOCUMENT XML)

    in ttspace compress yes@

    As XML documents are stored in parsed hierarchical format natively in the XQueryData Model (XDM), there is no need for translation or mapping; the format used tostore XML documents is the format used to process it. This allows for greaterperformance.

    Utilities such as backup, restore and import apply to tables with XML columns thesame as in any other tables. XML data can be inserted into the XML column eitherby using the INSERT statement or by using the DB2 IMPORT utility. Prior toimporting XML documents received from third parties, it is a good idea to validate

    these documents against a pre-defined XML schema. To register against an XMLschema, DBAs are required to issue the REGISTER XML SCHEMA command,ended with COMPLETE XML SCHEMA to complete the registration process. DB2also supports indexes to be created on a subset of an XML document, or on theentire document. An XPATH needs to be specified when creating an index whichwould point to that particular element/attribute to be indexed.

    With DB2 you now have four ways to access relational and XML data:

    Plain SQL (no XQuery involved)

    SQL/XML, that is, XQuery embedded in SQL

    XQuery as a stand-alone language (no SQL involved)

    Xquery with embedded SQL

    In DB2 9.7 additional XML features were included such as support for the XML typein User Defined Funcions. Important enhancements in DB2 9.7 are that the LOAD

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 25 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    26/39

    utility can now be used to load XML data. Also, On partitioned tables, indexes overXML data that you create with DB2 V9.7 or earlier are nonpartitioned. Starting inDB2 Version 9.7 Fix Pack 1, you can create an index over XML data on a partitionedtable as either partitioned or nonpartitioned.

    There are more developerWorks articles on IBM pureXML capabilities such asQuery DB2 XML data with XQuery, Query DB2 XML Data with SQL amongst othersfor more in-depth discussions.

    Partitioning

    Oracle Partitioning offers several partitioning strategies that control how thedatabase places data into partitions. The basic strategies are range, list, and hashpartitioning.

    DB2's table partitioning (a.k.a Range partitioning), is similar to Oracle's partitioning.It basically allows a single logical table to be broken up into multiple physical storageobjects across one or more table spaces. Each of the objects would correspond to a'partition' and would allow each table space to contain a range of data which can beaccessed very easily.

    In DB2 there are several ways to partition your data, and you can apply thesemethods simultaneously on the same data. To avoid confusion, here is a shortexplanation about the different ways to provide this partitioning:

    DATABASE PARTITIONING - distributing data by key hash across logical

    nodes of the database (DPF). RANGE/TABLE PARTITIONING (Available with DB2 9) - splitting data by

    key range over multiple physical objects within a logical databasepartition.

    MULTI DIMENSIONAL CLUSTERING (MDC) - organizing data in table(or range of a table) by multiple key values.

    In Version 9.7, you can have indexes that refer to rows of data across all partitions ina data partitioned table (known as nonpartitioned indexes), or you can have theindex itself partitioned such that each data partition has an associated index

    partition. You can have both nonpartitioned and partitioned indexes for partitionedtables.

    The following example creates a table customer where rows with l_shipdate >='01/01/2006' and l_shipdate = '04/01/2006' and l_shipdate

  • 8/3/2019 Db2 Oracle

    27/39

    Listing 3. Range partitoning a table

    CREATE TABLE customer (l_shipdate, l_name CHAR(30))IN ts1, ts2, ts3, ts4, ts5PARTITION BY RANGE(l_shipdate)

    (STARTING FROM ('01/01/2006')

    ENDING AT ('12/31/2006')EVERY (3 MONTHS))

    A comparison of Oracle and DB2 partitioning terminology can be found in Table 1 ofthe article Migrate from Oracle or Sybase to DB2 in weeks.

    Compression

    There are three compression features provided by Oracle; index, table and row levelcompression. Improper planning of these features may have adverse effect inperformance.

    Oracle introduced index compression since version 8i. Indexes that can becompressed are bitmap, btree and index organized tables. To use indexcompression is straightforward; for example, to create an index with thecompression feature, use:

    Listing 4. Create index with compression

    CREATE INDEX ord_customer_ix_demoON orders (customer_id, sales_rep_id)

    COMPRESS 1;

    For indexes that were not created initially with compression, you can turn them tocompression by altering them. Listing 5 shows an example of how you can alter anindex to include compression.

    Listing 5. Alter index with compression

    alter index ord_customer_ix_demo rebuild compress

    Currently, Oracle doesn't provide any automated advisor to pinpoint which indexesshould be compressed. Most of the benefits gained by index compression requiresproper planning by seasoned DBAs who with intimate knowledge of Oracle CBO.

    Table compression on the other hand, was introduced in Oracle 9i release 2. It canbe used to compress entire tables, table partitions, and materialized views. Thecompression can be applied to all partitions or some partitions. Though table

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 27 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    28/39

    compression works for a non-partitioned table, its usage for non-partitioned tables inOLTP workloads may not be desirable as insert and update performance may suffer.In Oracle table compression, duplicate values are removed in a database block, andinformation is stored to recreate the uncompressed data within the block.

    The following example shows how to create partition table with compression.

    Listing 6. Create table with compression

    CREATE TABLE costs_demo (prod_id NUMBER(6), time_id DATE,unit_cost NUMBER(10,2), unit_price NUMBER(10,2))

    PARTITION BY RANGE (time_id)(PARTITION costs_old

    VALUES LESS THAN (TO_DATE('01-JAN-2003', 'DD-MON-YYYY')) COMPRESS,PARTITION costs_q1_2003

    VALUES LESS THAN (TO_DATE('01-APR-2003', 'DD-MON-YYYY')),PARTITION costs_q2_2003

    VALUES LESS THAN (TO_DATE('01-JUN-2003', 'DD-MON-YYYY')),

    PARTITION costs_recent VALUES LESS THAN (MAXVALUE));

    To turn a table into a compressed table, use alter table movecompress. A compressed table, however, does not allow adding or dropping ofcolumns.

    In DB2 9.7, row compression, also referred to as deep compression, compressesdata rows by replacing patterns of values that repeat across rows with shortersymbol strings. Of the various data compression techniques available in DB2 9.7,row compression offers the biggest possibilities for storage savings. Rowcompression requires the creation of a dictionary which stores a mapping between

    repetitive patterns or entries and numeric keys. The compression algorithm isintelligent enough not to compress rows that will not realize in any significantdisk-space saving.

    DB2's row compression, unlike Oracle's key compression, does not require keys tobe specified.

    Compression is enabled at individual table level via the CREATE TABLE or ALTERTABLE commands. For example:

    Listing 7. Create/Alter table with COMPRESSION YES

    CREATE TABLE Sales COMPRESS YESALTER TABLE Sales COMPRESS YES

    To achieve the same effect using the DB2 Control Center, during the columndefinition (second step in the table creation wizard), ensure that you choose thecheckbox, Store table data in a compressed format located at the bottom of the

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 28 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    29/39

    panel (as the following diagram shows).

    Figure 12. DB2 Control Center - Creating table with compression

    The table dictionary is built only when a REORG is performed, after which the datain the table can be compressed. The dictionary gets updated for every subsequentREORG operation. The compressed data is kept both on disk and memory and DB2also compresses user data stored in log files, thereby reducing log file size.

    Note that each partition of a partitioned table can have a different compression

    dictionaries and each partition of a table in DPF can have a different compressiondictionaries.

    Besides, data row compression, other compression mechanisms offered by DB2 9.7include:

    NULL and Default Value Compression (V8 GA): Compression for null,zero length data in variable length columns and system default value.

    Multidimensional Clustering (V8 GA): Implements a form of indexcompression by using block indexes, one index entry for thousands of

    records.

    Database Backup Compression (V8 FP4): Compression to result insmaller backup images.

    XML Parsing

    Autonomic Features

    There are a few tuning improvements provided in Oracle 11g. Oracle automated thefollowing tuning areas:

    Redo Logfile Sizing Advisor - This feature recommends the optimal sizeof redo log files in order to avoid excessive disk I/Os due to frequentcheckpointing.

    Automatic Checkpoint Tuning - The Oracle Database can now self-tunecheckpointing to achieve good recovery times with low impact on normal

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 29 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    30/39

    throughput. You no longer have to set any checkpoint-related parameters.

    Automatic Shared Memory Tuning - Automatic Shared Memory Tuningautomates the configuration of System Global Area (SGA)memory-related parameters (buffer cache, shared pool) throughself-tuning algorithms. It simplifies database configuration, ensures most

    efficient utilization of available memory and improves performance.

    Transaction Rollback and Recovery Monitoring - This feature enables youestimate how long it will take to roll back a transaction. You can alsomonitor the progress of transactions being recovered and estimate theaverage speed of transaction recovery.

    SQL Tuning - The SQL Tuning Advisor automatically tunes high cost SQLstatements.

    Automatic Storage manager - The automatic storage manager (ASM)simplifies the managment or Oracle related files.

    Oracle also provides some advisors such as segment and undo advisors. Thesegment advisor is based on the level of space fragmentation within an object, andas result, gives advice on whether an object is a good candidate for the new onlineshrink operation. As well, this advisor give reports on the historical growth trend ofsegments, and proved to be especially informative for capacity planning.

    Undo Advisor, on the other hand, helps administrators to make the right judgementin sizing the undo table space in both flash back and non-flashback features. Itadvises administrators in setting UNDO_RETENTION appropriately to avoid theage-old 'snapshot too old' problem.

    DB2 9.7 has several autonomic features to assist in managing its environment thatare self-configuring, self-healing, self-optimizing, and self-protecting. By sensing andresponding to situations that occur, autonomic computing shifts the burden ofmanaging a computing environment from database administrators to technology.

    Automatic memory tuning

    DB2 9.7 features a self-tuning memory feature called the Self Tuning MemoryManager that simplifies the task of memory configuration by automatically settingvalues for several memory configuration parameters. When enabled, the automatictuner acting as dispatcher will figure out the memory resources available and

    distribute them to several memory consumers for the database dynamically.Self-tuning memory only applies to single partition databases.

    Automatic configuration

    With the AUTOCONFIGURE command you can calculate and displays initial valuesfor the buffer pool size, database configuration and database manager configuration

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 30 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    31/39

    parameters, with the option of applying these recommended values.

    Automatic storage management

    Automatic storage automatically grows the size of your database across disk and filesystems and since it automatically grows the size of the database, it removes theneed to managing storage containers by DBAs. When you create databases in DB29.7 the automatic storage management feature is enabled by default.

    Automatic Maintenance

    DB2 9.7 has automatic maintenance capabilities that are used for automaticallyperforming maintenance functions such as:

    Automatic database backups which provide the capability of a fulldatabase backup performed as needed.

    Automatic statistics collection. DB2 determines which statistics arerequired and need to be updated and then automatically executes theRUNSTATS utility in the background.

    Automatic table and index reorganisation. DB2 determines if a table orindex reorganization by periodically checking tables and indexes thathave had their statistics updated, and schedules such operationswhenever they are necessary.

    Tools

    We shall look at tools from different areas such as database creation andmaintenance, network, administration GUI, performance tuning, data movement andbackup-recovery tools. Figure 13 shows the DB2 9.7 GUI tools.

    Figure 13. DB2 9.7 GUI Tools

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 31 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    32/39

    Let's take a look at how similar tasks are performed in Oracle and DB2 9.7.

    Database Creation and Maintenance

    Oracle provides the Database Configuration Assistant (dbca) as the GUI tool to

    create databases. For database maintenance, Oracle provides the Oracle EnterpriseManager. DB2 databases can be created and maintained from the DB2 ControlCenter.

    Network

    Oracle provides the Network Configuration Assistant (netca) for networkconfiguration. Alternatively, you can use the Oracle Network Manager to configureservice naming, listener, profile and Oracle name servers. DB2 uses the CATALOGcommand to catalog nodes and databases. Cataloging can also be done usingeither the DB2 command line or DB2 Configuration Assistant GUI.

    Administration

    The Oracle Enterprise Manager provides a wide range of administrative capabilitiesfor the day-to-day tasks of administrators. DB2 Control Center provides similarfunctions as Oracle Enterprise Manager. Apart from the DB2 Control Center, youcan also use the DB2 command line processor to issue DDL and DML statements.This utility is similar to the Oracle SQLPLUS utility. Figure 14 shows the DB2

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 32 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    33/39

    command line processor.

    Figure 14. DB2 Command Line Processor

    Commands can also be issued from the Command Center, shown in Figure 15.

    Figure 15. Command Center GUI (GUI version of DB2 Command LineProcessor)

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 33 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    34/39

    Performance tuning

    Oracle Enterprise Manager comes with Change Management pack, Tuning Pack,and Diagnostic Pack. DB2 provides the Activity Monitor, Event Analyzer, HealthCenter, Indoubt Transaction Manager and Memory Visualizer as GUI tools forperformance tuning tasks.

    Data movement

    Oracle provides SQL Loader (sqlldr) for loading data in delimited text format. Import(imp) and export (exp) can be used to perform logical import and export. DB2provides similar import, export and load utilities . For cross platform data movement,DB2 provides the db2move utility.

    Backup and Recovery

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 34 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    35/39

    Oracle provides Recovery Manager as an option for hot backup. Backing updatabases in DB2 can be accomplished using the backup command or the DB2Control Center.

    Oracle 11g Enteprise Manager comes with new performance overview charts. The

    enhanced Oracle Enterprise Manager HTML interface provides a central point ofaccess to all database performance-related statistics and facilitates completemonitoring and diagnostics.

    Apart from interfaces that are shipped with DB2 9.7 there is a no-charge applicationdevelopment tool, based on the Eclipse framework called tbe IBM Data Studio (DataStuidio). Data Stuidio is a one-stop center for creating, editing, debugging,deploying, and testing DB2 stored procedures and user-defined functions. You canalso use the Data Stuidio to develop SQLJ applications, and create, edit, and runSQL statements and XML queries.

    You can download IBM Data Studio from the Developerworks web site.

    For more details about IBM Data Studio review this tutorial tutorial indeveloperWorks. For examples and features, refer to the IBM Data Studio Featuresand Benefits web page. article in developerWorks.

    Summary

    In this article we've introduced you to DB2 9.7 for Linux, UNIX and Windows byusing your current knowledge of Oracle 11g as leverage. We briefly described theDB2 architecture, background processes, memory model, security, tools, and so on.

    There are many similarities between Oracle and DB2 9, and we have pointed outsome of the differences so you can use your current knowledge to becomesuccessful with DB2 9.7.

    Table 3 summarizes the differences and similarities between Oracle and DB2 thatwe've discussed.

    Table 3. Summary of Oracle vs. DB2 concepts

    Oracle DB2 Comment

    Instance Instance A DB2 instance can containseveral databases

    Database Database

    initSID.ora OR SPFILE DBM CFG andDB CFG DB2 uses two levels ofconfiguration:- DatabaseManager Configuration (DBMCFG) (at the instance level)-Database Configuration (DBCFG) (at the databaselevel).Like in Oracle, many of

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 35 of 39

    http://www.ibm.com/developerworks/downloads/im/data/http://www.ibm.com/developerworks/data/tutorials/dm0711eaton/http://www-01.ibm.com/software/data/optim/data-studio/features.html?S_CMP=wspacehttp://www-01.ibm.com/software/data/optim/data-studio/features.html?S_CMP=wspacehttp://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/http://www-01.ibm.com/software/data/optim/data-studio/features.html?S_CMP=wspacehttp://www-01.ibm.com/software/data/optim/data-studio/features.html?S_CMP=wspacehttp://www.ibm.com/developerworks/data/tutorials/dm0711eaton/http://www.ibm.com/developerworks/downloads/im/data/
  • 8/3/2019 Db2 Oracle

    36/39

    these configuration parameterscan be dynamically changed.

    Table spaces Table spaces DB2 supports SMS and DMSTable spaces. DMS Tablespaces are similar to Oracle's.

    Data Blocks Pages DB2 supports these page sizes:4k, 8k, 16k, 32k. A row must fitany of these page sizes. Itcannot span to other pages likein Oracle's.

    Extents Extents

    Data Files DMS Table space containers Containers for DMS tablespaces can be raw devices orfiles.

    Redo Log Files Transaction Log Files

    Data Buffers Buffer pools. DB2 does not have a predefined

    set of bufferpools, but you cancreate as many as desired. Abufferpool of a given page sizemust be exist prior to creating atable space with the given pagesize.

    SGA Database Manager andDatabase Shared memory

    Data Dictionary Catalog

    Library cache Package cache

    Large Pool Utility Heap

    Data Dictionary Cache Catalog cache

    SYSTEM table space SYSCATSPACE table space

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 36 of 39

    http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/
  • 8/3/2019 Db2 Oracle

    37/39

    Resources

    Learn

    The article "Migrate from Oracle or Sybase to DB2 in weeks" (Data

    Management Magazine, Oct 2010) contains some helpful comparisons of DB2and Oracle terminology and technology.

    The article "DB2 9.7: Run Oracle applications on DB2 9.7 for Linux, UNIX, andWindows" (developerWorks, May 2010) describes the out-of-the-box support forOracle's SQL and PL/SQL dialects in DB2 9.7.

    "IBM Data Movement Tool" (developerWorks, Nov 2010): Move data fromsource databases to DB2 the easy way.

    The Redbooks publication Oracle to DB2 Conversion Guide: CompatibilityMade Easy is an Oracle to DB2 migration guide. It describes the new DB2Oracle Database compatibility features, new technology, best practices formoving to DB2, and how to handle some common scenarios.

    The article "Everything you wanted to know about DB2 processes"(developerWorks, Apr 2003) describes the processes that DB2 uses on Linux,UNIX, and Windows, and details their functions.

    The IBM Redbooks publication Oracle to DB2 Conversion Guide for Linux,UNIX, and Windows is a step-by-step guide for migrating from Oracle to DB2.

    Visit the developerWorks resource page for DB2 for Linux, UNIX, and Windowsto read articles and tutorials and connect to other resources to expand yourDB2 skills.

    Learn about DB2 Express-C, the no-charge version of DB2 Express Edition forthe community.

    Get products and technologies

    Download a free trial version of DB2 for Linux, UNIX, and Windows.

    Now you can use DB2 for free. Download DB2 Express-C, a no-charge versionof DB2 Express Edition for the community that offers the same core datafeatures as DB2 Express Edtion and provides a solid base to build and deployapplications.

    Download IBM product evaluation versions and get your hands on applicationdevelopment tools and middleware products from DB2, Lotus, Rational,Tivoli, and WebSphere.

    Discuss

    Participate in the discussion forum for this content.

    ibm.com/developerWorks developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 37 of 39

    http://www.ibm.com/developerworks/data/library/dmmag/DMMag_2010_Issue4/CoverMigrate/index.htmlhttp://www.ibm.com/developerworks/data/library/dmmag/DMMag_2010_Issue4/CoverMigrate/index.htmlhttp://www.ibm.com/developerworks/data/library/techarticle/dm-0907oracleappsondb2/index.htmlhttp://www.ibm.com/developerworks/data/library/techarticle/dm-0907oracleappsondb2/index.htmlhttp://www.ibm.com/developerworks/data/library/techarticle/dm-0907oracleappsondb2/index.htmlhttp://www.ibm.com/developerworks/data/library/techarticle/dm-0906datamovement/http://www.ibm.com/developerworks/data/library/techarticle/dm-0906datamovement/http://www.redbooks.ibm.com/abstracts/sg247736.htmlhttp://www.redbooks.ibm.com/abstracts/sg247736.htmlhttp://www.ibm.com/developerworks/db2/library/techarticle/0304chong/0304chong.htmlhttp://www.ibm.com/developerworks/db2/library/techarticle/0304chong/0304chong.htmlhttp://www.redbooks.ibm.com/abstracts/sg247048.html?Openhttp://www.redbooks.ibm.com/abstracts/sg247048.html?Openhttp://www.ibm.com/developerworks/data/products/db2luw/http://www.ibm.com/software/data/db2/express/http://www.ibm.com/developerworks/downloads/im/udb/index.htmlhttp://www.ibm.com/developerworks/downloads/im/udbexp/index.htmlhttp://www.ibm.com/developerworks/downloads/http://www.ibm.com/developerworks/forums/dw_forum.jsp?forum=842http://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/developerworks/forums/dw_forum.jsp?forum=842http://www.ibm.com/developerworks/downloads/http://www.ibm.com/developerworks/downloads/im/udbexp/index.htmlhttp://www.ibm.com/developerworks/downloads/im/udb/index.htmlhttp://www.ibm.com/software/data/db2/express/http://www.ibm.com/developerworks/data/products/db2luw/http://www.redbooks.ibm.com/abstracts/sg247048.html?Openhttp://www.redbooks.ibm.com/abstracts/sg247048.html?Openhttp://www.ibm.com/developerworks/db2/library/techarticle/0304chong/0304chong.htmlhttp://www.redbooks.ibm.com/abstracts/sg247736.htmlhttp://www.redbooks.ibm.com/abstracts/sg247736.htmlhttp://www.ibm.com/developerworks/data/library/techarticle/dm-0906datamovement/http://www.ibm.com/developerworks/data/library/techarticle/dm-0907oracleappsondb2/index.htmlhttp://www.ibm.com/developerworks/data/library/techarticle/dm-0907oracleappsondb2/index.htmlhttp://www.ibm.com/developerworks/data/library/dmmag/DMMag_2010_Issue4/CoverMigrate/index.html
  • 8/3/2019 Db2 Oracle

    38/39

    Check out developerWorks blogs and get involved in the developerWorkscommunity.

    About the authors

    Suita Gupta

    Suita Gupta is part of the GTS Information Management Support teambased at IBM Farnborough, UK. She provides DB2 technical support tocustomers. In her previous role Suita worked as a Technical Consultantat the IBM Innovation Center, Kuala Lumpur assisting ISVs with DB2migration initiatives. Suita can be contacted at [email protected].

    Allan Tham

    Allan Tham works as a DB2 Content Manager Technical PresalesSupport for Business Partners in IBM Malaysia. Allan helps businesspartners solve a wide range of technical issues. Allan has DB2 ContentManagement certification for administration. Prior to joining IBM, Allanworked in an end user environment, where he was an Oracle DBA for 3years.

    Raul Chong

    Raul Chong is a database consultant from the IBM Toronto Laboratoryand works primarily with IBM Business Partners. Raul has worked forsix years in IBM, three of them in DB2 9.1 Technical Support, and theother three as a consultant specializing in database applicationdevelopment and migrations from other RDBMSs to DB2 9.1.

    Alain Fisher

    developerWorks ibm.com/developerWorks

    Leverage your Oracle 11g skills to learn DB2 9.7 for Linux, UNIX and Windows Trademarks Copyright IBM Corporation 2003, 2011. All rights reserved. Page 38 of 39

    http://www.ibm.com/developerworks/blogs/http://www.ibm.com/developerworks/communityhttp://www.ibm.com/developerworks/communityhttp://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/ibm/trademarks/http://www.ibm.com/developerworks/communityhttp://www.ibm.com/developerworks/communityhttp://www.ibm.com/developerworks/blogs/
  • 8/3/2019 Db2 Oracle

    39/39

    Alain Fisher is part of GTS Information Management Support teambased at IBM North Harbour. He provides DB2 technical support to UKand Ireland based customers. He previously supported Microsoftdesktop and server products as well as VMware ESX server fromrelease 1. Alain can be contacted at [email protected].

    ibm.com/developerWorks developerWorks