break free from oracle, leveraging your existing oracle ...€¦ · break free from oracle,...

25
© 2013 IBM Corporation Information Management Information Management Break Free from Oracle, leveraging your existing Oracle skills!

Upload: tranque

Post on 20-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

© 2013 IBM Corporation

Information Management

Information Management

Break Free from Oracle, leveraging your existing Oracle skills!

2 © 2013 IBM Corporation

Information Management

Migration Challenges

Oracle SQL and PL/SQL

Transact-SQL

DB2's SQL/PL (based on SQL/PSM)

■ Applications are locked to the chosen RDBMS– Moving to a different RDBMS requires extensive rewrite of code– Your team's skill set cannot be leveraged

■ DB2 10 further enhanced the revolutionary compatibility feature introduced in DB2 9.7

3 © 2013 IBM Corporation

Information Management

� Native PL/SQL Support: The DB2 engine includes a PL/SQL compiler– No translation. No emulation– Source level debugging and profiling

� Several benefits– Reduce the time and complexity of

enabling applications– Developers can continue working in

their language– One source code runs against both

Oracle and DB2– Both PL/SQL and SQL PL perform

at the same level

Data Studio

PL/SQLCompiler

SQL PLCompiler

SURE(SQL Unified Runtime Engine)

Database

Debugger

Profiler

Editor

DB2 Server

Support to Oracle SQL Dialect and PL/SQL

4 © 2013 IBM Corporation

Information Management

Increase compatibilityLocal Type Definitions10

Increase compatibilityRuntime “purity level” Enforcement9.7.3

PerformanceNUMBER Performance9.7.3

Increase compatibilityNCHAR, NVARCHAR, NCLOB9.7.2

EnhancementObfuscation9.7.2

Increase compatibilityUDF Parameters: DEFAULT 9.7.2

Broaden coverageOCI Support9.7.1

Broaden coverageBasic DPF Support9.7.1

EnhancementConditional Compilation9.7.1

Increase compatibilityImprove BOOLEAN9.7.1

Increase compatibilityFORALL/BULK COLLECT9.7.1

Increase compatibilityUDF Parameters: INOUT 9.7.1

Increase compatibilitySUB STRB9.7.1

Increase compatibilityAutonomous Tx Improvements9.7.4

Increase compatibilityMulti-action Trigger & Update Before Trigger9.7.4

Increase compatibilitySmall LOB Compare9.7.3

Increase compatibilityRAISE_APPLICATION_ERROR9.7.3

Increase compatibilityRATIO_TO_REPORT Function9.7.3

Increase compatibilityROW & ARRAY of ROW JDBC Support9.7.4

Increase compatibilityLIKE Improvements, LISTAGG9.7.4

PerformancePL/SQL Performance10

Increase compatibilityLocal Procedure Definitions10

Increase compatibilityNested Complex Objects9.7.5

Increase compatibilityPro*C Support9.7.5

Out-of-the-box support for Oracle’s SQL and PL/SQL dialects- compatible system functions,

SQL, concurrency control

- Extended data type support

- and more…

Continuous effort to increase compatibility- Worked with a large breadth of

companies across industries to determine compatibility requirements

Average PL/SQL Compatibility Moves above 99%

5 © 2013 IBM Corporation

Information Management

DB2 10 Further Reduces Porting Efforts

6 © 2013 IBM Corporation

Information Management

A total of 2,513,236 LOC PL/SQLstudied

Between 90.1% and 99.9% of

PL/SQL statements directly

compatible with DB2

An average of 98.6% of PL/SQL directly compatible!

Improved PL/SQL Compatibility

7 © 2013 IBM Corporation

Information Management

Extended and More Flexible Language

■ New data types add support to non-standard Oracle types– Basic and complex PL/SQL types

■ SQL restrictions have been lifted, to enhance compatibility

■ Synonyms for syntax to accommodate other RDMSes

■ Implicit Casting and Type Resolution– Strings and numbers can be compared, assigned, and

operated on in a very flexible fashion– Untyped NULLs and parameter markers can be used in

many more places• DB2 defers the type resolution until a value is assigned

2.34“2.34”

NUMBER

VARCHAR2REF CURSOR

