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),

Post on 17-Oct-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

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

Edition Based Redefinition

Oren Nakdimon

www.db-oriented.com

oren@db-oriented.com

+972-54-4393763

@DBoriented

© Oren Nakdimon

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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© O

ren N

akdim

on

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

16

Tip

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© 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

© O

ren N

akdim

on

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

View Program

Unit

ELIMINATING DEPENDENCY

27

Table

© 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

© 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

© 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

© O

ren N

akdim

on

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

31

Tip

© O

ren N

akdim

on

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

32

Tip

© 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

© 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

© 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

© 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

© O

ren N

akdim

on

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

37

Tip

© 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

© 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

© O

ren N

akdim

on

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

40

Tip

© 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

© 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…

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

THANK YOU

© Oren Nakdimon

43

Oren Nakdimon

www.db-oriented.com

oren@db-oriented.com

+972-54-4393763

@DBoriented

top related