Oracle12c.pptx

Embed Size (px)

Citation preview

  • 8/12/2019 Oracle12c.pptx

    1/87

    juliandyke.com1 2013 - Julian Dyke

    Web Version

    Oracle 12c

    New Features

  • 8/12/2019 Oracle12c.pptx

    2/87

    juliandyke.com2 2013 - Julian Dyke

    Agenda

    Introduction

    Pluggable Database

    Partial Indexes

    Online Data File Move

    Online Partition Move

    Index Columns

    Invisible Columns Identity Clause

    Session Sequences

    Global Temporary Table Undo

    Temporal Validity

    Extended Columns

    Row Limiting Clause

    Histograms

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    3/87

    juliandyke.com3 2013 - Julian Dyke

    IntroductionThis presentation investigates a selection of Oracle 12c new features thatI believe will be interesting to DBAs

    The presentation was originally delivered at the UKOUG Conference 2013in Manchester, England

    I have added section headers containing comments and feedback fromdelegates

  • 8/12/2019 Oracle12c.pptx

    4/87

    juliandyke.com4 2013 - Julian Dyke

    What History Tells Us.... Oracle 9i , 10g and 11g

    R1 releases have been available for 18-24 months R2 releases have been available for several years

    R2 releases include terminal release

    Support has often been extended for terminal release

    CPU and PSU support is limited for R1 releases

    Longer and more comprehensive for R2 releases

    It is occasionally necessary to upgrade to a terminal release in order tomigrate to new functionality

    In past releases there have been compatibility issues between new features Occasionally bugs....

    Sometimes new features are documented but not released

  • 8/12/2019 Oracle12c.pptx

    5/87

    juliandyke.com5 2013 - Julian Dyke

    New Features Oracle Marketing concentrates on a limited subset of new features

    Particularly new licensing options

    Product Managers and Pre Sales are usually a better source of information

    New features are often overlooked by everyone:

    Particularly additional features in Standard/Enterprise Editions

    Too many in each release to investigate them all

    Documentation and support is often limited at initial release

  • 8/12/2019 Oracle12c.pptx

    6/87

    juliandyke.com6 2013 - Julian Dyke

    Pluggable DatabaseOther presenters will have discussed pluggable databases in more detail

    The concept was announced in September 2012 and I now believe it istime to consider how and where it is appropriate to deploy pluggabledatabases

    My example of a possible deployment was a container database with alarge number of pluggable databases replacing SYBASE. I know thatSYBASE replacement has been a goal at a few of the larger banks formany years.

    Something I missed is that pluggable databases can be cloned allowingtest databases to be created rapidly from production databases.

    I have not investigated this feature yet, so have limited my comments totechnical questions I would still like to answer

  • 8/12/2019 Oracle12c.pptx

    7/87juliandyke.com7 2013 - Julian Dyke

    Pluggable Database Definitely the most attractive marketing feature

    Easy to explain Impresses managers and technical staff

    Obvious benefits

    May be more efficient than virtualization for large numbers of similardatabases

    For example migrations from SYBASE

    Potential reduction in resource consumption including:

    CPU

    memory

    background processes management costs

  • 8/12/2019 Oracle12c.pptx

    8/87juliandyke.com8 2013 - Julian Dyke

    Pluggable Database Reduction in CPU might reduce processor license requirements

    Separately licensed as Oracle Multi Tenant option

    US list price is $17,500 per processor (EE is $47,500)

    All options will need to be licenced for all pluggable databases

    Possibly irrespective of usage e.g.

    Partitioning, Advanced Compression, Advanced Security

  • 8/12/2019 Oracle12c.pptx

    9/87juliandyke.com9 2013 - Julian Dyke

    Pluggable Database Only one redo thread per container instance

    Online redo logs may be a bottleneck

    Data Guard

    Single configuration for container database

    Pluggable databases share redo thread

    May become difficult to manage if standby databases need to be rebuilt

    Single large SGA may increase size of kernel page tables area for eachprocess (foreground / background or both)

    Will offset some of the savings in background process memory

    New In-Memory database may have same problem

    Pluggable databases may contend for resources

    e.g. RAC background processes

  • 8/12/2019 Oracle12c.pptx

    10/87juliandyke.com10 2013 - Julian Dyke

    Partial IndexesI believe this is one of the best features in Oracle 12c for sites using thePartitioning Option

    Most sites partition their tables based on time e.g. year, month, week, dayetc. Most activity centres around the latest (hot) partitions where indexesare often required to optimize access paths. However, the cost of creatingan index for the entire table often prevents creation of appropriateindexes as, in current versions, the index needs to be created for allpartitions, requiring additional storage and increasing backup and restore

    times.

    Partial indexes will not reduce redo generation, but could significantlyreduce overall database sizes as they will often affect the largest tables

    I think the current implementation is limited, but I still think this is a greatfeature

  • 8/12/2019 Oracle12c.pptx

    11/87juliandyke.com11 2013 - Julian Dyke

    Partial Indexes One of the most important new features in Oracle 12.1

    Allows additional indexes to be created for performance tuning

    Potentially reduces amount of storage required for indexes

    May reduce backup and restore times

    Will probably not reduce redo / archive generation

    Functionality is limited

    For a specific table, only one set of table partitions can be enabled forindex partitions

  • 8/12/2019 Oracle12c.pptx

    12/87juliandyke.com12 2013 - Julian Dyke

    Partial Indexes Useful for range-based partitioned tables

    Create partial indexes on most recent (hot) partitions Alternatively create partial indexes on older (archived) partitions

    However cannot create partial indexes on both

    Partial indexing must specified on table partitions

    INDEXING ONpartial indexes enabled

    INDEXING OFFpartial indexes disabled

    If a table partition has INDEXING ON then all rows in that partition will beindexed in each partial index

  • 8/12/2019 Oracle12c.pptx

    13/87juliandyke.com13 2013 - Julian Dyke

    Partial Indexes Partial Local and Global Indexes

    CREATE TABLE pcar(

    season_key NUMBER,race_key NUMBER,driver_key VARCHAR2(4),team_key VARCHAR2(3),

    position NUMBER,laps_completed NUMBER,race_points NUMBER

    )PARTITION BY RANGE (season_key)(

    PARTITION p2008 VALUES LESS THAN (2009) INDEXING OFF,

    PARTITION p2009 VALUES LESS THAN (2010) INDEXING OFF,PARTITION p2010 VALUES LESS THAN (2011) INDEXING OFF,PARTITION p2011 VALUES LESS THAN (2012) INDEXING ON,PARTITION p2012 VALUES LESS THAN (2013) INDEXING ON

    );

  • 8/12/2019 Oracle12c.pptx

    14/87

    juliandyke.com14 2013 - Julian Dyke

    Partial Indexes Partial Local and Global Indexes

    SELECT season_key, COUNT(*)FROM pcarGROUP BY season_keyORDER BY season_key;

    SEASON_KEY COUNT(*)

    2008 3682009 3382010 4562011 4562012 480

  • 8/12/2019 Oracle12c.pptx

    15/87

    juliandyke.com15 2013 - Julian Dyke

    Partial Indexes Example - Partial Local Index

    CREATE INDEX pcar1 ON pcar (driver_key) LOCALINDEXING PARTIAL;

    dbms_stats.gather_index_stats(

    ownname => 'GP',indname => 'PCAR1',

    estimate_percent => NULL);

    SELECT partition_name,num_rowsFROM dba_ind_partitionsWHERE index_name = 'PCAR1';

    PARTITION_NAME NUM_ROWSP2008 0P2009 0P2010 0P2011 456P2012 480

  • 8/12/2019 Oracle12c.pptx

    16/87

    juliandyke.com16 2013 - Julian Dyke

    Partial Indexes Example - Partial Global Index

    CREATE INDEX pcar2 ON pcar (team_key) GLOBALINDEXING PARTIAL;

    dbms_stats.gather_index_stats(

    ownname => 'GP',indname => 'PCAR2',

    estimate_percent => NULL);

    SELECT num_rowsFROM dba_indexesWHERE index_name = 'PCAR2';

    NUM_ROWS936

  • 8/12/2019 Oracle12c.pptx

    17/87

    juliandyke.com17 2013 - Julian Dyke

    Partial Indexes Execution Plans - Partial Local Index

    CREATE INDEX pcar3 ON pcar (season_key,race_key,position)LOCAL INDEXING PARTIAL;

    SELECT COUNT(*) FROM pcarWHERE season_key = '2010'; -- Unindexed

    0 SELECT STATEMENT1 SORT AGGREGATE2 PARTITION RANGE SINGLE3 TABLE ACCESS FULL (PCAR)

    Predicate Information (identified by operation id):

    3 - filter("SEASON_KEY"=2010)

    Cost = 14

  • 8/12/2019 Oracle12c.pptx

    18/87

    juliandyke.com18 2013 - Julian Dyke

    Partial Indexes Execution Plans - Partial Local Index

    CREATE INDEX pcar3 ON pcar (season_key,race_key,position)LOCAL INDEXING PARTIAL;

    SELECT COUNT(*) FROM pcarWHERE season_key = '2011'; -- Indexed

    0 SELECT STATEMENT1 SORT AGGREGATE2 PARTITION RANGE SINGLE3 INDEX FAST FULL SCAN (PCAR3)

    Predicate Information (identified by operation id):

    3 - filter("SEASON_KEY"=2011)

    Cost = 2

  • 8/12/2019 Oracle12c.pptx

    19/87

    juliandyke.com19 2013 - Julian Dyke

    Partial Indexes Execution Plans - Partial Local Index

    SELECT COUNT(*) FROM pcarWHERE season_key IN ('2010','2011'); -- Combined

    0 SELECT STATEMENT1 SORT AGGREGATE2 PARTITION RANGE INLIST3 TABLE ACCESS FULL (PCAR)

    Predicate Information (identified by operation id):

    3 - filter("SEASON_KEY"=2010 OR "SEASON_KEY"=2011)

    Cost = 27

    CREATE INDEX pcar3 ON pcar (season_key,race_key,position)LOCAL INDEXING PARTIAL;

  • 8/12/2019 Oracle12c.pptx

    20/87

    juliandyke.com20 2013 - Julian Dyke

    Online Data File MoveThis is a great new feature which I have already been using to resolvespace issues in my own virtual machines

    I have successfully used this to move the data file containing theSYSAUX tablespacenot sure I would want to risk it with the SYStablespace

  • 8/12/2019 Oracle12c.pptx

    21/87

    juliandyke.com21 2013 - Julian Dyke

    Online Data File Move In Oracle 12.1 and above any data file can be moved online

    For example:

    ALTER DATABASE MOVEDATAFILE '/u01/app/oradata/PROD/users01.dbfTO '/u02/app/oradata/PROD/users01.dbf';

    The database can be open and accessing the data file while the move is inprogress

    Data files can be moved online:

    from file system to file system

    from file system to ASM

    from ASM to file system

    from ASM to ASM

  • 8/12/2019 Oracle12c.pptx

    22/87

    juliandyke.com22 2013 - Julian Dyke

    Online Partition MoveThis feature could be very useful for sites with partitioned tables on tieredstorage. Most likely usage is migrating partitions from fast expensive

    storage (SSD) to slower cheaper storage (SAS or SATA)

    The Oracle documentation hints that there are a lot of places where thispartition move can fail, and the DBMS_PART package contains somesubroutines that allow recovery from failures.

  • 8/12/2019 Oracle12c.pptx

    23/87

    juliandyke.com23 2013 - Julian Dyke

    Online Partition Move In Oracle 12c partitions can be moved online

    Useful for tiered storage

    Move from SSD to SAS to SATA

    May be useful with OLTP compression

    Also works for sub-partitions

    Not supported in the following cases:

    For tables owned by SYS

    For IOTs

    For heap tables containing object types For heap tables containing bitmap join indexes or domain indexes

    If database-supplemental logging is enabled

    When parallel DML or direct path INSERTs are executing on the table

  • 8/12/2019 Oracle12c.pptx

    24/87

    juliandyke.com24 2013 - Julian Dyke

    Online Partition Move Consider the following example

    CREATE TABLE pcar(

    season_key NUMBER,race_key NUMBER,driver_key VARCHAR2(4),team_key VARCHAR2(3),

    position NUMBER,laps_completed NUMBER,race_points NUMBER

    )PARTITION BY RANGE (season_key)(

    PARTITION p2010 VALUES LESS THAN (2011) TABLESPACE sas,

    PARTITION p2011 VALUES LESS THAN (2012) TABLESPACE sas,PARTITION p2012 VALUES LESS THAN (2013) TABLESPACE ssd,PARTITION p2013 VALUES LESS THAN (2014) TABLESPACE ssd

    );

    ALTER TABLE pcar MOVE PARTITION P2012 TABLESPACE sas;

  • 8/12/2019 Oracle12c.pptx

    25/87

    juliandyke.com25 2013 - Julian Dyke

    Online Partition Move If online partition move operation fails, it can be cleaned up manually using:

    DBMS_PART.CLEANUP_ONLINE_OP

    DBMS_PART.CLEANUP_ONLINE_OP (,,);

    Clean up failed operations on

    Clean up failed operations on

    DBMS_PART.CLEANUP_ONLINE_OP (,);

    Clean up failed operations on

    DBMS_PART.CLEANUP_ONLINE_OP ();

    Clean up all failed operations in database

    DBMS_PART.CLEANUP_ONLINE_OP;

  • 8/12/2019 Oracle12c.pptx

    26/87

    juliandyke.com26 2013 - Julian Dyke

    Index ColumnsThis is a useful new feature that allows multiple indexes to be createdwith the same column list

    For any given column list, only one index can be visible at a time.However, this enhancement will allow new indexes to be created invisiblyand then made visible at an appropriate time.

  • 8/12/2019 Oracle12c.pptx

    27/87

    juliandyke.com27 2013 - Julian Dyke

    Index Columns Multiple indexes can be created on the same set of columns

    The following conditions must be met:

    The indexes must have different properties e.g. type, partitioning,uniqueness

    Only one of the indexes can be VISIBLEat any given time

    Recommendation: Check existing databases for indexes thathave been made invisible and then forgotten.

  • 8/12/2019 Oracle12c.pptx

    28/87

    juliandyke.com28 2013 - Julian Dyke

    Index Columns Consider the following table and global index

    CREATE TABLE pcar(

    season_key NUMBER,race_key NUMBER,driver_key VARCHAR2(4),team_key VARCHAR2(3),

    position NUMBER,laps_completed NUMBER,race_points NUMBER

    )PARTITION BY RANGE (season_key)(

    PARTITION p2010 VALUES LESS THAN (2011),

    PARTITION p2011 VALUES LESS THAN (2012),PARTITION p2012 VALUES LESS THAN (2013),PARTITION p2013 VALUES LESS THAN (2014)

    );

    CREATE INDEX pcar_global ON pcar (season_key,race_key,position);

  • 8/12/2019 Oracle12c.pptx

    29/87

    juliandyke.com29 2013 - Julian Dyke

    Index Columns We realise the index should be local so we can drop partitions efficiently

    The following statement fails with ORA-01408

    CREATE INDEX pcar_local ON pcar (season_key,race_key,position) LOCAL;*

    ERROR at line 1:ORA-01408: such column list already indexed

    Create the new index INVISIBLE

    CREATE INDEX pcar_local ON pcar (season_key,race_key,position) LOCALINVISIBLE;

    Index created *

    ALTER INDEX pcar_global INVISIBLE;

    ALTER INDEX pcar_local VISIBLE;

    Switch the indexes

    The new index (PCAR_LOCAL) is now visible

    The old index (PCAR_GLOBAL) can be dropped

  • 8/12/2019 Oracle12c.pptx

    30/87

    juliandyke.com30 2013 - Julian Dyke

    Invisible ColumnsI strongly believe this is a very dangerous feature. Whilst it achieves itsobjectives, it is open to both accidental and malicious misuse as shown

    in the example.Misuse of this feature could introduce data corruptions that may gounnoticed for months or years and prove to be extremely difficult toresolve

  • 8/12/2019 Oracle12c.pptx

    31/87

    juliandyke.com31 2013 - Julian Dyke

    Invisible Columns Consider the following table:

    CREATE TABLE icar(season_key NUMBER,race_key NUMBER,driver_key VARCHAR2(4),team_key VARCHAR2(3),position NUMBER,

    laps_completed NUMBER,race_points NUMBER

    );

    DESCRIBE icar

    Name Null? Type

    SEASON_KEY NUMBERRACE_KEY NUMBERDRIVER_KEY VARCHAR2(4)TEAM_KEY VARCHAR2(3)POSITION NUMBERLAPS_COMPLETED NUMBERRACE_POINTS NUMBER

  • 8/12/2019 Oracle12c.pptx

    32/87

    juliandyke.com32 2013 - Julian Dyke

    Invisible Columns In the data dictionary COL$ contains the following rows for the ICAR table

    SELECT c.name,c.type#,c.col#,c.intcol#,c.segcol#,TO_CHAR (c.property,'XXXXXXXXXXXX') AS property

    FROM sys.col$ c, sys.obj$ o, sys.user$ uWHERE c.obj# = o.obj#AND o.owner# = u.user#AND u.name = 'GP

    AND o.name = 'ICAR';

    NAME TYPE# COL# INTCOL# SEGCOL# PROPERTY

    SEASON_KEY 2 1 1 1 0RACE_KEY 2 2 2 2 0DRIVER_KEY 1 3 3 3 0TEAM_KEY 1 4 4 4 0POSITION 2 5 5 5 0LAPS_COMPLETED 2 6 6 6 0RACE_POINTS 2 7 7 7 0

  • 8/12/2019 Oracle12c.pptx

    33/87

    juliandyke.com33 2013 - Julian Dyke

    Invisible Columns Make the LAPS_COMPLETED column invisible:

    ALTER TABLE icar MODIFY laps_completed INVISIBLE;

    DESCRIBE icar

    Name Null? TypeSEASON_KEY NUMBERRACE_KEY NUMBERDRIVER_KEY VARCHAR2(4)TEAM_KEY VARCHAR2(3)POSITION NUMBERRACE_POINTS NUMBER

    Describe the table again

    The LAPS_COMPLETED column is now invisible

  • 8/12/2019 Oracle12c.pptx

    34/87

    juliandyke.com34 2013 - Julian Dyke

    Invisible Columns In the data dictionary COL$ now contains the following rows for ICAR:

    SELECT c.name,c.type#,c.col#,c.intcol#,c.segcol#,TO_CHAR (c.property,'XXXXXXXXXXXX') AS property

    FROM sys.col$ c, sys.obj$ o, sys.user$ uWHERE c.obj# = o.obj#AND o.owner# = u.user#AND u.name = 'GP

    AND o.name = 'ICAR';

    NAME TYPE# COL# INTCOL# SEGCOL# PROPERTY

    SEASON_KEY 2 1 1 1 0RACE_KEY 2 2 2 2 0DRIVER_KEY 1 3 3 3 0

    TEAM_KEY 1 4 4 4 0POSITION 2 5 5 5 0LAPS_COMPLETED 2 0 6 6 400000020RACE_POINTS 2 6 7 7 0

    0x400000000 = Invisible Column? 0x20 = Hidden Column

  • 8/12/2019 Oracle12c.pptx

    35/87

    juliandyke.com35 2013 - Julian Dyke

    Invisible Columns Make the LAPS_COMPLETED column visible again:

    ALTER TABLE icar MODIFY laps_completed VISIBLE;

    DESCRIBE icar

    Name Null? TypeSEASON_KEY NUMBERRACE_KEY NUMBERDRIVER_KEY VARCHAR2(4)TEAM_KEY VARCHAR2(3)POSITION NUMBER

    RACE_POINTS NUMBERLAPS_COMPLETED NUMBER

    The LAPS_COMPLETED column now appears at end of table

    Describe the table again:

  • 8/12/2019 Oracle12c.pptx

    36/87

    juliandyke.com36 2013 - Julian Dyke

    Invisible Columns In the data dictionary COL$ now contains the following rows for ICAR:

    SELECT c.name,c.type#,c.col#,c.intcol#,c.segcol#,TO_CHAR (c.property,'XXXXXXXXXXXX') AS property

    FROM sys.col$ c, sys.obj$ o, sys.user$ uWHERE c.obj# = o.obj#AND o.owner# = u.user#AND u.name = 'GP

    AND o.name = 'ICAR';

    NAME TYPE# COL# INTCOL# SEGCOL# PROPERTY

    SEASON_KEY 2 1 1 1 0RACE_KEY 2 2 2 2 0DRIVER_KEY 1 3 3 3 0TEAM_KEY 1 4 4 4 0POSITION 2 5 5 5 0LAPS_COMPLETED 2 7 6 6 0RACE_POINTS 2 6 7 7 0

    LAPS_COMPLETED is now COL# 7

  • 8/12/2019 Oracle12c.pptx

    37/87

    juliandyke.com37 2013 - Julian Dyke

    Invisible Columns Why is this dangerous? Consider the following:

    INSERT INTO icar VALUES (2013,1,'KRAI','LOT',1,58,25);

    SEASON_KEY RACE_KEY DRIVER_KEY TEAM_KEY POSITION LAPS_COMPLETED RACE_POINTS

    2013 1 KRAI LOT 1 58 25

    SELECT * FROM icar;

    ALTER TABLE icar MODIFY laps_completed INVISIBLE;

    ALTER TABLE icar MODIFY laps_completed VISIBLE;

    SEASON_KEY RACE_KEY DRIVER_KEY TEAM_KEY POSITION RACE_POINTS LAPS_COMPLETED

    2013 1 KRAI LOT 1 25 582013 1 FALO FER 2 58 18

    INSERT INTO icar VALUES (2013,1,'FALO','FER',2,58,18);

    SELECT * FROM icar;

  • 8/12/2019 Oracle12c.pptx

    38/87

    juliandyke.com38 2013 - Julian Dyke

    Invisible Columns Continued...

    ALTER TABLE icar MODIFY race_points INVISIBLE;

    ALTER TABLE icar MODIFY race_points VISIBLE;

    SEASON_KEY RACE_KEY DRIVER_KEY TEAM_KEY POSITION LAPS_COMPLETED RACE_POINTS

    2013 1 KRAI LOT 1 58 252013 1 FALO FER 2 18 582013 1 SVET RBR 3 58 15

    INSERT INTO icar VALUES (2013,1,SVET',RBR',3,58,15);

    SELECT * FROM icar;

    Column order is restored, but Fernando Alonso now has 58 points

  • 8/12/2019 Oracle12c.pptx

    39/87

    juliandyke.com39 2013 - Julian Dyke

    Identity ClauseThis new feature simplifies management of sequences used as primarykeys for tables. The identity clause allows an implicit index to be created

    for the specified column.If the table is truncated, the sequence is unaffected

    If the table is dropped and recreated the sequence will dropped andrecreated and will restart at the minimum value for the next insertion

  • 8/12/2019 Oracle12c.pptx

    40/87

    juliandyke.com40 2013 - Julian Dyke

    Identity Clause In Oracle 12.1 and above an identity clause can be used to specify a sequence

    column in CREATE TABLE and ALTER TABLE statements

    GENERATED[ ALWAYS | BY DEFAULT [ ON NULL ] ]AS IDENTITY [ ( identity_options ) ]

    Syntax is:

    where are:

    { START WITH ( integer | LIMIT VALUE )| INCREMENT BY integer| ( MAXVALUE integer | NOMAXVALUE )| ( MINVALUE integer | NOMINVALUE )| ( CYCLE | NOCYCLE )

    | ( CACHE integer | NOCACHE )| ( ORDER | NOORDER ) } . . .

  • 8/12/2019 Oracle12c.pptx

    41/87

    juliandyke.com41 2013 - Julian Dyke

    Identity Clause Example:

    CREATE TABLE driver2(

    driver_key NUMBER GENERATED AS IDENTITY,driver_name VARCHAR2(30),driver_dob DATE,country_key VARCHAR2(3)

    );

    INSERT INTO driver2 (driver_name,driver_dob,country_key)VALUES ('Sebastian Vettel','03-JUL-1987','GER');

    INSERT INTO driver2 (driver_name,driver_dob,country_key)VALUES ('Fernando Alonso',29-JUL-1981','SPA');

    INSERT INTO driver2 (driver_name,driver_dob,country_key)VALUES ('Kimi Raikkonen','17-OCT-1979','FIN');

    SELECT * FROM driver2;

    DRIVER_KEY DRIVER_NAME DRIVER_DOB COUNTRY_KEY1 Sebastian Vettel 03-JUL-1987 GER2 Fernando Alonso 29-JUL-1981 SPA3 Kimi Raikkonen 17-OCT-1979 FIN

  • 8/12/2019 Oracle12c.pptx

    42/87

    juliandyke.com42 2013 - Julian Dyke

    Identity Clause DESCRIBE includes identity column

    DESCRIBE driver2

    Name Null? Type

    DRIVER_KEY NOT NULL NUMBERDRIVER_NAME VARCHAR2(30)DRIVER_DOB DATECOUNTRY_KEY VARCHAR2(3)

    No additional indexes are created

  • 8/12/2019 Oracle12c.pptx

    43/87

    juliandyke.com43 2013 - Julian Dyke

    Identity Clause Columns are stored in the data dictionary as follows:

    SELECT c.name,c.type#,c.col#,c.intcol#,c.segcol#,TO_CHAR (c.property,'XXXXXXXXXX') AS property

    FROM sys.col$ c, sys.obj$ o, sys.user$ uWHERE c.obj# = o.obj#AND o.owner# = u.user#AND u.name = 'GPAND o.name = 'DRIVER2

    ORDER BY intcol#;

    NAME TYPE# COL# INTCOL# SEGCOL# PROPERTY

    DRIVER_KEY 2 1 1 1 2800000000DRIVER_NAME 1 2 2 2 0

    DRIVER_DOB 12 3 3 3 0COUNTRY_KEY 1 4 4 4 0

    0x800000000 = Default as Sequence

    0x2000000000 = Generated ALWAYS identity column

  • 8/12/2019 Oracle12c.pptx

    44/87

    juliandyke.com44 2013 - Julian Dyke

    Identity Clause Default value for DRIVER_KEY column can be found in DBA_TAB_COLUMNS:

    SELECT data_defaultFROM dba_tab_columnsWHERE owner = 'GPAND table_name = 'DRIVER2AND column_name = 'DRIVER_KEY';

    "GP"."ISEQ$$_92584".nextval

    SELECTsequence_owner AS owner,min_value,max_value,increment_by,cycle_flag,order_flag,cache_size

    FROM dba_sequencesWHERE sequence_name = 'ISEQ$$_92584';

    OWNER MIN_VALUE MAX_VALUE INCREMENT_BY C O CACHE_SIZE

    GP 1 1.0000E+28 1 N N 20

    In this example 92584 is the object ID of the GP.DRIVER2 table

  • 8/12/2019 Oracle12c.pptx

    45/87

    juliandyke.com45 2013 - Julian Dyke

    Session SequencesThis new feature allows sequences to be created that exist for the lifetimeof the current session only.

    Intended for use with global temporary tables, but possibly useful inother places and more flexible than the ROWNUM pseudo column

  • 8/12/2019 Oracle12c.pptx

    46/87

    juliandyke.com46 2013 - Julian Dyke

    Session Sequences In Oracle 12.1 and above sequences can have session visibility

    Current value only visible to session

    For example:

    CREATE SEQUENCE seq1 SESSION;

    SQL> CONNECT gp/gp

    SQL> SELECT seq1.NEXTVAL FROM dual;NEXTVAL

    1

    SQL> SELECT seq1.NEXTVAL FROM dual;NEXTVAL

    2SQL> CONNECT gp/gp

    SQL> SELECT seq1.NEXTVAL FROM dual;NEXTVAL

    1

  • 8/12/2019 Oracle12c.pptx

    47/87

    juliandyke.com47 2013 - Julian Dyke

    Global TemporaryTable UndoThis new feature allows undo for global temporary tables to be written to

    the temporary table spaceIt will not have much impact for insertions, but could have a significantimpact on redo generation caused by GTT undo during updates

    I envisage this becoming the default in future versions

  • 8/12/2019 Oracle12c.pptx

    48/87

    juliandyke.com48 2013 - Julian Dyke

    Global Temporary Table Undo By default DML on Global Temporary Tables

    Does not generate redo directly

    Does generate undo and indirect redo

    Undo is required to rollback transactions

    Redo will be archived, backed up , propagated to standby etc

    In Oracle 12c Global Temporary Table undo can be stored in a temporarytablespace

    Set TEMP_UNDO_ENABLED= TRUE

    Will not have much impact for INSERTstatements

    May have significant impact for UPDATEand DELETEstatements

    Review whether DELETEstatements are necessary

  • 8/12/2019 Oracle12c.pptx

    49/87

    juliandyke.com49 2013 - Julian Dyke

    Temporal Validity

    Temporal validity allows tables to be created where rows are valid for aspecific period of time

    A major defect is that is not possible to create primary keys with temporalvalidity. This functionality may be added in a future release, until whichtime this feature may be of limited use.

  • 8/12/2019 Oracle12c.pptx

    50/87

    juliandyke.com50 2013 - Julian Dyke

    Temporal Validity Flashback Data Archive was introduced in Oracle 11.1

    Originally known as Total Recall

    Allows historic data to be inspected at any point in time

    Was a separately licensed option

    Consequently not very popular

    Now available free in Enterprise Edition (at least)

    Including Oracle 11.2

    In Oracle 12.1 and above Temporal Validity builds on these concepts

  • 8/12/2019 Oracle12c.pptx

    51/87

    juliandyke.com51 2013 - Julian Dyke

    Temporal Validity For example:

    CREATE TABLE driver(

    driver_key VARCHAR2(4),team_key VARCHAR2(3),

    joining_date DATE,leaving_date DATE,

    PERIOD FOR team_member_valid_time (joining_date,leaving_date));

    INSERT INTO driver VALUES ('FALO','FER','01-JAN-2010',NULL);

    INSERT INTO driver VALUES ('FMAS','FER','01-JAN-2006','31-DEC-2013');INSERT INTO driver VALUES ('KRAI','FER','01-JAN-2007','31-DEC-2009');

    INSERT INTO driver VALUES ('RBAR','FER','01-JAN-2000','31-DEC-2007');

    INSERT INTO driver VALUES ('MSCH','FER','01-JAN-1996','31-DEC-2006');

    Insert some data

    Note: the above data is inaccurate

  • 8/12/2019 Oracle12c.pptx

    52/87

    juliandyke.com52 2013 - Julian Dyke

    Temporal Validity For example:

    SELECT * FROM driver;

    DRIVER_KEY TEAM_KEY JOINING_DATE LEAVING_DATEFALO FER 01-JAN-2010FMAS FER 01-JAN-2006 31-DEC-2013KRAI FER 01-JAN-2007 31-DEC-2009

    RBAR FER 01-JAN-2000 31-DEC-2007

    MSCH FER 01-JAN-1996 31-DEC-2006

    SELECT * FROM driverAS OF PERIOD FOR team_member_valid_time TO_DATE (20-JUN-2009);

    DRIVER_KEY TEAM_KEY JOINING_DATE LEAVING_DATEFMAS FER 01-JAN-2006 31-DEC-2013KRAI FER 01-JAN-2007 31-DEC-2009

    Who was in the team for the 2009 British Grand Prix qualifying?

  • 8/12/2019 Oracle12c.pptx

    53/87

    juliandyke.com53 2013 - Julian Dyke

    Temporal Validity Describe the driver table

    DESCRIBE driver

    Name Null? TypeDRIVER_KEY VARCHAR2(4)TEAM_KEY VARCHAR2(3)JOINING_DATE DATELEAVING_DATE DATE

  • 8/12/2019 Oracle12c.pptx

    54/87

    juliandyke.com54 2013 - Julian Dyke

    Temporal Validity List the columns in COL$

    SELECT c.name,c.col#,c.intcol#,c.segcol#,c.type#,TO_CHAR (c.property,'XXXXX')FROM sys.col$ c, sys.obj$ oWHERE c.obj# = o.obj#AND o.name = 'DRIVER3ORDER BY c.intcol#

    NAME COL# INTCOL# SEGCOL# TYPE# PROPERTYTEAM_MEMBER_VALID_TIME 0 1 0 2 10028DRIVER_KEY 1 2 1 1 0TEAM_KEY 2 3 2 1 0JOINING_DATE 3 4 3 12 0

    LEAVING_DATE 4 5 4 12 0

    0x10000 = Virtual Column

    0x20 = Hidden Column

    0x8 = Virtual Column

  • 8/12/2019 Oracle12c.pptx

    55/87

    juliandyke.com55 2013 - Julian Dyke

    Extended Columns

    This feature allows the size of VARCHAR2, NVARCHAR2 and RAWcolumns stored in the database to be increased to 32767 bytes. If thevalue is longer than 4000 bytes it is stored as an out of line LOB

    Built-in functions appear to work correctly with the longer column sizes

    This feature needs to be enabled by setting MAX_STRING_SIZE toEXTENDED. This parameter is not set by default. You may want to set thisparameter before creating a database, otherwise you will need an outage

    as the parameter must be set when the database is in UPGRADE mode

  • 8/12/2019 Oracle12c.pptx

    56/87

  • 8/12/2019 Oracle12c.pptx

    57/87

    juliandyke.com57 2013 - Julian Dyke

    Extended Columns By default attempts to create an extended column will fail:

    ALTER SYSTEM SET max_string_size = 'EXTENDED'

    *

    ERROR at line 1:

    ORA-02097: parameter cannot be modified because specified value isinvalid

    ORA-14694: database must in UPGRADE mode to beginMAX_STRING_SIZE migration

    MAX_STRING_SIZEparameter must be set to EXTENDED

    Default is value is STANDARD

    ALTER TABLE car MODIFY notes VARCHAR2(32767);*

    ERROR at line 1:

    ORA-00910: specified length too long for its datatype

    MAX_STRING_SIZEparameter cannot be updated when database is open:

  • 8/12/2019 Oracle12c.pptx

    58/87

    juliandyke.com58 2013 - Julian Dyke

    Extended Columns To change the MAX_STRING_SIZEparameter, restart the database in

    UPGRADE mode

    SQL> SHUTDOWN IMMEDIATE

    SQL> STARTUP MIGRATE

    Set the parameter value to EXTENDED:

    SQL> ALTER SYSTEM SET max_string_size = EXTENDED;

    Run the utl32k.sqlscript

    SQL> @$ORACLE_HOME/rdbms/admin/utl32k.sql;

    Restart the database

    SQL> SHUTDOWN IMMEDIATE

    SQL> STARTUP

    It is not possible to convert the MAX_STRING_SIZEparameter back fromEXTENDEDto STANDARD

  • 8/12/2019 Oracle12c.pptx

    59/87

  • 8/12/2019 Oracle12c.pptx

    60/87

    juliandyke.com60 2013 - Julian Dyke

    Extended Columns Extended columns are implemented as SECUREFILE LOBs

    SELECT column_name,segment_name,securefileFROM dba_lobsWHERE owner = 'GPAND table_name = 'ECAR';

    COLUMN_NAME SEGMENT_NAME SECUREFILE

    NOTES SYS_LOB0000092626C00007$$ YES

    SECUREFILE LOBs have a system-created index

    SELECT column_name,index_nameFROM dba_lobsWHERE owner = 'GPAND table_name = 'ECAR';

    COLUMN_NAME INDEX_NAME

    NOTES SYS_IL0000092626C00007$$

  • 8/12/2019 Oracle12c.pptx

    61/87

    juliandyke.com61 2013 - Julian Dyke

    Row Limiting Clause

    This feature provides a more comprehensive syntax for Top-N queries

    The new syntax uses analytic query operations as opposed to regularsort options

    It is probably worth doing comparative performance tests before adoptingthe new syntax

    Beware with the OFFSET clauseeach invocation will require a full sortof the data before returning any rows

  • 8/12/2019 Oracle12c.pptx

    62/87

    juliandyke.com62 2013 - Julian Dyke

    Row Limiting Clause In Oracle 12c and above SELECTstatements can include the FETCH FIRST

    clause

    Limits rows returned by query

    Optional replacement syntax for TOP-N queries

    [ OFFSET offset { ROW | ROWS } ]

    [ FETCH { FIRST | NEXT } [ { rowcount | percent PERCENT } ]{ ROW | ROWS } { ONLY | WITH TIES } ]

    Syntax is:

    OFFSETspecifies number of rows to skip before row limiting begins

    FETCHspecifies number of rows or percentage of rows to return ONLYreturn exactly the number of rows specified

    WITH TIES return additional rows with same sort key as last row fetched

  • 8/12/2019 Oracle12c.pptx

    63/87

    juliandyke.com63 2013 - Julian Dyke

    Row Limiting Clause An ORDER BY clause is normally required to ensure that sort order is

    deterministic

    Restrictions

    Cannot be specified in SELECT FOR UPDATE statements

    Cannot be used with CURRVAL or NEXTVAL pseudo-columns

    Cannot be used with materialized view incremental refresh

  • 8/12/2019 Oracle12c.pptx

    64/87

    juliandyke.com64 2013 - Julian Dyke

    Row Limiting Clause Exampletop ten drivers in 2012

    Driver Name Points

    Sebastian Vettel 281Fernando Alonso 278Kimi Raikkonen 207Lewis Hamilton 190Jenson Button 188

    Mark Webber 179Felipe Massa 122Romain Grosjean 96Nico Rosberg 93Sergio Perez 66

  • 8/12/2019 Oracle12c.pptx

    65/87

    juliandyke.com65 2013 - Julian Dyke

    Row Limiting Clause ExampleTop N query

    SELECT * FROM(

    SELECT d.driver_name,t.team_name,SUM(c.driver_points)FROM car c,driver d,team tWHERE c.season_key = 2012AND c.driver_key = d.driver_keyAND c.team_key = t.team_keyGROUP BY d.driver_name,t.team_nameORDER BY SUM(c.driver_points) DESC

    )WHERE ROWNUM

  • 8/12/2019 Oracle12c.pptx

    66/87

    juliandyke.com66 2013 - Julian Dyke

    Row Limiting Clause ExampleFetch Only Clause

    SELECT d.driver_name,t.team_name,SUM(c.driver_points)FROM car c,driver d,team tWHERE c.season_key = 2012AND c.driver_key = d.driver_keyAND c.team_key = t.team_keyGROUP BY d.driver_name,t.team_nameORDER BY SUM(c.driver_points) DESCFETCH FIRST 5 ROWS ONLY;

    -------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost ( CPU)|-------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 480 | 44640 | 41 (0)|| 1 | SORT ORDER BY | | 480 | 44640 | 41 (0)||* 2 | VIEW | | 480 | 44640 | 41 (0)||* 3 | WINDOW SORT PUSHED RANK| | 480 | 23520 | 41 (0)|| 4 | HASH GROUP BY | | 480 | 23520 | 41 (0)||* 5 | HASH JOIN | | 480 | 23520 | 41 (0)|| 6 | TABLE ACCESS FULL | TEAM | 104 | 1248 | 2 (0)||* 7 | HASH JOIN | | 480 | 17760 | 39 (0)||* 8 | TABLE ACCESS FULL | CAR | 480 | 8160 | 36 (0)|| 9 | TABLE ACCESS FULL | DRIVER | 493 | 9860 | 3 (0)|-------------------------------------------------------------------------

    Driver Name Points

    Sebastian Vettel 281Fernando Alonso 278Kimi Raikkonen 207Lewis Hamilton 190Jenson Button 188

  • 8/12/2019 Oracle12c.pptx

    67/87

    juliandyke.com67 2013 - Julian Dyke

    Row Limiting Clause ExampleFetch Percent With Ties Clause

    SELECT d.driver_name,t.team_name,SUM(c.driver_points)FROM car c,driver d,team tWHERE c.season_key = 2012AND c.driver_key = d.driver_keyAND c.team_key = t.team_keyGROUP BY d.driver_name,t.team_nameORDER BY SUM(c.driver_points) DESCFETCH FIRST 20 PERCENT ROWS WITH TIES;

    -----------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost ( CPU)|-----------------------------------------------------------------------| 0 | SELECT STATEMENT | | 480 | 50880 | 41 (0)|| 1 | SORT ORDER BY | | 480 | 50880 | 41 (0)||* 2 | VIEW | | 480 | 50880 | 41 (0)|| 3 | WINDOW SORT | | 480 | 23520 | 41 (0)|| 4 | HASH GROUP BY | | 480 | 23520 | 41 (0)||* 5 | HASH JOIN | | 480 | 23520 | 41 (0)|| 6 | TABLE ACCESS FULL | TEAM | 104 | 1248 | 2 (0)||* 7 | HASH JOIN | | 480 | 17760 | 39 (0)||* 8 | TABLE ACCESS FULL| CAR | 480 | 8160 | 36 (0)|| 9 | TABLE ACCESS FULL| DRIVER | 493 | 9860 | 3 (0)|-----------------------------------------------------------------------

    Driver Name Points

    Sebastian Vettel 281Fernando Alonso 278Kimi Raikkonen 207Lewis Hamilton 190Jenson Button 188

  • 8/12/2019 Oracle12c.pptx

    68/87

    juliandyke.com68 2013 - Julian Dyke

    Row Limiting Clause ExampleFetch with Offset Clause

    SELECT d.driver_name,t.team_name,SUM(c.driver_points)FROM car c,driver d,team tWHERE c.season_key = 2012AND c.driver_key = d.driver_keyAND c.team_key = t.team_keyGROUP BY d.driver_name,t.team_nameORDER BY SUM(c.driver_points) DESCOFFSET 5 ROWSFETCH FIRST 5 ROWS ONLY;

    -------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost ( CPU)|-------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 480 | 44640 | 41 (0)|| 1 | SORT ORDER BY | | 480 | 44640 | 41 (0)||* 2 | VIEW | | 480 | 44640 | 41 (0)||* 3 | WINDOW SORT PUSHED RANK| | 480 | 23520 | 41 (0)|| 4 | HASH GROUP BY | | 480 | 23520 | 41 (0)||* 5 | HASH JOIN | | 480 | 23520 | 41 (0)|| 6 | TABLE ACCESS FULL | TEAM | 104 | 1248 | 2 (0)||* 7 | HASH JOIN | | 480 | 17760 | 39 (0)||* 8 | TABLE ACCESS FULL | CAR | 480 | 8160 | 36 (0)|| 9 | TABLE ACCESS FULL | DRIVER | 493 | 9860 | 3 (0)|-------------------------------------------------------------------------

    Driver Name Points

    Mark Webber 179Felipe Massa 122Romain Grosjean 96Nico Rosberg 93Sergio Perez 66

  • 8/12/2019 Oracle12c.pptx

    69/87

    juliandyke.com69 2013 - Julian Dyke

    Histograms

    There are several enhancements to histograms in Oracle 12c. Thissection concentrates on the increase in maximum number of bucketsfrom 254 to 2048. Increasing the number of buckets allows bettercardinalities to be estimated by the optimization, potentially generatingmore efficient execution plans

    The increased bucket sizes work for both single column and multi columnstatistics

    This is particular useful with my Formula 1 database which (for the period1961 to 2012) contains 492 drivers and 1289 driver/team combinations.

  • 8/12/2019 Oracle12c.pptx

    70/87

    juliandyke.com70 2013 - Julian Dyke

    Histograms Maximum bucket size increased to 2048

    Default bucket size is still 256

    For example, an inefficient execution plan has been generated for a query

    We determine that the root cause is poor cardinality estimates for theDRIVER_KEYcolumn in the CAR table

    The DRIVER_KEYcolumn has 492 distinct values

    SELECT COUNT (DISTINCT (driver_key)) AS driver_key FROM car;

    DRIVER_KEY

    492

  • 8/12/2019 Oracle12c.pptx

    71/87

    juliandyke.com71 2013 - Julian Dyke

    Histograms Default statistics collection only gathers minimum and maximum values:

    dbms_stats.gather_table_stats(

    ownname => 'GP',tabname => 'CAR',estimate_percent => NULL

    );

    SELECT COUNT (*) FROM dba_histogramsWHERE owner = GP

    AND table_name = CARAND column_name = DRIVER_KEY;

    COUNT (*)2

    Hi

  • 8/12/2019 Oracle12c.pptx

    72/87

    juliandyke.com72 2013 - Julian Dyke

    Histograms Collect histograms on the DRIVER_KEYcolumn

    dbms_stats.gather_table_stats(

    ownname => 'GP',tabname => 'CAR',estimate_percent => NULLmethod_opt => 'FOR COLUMNS driver_key'

    );

    SELECT COUNT (*) FROM dba_histogramsWHERE owner = GP

    AND table_name = CARAND column_name = DRIVER_KEY;

    COUNT (*)75

    Default behaviour is to create a maximum of 256 buckets

    Hi t

  • 8/12/2019 Oracle12c.pptx

    73/87

    juliandyke.com73 2013 - Julian Dyke

    Histograms If more than 256 buckets are required, this must be specified explicitly:

    dbms_stats.gather_table_stats(

    ownname => 'GP',tabname => 'CAR',estimate_percent => NULLmethod_opt => 'FOR COLUMNS driver_key SIZE 2048'

    );

    SELECT COUNT (*) FROM dba_histogramsWHERE owner = GP

    AND table_name = CARAND column_name = DRIVER_KEY;

    COUNT (*)492

    Hi t

  • 8/12/2019 Oracle12c.pptx

    74/87

    juliandyke.com74 2013 - Julian Dyke

    Histograms Multi-Column Statistics

    DECLAREl_extension_name VARCHAR2(30);BEGIN

    l_extension_name := dbms_stats.create_extended_stats(

    ownname => 'GP',tabname => 'CAR6',

    extension => '(driver_key,team_key));

    END;

    BEGINdbms_stats.gather_table_stats(

    ownname => 'GP',tabname => 'CAR6',estimate_percent => NULL,method_opt => 'FOR COLUMNS (DRIVER_KEY,TEAM_KEY) SIZE 2048

    );END;

    Hi t

  • 8/12/2019 Oracle12c.pptx

    75/87

    juliandyke.com75 2013 - Julian Dyke

    Histograms Multi-Column Statistics

    DECLAREl_extension_name VARCHAR2(30);BEGIN

    l_extension_name := dbms_stats.create_extended_stats(

    ownname => 'GP',tabname => 'CAR6',

    extension => '(driver_key,team_key));

    END;

    BEGINdbms_stats.gather_table_stats(

    ownname => 'GP',tabname => 'CAR6',estimate_percent => NULL,method_opt => 'FOR COLUMNS (DRIVER_KEY,TEAM_KEY) SIZE 2048

    );END;

    Hi t

  • 8/12/2019 Oracle12c.pptx

    76/87

    juliandyke.com76 2013 - Julian Dyke

    Histograms Multi-Column Statistics

    7

    Id Operation Name Rows Bytes Cost (%CPU) Time

    0 SELECT STATEMENT 1 9 39 (0) 00:00:01

    1 SORT AGGREGATE 1 9

    2 TABLE ACCESS FULL CAR 181 1629 39 (0) 00:00:01

    SELECT COUNT(*) FROM gp.carWHERE driver_key = MSCH'AND team_key = 'FER';

    COUNT(*)181

    CorrectCardinality

    Hi t

  • 8/12/2019 Oracle12c.pptx

    77/87

    juliandyke.com77 2013 - Julian Dyke

    Histograms Multi-Column Statistics

    7

    Id Operation Name Rows Bytes Cost (%CPU) Time

    0 SELECT STATEMENT 1 9 39 (0) 00:00:01

    1 SORT AGGREGATE 1 9

    2 TABLE ACCESS FULL CAR 1 1629 39 (0) 00:00:01

    SELECT COUNT(*) FROM gp.carWHERE driver_key = MSCH'AND team_key = JOR';

    COUNT(*)1

    CorrectCardinality

  • 8/12/2019 Oracle12c.pptx

    78/87

    juliandyke.com78 2013 - Julian Dyke

    Application ContinuityThis is potentially a very important new feature which allowsuncommitted transactions to be replayed in another instance following aRAC or Data Guard failover or session relocation

    I anticipate many sites will wish to take advantage of this newfunctionality.

    Initially I have attempted to create a simple test example of thisfunctionality using a JDBC thin client application, but have so far beenunsuccessful.

    I know that Trivadis have successful created a demonstration of

    Application Continuity using the Universal Connection Pool (UCP) so itdoes work.

    Further investigation is required for the JDBC Thin example. In themeantime this session contains the configuration that I have completedso far.

    A li ti C ti it

  • 8/12/2019 Oracle12c.pptx

    79/87

    juliandyke.com79 2013 - Julian Dyke

    Application Continuity Failed transactions are replayed on another instance / database

    Similar goals to TAF and FCF

    Better implementation

    Can be configured for:

    RAC

    Data Guard

    Single Instance

    Must use one of:

    Weblogic pool

    Universal Connection Pool (UCP)

    JDBC Thin

    OCI not currently supported

    Limitations may drive future development decisions e.g. connections pools

    A li ti C ti it

  • 8/12/2019 Oracle12c.pptx

    80/87

    juliandyke.com80 2013 - Julian Dyke

    Application Continuity JDBC calls should handle events for the current session such as:

    Service shutdown

    Instance failure

    Network failure

    Node failure

    Session will attempt to reconnect again (same or different instance)

    Failed transactions will be rolled back and re-executed

    Similar (but not the same) as Database Replay

    Calls replayed with bind variables etc.

    Fewer synchronization issuesreplay only includes last uncommittedtransaction

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    81/87

    juliandyke.com81 2013 - Julian Dyke

    Application Continuity Must connect to a user-defined service

    Not the database service

    E.g. for single instance database

    DECLAREl_arr DBMS_SERVICE.SVC_PARAMETER_ARRAY;

    BEGINl_arr ('FAILOVER_TYPE') := 'TRANSACTION';l_arr ('REPLAY_INITIATION_TIMEOUT') := 600;

    l_arr ('FAILOVER_DELAY') := 3;l_arr ('FAILOVER_RETRIES') := 20;l_arr ('SESSION_STATE_CONSISTENCY') := 'DYNAMIC';l_arr ('COMMIT_OUTCOME') := 'TRUE';l_arr ('AQ_HA_NOTIFICATIONS') := 'TRUE';

    DBMS_SERVICE.CREATE_SERVICE

    (service_name => 'SERVICE1',network_name => 'SERVICE1,parameter_array => l_arr

    );END;

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    82/87

    juliandyke.com82 2013 - Julian Dyke

    Application Continuity E.g. for a RAC database

    srvctl add service -db TEST \-service SERVICE1 \-preferred TEST1 \-available TEST2 \-failovertype TRANSACTION \-notification TRUE \-commit_outcome TRUE \

    -replay_init_time 600 \-failoverretry 30 \-failoverdelay 10

    srvctl start serviced TESTs SERVICE1i TEST1

    Remember to start the service...

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    83/87

    juliandyke.com83 2013 - Julian Dyke

    Application Continuity Client connection string should include values for:

    TRANSPORT_CONNECT_TIMEOUT

    CONNECT_TIMEOUT

    RETRY_COUNT

    For example:

    jdbc:oracle:thin:gp/gp@(DESCRIPTION=(TRANSPORT_CONNECT_TIMEOUT=3)

    (CONNECT_TIMEOUT=60)(RETRY_COUNT=10)(FAILOVER=ON)(ADDRESS=(PROTOCOL=tcp)(PORT=1521)(HOST=vmcluster1-scan.juliandyke.com))(CONNECT_DATA=(SERVICE_NAME=SERVICE1)))

    REMOTE_LISTENERdatabase parameter must include

    SCAN name if clients specify SCAN names

    Node names if clients specify address list

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    84/87

    juliandyke.com84 2013 - Julian Dyke

    Application Continuity Configure the Oracle JDBC 12c Replay Data Source in the property file or in

    the thin JDBC application e.g.

    import oracle.jdbc.replay.OracleDataSourceImpl;import oracle.jdbc.replay.ReplayableConnection;

    OracleDataSourceImpl ods = new OracleDataSourceImpl();ods.setURL(url);

    connection = ods.getConnection();connection.setAutoCommit (false);

    ...

    ((ReplayableConnection)connection).beginRequest();

    # Application processing

    ((ReplayableConnection)connection).endRequest();

    Requires $ORACLE_HOME/jdbc/lib/ojdbc6.jaron CLASSPATH

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    85/87

    juliandyke.com85 2013 - Julian Dyke

    Application Continuity Debugging replayable connections

    Add $ORACLE_HOME/jdbc/lib/ojdbc6_g.jar to the CLASSPATH

    java -Djava.util.logging.config.file=/home/oracle/appcon/properties J7

    Execute using:

    Writes trace to replay_0.trc.0

    Add the following to the properties file

    oracle.jdbc.internal.replay.level = FINESThandlers = java.util.logging.FileHandler

    java.util.logging.FileHandler.pattern = /home/oracle/12c/appcon2/replay_%U.trcjava.util.logging.FileHandler.limit = 500000000java.util.logging.FileHandler.count = 1000java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter

    Application Continuity

  • 8/12/2019 Oracle12c.pptx

    86/87

    juliandyke.com86 2013 - Julian Dyke

    Application Continuity Potentially a very powerful feature

    Easier to implement, test and support than TAF

    Builds on FCF

    Applications need to be designed specifically for application continuity

    Very difficult to retrofit existing applications

    Special attention required for pseudo columns such as SYSDATE

    Sequences should use the new KEEP clause

    If you plan to use this feature in the future, I recommend

    DBAs become familiar with it in Oracle 12.1 so they can supportdevelopments

    New applications follow the development guidelines for this feature

    Expect to deploy the new applications in Oracle 12.2

    Thank You For Your Interest

  • 8/12/2019 Oracle12c.pptx

    87/87

    Thank You For Your Interest

    [email protected]