oracle 12c new features

110
Oracle Database 12c The Best Oracle Database 12c New Features for Developers and DBAs Presented by: Alex Zaballa, Oracle DBA

Upload: guatemala-user-group

Post on 16-Apr-2017

452 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Oracle 12c New Features

Oracle Database 12c

The Best Oracle Database 12c New Features for Developers and

DBAs

Presentedby: AlexZaballa,OracleDBA

Page 2: Oracle 12c New Features

Alex Zaballa

http://alexzaballa.blogspot.com/

@alexzaballa206andcounting…https://www.linkedin.com/in/alexzaballa

Page 3: Oracle 12c New Features

Workedfor7 yearsinBrazil asanOracleDeveloper.2000- 2007

Workedfor8 yearsinAngolaasanOracleDBAfortheMinistryofFinance.2007- 2015

Page 4: Oracle 12c New Features
Page 5: Oracle 12c New Features

Oracle Database 12c

New Features for Developers and DBAs

Page 6: Oracle 12c New Features

OracleOfficialDocumentation12.1.0.2

• http://docs.oracle.com/database/121/NEWFT/chapter12102.htm

OracleLearningLibrary(OLL)

• https://apexapps.oracle.com/pls/apex/f?p=44785:1:0

Page 7: Oracle 12c New Features

Articlesabout12c

• https://oracle-base.com/articles/12c/articles-12c

Page 8: Oracle 12c New Features

“Withmorethan500newfeatures,OracleDatabase12c isdesignedtogiveOraclecustomersexactlywhatthey’vetoldustheyneedforcloudcomputing,bigdata,security,andavailability.”

Page 9: Oracle 12c New Features

OracleAnnouncesBetaAvailabilityofOracleDatabase12cRelease2 - Oct26,2015

• PLUGGABLEDATABASESFrom252to4096

• HOTCLONINGDon’tneedtoputthesourceinread-onlyforcloning

• SHARDINGIt’slikepartitioninginasharednothingdatabaseThedataissplitintomultipledatabases

• In-MemoryIn-MemorycolumnStoreonActiveDataGuardHeatMap

• APPLICATIONCONTAINERPluggableDatabaseswillshareapplicationobjects

• Moreisolation,resourcemanagerwilllimitthememoryinadditiontoCPUandI/O.• AWRwillworkonActiveDataGuardDatabase:youcantuneyourreportingdatabase

Page 10: Oracle 12c New Features

AvailabilityofOracleDatabase12.2

Source:https://blogs.oracle.com/UPGRADE/entry/oracle_database_12_2_just

Page 11: Oracle 12c New Features

OracleDatabaseReleaseStatusMOSNote:742060.1

Page 12: Oracle 12c New Features

Upgradeto12.1.0.2orwaitfor12.2?

CDBouNON-CDB?

Page 13: Oracle 12c New Features

Let’sstart…

Page 14: Oracle 12c New Features

JSON

OTNArticlebyAlexZaballa

http://www.oracle.com/technetwork/pt/articles/sql/json-oracle-database-12c-2378776-ptb.html

Page 15: Oracle 12c New Features

JSON

• OracleDatabase12.1.0.2hasnownativesupportforJSON.

• “JSON (JavaScriptObjectNotation)isalightweightdata-interchangeformat.Itiseasyforhumanstoreadandwrite.Itiseasyformachinestoparseandgenerate.”

Source:http://json.org/

Page 16: Oracle 12c New Features

JSON

Page 17: Oracle 12c New Features

JSON

Page 18: Oracle 12c New Features

DEMO

Page 19: Oracle 12c New Features

DataRedaction

OTNArticleinEnglishbyAlexZaballa

http://www.oracle.com/technetwork/articles/database/data-redaction-odb12c-2331480.html

Page 20: Oracle 12c New Features

DataRedaction

• One of the new features introduced in Oracle Database 12c

• Part of the Advanced Security option• Enables the protection of data shown to the

user in real time, without requiring changes to the application

Page 21: Oracle 12c New Features

DataRedaction

Page 22: Oracle 12c New Features

DataRedaction

Page 23: Oracle 12c New Features

DEMO

Page 24: Oracle 12c New Features

InvisibleColumnsCREATETABLEtable_test_inv(column1NUMBER,column2NUMBER,column3NUMBERINVISIBLE,column4NUMBER);

