Your SlideShare is downloading. ×
0
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
Edition Based Redefinition - Continuous Database Application Evolution with Oracle Database 11g Release 2
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.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
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

6,047

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

    ×