43
This presentation is available in http://db-oriented.com/presentations Edition Based Redefinition Oren Nakdimon www.db-oriented.com [email protected] +972-54-4393763 @DBoriented © Oren Nakdimon 1

Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

This presentation is available in http://db-oriented.com/presentations

Edition Based Redefinition

Oren Nakdimon

www.db-oriented.com

[email protected]

+972-54-4393763

@DBoriented

© Oren Nakdimon

1

Page 2: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

WHO AM I?

Chronology by “Oracle years”

Today:

Freelance database expert

Courses

Development

Database Administration

When What Where

Oracle 6/7 1991-1997 Developer IAF

Oracle 8 1997-1998 Server group manager Golden Screens

Oracle 8i/9i 1998-2003 DBA group manager TELEknowledge

Oracle

10g/11g

2004-2011 VP R&D and

Israel Site Manager

Olista

“An expert is a person

who has made all the

mistakes that can be

made in a very narrow

field” Niels Bohr (1885-1962)

2

Page 3: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

SHARING EXPERIENCE FROM…

A 24x7 system

Millions of end-users

Thousands of concurrent end-users

All around the world

Lots of PL/SQL code

Frequent upgrades

Oracle 11gR2 Standard Edition

Intensive use of EBR

3

Page 4: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

THE BOTTOM LINE

I think EBR is great!

It is quite a big and complex feature,

but…

It is very easy to start using it

It may take some time to know all the

details and nuances

Warning: as with any other feature,

make sure to test it thoroughly before you

decide to apply it in production

4

Page 5: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

AGENDA

Application upgrades

Scenarios

Methods

EBR introduction

Upgrade use cases

Requirements

Challenges with online upgrade

Solving with EBR

Tips

5

Page 6: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

APPLICATION UPGRADES – SCENARIOS

Bug fix

Patch

New application version (minor / major)

Downgrade

6

Page 7: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

APPLICATION UPGRADES – METHODS

Cold cutover

Warm cutover

Hot rollover

7

Page 8: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

EDITION BASED REDEFINITION

EBR is a feature set that lets you

upgrade the database component of an

application while it is in use, thereby

minimizing or eliminating downtime

Introduced in 11gR2

EBR is supported in all editions, and

requires no special license

8

Page 9: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

The fundamental ability is that different

copies of the same object may coexist

Not all objects are editionable

EDITION BASED REDEFINITION

9

Edition1

Edition2

PKG_A

JERRY TOM

PKG_A

PKG_A

MY_VIEW

MY_VIEW

TRGR_8

TRGR_8

TABLE_X TABLE_Y

Page 10: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

EDITIONS

Edition is a non-schema object

There must be at least one edition in the

database

The initial edition is ORA$BASE

There is always one database-level default

edition

10

Page 11: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

EDITIONS – CONT.

Every new edition is created

as a child of an existing

edition

Currently (11.2, 12.1), each

edition may have at most one

child edition

11

Ask me later about…

Enabling editions to users

Granting use on editions

Edition1

Edition2

Edition3 Edition3b

Page 12: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

OUR EXAMPLE

12

PEOPLE

(table)

PEOPLE_DL

(package)

add | remove

APP_MGR

(package)

do_something

Page 13: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

13

S B S B Table

APP_MGR PEOPLE_DL

@people_setup

OUR EXAMPLE

Page 14: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 1 – THE REQUIREMENTS

A package body should be changed

No change in package spec

No change in table structure

14

Page 15: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 1 – THE CHALLENGES

Blocking

Compilation is blocked by active clients

Clients are blocked during compilation

15

Page 16: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

16

Tip

Page 17: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

SESSION EDITION

Each session uses one edition at a time

The current session edition:

SHOW EDITION (SQL*Plus)

SYS_CONTEXT(‘userenv’,’session_edition_name’)

To change the session edition:

ALTER SESSION SET EDITION = edition;

Must be the first statement of a transaction 17

Page 18: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