SQL>desc table_test_invName-----------------------------------------COLUMN1NUMBERCOLUMN2NUMBERCOLUMN4NUMBER

Page 25: Oracle 12c New Features

InvisibleColumns

INSERTINTOtable_test_inv(column1,column2,column3,column4)VALUES(1,2,3,4);

INSERTINTOtable_test_inv VALUES(1,2,4);

Page 26: Oracle 12c New Features

InvisibleColumns

SETCOLINVISIBLEON

SQL>desc table_test_invName-----------------------------------------COLUMN1NUMBERCOLUMN2NUMBERCOLUMN4NUMBERCOLUMN3(INVISIBLE)NUMBER

Page 27: Oracle 12c New Features

InvisibleColumns

ALTERTABLEtable_test_inv MODIFYcolumn3VISIBLE;

WHY?

Youarepreparingthechangesonthedatabase,buttheapplicationisnotpreparedyet.

Select*from…...

InsertintoTABLEVALUES(......,.....,.....)

Page 28: Oracle 12c New Features

DEMO

Page 29: Oracle 12c New Features

SQLTextExpansion

SQL>variableretorno clobSQL>begindbms_utility.expand_sql_text(input_sql_text=>'select*fromemp',output_sql_text=>:retorno );end;

Page 30: Oracle 12c New Features

SQLTextExpansion

• Views• VPDs

Page 31: Oracle 12c New Features

DEMO

Page 32: Oracle 12c New Features

ExtendedDataTypes

SQL>createtabletable_test(column01varchar2(4001));*ERRORatline1:ORA-00910:specifiedlengthtoolongforitsdatatype

Page 33: Oracle 12c New Features

ExtendedDataTypes

- VARCHAR2:32767bytes- NVARCHAR2:32767bytes- RAW:32767bytes

Page 34: Oracle 12c New Features

ExtendedDataTypes

SHUTDOWNIMMEDIATE;STARTUPUPGRADE;ALTERSYSTEMSETmax_string_size=extended;@?/rdbms/admin/utl32k.sqlSHUTDOWNIMMEDIATE;STARTUP;

**Onceyouswitchtoextendeddatatypesyoucan'tswitchback

Page 35: Oracle 12c New Features

DEMO

Page 36: Oracle 12c New Features

MultipleIndexesonthesamesetofColumns

Pre12c:

ORA-01408:suchcolumnlistalreadyindexederror.

Page 37: Oracle 12c New Features

MultipleIndexesonthesamesetofColumns

Istheabilitytocreatemorethanoneindexonthesamesetofcolumnsin12c.

**Onlyoneoftheseindexescanbevisibleatatime

Page 38: Oracle 12c New Features

MultipleIndexesonthesamesetofColumns

Whywouldyouwanttodothat?

• Uniqueversusnonunique

• B-treeversusbitmap

• Differentpartitioningstrategies

Page 39: Oracle 12c New Features

DEMO

Page 40: Oracle 12c New Features

READObjectPrivilegeandREADANYTABLESystemPrivilege

WhatisthedifferencetoSELECT andSELECTANYTABLE?

Page 41: Oracle 12c New Features

READObjectPrivilegeandREADANYTABLESystemPrivilege

SELECT andSELECTANYTABLEprovidestheabilitytolockrows:

LOCKTABLEtable_name INEXCLUSIVEMODE;SELECT...FROMtable_name FORUPDATE;

Page 42: Oracle 12c New Features

READObjectPrivilegeandREADANYTABLESystemPrivilege

SQL>grantselectonscott.emp toteste;Grantsucceeded.

SQL>locktablescott.emp inexclusivemode;Table(s)Locked.

Page 43: Oracle 12c New Features

READObjectPrivilegeandREADANYTABLESystemPrivilege

SQL>grantreadonscott.emp toteste;Grantsucceeded.

SQL>locktablescott.emp inexclusivemode;locktablescott.emp inexclusivemode

*ERRORatline1:ORA-01031:insufficientprivileges

Page 44: Oracle 12c New Features

DEMO

Page 45: Oracle 12c New Features

StatisticsDuringLoads

Theabilitytogatherstatisticsautomaticallyduringbulkloads:

