Your SlideShare is downloading. ×
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2

5,876
views

Published on

Performing an application upgrade with new versions of tables, views, and packages without downtime: that is the objective of many organizations striving for high availability of applications. A …

Performing an application upgrade with new versions of tables, views, and packages without downtime: that is the objective of many organizations striving for high availability of applications. A related objective is to run several versions of an application in parallel, with some users running against one version and others against another. In this session, learn how these objectives can be met and how database development can be organized using capabilities in the upcoming Oracle Database 11g Release 2. The session includes tips for migrating users and client applications one by one to the latest versions of the database objects without loss of availability; guidelines for benefiting from Release 2 functionality in this area; and a demo.

Published in: Technology, Business

0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,876
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
10
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Synonyms are editionableADT are not – though ADTs not used in (Editionable) Table may beAfter a drop you can recreate an object –the ancestry is based on name alone so the end result is the same as the starting pointEditions really is an extension of the Name Resolution mechanismIn addition to name and schema, the edition is taken into accountSQL Execution plans are the same for queries against the table and against the Editioning ViewWhen View 1 depends on View 2 – which version of View 2 is the one picked for view 1?The selection is made like this: whichever version of View 2 that is actual in the Edition where View 1 is createdFixed in 11g – DDL in parallel with running transactions against the same objects (?)Also/part of that: fine grained dependency trackingTools for comparing Editions?List of actual in Edition 2 and Edition 1Compare object levelDIYVPD and FGA work fine with Editionable Views
  • Transcript

    • 1. Release 2
      Release 3
      Base Release
      Continuous Database Application Evolution with Oracle Database 11g Release 2
      Lucas Jellema
      AMIS, The Netherlands
    • 2. Introducing Oracle 11gR2 Edition Based Redefinitionthe story of the Parallel Application Universes
      Release 2
      Release 3
      Base Release
      Lucas Jellema
      AMIS, The Netherlands
    • 3. Availability
      Availability = Performance * (Up or Down)
      Up = !Down
      Down = Unplanned Down + Planned Down
      Planned Down???
      System Maintenance
      Power-supply, Hardware & Network, O/S upgrade
      Database patching & Upgrade
      Application Upgrades
    • 4. Maximum Availability Architecture
    • 5. Application Upgrade
      Creation of new objects
      Changing existing objects (alter and create or replace)
      Add, Modify or Drop columns or constraints
      Change packages and stored procedures
      Recompile
      Drop redundant objects
      Convert or migrate data
      Resume normal operations
      Application is DOWN
    • 6. Compare with road maintenance
    • 7. Restructuring A12
      Build new road next to current one (A12-B)
      Same “functionality” as the old road
      At the cut-over moment
      Open new A12-B:
      Newly arriving traffic travels on temporary road
      Close A12 (original)
      Cars already on old road keep going
    • 8. 11gR2 Editioning is similar
      Application Upgrade:
      Prepare new release
      Construct the release in parallel to the existing
      Operations in existing application ‘edition’ continue normally
      From the cut-over point:
      Have new sessions operate on new release
      Existing sessions can continue to run on existing release
    • 9. 11gR2 Editions introduces a new dimension in the database
      Release 3
      Release 2
      Base Release
    • 10. Editions introduce or inherit versions of objects
      Release 2
      Release 3
      Base Release
    • 11. Editions are parallel universes
      Database Objects are identified by
      Object Type
      Schema
      Object Name
      …. Edition!
      (release, application version, stripe, parallel universe id)
      Database Sessions run in the context of a specific edition
      Using a specific collection of versions of objects
    • 12. Database sessions run in a specific edition –one version of each object
      Release 2
      Release 3
      Base Release
      The database as seen by a sessionrunning in the context of Release 3
      3
      2
      3
      B
      2
      2
      3
      3
      2
    • 13. Demo of Application Upgrade
      Existing base application, in base edition
      Create new editon – release_2
      Create and Alter database objects
      Base application continues running
      Cut-over point
      New sessions run in release_2 edition
      Current sessions continue in base
    • 14. Some Rules for EBR (Edition Based Redefinition)
      Editioning acts on packages, functions, triggers, procedures, views, types and synonyms
      Editioning does not apply to tables
      Data is not versionend, cloned, migrated
      Different incarnations of a table are suggested through editionable views – there is only one table
      Applications should never access tables directly!
    • 15. But wait, there is more
      After the release of a new edition – there is no reason why you cannot keep the previous one going for some time
      And multiple previous ones!
      That means – END OF THE BIG BANG upgrade!
      Multiple versions of the application can continue running to suport various user groups (e.g. SaaS)
      Without data migration and additional downtime upon later move over of user groups
    • 16. Parallel Application Versions
      Application X
      VERSION 1
      Application X
      VERSION 2
      Release 2
      Release 3
      Base Release
    • 17. Version 1 on Base Edition
    • 18. Version 1 on Edition Release 2
    • 19. Upgrade Base to Release 2
      Authors
      New columns COUNTRY and BIOGRAPHY
      Books
      Drop column NUM_OF_PAGES
      Modified column ISBN (10 to 20 characters)
      New columns LANGUAGE and PUBLICATION_YEAR
    • 20. Version 2 (on Edition Release 2)
    • 21. Version 2 on Base Edition
    • 22. Editions and Tables
      Tables cannot be versioned: there is only one definition of a table across all Editions
      Data is not versioned: a record exists once and only once
      The solution for managing changes to Tables: Editioning Views and Cross Edition Triggers
      Editioning Views are defined on base table (no joins)
      Editioning Views can have DML triggers defined (just like base table)
      Using an editioning view in a query or DML statement does not impact the performance of the query or DML
    • 23. Editions and Tables
      Application A
      Application B
      Table EMP
      SAL
      MGR
      JOB
      ENAME
      HIREDATE
      COMM
    • 24. Editions and Tables
      Application A
      Application B
      Editioning View EMP
      Table EMP_BASE
      SAL
      MGR
      JOB
      ENAME
      HIREDATE
      COMM
    • 25. Oracle guarantees:The Execution Plan for a SQL query that uses an Editioning View is identical to that for the same query based directly on the table
    • 26. Migrate to Editioning Views
      Rename Table (for example to <old table name>_BASE)
      Constraints continue to refer to the table
      Create the Editioning View with the old table name
      Using the ‘CREATE OR REPLACE EDITIONING VIEW <view name>’ statement
      Reroute privileges – grant on view rather than table
      Recompile the triggers on the table
      These now become triggers on the Editioning View
      Recompile all invalid PL/SQL program units and Views
      They now refer to the Editioning View instead of the table
      VPD policies are reassigned to the View
      Regular auditing and FGA is on the table
    • 27. Demo
      ALTER TABLE EMP RENAME TO EMP_BASE;
      CREATE OR REPLACE EDITIONING VIEW EMP
      AS
      SELECT ...
      FROM EMP_BASE
      /
      DROP TRIGGER EMP_BRI
      /
      Rem recreate trigger on Editioning View
      @<EMP_BRI>.trg
      Rem recompile invalid Views and PL/SQL units
    • 28. Multiple versions of Editioning View
      Application A
      Application B
      Edition R2
      Edition R1
      Editioning View EMP
      Editioning View EMP
      Table EMP_BASE
      SAL
      MGR
      JOB
      ENAME
      HIREDATE
      COMM
    • 29. Multiple versions of Editioning View
      Application A
      Application B
      Edition R2
      Edition R1
      View EMP (1.1)
      …* Language
      View EMP (1.0)
      Table EMP_BASE
      SAL
      MGR
      JOB
      ENAME
      LANGUAGE
      HIREDATE
      COMM
      Forward CrosseditionTrigger
    • 30. Demo
      CREATE EDITION R2 AS CHILD OF R1;
      ALTER SESSION SET EDITION R2;
      SELECT SYS_CONTEXT('Userenv', 'Current_Edition_Name') "Current_Edition" FROM DUAL;
      ALTER TABLE EMP_BASE
      ADD (LANGUAGE VARCHAR2(2) NULL);
      Rem function for deriving value for language
      CREATE OR REPLACE FUNCTION
      GET_LANGUAGE( p_job in varchar2) return varchar2
      is
      begin
      return case p_job when 'MANAGER' then 'fr'
      else 'en' end;
      end;
    • 31. Demo
      Rem Create Forward Crossedition Trigger
      Rem Applies to DML operations on EMP_BASE from
      Rem Earlier Editions
      CREATE OR REPLACE TRIGGER EMP_1_1_Fwd_Xed
      BEFORE INSERT OR UPDATE ON EMP_BASE
      FOR EACH ROW
      FORWARD CROSSEDITION
      DISABLE
      BEGIN
      :new.language = get_language(:new.job);
      END EMP_1_1_Fwd_Xed;
      Rem Enable the Forward Crossedition Trigger
      ALTER TRIGGEREMP_1_1_Fwd_Xed ENABLE;
    • 32. Demo
      Rem Use Forward Crossedition trigger to
      Rem upgrade existing table records according to new table
      Rem version (for large # records use dbms_parallel_execute)
      DECLARE
      c NUMBER := DBMS_SQL.OPEN_CURSOR();
      x NUMBER;
      BEGIN
      DBMS_SQL.PARSE
      ( c => c
      , Language_Flag => DBMS_SQL.NATIVE
      , Statement => 'UPDATE EMP_BASE SET EMPNO = EMPNO'
      , Apply_Crossedition_Trigger => 'EMP_1_1_Fwd_Xed'
      );
      x := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.CLOSE_CURSOR(c);
      COMMIT;
      END;
    • 33. Upgrade Table Definition
      (Create Edition,) Set target Edition for session
      Make desired changes to the table
      Add columns, modify Columns, … (online redefinition)
      Modify the Editioning View in the Edition
      To reflect the table as its latest version should look
      Perhaps hiding columns you eventually want to drop
      (optional) Create Forward Crossedition Trigger on base table to have DML on previous Editions made valid
      (optional) Create Reverse Crossedition Trigger on base table to have DML on current Edition synch back
    • 34. Cross Edition Triggers
      If you remove a (mandatory) column from the current Editioning View…
      a Reverse Crossedition Trigger ensures that new records get some value in that (invisible) column
      If you add a (mandatory) column to the table (and the current Editioning View)…
      a Forward Crossedition Trigger ensures that records DMLed through previous Editioning View versions are made valid
      (optionally) Apply Forward Crossedition Trigger for all existing records (created in old edition of the table)
      Use DBMS_SQL.parse (with parameter Apply_Crossedition_Trigger set to name of trigger)
      Use DBMS_PARALLEL_EXECUTE
    • 35. Multiple versions of Editioning View
      Application A
      Application B
      Edition R3
      View EMP (1.1)
      … (minus ENAME)* Language
      o FIRST_NAME
      * LAST_NAME
      Edition R1
      Edition R2
      View EMP (1.1)
      …* Language
      View EMP (1.0)
      Table EMP_BASE
      Reverse Crossedition Trigger
      SAL
      MGR
      JOB
      ENAME
      LANGUAGE
      FIRSTNAME
      LASTNAME
      HIREDATE
      COMM
      Forward CrosseditionTrigger
    • 36. “Suggested (best) Practices”
      Every application (release) sets the Edition it requires when it connects to a session
      At the same time it calls dbms_application_info
      And sets other Context details
      Applications should never access tables – all access should be through views
      Only through views can the data structure itself be Editioned
      Even triggers should be on the Editioning View
    • 37. Interesting EBR Tid-Bits
      Drop Object in an Edition stops the inheritance from previous Edition. Object no longer is carried forward
      Edition can have only one child – no branches (yet)
      DBMS_SQL.PARSE can be executed in a specific Edition
      Use parameter edition to specify other than current edition
      If no explicit edition is set for a session, the default edition is used
      ALTER DATABASE DEFAULT EDITION = edition_name;
      Hints in queries against Editionable Views are understood in terms of the underlying table
      Logical EV column references are correctly mapped
    • 38. Interesting EBR Tid-Bits
      DB Links & Materialized Views currently not editionable
      Objects of an editionable type are not editionable when used by a non-editional object
      PL/SQL Function used in Function Based Index or the definition of a Materialized View
      ADT used as the base type for a column in a table
      EBR (online upgrade) benefits from Online Table Redefinition and Fine Grained Dependency tracking
      Data Dictionary Views
      DBA_/ALL_EDITIONS – editions in the database
      DBA_/ALL_OBJECTS – objects (inherited) in current edition
      DBA_/ALL_OBJECTS_AE – actual objects across all editions
    • 39. Summary
      11gR2 Editions are parallel, co-existing universes with incarnations of database objects
      The new release can be constructed, tested and run in a new edition
      The old edition can be switched off at cut-over
      Editions also allow long time co-existence of multiple releases of an application
      Application Upgrade no longer needs to disrupt the operation through planned downtime
      By the way: EBR is available in all DB editions
    • 40. Conclusion
      See our blog for Oracle Database 11gR2 articles (other topics as well)
      http://technology.amis.nl/blog
      This presentation and the demo scripts are on the blog too
      Contact me: lucas.jellema@amis.nl