EDITIONED OBJECTS

An editioned object in an edition is either:

Inherited

or

Actual

Note: actualization is irreversible!

18

@end_user_session

@use_case_1

Page 19: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 2 – THE REQUIREMENTS

A package spec should be changed

No change in table structure

19

S B S B

Table

ora$base

APP_MGR PEOPLE_DL

V1 B

Page 20: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 2 – THE CHALLENGES

Invalidation

Compilation errors (hopefully not…)

Object dependency

Revalidation occurs automatically when an object is

referenced

Multiple interrelated objects need to be

changed

20

S B S B

Table

APP_MGR PEOPLE_DL

Page 21: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 2

A package spec should be changed

No change in table structure

21

S B S B ora$base

APP_MGR PEOPLE_DL

V1 B

V2 S

Table

Page 22: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 2

A package spec should be changed

No change in table structure

22 @use_case_2

S B S B

Table

ora$base

APP_MGR PEOPLE_DL

V1 B

V2 S B B

Page 24: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

24

Ask me later about…

How to identify dependent

objects

Different ways to actualize

Tip

Page 25: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 3 – THE REQUIREMENTS

A new column should be added

It represents a new logic

An existing package should be changed

accordingly

25

Page 26: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 3 – THE CHALLENGES

Invalidation

Code dependent on the table is invalidated (!)

26

S B S B

Table

ora$base

APP_MGR PEOPLE_DL

V1 B

V2 S B B

Page 27: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

View Program

Unit

ELIMINATING DEPENDENCY

27

Table

Page 28: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

EDITIONING VIEWS

Editioning Views are:

Views (hence editionable)

Deliberately limited:

One per table

May contain only the SELECT and FROM clauses

The FROM clause refers to a single table

The SELECT list may contain only columns and

aliases (no expressions)

DML triggers can be defined on them

28

Page 29: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

29

Editioning Views are

the Interface

between the

Application and the

Tables

Page 30: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

30 @use_case_3

Ask me later about…

Other schema changes that

cause invalidations

And how to handle them

Tip

Page 31: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

31

Tip

Page 32: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

32

Tip

Page 33: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 4 – THE REQUIREMENTS

A new column should be added

It replaces an existing column

Cutover

33 @use_case_4

Page 34: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 4 – THE CHALLENGES

Keeping the old representation and new

representation in sync until the cutover

34

Page 35: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

CROSSEDITION TRIGGERS

A crossedition trigger is a “bridge” for

moving data between editions

Temporary in nature

Forward crossedition triggers transform

pre-upgrade representation to post-

upgrade representation

35 @fce_trigger

Page 36: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

36

Ask me later about…

Mass update of the data

Tip

Page 37: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

37

Tip

Page 38: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

USE CASE 5

A new column should be added

It replaces an existing column

Rollover

38

Page 39: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

REVERSE CROSSEDITION TRIGGERS

Reverse crossedition triggers transform

post-upgrade representation to pre-

upgrade representation

39 @rce_trigger

Page 40: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

40

Tip

Page 41: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

EXPOSING THE NEW VERSION

Database-level:

ALTER DATABASE DEFAULT EDITION = edition;

Session level

Statement level – using

DBMS_SQL.PARSE

Service level

41

Ask me later about…

ORA-04068

After Logon trigger

Page 42: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

© O

ren N

akdim

on

This presentation is available in http://db-oriented.com/presentations

42

Ask me later about…

Retiring editions

Dropping editions

What’s new in 12c

Jobs and editions

DB links and editions

Whatever you like…

Page 43: Edition Based Redefinition - nakdimon.comnakdimon.com/db-oriented/wp-content/uploads/2014/... · Every new edition is created as a child of an existing edition Currently (11.2, 12.1),

This presentation is available in http://db-oriented.com/presentations

THANK YOU

© Oren Nakdimon

43

Oren Nakdimon

www.db-oriented.com

[email protected]

+972-54-4393763

@DBoriented