- CREATETABLEASSELECT

- INSERTINTO...SELECTintoanemptytableusingadirectpathinsert

Page 46: Oracle 12c New Features

DEMO

Page 47: Oracle 12c New Features

PartialIndexesforPartitionedTable

• Youcancreatelocalandglobalindexesonasubset ofthepartitionsofatable,enablingmoreflexibilityinindexcreation.

• Thisfeatureisnotsupportedforuniqueindexes,orforindexesusedforenforcinguniqueconstraints.

Page 48: Oracle 12c New Features

PartialIndexesforPartitionedTable

Page 49: Oracle 12c New Features

DEMO

Page 50: Oracle 12c New Features

SQL*LoaderExpress

• Youdon'tneedtotowriteandtestaSQL*Loadercontrolfile.

• Thebenefitmainisthesavingsfortimeandeffort.

Page 51: Oracle 12c New Features

SQL*LoaderExpress[oracle@oracle01tmp]$catEMP_TEST.dat1,Emp12,Emp23,Emp34,Emp45,Emp56,Emp67,Emp78,Emp89,Emp9

Page 52: Oracle 12c New Features

SQL*LoaderExpress

[oracle@oracle01tmp]$sqlldr teste/testeTABLE=EMP_TESTSQL*Loader:Release12.1.0.1.0- ProductiononSatJan1112:16:282014Copyright(c)1982,2013,Oracleand/oritsaffiliates.Allrightsreserved.ExpressModeLoad,Table:EMP_TESTPathused:ExternalTable,DEGREE_OF_PARALLELISM=AUTO

TableEMP_TEST:9Rowssuccessfullyloaded.

Checkthelogfiles:EMP_TEST.logEMP_TEST_%p.log_xtformoreinformationabouttheload.

Page 53: Oracle 12c New Features

DEMO

Page 54: Oracle 12c New Features

TruncateCascade

SQL>truncatetablescott.dept;truncatetablescott.dept

*ERRORatline1:ORA-02266:unique/primarykeysintablereferencedbyenabledforeignkeys

Page 55: Oracle 12c New Features

TruncateCascade

SQL>truncatetablescott.dept cascade;Tabletruncated.

TheconstraintshouldbeONDELETECASCADE.

Page 56: Oracle 12c New Features

DEMO

Page 57: Oracle 12c New Features

LimitthePGA

SQL>showparameterpga

NAME TYPEVALUE-------------------------- ------------- ----------------------pga_aggregate_limit biginteger2G

pga_aggregate_target ****

Page 58: Oracle 12c New Features

LimitthePGA

PGA_AGGREGATE_LIMIT issettothegreaterof:

- 2GB(defaultvalue)- 200%ofPGA_AGGREGATE_TARGET- 3MBtimesthePROCESSESparameter

Page 59: Oracle 12c New Features

FullDatabaseCaching

Canbeusedtocachetheentiredatabaseinmemory.Itshouldbeusedwhenthebuffercachesizeofthedatabaseinstanceisgreaterthanthewholedatabasesize.

Page 60: Oracle 12c New Features

RMANTableRecoveryin12c

RMANenablesyoutorecoveroneormoretablesortablepartitionstoaspecifiedpointintime.

Page 61: Oracle 12c New Features

RMANTableRecoveryin12c

RMAN>RECOVERTABLEHR.REGIONSUNTILTIME"TO_DATE('01/10/201309:33:39','DD/MM/RRRRHH24:MI:SS')"AUXILIARYDESTINATION'/tmp/backups'

Page 62: Oracle 12c New Features

In-DatabaseArchiving

SQL>createtabletable_test(column1number)rowarchival;

insertintotable_test values(1);insertintotable_test values(2);insertintotable_test values(3);

Page 63: Oracle 12c New Features

In-DatabaseArchiving

Page 64: Oracle 12c New Features

In-DatabaseArchiving

updatetable_testsetora_archive_state=DBMS_ILM.ARCHIVESTATENAME(1)wherecolumn1=3;

Page 65: Oracle 12c New Features

In-DatabaseArchiving

altersessionsetrowarchivalvisibility=all;

Page 66: Oracle 12c New Features

HeatMap,AutomaticDataOptimizationandILM

OTNArticleinPortuguesebyDanielDaMeda andAlexZaballa