%TYPE, %ROWTYPE

...VARRAY

BOOLEAN

8 © 2013 IBM Corporation

Information Management

� It is a mechanism whereby database objects that have been invalidated undergo revalidation automatically

– By default, validation is DEFERRED until the next time an invalid object is used

– Configured by DB configuration parameter AUTO_REVAL• DEFERRED_FORCE: same as DEFERRED, but additional CREATE with error feature is

enabled

DROP

table1

CREATE

table1

SELECT

* FROM

table1 table1 table1

view1view1view1

depends on

marked

as invalid

depends on depends on

still invalid revalidated

DROP

table1

CREATE

table1

SELECT

* FROM

table1 table1

view1view1view1

depends on

created

as invalid

depends on depends on

still invalid revalidated

auto_reval = DEFERRED auto_reval = DEFERRED_FORCE

Automatic Revalidation

9 © 2013 IBM Corporation

Information Management

Change is the Exception, Not the Rule!

No longer a migration, its an Enablement

Oracle DB2

Concurrency Control ���� Native support

Oracle SQL dialect ���� Native support

PL/SQL ���� Native support

PL/SQL Packages ���� Native support

Built-in package library ���� Native support

Online Schema Changes ���� Native support

RAC ���� DB2 pureScale

Application Compatibility Vitals

10 © 2013 IBM Corporation

Information Management

� Oracle-specific JDBC extensions– DB2 JDBC driver provides, among other things, support for calling procedures with

reference cursor and VARRAY parameters

� Support for OCI applications– DB2CI supports 150+ OCI functions

� SQL*Plus scripts support using CLPPlus– CLPPlus: a command line interface for execution of SQL statements and database

commands.

� Moving away from Oracle Forms– Partnership between IBM & WonderWorks group– Simplifies migration of Oracle Forms apps to JEE and SOA architecture with high

accuracy, low cost, and lowered risk.

� Enhanced support for migration of embedded SQL C applications– Support of local scope for host variables– Support for VARCHAR AND INT types– Use of a string literals to prepare a statement

Other Features

11 © 2013 IBM Corporation

Information Management

storage object segment

application shared memory and agent private memory program global area (PGA)

DB2INSTANCE environment variable ORACLE_SID environment variable

circular logging noarchive log mode

database manager configuration file and database configuration file init.ora file and Server Parameter File (SPFILE)

instance or database manager instance

transaction log redo log

application global memory user global area (UGA) instance shared memory and database shared memory system global area (SGA)

SYSCATSPACE table space SYSTEM table space

utility heap large pool package cache library cache

Online archive logInactive log

db2start command startup nomount command role role SQL Procedural Language (SQL PL) Procedural Language/Structured Query Language (PL/SQL)

DB2CI, Call Level Interface (CLI)Oracle Call Interface (OCI) Oracle Call Interface (OCI)

materialized query table (MQT) materialized view partitioned index local index non- partitioned index global index snapshot monitor SQL administrative views dynamic performance views nickname database link

container data file catalog cache data dictionary cache system catalog data dictionary

buffer pool data buffer cache

data page data block

diagpath background_dump_dest

log archiving archive log mode

offline archive log archive log

db2diag log files and administration notification log alert log active log active log

DB2Oracle

Terminology Mapping – Oracle to DB2

12 © 2013 IBM Corporation

Information Management

� DB2 stores metadata regarding the database in its System Catalog:– Contains metadata in the form of tables and views– Database manager creates and maintains two sets of catalog views

• SYSCAT views• SYSSTAT views

� Oracle data dictionary plays the same role as DB2’s System Catalog

■ With SQL Compatibility, DB2 supports Oracle data dictionary-compatible views

– Automatically created when you create the database– Query dictionary views as you would in Oracle

Oracle Data Dictionary–compatible Views

connect to mydb

select * from dictionary

Select * from user_sys_privs

13 © 2013 IBM Corporation

Information Management

Summary of PL/SQL Support

