Your SlideShare is downloading. ×
0
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
Oracle12c by julian dyke
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

Oracle12c by julian dyke

281

Published on

Oracle12c by julian dyke

Oracle12c by julian dyke

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
281
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
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

Transcript

  1. juliandyke.com1 © 2013 - Julian Dyke Web Version Oracle 12c New Features
  2. juliandyke.com2 © 2013 - Julian Dyke Agenda u  Introduction u  Pluggable Database u  Partial Indexes u  Online Data File Move u  Online Partition Move u  Index Columns u  Invisible Columns u  Identity Clause u  Session Sequences u  Global Temporary Table Undo u  Temporal Validity u  Extended Columns u  Row Limiting Clause u  Histograms u  Application Continuity
  3. juliandyke.com3 © 2013 - Julian Dyke Introduction This presentation investigates a selection of Oracle 12c new features that I believe will be interesting to DBAs The presentation was originally delivered at the UKOUG Conference 2013 in Manchester, England I have added section headers containing comments and feedback from delegates
  4. juliandyke.com4 © 2013 - Julian Dyke What History Tells Us.... u  Oracle 9i , 10g and 11g u  R1 releases have been available for 18-24 months u  R2 releases have been available for several years u  R2 releases include terminal release u  Support has often been extended for terminal release u  CPU and PSU support is limited for R1 releases u  Longer and more comprehensive for R2 releases u  It is occasionally necessary to upgrade to a terminal release in order to migrate to new functionality u  In past releases there have been compatibility issues between new features u  Occasionally bugs.... u  Sometimes new features are documented but not released
  5. juliandyke.com5 © 2013 - Julian Dyke New Features u  Oracle Marketing concentrates on a limited subset of new features u  Particularly new licensing options u  Product Managers and Pre Sales are usually a better source of information u  New features are often overlooked by everyone: u  Particularly additional features in Standard/Enterprise Editions u  Too many in each release to investigate them all u  Documentation and support is often limited at initial release
  6. juliandyke.com6 © 2013 - Julian Dyke Pluggable Database Other presenters will have discussed pluggable databases in more detail The concept was announced in September 2012 and I now believe it is time to consider how and where it is appropriate to deploy pluggable databases My example of a possible deployment was a container database with a large number of pluggable databases replacing SYBASE. I know that SYBASE replacement has been a goal at a few of the larger banks for many years. Something I missed is that pluggable databases can be cloned allowing test databases to be created rapidly from production databases. I have not investigated this feature yet, so have limited my comments to technical questions I would still like to answer
  7. juliandyke.com7 © 2013 - Julian Dyke Pluggable Database u  Definitely the most attractive marketing feature u  Easy to explain u  Impresses managers and technical staff u  Obvious benefits u  May be more efficient than virtualization for large numbers of similar databases u  For example migrations from SYBASE u  Potential reduction in resource consumption including: u  CPU u  memory u  background processes u  management costs
  8. juliandyke.com8 © 2013 - Julian Dyke Pluggable Database u  Reduction in CPU might reduce processor license requirements u  Separately licensed as Oracle Multi Tenant option u  US list price is $17,500 per processor (EE is $47,500) u  All options will need to be licenced for all pluggable databases u  Possibly irrespective of usage e.g. u  Partitioning, Advanced Compression, Advanced Security
  9. juliandyke.com9 © 2013 - Julian Dyke Pluggable Database u  Only one redo thread per container instance u  Online redo logs may be a bottleneck u  Data Guard u  Single configuration for container database u  Pluggable databases share redo thread u  May become difficult to manage if standby databases need to be rebuilt u  Single large SGA may increase size of kernel page tables area for each process (foreground / background or both) u  Will offset some of the savings in background process memory u  New In-Memory database may have same problem u  Pluggable databases may contend for resources u  e.g. RAC background processes
  10. juliandyke.com10 © 2013 - Julian Dyke Partial Indexes I believe this is one of the best features in Oracle 12c for sites using the Partitioning Option Most sites partition their tables based on time e.g. year, month, week, day etc. Most activity centres around the latest (hot) partitions where indexes are often required to optimize access paths. However, the cost of creating an index for the entire table often prevents creation of appropriate indexes as, in current versions, the index needs to be created for all partitions, requiring additional storage and increasing backup and restore times. Partial indexes will not reduce redo generation, but could significantly reduce 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 great feature
  11. juliandyke.com11 © 2013 - Julian Dyke Partial Indexes u  One of the most important new features in Oracle 12.1 u  Allows additional indexes to be created for performance tuning u  Potentially reduces amount of storage required for indexes u  May reduce backup and restore times u  Will probably not reduce redo / archive generation u  Functionality is limited u  For a specific table, only one set of table partitions can be enabled for index partitions
  12. juliandyke.com12 © 2013 - Julian Dyke Partial Indexes u  Useful for range-based partitioned tables u  Create partial indexes on most recent (hot) partitions u  Alternatively create partial indexes on older (archived) partitions u  However cannot create partial indexes on both u  Partial indexing must specified on table partitions u  INDEXING ON – partial indexes enabled u  INDEXING OFF – partial indexes disabled u  If a table partition has INDEXING ON then all rows in that partition will be indexed in each partial index
  13. juliandyke.com13 © 2013 - Julian Dyke Partial Indexes u  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 );
  14. juliandyke.com14 © 2013 - Julian Dyke Partial Indexes u  Partial Local and Global Indexes SELECT season_key, COUNT(*) FROM pcar GROUP BY season_key ORDER BY season_key; SEASON_KEY COUNT(*) 2008 368 2009 338 2010 456 2011 456 2012 480
  15. juliandyke.com15 © 2013 - Julian Dyke Partial Indexes u  Example - Partial Local Index CREATE INDEX pcar1 ON pcar (driver_key) LOCAL INDEXING PARTIAL; dbms_stats.gather_index_stats ( ownname => 'GP', indname => 'PCAR1', estimate_percent => NULL ); SELECT partition_name,num_rows FROM dba_ind_partitions WHERE index_name = 'PCAR1'; PARTITION_NAME NUM_ROWS P2008 0 P2009 0 P2010 0 P2011 456 P2012 480
  16. juliandyke.com16 © 2013 - Julian Dyke Partial Indexes u  Example - Partial Global Index CREATE INDEX pcar2 ON pcar (team_key) GLOBAL INDEXING PARTIAL; dbms_stats.gather_index_stats ( ownname => 'GP', indname => 'PCAR2', estimate_percent => NULL ); SELECT num_rows FROM dba_indexes WHERE index_name = 'PCAR2'; NUM_ROWS 936
  17. juliandyke.com17 © 2013 - Julian Dyke Partial Indexes u  Execution Plans - Partial Local Index CREATE INDEX pcar3 ON pcar (season_key,race_key,position) LOCAL INDEXING PARTIAL; SELECT COUNT(*) FROM pcar WHERE season_key = '2010'; -- Unindexed 0 SELECT STATEMENT 1 SORT AGGREGATE 2 PARTITION RANGE SINGLE 3 TABLE ACCESS FULL (PCAR) Predicate Information (identified by operation id): 3 - filter("SEASON_KEY"=2010) u  Cost = 14
  18. juliandyke.com18 © 2013 - Julian Dyke Partial Indexes u  Execution Plans - Partial Local Index CREATE INDEX pcar3 ON pcar (season_key,race_key,position) LOCAL INDEXING PARTIAL; SELECT COUNT(*) FROM pcar WHERE season_key = '2011'; -- Indexed 0 SELECT STATEMENT 1 SORT AGGREGATE 2 PARTITION RANGE SINGLE 3 INDEX FAST FULL SCAN (PCAR3) Predicate Information (identified by operation id): 3 - filter("SEASON_KEY"=2011) u  Cost = 2
  19. juliandyke.com19 © 2013 - Julian Dyke Partial Indexes u  Execution Plans - Partial Local Index SELECT COUNT(*) FROM pcar WHERE season_key IN ('2010','2011'); -- Combined 0 SELECT STATEMENT 1 SORT AGGREGATE 2 PARTITION RANGE INLIST 3 TABLE ACCESS FULL (PCAR) Predicate Information (identified by operation id): 3 - filter("SEASON_KEY"=2010 OR "SEASON_KEY"=2011) u  Cost = 27 CREATE INDEX pcar3 ON pcar (season_key,race_key,position) LOCAL INDEXING PARTIAL;
  20. juliandyke.com20 © 2013 - Julian Dyke Online Data File Move This is a great new feature which I have already been using to resolve space issues in my own virtual machines I have successfully used this to move the data file containing the SYSAUX tablespace – not sure I would want to risk it with the SYS tablespace
  21. juliandyke.com21 © 2013 - Julian Dyke Online Data File Move u  In Oracle 12.1 and above any data file can be moved online u  For example: ALTER DATABASE MOVE DATAFILE '/u01/app/oradata/PROD/users01.dbf‘ TO '/u02/app/oradata/PROD/users01.dbf'; u  The database can be open and accessing the data file while the move is in progress u  Data files can be moved online: u  from file system to file system u  from file system to ASM u  from ASM to file system u  from ASM to ASM
  22. juliandyke.com22 © 2013 - Julian Dyke Online Partition Move This feature could be very useful for sites with partitioned tables on tiered storage. 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 this partition move can fail, and the DBMS_PART package contains some subroutines that allow recovery from failures.
  23. juliandyke.com23 © 2013 - Julian Dyke Online Partition Move u  In Oracle 12c partitions can be moved online u  Useful for tiered storage u  Move from SSD to SAS to SATA u  May be useful with OLTP compression u  Also works for sub-partitions u  Not supported in the following cases: u  For tables owned by SYS u  For IOTs u  For heap tables containing object types u  For heap tables containing bitmap join indexes or domain indexes u  If database-supplemental logging is enabled u  When parallel DML or direct path INSERTs are executing on the table
  24. juliandyke.com24 © 2013 - Julian Dyke Online Partition Move u  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;
  25. juliandyke.com25 © 2013 - Julian Dyke Online Partition Move u  If online partition move operation fails, it can be cleaned up manually using: u  DBMS_PART.CLEANUP_ONLINE_OP DBMS_PART.CLEANUP_ONLINE_OP (<schema>,<table>,<partition>); u  Clean up failed operations on <partition> u  Clean up failed operations on <table> DBMS_PART.CLEANUP_ONLINE_OP (<schema>,<table>); u  Clean up failed operations on <schema> DBMS_PART.CLEANUP_ONLINE_OP (<schema>); u  Clean up all failed operations in database DBMS_PART.CLEANUP_ONLINE_OP;
  26. juliandyke.com26 © 2013 - Julian Dyke Index Columns This is a useful new feature that allows multiple indexes to be created with 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 invisibly and then made visible at an appropriate time.
  27. juliandyke.com27 © 2013 - Julian Dyke Index Columns u  Multiple indexes can be created on the same set of columns u  The following conditions must be met: u  The indexes must have different properties e.g. type, partitioning, uniqueness u  Only one of the indexes can be VISIBLE at any given time Recommendation: Check existing databases for indexes that have been made invisible and then forgotten.
  28. juliandyke.com28 © 2013 - Julian Dyke Index Columns u  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);
  29. juliandyke.com29 © 2013 - Julian Dyke Index Columns u  We realise the index should be local so we can drop partitions efficiently u  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 u  Create the new index INVISIBLE CREATE INDEX pcar_local ON pcar (season_key,race_key,position) LOCAL INVISIBLE; Index created * ALTER INDEX pcar_global INVISIBLE; ALTER INDEX pcar_local VISIBLE; u  Switch the indexes u  The new index (PCAR_LOCAL) is now visible u  The old index (PCAR_GLOBAL) can be dropped
  30. juliandyke.com30 © 2013 - Julian Dyke Invisible Columns I strongly believe this is a very dangerous feature. Whilst it achieves its objectives, it is open to both accidental and malicious misuse as shown in the example. Misuse of this feature could introduce data corruptions that may go unnoticed for months or years and prove to be extremely difficult to resolve
  31. juliandyke.com31 © 2013 - Julian Dyke Invisible Columns u  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 NUMBER RACE_KEY NUMBER DRIVER_KEY VARCHAR2(4) TEAM_KEY VARCHAR2(3) POSITION NUMBER LAPS_COMPLETED NUMBER RACE_POINTS NUMBER
  32. juliandyke.com32 © 2013 - Julian Dyke Invisible Columns u  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$ u WHERE 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 0 RACE_KEY 2 2 2 2 0 DRIVER_KEY 1 3 3 3 0 TEAM_KEY 1 4 4 4 0 POSITION 2 5 5 5 0 LAPS_COMPLETED 2 6 6 6 0 RACE_POINTS 2 7 7 7 0
  33. juliandyke.com33 © 2013 - Julian Dyke Invisible Columns u  Make the LAPS_COMPLETED column invisible: ALTER TABLE icar MODIFY laps_completed INVISIBLE; DESCRIBE icar Name Null? Type SEASON_KEY NUMBER RACE_KEY NUMBER DRIVER_KEY VARCHAR2(4) TEAM_KEY VARCHAR2(3) POSITION NUMBER RACE_POINTS NUMBER u  Describe the table again u  The LAPS_COMPLETED column is now invisible
  34. juliandyke.com34 © 2013 - Julian Dyke Invisible Columns u  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$ u WHERE 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 0 RACE_KEY 2 2 2 2 0 DRIVER_KEY 1 3 3 3 0 TEAM_KEY 1 4 4 4 0 POSITION 2 5 5 5 0 LAPS_COMPLETED 2 0 6 6 400000020 RACE_POINTS 2 6 7 7 0 u  0x400000000 = Invisible Column? 0x20 = Hidden Column
  35. juliandyke.com35 © 2013 - Julian Dyke Invisible Columns u  Make the LAPS_COMPLETED column visible again: ALTER TABLE icar MODIFY laps_completed VISIBLE; DESCRIBE icar Name Null? Type SEASON_KEY NUMBER RACE_KEY NUMBER DRIVER_KEY VARCHAR2(4) TEAM_KEY VARCHAR2(3) POSITION NUMBER RACE_POINTS NUMBER LAPS_COMPLETED NUMBER u  The LAPS_COMPLETED column now appears at end of table u  Describe the table again:
  36. juliandyke.com36 © 2013 - Julian Dyke Invisible Columns u  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$ u WHERE 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 0 RACE_KEY 2 2 2 2 0 DRIVER_KEY 1 3 3 3 0 TEAM_KEY 1 4 4 4 0 POSITION 2 5 5 5 0 LAPS_COMPLETED 2 7 6 6 0 RACE_POINTS 2 6 7 7 0 u  LAPS_COMPLETED is now COL# 7
  37. juliandyke.com37 © 2013 - Julian Dyke Invisible Columns u  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 POSITIONLAPS_COMPLETEDRACE_POINTS 2013 1 KRAI LOT 158 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 POSITIONRACE_POINTSLAPS_COMPLETED 2013 1 KRAI LOT 125 58 2013 1 FALO FER 258 18 INSERT INTO icar VALUES (2013,1,'FALO','FER',2,58,18); SELECT * FROM icar;
  38. juliandyke.com38 © 2013 - Julian Dyke Invisible Columns u  Continued... ALTER TABLE icar MODIFY race_points INVISIBLE; ALTER TABLE icar MODIFY race_points VISIBLE; SEASON_KEY RACE_KEY DRIVER_KEY TEAM_KEY POSITIONLAPS_COMPLETEDRACE_POINTS 2013 1 KRAI LOT 158 25 2013 1 FALO FER 218 58 2013 1 SVET RBR 358 15 INSERT INTO icar VALUES (2013,1,‘SVET',‘RBR',3,58,15); SELECT * FROM icar; u  Column order is restored, but Fernando Alonso now has 58 points
  39. juliandyke.com39 © 2013 - Julian Dyke Identity Clause This new feature simplifies management of sequences used as primary keys 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 and recreated and will restart at the minimum value for the next insertion
  40. juliandyke.com40 © 2013 - Julian Dyke Identity Clause u  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 ) ] u  Syntax is: u  where <identity_options> are: { START WITH ( integer | LIMIT VALUE ) | INCREMENT BY integer | ( MAXVALUE integer | NOMAXVALUE ) | ( MINVALUE integer | NOMINVALUE ) | ( CYCLE | NOCYCLE ) | ( CACHE integer | NOCACHE ) | ( ORDER | NOORDER ) } . . .
  41. juliandyke.com41 © 2013 - Julian Dyke Identity Clause u  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_KEY 1 Sebastian Vettel 03-JUL-1987 GER 2 Fernando Alonso29-JUL-1981 SPA 3 Kimi Raikkonen 17-OCT-1979 FIN
  42. juliandyke.com42 © 2013 - Julian Dyke Identity Clause u  DESCRIBE includes identity column DESCRIBE driver2 Name Null? Type DRIVER_KEY NOT NULL NUMBER DRIVER_NAME VARCHAR2(30) DRIVER_DOB DATE COUNTRY_KEY VARCHAR2(3) u  No additional indexes are created
  43. juliandyke.com43 © 2013 - Julian Dyke Identity Clause u  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$ u WHERE c.obj# = o.obj# AND o.owner# = u.user# AND u.name = 'GP‘ AND o.name = 'DRIVER2‘ ORDER BY intcol#; NAME TYPE# COL# INTCOL# SEGCOL# PROPERTY DRIVER_KEY 2 1 1 1 2800000000 DRIVER_NAME 1 2 2 2 0 DRIVER_DOB 12 3 3 3 0 COUNTRY_KEY 1 4 4 4 0 u  0x800000000 = Default as Sequence u  0x2000000000 = Generated ALWAYS identity column
  44. juliandyke.com44 © 2013 - Julian Dyke Identity Clause u  Default value for DRIVER_KEY column can be found in DBA_TAB_COLUMNS: SELECT data_default FROM dba_tab_columns WHERE owner = 'GP‘ AND table_name = 'DRIVER2‘ AND column_name = 'DRIVER_KEY'; "GP"."ISEQ$$_92584".nextval SELECT sequence_owner AS owner,min_value,max_value,increment_by, cycle_flag,order_flag,cache_size FROM dba_sequences WHERE sequence_name = 'ISEQ$$_92584'; OWNER MIN_VALUE MAX_VALUEINCREMENT_BY C OCACHE_SIZE GP 1 1.0000E+28 1 N N 20 u  In this example 92584 is the object ID of the GP.DRIVER2 table
  45. juliandyke.com45 © 2013 - Julian Dyke Session Sequences This new feature allows sequences to be created that exist for the lifetime of the current session only. Intended for use with global temporary tables, but possibly useful in other places and more flexible than the ROWNUM pseudo column
  46. juliandyke.com46 © 2013 - Julian Dyke Session Sequences u  In Oracle 12.1 and above sequences can have session visibility u  Current value only visible to session u  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 2 SQL> CONNECT gp/gp SQL> SELECT seq1.NEXTVAL FROM dual; NEXTVAL 1
  47. juliandyke.com47 © 2013 - Julian Dyke Global Temporary Table Undo This new feature allows undo for global temporary tables to be written to the temporary table space It will not have much impact for insertions, but could have a significant impact on redo generation caused by GTT undo during updates I envisage this becoming the default in future versions
  48. juliandyke.com48 © 2013 - Julian Dyke Global Temporary Table Undo u  By default DML on Global Temporary Tables u  Does not generate redo directly u  Does generate undo and indirect redo u  Undo is required to rollback transactions u  Redo will be archived, backed up , propagated to standby etc u  In Oracle 12c Global Temporary Table undo can be stored in a temporary tablespace u  Set TEMP_UNDO_ENABLED = TRUE u  Will not have much impact for INSERT statements u  May have significant impact for UPDATE and DELETE statements u  Review whether DELETE statements are necessary
  49. juliandyke.com49 © 2013 - Julian Dyke Temporal Validity Temporal validity allows tables to be created where rows are valid for a specific period of time A major defect is that is not possible to create primary keys with temporal validity. This functionality may be added in a future release, until which time this feature may be of limited use.
  50. juliandyke.com50 © 2013 - Julian Dyke Temporal Validity u  Flashback Data Archive was introduced in Oracle 11.1 u  Originally known as Total Recall u  Allows historic data to be inspected at any point in time u  Was a separately licensed option u  Consequently not very popular u  Now available free in Enterprise Edition (at least) u  Including Oracle 11.2 u  In Oracle 12.1 and above Temporal Validity builds on these concepts
  51. juliandyke.com51 © 2013 - Julian Dyke Temporal Validity u  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'); u  Insert some data u  Note: the above data is inaccurate
  52. juliandyke.com52 © 2013 - Julian Dyke Temporal Validity u  For example: SELECT * FROM driver; DRIVER_KEY TEAM_KEY JOINING_DATE LEAVING_DATE FALO FER 01-JAN-2010 FMAS FER 01-JAN-2006 31-DEC-2013 KRAI 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 driver AS OF PERIOD FOR team_member_valid_time TO_DATE (‘20-JUN-2009’); DRIVER_KEY TEAM_KEY JOINING_DATE LEAVING_DATE FMAS FER 01-JAN-2006 31-DEC-2013 KRAI FER 01-JAN-2007 31-DEC-2009 u  Who was in the team for the 2009 British Grand Prix qualifying?
  53. juliandyke.com53 © 2013 - Julian Dyke Temporal Validity u  Describe the driver table DESCRIBE driver Name Null? Type DRIVER_KEY VARCHAR2(4) TEAM_KEY VARCHAR2(3) JOINING_DATE DATE LEAVING_DATE DATE
  54. juliandyke.com54 © 2013 - Julian Dyke Temporal Validity u  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$ o WHERE c.obj# = o.obj# AND o.name = 'DRIVER3‘ ORDER BY c.intcol# NAME COL# INTCOL# SEGCOL# TYPE# PROPERTY TEAM_MEMBER_VALID_TIME 0 1 0 2 10028 DRIVER_KEY 1 2 1 1 0 TEAM_KEY 2 3 2 1 0 JOINING_DATE 3 4 3 12 0 LEAVING_DATE 4 5 4 12 0 u  0x10000 = Virtual Column u  0x20 = Hidden Column u  0x8 = Virtual Column
  55. juliandyke.com55 © 2013 - Julian Dyke Extended Columns This feature allows the size of VARCHAR2, NVARCHAR2 and RAW columns stored in the database to be increased to 32767 bytes. If the value 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 to EXTENDED. This parameter is not set by default. You may want to set this parameter before creating a database, otherwise you will need an outage as the parameter must be set when the database is in UPGRADE mode
  56. juliandyke.com56 © 2013 - Julian Dyke Extended Columns u  In Oracle 12c and above maximum column length has increased Data Type Oracle 11.2 and below Oracle 12.1 and above VARCHAR2 4000 32767 NVARCHAR2 2000 16383 RAW 2000 32767 u  Note that NVARCHAR2 limits assume two bytes per character u  Maximum length of CHAR and NCHAR remains at 2000 and 1000 respectively u  Extended columns are stored as SECUREFILE LOBs u  Stored in line if <= 4K u  Stored out of line if > 4K u  COMPATIBLE parameter must be 12.0.0.0.0 or above
  57. juliandyke.com57 © 2013 - Julian Dyke Extended Columns u  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 is invalid ORA-14694: database must in UPGRADE mode to begin MAX_STRING_SIZE migration u  MAX_STRING_SIZE parameter must be set to EXTENDED u  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 u  MAX_STRING_SIZE parameter cannot be updated when database is open:
  58. juliandyke.com58 © 2013 - Julian Dyke Extended Columns u  To change the MAX_STRING_SIZE parameter, restart the database in UPGRADE mode SQL> SHUTDOWN IMMEDIATE SQL> STARTUP MIGRATE u  Set the parameter value to EXTENDED: SQL> ALTER SYSTEM SET max_string_size = EXTENDED; u  Run the utl32k.sql script SQL> @$ORACLE_HOME/rdbms/admin/utl32k.sql; u  Restart the database SQL> SHUTDOWN IMMEDIATE SQL> STARTUP u  It is not possible to convert the MAX_STRING_SIZE parameter back from EXTENDED to STANDARD
  59. juliandyke.com59 © 2013 - Julian Dyke Extended Columns u  When MAX_STRING_SIZE is set to EXTENDED then tables can be created with extended columns: CREATE TABLE ecar ( season_key NUMBER, race_key NUMBER, driver_key VARCHAR2(4), team_key VARCHAR2(3), position NUMBER, laps_completed NUMBER, notes VARCHAR2(32767), race_points NUMBER ); u  Alternatively maximum size of columns in existing tables can be increased: ALTER TABLE car MODIFY notes VARCHAR2(32767);
  60. juliandyke.com60 © 2013 - Julian Dyke Extended Columns u  Extended columns are implemented as SECUREFILE LOBs SELECT column_name,segment_name,securefile FROM dba_lobs WHERE owner = 'GP‘ AND table_name = 'ECAR'; COLUMN_NAME SEGMENT_NAME SECUREFILE NOTES SYS_LOB0000092626C00007$$ YES u  SECUREFILE LOBs have a system-created index SELECT column_name,index_name FROM dba_lobs WHERE owner = 'GP‘ AND table_name = 'ECAR'; COLUMN_NAME INDEX_NAME NOTES SYS_IL0000092626C00007$$
  61. 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 regular sort options It is probably worth doing comparative performance tests before adopting the new syntax Beware with the OFFSET clause – each invocation will require a full sort of the data before returning any rows
  62. juliandyke.com62 © 2013 - Julian Dyke Row Limiting Clause u  In Oracle 12c and above SELECT statements can include the FETCH FIRST clause u  Limits rows returned by query u  Optional replacement syntax for TOP-N queries [ OFFSET offset { ROW | ROWS } ] [ FETCH { FIRST | NEXT } [ { rowcount | percent PERCENT } ] { ROW | ROWS } { ONLY | WITH TIES } ] u  Syntax is: u  OFFSET specifies number of rows to skip before row limiting begins u  FETCH specifies number of rows or percentage of rows to return u  ONLY return exactly the number of rows specified u  WITH TIES return additional rows with same sort key as last row fetched
  63. juliandyke.com63 © 2013 - Julian Dyke Row Limiting Clause u  An ORDER BY clause is normally required to ensure that sort order is deterministic u  Restrictions u  Cannot be specified in SELECT FOR UPDATE statements u  Cannot be used with CURRVAL or NEXTVAL pseudo-columns u  Cannot be used with materialized view incremental refresh
  64. juliandyke.com64 © 2013 - Julian Dyke Row Limiting Clause u  Example – top ten drivers in 2012 Driver Name Points Sebastian Vettel 281 Fernando Alonso 278 Kimi Raikkonen 207 Lewis Hamilton 190 Jenson Button 188 Mark Webber 179 Felipe Massa 122 Romain Grosjean 96 Nico Rosberg 93 Sergio Perez 66
  65. juliandyke.com65 © 2013 - Julian Dyke Row Limiting Clause u  Example – Top N query SELECT * FROM ( SELECT d.driver_name,t.team_name,SUM(c.driver_points) FROM car c,driver d,team t WHERE c.season_key = 2012 AND c.driver_key = d.driver_key AND c.team_key = t.team_key GROUP BY d.driver_name,t.team_name ORDER BY SUM(c.driver_points) DESC ) WHERE ROWNUM <= 5; ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 5 | 335 | 41 (0)| |* 1 | COUNT STOPKEY | | | | | | 2 | VIEW | | 480 | 32160 | 41 (0)| |* 3 | SORT ORDER BY STOPKEY| | 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 281 Fernando Alonso 278 Kimi Raikkonen 207 Lewis Hamilton 190 Jenson Button 188
  66. juliandyke.com66 © 2013 - Julian Dyke Row Limiting Clause u  Example – Fetch Only Clause SELECT d.driver_name,t.team_name,SUM(c.driver_points) FROM car c,driver d,team t WHERE c.season_key = 2012 AND c.driver_key = d.driver_key AND c.team_key = t.team_key GROUP BY d.driver_name,t.team_name ORDER BY SUM(c.driver_points) DESC FETCH 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 281 Fernando Alonso 278 Kimi Raikkonen 207 Lewis Hamilton 190 Jenson Button 188
  67. juliandyke.com67 © 2013 - Julian Dyke Row Limiting Clause u  Example – Fetch Percent With Ties Clause SELECT d.driver_name,t.team_name,SUM(c.driver_points) FROM car c,driver d,team t WHERE c.season_key = 2012 AND c.driver_key = d.driver_key AND c.team_key = t.team_key GROUP BY d.driver_name,t.team_name ORDER BY SUM(c.driver_points) DESC FETCH 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 281 Fernando Alonso 278 Kimi Raikkonen 207 Lewis Hamilton 190 Jenson Button 188
  68. juliandyke.com68 © 2013 - Julian Dyke Row Limiting Clause u  Example – Fetch with Offset Clause SELECT d.driver_name,t.team_name,SUM(c.driver_points) FROM car c,driver d,team t WHERE c.season_key = 2012 AND c.driver_key = d.driver_key AND c.team_key = t.team_key GROUP BY d.driver_name,t.team_name ORDER BY SUM(c.driver_points) DESC OFFSET 5 ROWS FETCH 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 179 Felipe Massa 122 Romain Grosjean 96 Nico Rosberg 93 Sergio Perez 66
  69. juliandyke.com69 © 2013 - Julian Dyke Histograms There are several enhancements to histograms in Oracle 12c. This section concentrates on the increase in maximum number of buckets from 254 to 2048. Increasing the number of buckets allows better cardinalities to be estimated by the optimization, potentially generating more efficient execution plans The increased bucket sizes work for both single column and multi column statistics This is particular useful with my Formula 1 database which (for the period 1961 to 2012) contains 492 drivers and 1289 driver/team combinations.
  70. juliandyke.com70 © 2013 - Julian Dyke Histograms u  Maximum bucket size increased to 2048 u  Default bucket size is still 256 u  For example, an inefficient execution plan has been generated for a query u  We determine that the root cause is poor cardinality estimates for the DRIVER_KEY column in the CAR table u  The DRIVER_KEY column has 492 distinct values SELECT COUNT (DISTINCT (driver_key)) AS driver_key FROM car; DRIVER_KEY 492
  71. juliandyke.com71 © 2013 - Julian Dyke Histograms u  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_histograms WHERE owner = ‘GP’ AND table_name = ‘CAR’ AND column_name = ‘DRIVER_KEY’; COUNT (*) 2
  72. juliandyke.com72 © 2013 - Julian Dyke Histograms u  Collect histograms on the DRIVER_KEY column dbms_stats.gather_table_stats ( ownname => 'GP', tabname => 'CAR', estimate_percent => NULL method_opt => 'FOR COLUMNS driver_key' ); SELECT COUNT (*) FROM dba_histograms WHERE owner = ‘GP’ AND table_name = ‘CAR’ AND column_name = ‘DRIVER_KEY’; COUNT (*) 75 u  Default behaviour is to create a maximum of 256 buckets
  73. juliandyke.com73 © 2013 - Julian Dyke Histograms u  If more than 256 buckets are required, this must be specified explicitly: dbms_stats.gather_table_stats ( ownname => 'GP', tabname => 'CAR', estimate_percent => NULL method_opt => 'FOR COLUMNS driver_key SIZE 2048' ); SELECT COUNT (*) FROM dba_histograms WHERE owner = ‘GP’ AND table_name = ‘CAR’ AND column_name = ‘DRIVER_KEY’; COUNT (*) 492
  74. juliandyke.com74 © 2013 - Julian Dyke Histograms u  Multi-Column Statistics DECLARE l_extension_name VARCHAR2(30); BEGIN l_extension_name := dbms_stats.create_extended_stats ( ownname => 'GP', tabname => 'CAR6', extension => '(driver_key,team_key)‘ ); END; BEGIN dbms_stats.gather_table_stats ( ownname => 'GP', tabname => 'CAR6', estimate_percent => NULL, method_opt => 'FOR COLUMNS (DRIVER_KEY,TEAM_KEY) SIZE 2048‘ ); END;
  75. juliandyke.com75 © 2013 - Julian Dyke Histograms u  Multi-Column Statistics DECLARE l_extension_name VARCHAR2(30); BEGIN l_extension_name := dbms_stats.create_extended_stats ( ownname => 'GP', tabname => 'CAR6', extension => '(driver_key,team_key)‘ ); END; BEGIN dbms_stats.gather_table_stats ( ownname => 'GP', tabname => 'CAR6', estimate_percent => NULL, method_opt => 'FOR COLUMNS (DRIVER_KEY,TEAM_KEY) SIZE 2048‘ ); END;
  76. juliandyke.com76 © 2013 - Julian Dyke Histograms u  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.car WHERE driver_key = ‘MSCH' AND team_key = 'FER'; COUNT(*) 181 Correct Cardinality
  77. juliandyke.com77 © 2013 - Julian Dyke Histograms u  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.car WHERE driver_key = ‘MSCH' AND team_key = ‘JOR'; COUNT(*) 1 Correct Cardinality
  78. juliandyke.com78 © 2013 - Julian Dyke Application Continuity This is potentially a very important new feature which allows uncommitted transactions to be replayed in another instance following a RAC or Data Guard failover or session relocation I anticipate many sites will wish to take advantage of this new functionality. Initially I have attempted to create a simple test example of this functionality using a JDBC thin client application, but have so far been unsuccessful. I know that Trivadis have successful created a demonstration of Application Continuity using the Universal Connection Pool (UCP) so it does work. Further investigation is required for the JDBC Thin example. In the meantime this session contains the configuration that I have completed so far.
  79. juliandyke.com79 © 2013 - Julian Dyke Application Continuity u  Failed transactions are replayed on another instance / database u  Similar goals to TAF and FCF u  Better implementation u  Can be configured for: u  RAC u  Data Guard u  Single Instance u  Must use one of: u  Weblogic pool u  Universal Connection Pool (UCP) u  JDBC Thin u  OCI not currently supported u  Limitations may drive future development decisions e.g. connections pools
  80. juliandyke.com80 © 2013 - Julian Dyke Application Continuity u  JDBC calls should handle events for the current session such as: u  Service shutdown u  Instance failure u  Network failure u  Node failure u  Session will attempt to reconnect again (same or different instance) u  Failed transactions will be rolled back and re-executed u  Similar (but not the same) as Database Replay u  Calls replayed with bind variables etc. u  Fewer synchronization issues – replay only includes last uncommitted transaction
  81. juliandyke.com81 © 2013 - Julian Dyke Application Continuity u  Must connect to a user-defined service u  Not the database service u  E.g. for single instance database DECLARE l_arr DBMS_SERVICE.SVC_PARAMETER_ARRAY; BEGIN l_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;
  82. juliandyke.com82 © 2013 - Julian Dyke Application Continuity u  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 service –d TEST –s SERVICE1 –i TEST1 u  Remember to start the service...
  83. juliandyke.com83 © 2013 - Julian Dyke Application Continuity u  Client connection string should include values for: u  TRANSPORT_CONNECT_TIMEOUT u  CONNECT_TIMEOUT u  RETRY_COUNT u  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))) u  REMOTE_LISTENER database parameter must include u  SCAN name if clients specify SCAN names u  Node names if clients specify address list
  84. juliandyke.com84 © 2013 - Julian Dyke Application Continuity u  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(); u  Requires $ORACLE_HOME/jdbc/lib/ojdbc6.jar on CLASSPATH
  85. juliandyke.com85 © 2013 - Julian Dyke Application Continuity u  Debugging replayable connections u  Add $ORACLE_HOME/jdbc/lib/ojdbc6_g.jar to the CLASSPATH java -Djava.util.logging.config.file=/home/oracle/appcon/properties J7 u  Execute using: u  Writes trace to replay_0.trc.0 u  Add the following to the properties file oracle.jdbc.internal.replay.level = FINEST handlers = java.util.logging.FileHandler java.util.logging.FileHandler.pattern = /home/oracle/12c/appcon2/replay_%U.trc java.util.logging.FileHandler.limit = 500000000 java.util.logging.FileHandler.count = 1000 java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
  86. juliandyke.com86 © 2013 - Julian Dyke Application Continuity u  Potentially a very powerful feature u  Easier to implement, test and support than TAF u  Builds on FCF u  Applications need to be designed specifically for application continuity u  Very difficult to retrofit existing applications u  Special attention required for pseudo columns such as SYSDATE u  Sequences should use the new KEEP clause u  If you plan to use this feature in the future, I recommend u  DBAs become familiar with it in Oracle 12.1 so they can support developments u  New applications follow the development guidelines for this feature u  Expect to deploy the new applications in Oracle 12.2
  87. juliandyke.com87 © 2013 - Julian Dyke Thank You For Your Interest info@juliandyke.com

×