http://www.oracle.com/technetwork/pt/articles/database-performance/ilm-e-automatic-data-optimization-2601873-ptb.html

Page 67: Oracle 12c New Features

HeatMap,AutomaticDataOptimizationandILM

• HeatMap:OracleDatabase12cfeaturethatstoressystem-generateddatausagestatisticsattheblockandsegmentlevels.Automaticallytracksmodificationandquerytimestampsattherowandsegmentlevels.

• AutomaticDataOptimization(ADO): automaticallymovesandcompressesdataaccordingtouser-definedpoliciesbasedontheinformationcollectedbyHeatMap

• ILM: HeatMapandAutomaticDataOptimizationmakeOracleDatabase12cidealforimplementingILM

Page 68: Oracle 12c New Features

HeatMap,AutomaticDataOptimizationandILM

EnablingHeatMap

SQL>altersystemsetheat_map =on;

Page 69: Oracle 12c New Features

HeatMap,AutomaticDataOptimizationandILM

HeatMapstatisticscanbeviewedgraphicallythroughEMCloudControl:

Page 70: Oracle 12c New Features

HeatMap,AutomaticDataOptimizationandILM

CreatingADOpolicies

CompressthetablespaceUSER_DATAandallitsresidingsegmentsatOLTPlevelafter30daysoflowaccess:

ALTERTABLESPACEUSER_DATAILMADDPOLICYROWSTORECOMPRESSADVANCEDSEGMENTAFTER30DAYSOFLOWACCESS;

Page 71: Oracle 12c New Features

HeatMap,AutomaticDataOptimizationandILM

CreatingADOpolicies

CompressthetableORDER_ITEMSincludinganySecureFileLOBsatOLTPlevelafter90daysofnomodification:

ALTERTABLEORDER_ITEMSILMADDPOLICYROWSTORECOMPRESSADVANCEDGROUPAFTER90DAYSOFNOMODIFICATION;

Page 72: Oracle 12c New Features

DDLLOGGING

Page 73: Oracle 12c New Features

DDLLOGGING

/u01/app/oracle/diag/rdbms/orcl/orcl/log/ddl/log.xml

Page 74: Oracle 12c New Features

DirectSQLstatementexecutioninRMAN

Pre- 12c:RMAN> SQL‘SELECTsysdate FROMdual’;

12c:RMAN> SELECTsysdate FROMdual;

Page 75: Oracle 12c New Features

SessionprivatestatisticsforGlobalTemporaryTables

Pre12c,statisticsgatheredforglobaltemporarytables(GTTs)werecommontoallsessions.

Page 76: Oracle 12c New Features

SessionprivatestatisticsforGlobalTemporaryTables

On12c,bydefaultsession-privatestatisticsareenabled

SELECTDBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS')FROMdual;

STATS------------------------------------------------------------------------------SESSION

Page 77: Oracle 12c New Features

SessionprivatestatisticsforGlobalTemporaryTables

Howtochange?

Behaviorpre12c:BEGINDBMS_STATS.set_global_prefs (pname =>'GLOBAL_TEMP_TABLE_STATS',pvalue =>'SHARED');

END;/

Backtodefaulton12c:BEGINDBMS_STATS.set_global_prefs (pname =>'GLOBAL_TEMP_TABLE_STATS',pvalue =>'SESSION');

END;/

Page 78: Oracle 12c New Features

SessionprivatestatisticsforGlobalTemporaryTables

Howtochangeforonetable?

BEGINdbms_stats.set_table_prefs('SCOTT','GTT_TEST','GLOBAL_TEMP_TABLE_STATS','SHARED');END;

BEGINdbms_stats.set_table_prefs('SCOTT','GTT_TEST','GLOBAL_TEMP_TABLE_STATS’,’SESSION');END;

Page 79: Oracle 12c New Features

DEMO

Page 80: Oracle 12c New Features

TemporaryUndo

GlobalTemporaryTables(GTT)holdthedatainatemporarytablespace.ThedatainGTTsareeitherdeletedaftercommitorkeptuntilthesessionisconnecteddependingofthedefinitionoftheGTT.(ONCOMMITPRESERVEORDELETEROWS).

DMLsinaGlobalTemporaryTablesdonotgenerateREDO,butgenerateUNDO andthiswillresultinREDOgenerating.