■ You can compile:– PL/SQL procedures - CREATE [OR REPLACE] PROCEDURE– PL/SQL functions - CREATE [OR REPLACE] FUNCTION– PL/SQL triggers - CREATE [OR REPLACE] TRIGGER– PL/SQL anonymous blocks - BEGIN ... END– PL/SQL packages - CREATE [OR REPLACE] PACKAGE– PL/SQL package bodies - CREATE [OR REPLACE] PACKAGE BODY– PL/SQL collections - CREATE TYPE … AS VARRAY– PL/SQL cursors - DECLARE CURSOR

■ Features:– Data types: NUMBER, VARCHAR2, NCHAR, NCLOB, NVARCHAR, DATE, %TYPE,

%ROWTYPE, …– Basics: NULL, assignments, IF, CASE, EXIT, LOOP, …– System defined functions: TO_CHAR, TO_NUMBER, TO_NCLOB, TO_NCHAR,

LPAD, RPAD, …– Packages– Multi-event trigger support– Nested Routine support– Declare user-defined data types and procedures that are local to a

compound SQL (compiled) statement – REF CURSORS– SQL dialects: TRUNCATE TABLE, ROWNUM, DUAL, CONNECT BY, …– Implicit casting (aka Weak Typing)– Data Dictionary-compatible views– And much more!

14 © 2013 IBM Corporation

Information Management

� DB2 continues to improve the level of compatibility with more features and refinements

� Some compatibility features in DB2 9.7 and its fix packs– OCI applications compatible DB2CI client– Enhanced IBM Data Server Provider support for .NET– Support of Oracle's NCHAR, NVARCHAR and NCLOB data types

– Logon triggers– Pattern expressions based on other columns within a LIKE predicate

– Enhancements to facilitate the migration of embedded SQL C applications– Nested array and row types– NVL2 support and much more!

� New in DB2 10– CREATE TRIGGER statement allows more flexibility

• Statement triggers have been introduced– Declared user-defined data types and procedures enhanced– New scalar functions increase DB2 compatibility

NEWNEW

DB2 9.7

DB2 10Continuous Effort

15 © 2013 IBM Corporation

Information Management

DB2 Express-C

DB2 Express

DB2 Workgroup

DB2 Enterprise

DB2 Advanced Enterprise

DB2 Personal

Also available in Database Enterprise Developer

Edition

Available in all editions!

Available in all editions!

Which DB2 Editions Support Oracle Compatibility?

16 © 2013 IBM Corporation

Information Management

Configuring Compatibility Mode

■ DB2 Oracle DB Compatibility Features– Registry variable: DB2_COMPATIBILITY_VECTOR, set with db2set

• Accepts hexadecimal values (NULL or 00 to FFF)• Recommended value for Oracle migration is ORA (same as 0x10FFF)

Enables routines to enforce SQL data-access levels at run time.SQL data-access-level

enforcement17 (0x10000)

Specification of DEFAULT for INOUT parameter declarations INOUT parameters14 (0x2000)

Enables cursors that are defined with WITH RETURN to be insensitive if the select-statement does not explicitly specify FOR UPDATE.

Insensitive cursors13 (0x1000)

Bit Position Compatibility Feature Comment

1 (0x01) ROWNUM Synonym for ROW_NUMBER() OVER()

2 (0x02) DUAL Enables the DUAL dummy table

3 (0x04) Outer join operator Enables support for the outer join operator, which is the plus sign (+).

4 (0x08) Hierarchical queries Support for hierarchical queries using the CONNECT BY clause.

5 (0x10) NUMBER Support for the NUMBER data type and associated numeric processing

6 (0x20) VARCHAR2 VARCHAR2 and NVARCHAR2 data types and associated character string processing

7 (0x40) DATE Enables the interpretation of the DATE data type as the TIMESTAMP(0) data type

8 (0x80) TRUNCATE TABLE Alternative semantics for the TRUNCATE statement

9 (0x100) Character literals CHAR or GRAPHIC data type, instead of the VARCHAR or VARGRAPHIC data type

10 (0x200) Collection methods

Enables the use of methods to perform operations on arrays, such as first, last,

next, and previous.

Enables the use of parentheses in place of square brackets in references to specific elements in an array; Eg:array1(i) refers to element i of array1.

11 (0x400)Data dictionary-

compatible views *Data dictionary-compatible views are created when the database is created

12 (0x800) PL/SQL Compilation Enables compilation and execution of PL/SQL statements