Page 81: Oracle 12c New Features

TemporaryUndo

altersessionsettemp_undo_enabled=true;

**youcanchangeforthesessionorforthedatabase.

Page 82: Oracle 12c New Features

DEMO

Page 83: Oracle 12c New Features

IdentityColumns

CREATETABLEtabela_teste (idNUMBERGENERATEDALWAYS ASIDENTITY,coluna1VARCHAR2(30));

Page 84: Oracle 12c New Features

IdentityColumns

CREATETABLEtabela_teste (idNUMBERGENERATEDBYDEFAULTASIDENTITY,coluna1VARCHAR2(30));

Page 85: Oracle 12c New Features

IdentityColumns

CREATETABLEtabela_teste (idNUMBERGENERATEDBYDEFAULTONNULLASIDENTITY,coluna1VARCHAR2(30));

Page 86: Oracle 12c New Features

SQLQueryRowLimitsandOffsets

Page 87: Oracle 12c New Features

SQLQueryRowLimitsandOffsets

Page 88: Oracle 12c New Features

SQLQueryRowLimitsandOffsets

Top-NQueries– Pré 12c

Page 89: Oracle 12c New Features

SQLQueryRowLimitsandOffsets

Page 90: Oracle 12c New Features

SQLQueryRowLimitsandOffsets

Page 91: Oracle 12c New Features

SQLQueryRowLimitsandOffsets

Page 92: Oracle 12c New Features

DEMO

Page 93: Oracle 12c New Features

PL/SQLFromSQLwith

functionIs_Number(xinvarchar2)returnvarchar2isPlsql_Num_Error exception;pragmaexception_init(Plsql_Num_Error,-06502);beginif(To_Number(x)isNOTnull)thenreturn'Y';elsereturn'';endif;exceptionwhenPlsql_Num_Error thenreturn'N';

endIs_Number;selectrownum,x,is_number(x)is_num fromt;

Page 94: Oracle 12c New Features

SessionLevelSequences

Sessionlevelsequences areusedtoproduceuniquevaluesinasession.Oncethesessionends,thesequenceisreset.

GeneratingPrimaryKeysforaGlobalTemporaryTablewouldbeafieldwherethosekindsofsequencescouldbeused.

Page 95: Oracle 12c New Features

SessionLevelSequences

CREATESEQUENCEsequence_testSTARTWITH1INCREMENTBY1SESSION/

Page 96: Oracle 12c New Features

SessionLevelSequences

ALTERSEQUENCEsequence_testSESSION;

ALTERSEQUENCEsequence_testGLOBAL;

Page 97: Oracle 12c New Features

Multitenant

Page 98: Oracle 12c New Features

Fonte:OracleDocumentation

Page 99: Oracle 12c New Features

Multitenant

Fonte:https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle

Page 100: Oracle 12c New Features

Multitenant

Fonte:https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle

Page 101: Oracle 12c New Features

Multitenant

Fonte:https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle

Page 102: Oracle 12c New Features

In-Memory

Fonte:OracleDocumentation

Page 103: Oracle 12c New Features

SIMDVectorProcessing

Fonte:http://www.oracle.com/technetwork/database/in-memory/overview/twp-oracle-database-in-memory-2245633.html

Page 104: Oracle 12c New Features

In-Memory

In-MemoryArea– astaticpoolinSGA

Page 105: Oracle 12c New Features

In-Memory

Fonte:OracleBase.com

Page 106: Oracle 12c New Features

In-MemoryAltertablehr.EMPLOYEES inmemory;

ALTERTABLEsalesMODIFYPARTITIONSALES_Q1_1998INMEMORY;

ALTERTABLEsalesINMEMORYNOINMEMORY(prod_id);

CREATETABLESPACEtbs_testDATAFILE'+DG01SIZE100MDEFAULTINMEMORY;

Page 107: Oracle 12c New Features

In-Memory

Fonte:http://www.oracle.com/technetwork/database/in-memory/overview/twp-oracle-database-in-memory-2245633.html

Page 108: Oracle 12c New Features

SQLcl

http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

Page 109: Oracle 12c New Features
Page 110: Oracle 12c New Features

ThankYou

SlidesAvailable:http://www.slideshare.net/