* Must be set BEFORE database creation

17 © 2013 IBM Corporation

Information Management

Creating a DB2 Database with Oracle Compatibility

� Create target DB2 database enabling all compatibility features

db2set DB2_COMPATIBILITY_VECTOR=ORA

db2stop force

db2start

db2 “CREATE DATABASE dbName AUTOMATIC STORAGE YES

ON <storagePath1> PAGESIZE 32 K”

-- Recommended but not required

db2 UPDATE DB CFG FOR dbName

USING AUTO_REVAL deferred_force

DECFLT_ROUNDING round_half_up

Recommended to accommodate large

row length

Adjust rounding behaviour to match

that of Oracle

If you want to deploy objects out of

dependency order

Enables all Oracle DB compatibility features

18 © 2013 IBM Corporation

Information Management

Checking Enabled Compatibility Features

� Database Configuration Parameters get database cfg

Example using CLP

19 © 2013 IBM Corporation

Information Management

PL/SQL Packages in DB2

� Oracle PL/SQL Packages are similar to DB2 Modules– a collection of other database objects such as functions, procedures, types, and

variables

� View information about packages– SYSCAT.MODULES: Module information– SYSCAT.MODULEOBJECTS: Objects contained in the module information

M: DB2 ModuleP: PL/SQL Package

20 © 2013 IBM Corporation

Information Management

Built-in Packages in DB2 10

Server side I/O APIUTL_FILE

Routines for maintaining directory aliasesUTL_DIR

Monitoring data and generating text reports MONREPORT

“print debugging” and simple reportingDBMS_OUTPUT

Capability to operate on large objects DBMS_LOB

Job Scheduler, procedures for managementDBMS_JOB

Obfuscate DDL objectsDBMS_DDL

Feature Description

DBMS_ALERT Cross session semaphoring

DBMS_PIPE Cross session data pipe

DBMS_SQL Set of procedures to execute Dynamic SQL

DBMS_UTILITY Misc. functions and procedures

UTL_MAIL Server API to email

UTL_SMTP Server API to SMTP

21 © 2013 IBM Corporation

Information Management

Running PL/SQL Code in DB2

■ You can use any of the DB2 interfaces to run PL/SQL code– CLPPlus and programming interfaces (JDBC, .NET, etc)

– DB2 automatically detects the syntax in use

CLPPlus example

22 © 2013 IBM Corporation

Information Management

Reading Materials – Printed www.ibm.com/software/data/education/bookstore

• Study Guides• Books

Reading Materials - Online• Manuals http://www 01.ibm.com/support/docview.wss?rs=71&uid=swg27015148

• DB2 Information Center http://publib.boulder.ibm.com/infocenter/db2luw/v10r1/

• IBM Redbooks http://www.redbooks.ibm.com

• Best Practices www.ibm.com/developerworks/data/bestpractices/db2luw/

IBM Data Management Magazine http://ibmdatamag.com/

Learner Portal (BPs only) http://eb90.elearn.ihost.com/wps/portal/ibm

More DB2 on the web:

Learn DB2

www.ibm.com/developerworks/db2/

www.ibm.com/developerworks/wikis/display/DB2

www.channeldb2.com www.planetdb2.com

23 © 2013 IBM Corporation

Information Management

Standard Conversion Practice

� Conversion assessment phase � Conversion assessment questionnaire

� Application conversion session� Conversion assessment document

� Database object conversion phase� Conversion of database structures and objects

� Move of data from old to new system� Enabling compression

� Configuration of autonomic functions

� Application conversion phase� Code adjustments to existing application per conversion

assessment� Function and system test

� User and Function Test� ensuring identical application behavior

� Solution deployment phase� Additional database optimization� Index review� Overall solution health-check

� Skills Transfer and DB2 ramp up (independent of above)

If a PoC, is required, please addPlanning Phase- Outline conversion PoC process- Define resources required (HW, SW and people)- Define IBM and Client commitments- Application Selection(Goal is to ensure that we jointly select an application which showcases DB2's ease of conversion, yet can be contained within a PoC window)- Joint project plan with milestone dates.

24 © 2013 IBM Corporation

Information Management

Q & A

25 © 2013 IBM Corporation

Information Management