Oracle Database 12.1.0.2: New Features

47
Oracle Database 12.1.0.2: New Features Prepared by: Deiby Gómez Oracle Certified Master 11g Pythian Oracle Database Consultant

Transcript of Oracle Database 12.1.0.2: New Features

Page 1: Oracle Database 12.1.0.2: New Features

Oracle Database 12.1.0.2: New FeaturesPrepared by:Deiby GómezOracle Certified Master 11gPythian Oracle Database Consultant

Page 2: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential2

Page 3: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential3

ADVANCED INDEX COMPRESSIONCREATE INDEX (…) ON (…) COMPRESS ADVANCED LOW;

NO COMPRESSIONdgomez, Guatemala, 1Jose, Canada, 1Lucky, Mexico, 2dgomez, Guatemala, 2dgomez, guatemala, 3

WITH COMPRESSION$$, 1Jose, Canada, 1Lucky, Mexico, 2$$, 2$$, 3

Prefix: $$ Com

pres

sion

Perf

orm

ance

It’s good with so many repeated values

Page 4: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential4

ADVANCED INDEX COMPRESSIONkdxlepnro 3 <--How many prefixes exist kdxlepnco 1 (Adaptive) <--How many columns are being compressedprefix row#0[8023] flag: -P-----, lock: 0, len=9col 0; len 6; (6): 43 61 6e 61 64 61 <--'Canada'prc 1prefix row#1[8003] flag: -P-----, lock: 0, len=11col 0; len 8; (8): 43 6f 6c 6f 6d 62 69 61 <--'Colombia' prc 1prefix row#2[7982] flag: -P-----, lock: 0, len=12col 0; len 9; (9): 47 75 61 74 65 6d 61 6c 61 <-- 'Guatemala'prc 1row#0[8014] flag: -------, lock: 0, len=9col 0; len 6; (6): 01 80 00 dd 00 01 <-- Sufixpsno 0 <--Prefix #0row#1[7994] flag: -------, lock: 0, len=9 col 0; len 6; (6): 01 80 00 dd 00 02 <-- Sufixpsno 1 <--Prefix#1row#2[7973] flag: -------, lock: 0, len=9 col 0; len 6; (6): 01 80 00 dd 00 00 <-- Sufixpsno 2 <--Prefix #2----- end of leaf block Logical dump ---------- end of leaf block dump -----

Page 5: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential5

ADVANCED INDEX COMPRESSION

CREATE INDEX my_test_idx ON test(a, b) COMPRESS ADVANCED HIGH LOCAL (PARTITION p1 COMPRESS ADVANCED LOW, PARTITION p2 COMPRESS, PARTITION p3, PARTITION p4 NOCOMPRESS);

Page 6: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential6

ADVANCED INDEX COMPRESSIONHow does it work? At the block level in the following situations:

• During index creation when a leaf block becomes full• When reorganizing an index block as a result of DML (block split may

not occur)

Restrictions:

• It’s not supported for bitmap indexes or index-organized tables.

• It cannot be specified on a single column unique index. WHY?

Page 7: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential7

APPROXIMATE COUNT DISTINCT

COUNT(DISTINCT expression)

Cost

Page 8: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential8

APPROXIMATE COUNT DISTINCT

SQL> select APPROX_COUNT_DISTINCT(col1) aprox_col1 from dgomez.t1

APROX_COL1----------92611

------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost(%CPU)| Time |------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | 13 | 137 (1) |00:00:01|| 1 | SORT AGGREGATE APPROX| | 1 | 13 | | || 2 | TABLE ACCESS FULL | T1 | 249K | 3166K | 137 (1) |00:00:01|------------------------------------------------------------------------

Page 9: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential9

ATTRIBUTE CLUSTERING

“An attribute-clustered table stores data in close proximity on disk in an ordered way based on the values of a certain set of columns in the table or a set of

columns in the other tables.”

Page 10: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential10

ATTRIBUTE CLUSTERINGTypes of Attribute Clustering

• Attribute Clustering with Linear Ordering• Attribute Clustering with Interleaved Ordering

When occurs?• Direct-path insert operations - Set the ON LOAD option to YES• Data movement operations - Set the ON DATA MOVEMENT

option to YESo online table redefinition o partition operations:

MOVE MERGE SPLIT COALESCE

Page 11: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential11

ATTRIBUTE CLUSTERING

Page 12: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential12

ATTRIBUTE CLUSTERING - ADVANTAGES

• Eliminates storage costs associated with using indexes• Enables the accessing of clustered regions rather than performing random

I/O or full table scans when used in conjunction with zone maps• Provides I/O reduction when used in conjunction with any of the following:

• Oracle Exadata Storage Indexes• Oracle In-memory min/max pruning• Zone maps

• Enables clustering of fact tables based on dimension columns in star schemas

• Improves data compression ratios and in this way indirectly improves table scan costs

• Minimizes table lookup and single block I/O operations for index range scan operations when the attribute clustering is on the index selection criteria.

Page 13: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential13

AUTOMATIC BIG TABLE CACHING

• Big table cache is used for caching data for table scans.• Automatic big table caching uses temperature and object based

algorithms to track medium and big tables. How to enable it? • DB_BIG_TABLE_CACHE_PERCENT_TARGET

o percentage [0%,90%]o 10% of cache for No table scans

• PARALLEL_DEGREE_POLICY =AUTO | ADAPTIVE (RAC)

Page 14: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential14

AUTOMATIC BIG TABLE CACHING

If a large table is approximately the size of the combined size of the big table cache of all instances, then the table is partitioned and cached, or mostly cached, on all instances.

Where to check information about big table caching?

• V$BT_SCAN_CACHE• V$BT_SCAN_OBJ_TEMPS

Page 15: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential15

FDA SUPPORT FOR CDBS

In Release 12.1.0.1, Flashback Database Archive was not supported for multitenant container databases (CDBs).

In Release 12.1.0.1, Flashback Database Archive (FDA) is supported for CDBs

Page 16: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential16

FULL DATABASE CACHING

DB size > Buffer Cache

Little tables:• Allocated in memory If the table size < 2% of the Buffer Cache size

Medium tables:• Allocated in memory if table size [2%,10%] of Buffer Cache size (No

official information)• Oracle analyze the date when the table was used last time• Free space in Buffer Cache• Etc

Big Tables• Big tables are not allocated in Buffer Cache • Use "KEEP” to advice Oracle to allocate a big table in Buffer Cache

Page 17: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential17

FULL DATABASE CACHING

Buffer Cache > DB size

Little tables:• Allocated in memory If the table size < 2% of the Buffer Cache size

Medium tables:• Allocated in memory if table size [2%,10%] of Buffer Cache size (No

official information)• Oracle analyze the date when the table was used last time• Free space in Buffer Cache• Etc

Big Tables• Big tables are not allocated in Buffer Cache • Use "KEEP” to advice Oracle to allocate a big table in Buffer Cache

Page 18: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential18

FULL DATABASE CACHING

Buffer Cache > DB size

• Tables are not allocated in Buffer Cache immediately• Buffer Cache must be bigger than DB (Oracle doesn’t verify this)

Is Full Database Caching enabled?

SQL> SELECT FORCE_FULL_DB_CACHING FROM V$DATABASE; FORCE_FULL_DB_CACHING---------------------YES

Page 19: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential19

FULL DATABASE CACHING

Buffer Cache > DB size

What about if I enable it but Buffer Cache !> DB Size?

• Algorithms to allocate small, medium and large tables are not used.• More Objects Deallocation• New object scanned, blocks deallocated.

Page 20: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential20

FULL DATABASE CACHING

How to enabled it?SQL> shutdown immediate;SQL> startup mount;SQL> ALTER DATABASE FORCE FULL DATABASE CACHING;SQL> alter database open;

How to disable it?SQL> shutdown immediate;.SQL> startup ;SQL> ALTER DATABASE NO FORCE FULL DATABASE CACHING;SQL> alter database open;

Page 21: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential21

IN-MEMORY COLUMN STORE

“A DBA simply has to allocate memory to In-Memory Column Store. The optimizer is aware of In-Memory Column Store, so whenever a query accesses objects that reside in the column store, Optimizer takes advantage of

that.”

Page 22: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential22

IN-MEMORY COLUMN STORE

How to enable it?

The INMEMORY_SIZE initialization parameter must be set to a non-zero value. -Minimum 100M.-

IM column store can be enabled at any of the following levels:

• Column• Table• Materialized view• Tablespace• Partition

Page 23: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential23

IN-MEMORY COLUMN STOREAdvantages:

• A query that uses operators such as the following: =, <, >, and IN

• A query that selects a small number of columns from a table or materialized view with a large number of columns

• A query that joins a small table to a large table

INMEMORY PRIORITY Subclause

• PRIORITY NONE• PRIORITY LOW• PRIORITY MEDIUM• PRIORITY HIGH• PRIORITY CRITICAL

Page 24: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential24

JSON SUPPORT

Page 25: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential25

JSON SUPPORT

“You can access JSON data stored in the database the same

way you access other database data”

“Unlike XML data, which is stored using SQL data type XMLType, JSON data is stored in Oracle Database using SQL

data types VARCHAR2, CLOB, and BLOB”

Page 26: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential26

NEW FIPS 140 PARAMETER FOR ENCRYPTION

How to enable it?

ALTER SYSTEM SET DBFIPS_140 = TRUE;shutdown immediate;startup;

“FIPS 140-2 Security Requirements for Cryptographic Modules is a U.S. government standard for implementation of cryptographic modules that encrypt and decrypt data or perform other cryptographic operations (such

as creating or verifying digital signatures)”

**sqlnet.ora

Page 27: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential27

PDB CONTAINERS CLAUSESELECT ename FROM CONTAINERS(scott.emp) WHERE CON_ID IN (11, 13);

Page 28: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential28

PDB CONTAINERS CLAUSE

The tables and views, or synonyms of them, specified in the CONTAINERS clause must exist in the root and in all PDBs.

Each table and view specified in the CONTAINERS clause must be owned by the common user.

When a synonym is specified in the CONTAINERS clause, the synonym must resolve to a table or a view owned by the common user issuing the statement.

Page 29: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential29

PDB FILE PLACEMENT IN OMF

• FILE_NAME_CONVERT clause of CREATE PLUGGABLE DATABASE

• CREATE_FILE_DEST clause of CREATE PLUGGABLE DATABASE

• DB_CREATE_FILE_DEST (root level)

• PDB_FILE_NAME_CONVERT initialization parameter

Page 30: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential30

PDB LOGGING CLAUSE

• Table Level – Logging

• Index Level – Logging

• Tablespace Level – Logging

• Tablespace Level - Force Logging

• PDB Level – Logging

• PDB Level - Force No logging

• CDB - Force Logging

Page 31: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential31

PDB LOGGING CLAUSE

SQL> alter session set container=pdb1;SQL> startup restrict;SQL> alter pluggable database pdb1 nologging;

SQL> alter pluggable database pdb1 logging;

SQL> select pdb_name, logging, force_logging, force_nologging from cdb_pdbs;

PDB_NAME LOGGING FORCE_LOGGING FORCE_NOLOGGING---------- --------- --------------- ---------------PDB1 LOGGING NO NO

Page 32: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential32

PDB METADATA CLONE

NO DATA clause of the CREATE PLUGGABLE DATABASE

“This clause is useful for quickly creating clones of a PDB

with only the object definitions and no data.”

Page 33: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential33

PDB REMOTE CLONE

IN SOURCE DB:

**alter pluggable database pdbsource open read only;

create user C##dgomez identified by manager1;

grant create session to C##dgomez;

Page 34: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential34

PDB REMOTE CLONEIN TARGET DB:

create user C##dgomez identified by manager1;grant create session, create database link, create pluggable database to C##dgomez;

PDBSOURCE =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = db12102.oraworld.com)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = pdbsource)))

create database link dblinktosource connect to C##dgomez identified by manager1 using 'PDBSOURCE';

create pluggable database pdbtarget3 from pdbsource@dblinktosource;

Page 35: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential35

PDB REMOTE CLONETarget: 12.1.0.2Source: 12.1.0.1

SQL> create pluggable database pdbtarget from pdbsource@dblinktosource;*ERROR at line 1:ORA-17627: ORA-00600: internal error code, arguments: [ksrpcsexec_1], [158],[20], [], [], [], [], [], [], [], [], []ORA-17627: ORA-00600: internal error code, arguments: [ksrpcsexec_1], [158],[20], [], [], [], [], [], [], [], [], []

Page 36: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential36

PDB REMOTE CLONETarget: 12.1.0.1Source: 12.1.0.1

SQL> create pluggable database pdbtarget from sourcepdb@dblinktosource*ERROR at line 1:ORA-17628: Oracle error 19505 returned by remote Oracle serverORA-19505: failed to identify file ""

Page 37: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential37

PDB REMOTE CLONETarget: 12.1.0.2Source: 12.1.0.2

SQL> create pluggable database pdbtarget from pdbsource@dblinktosource;

Pluggable database created.

Page 38: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential38

PDB STANDBYS CLAUSE

PDB1

PDB2

PDB3

PDB1

PDB2

PDB3

Primary Standby

• Datafiles Offline• Unnamed

Page 39: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential39

PDB STANDBYS CLAUSE

“The STANDBYS clause of the CREATE PLUGGABLE DATABASE

statement specifies whether the new PDB is included in standby CDBs”

STANDBYS=ALL includes the new PDB in all of the standby CDBs. STANDBYS=NONE excludes the new PDB from all of the standby

CDBs.

Page 40: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential40

PDB STANDBYS CLAUSE

“It is possible to enable a PDB on a standby CDB after it was

excluded on that standby CDB.”

PDB data files need to be copied to the standby database from the primary database

The control file needs to be updated to reflect their paths

Execute ALTER PLUGGABLE DATABASE ENABLE RECOVERY It automatically onlines all of the data files belonging to the PDB.

Page 41: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential41

PDB STATE MANAGEMENT ACROSS CDB RESTART

Source: "Oracle Database 12c: New Features for Administrators” by Oracle University

12.1.0.1

Page 42: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential42

PDB STATE MANAGEMENT ACROSS CDB RESTART

1. Set the PDB at the State you want to save.

2. SQL> alter pluggable database pdb1 save state;

Pluggable database altered.

or

SQL> alter pluggable database pdb1 discard state;

Pluggable database altered.

12.1.0.2

Page 43: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential43

PDB STATE MANAGEMENT ACROSS CDB RESTART

SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT PDB1 SAVE STATE;

Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE ALL SAVE STATE;

Pluggable database altered.

12.1.0.2

Page 44: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential44

PDB SUBSET CLONING

“The USER_TABLESPACES clause of the CREATE PLUGGABLE DATABASE statement specifies which tablespaces are available in the new

PDB”o List one or more tablespaces to include.

o Specify ALL, the default, to include all of the tablespaces.

o Specify ALL EXCEPT to include all of the tablespaces, except for the tablespaces listed.

o Specify NONE to exclude all of the tablespaces.

Page 45: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential45

Database Source

PDB SUBSET CLONING

Tablespace 1

Tablespace 2

Tablespace 3

PDB 1Tablespace 1

PDB 2Tablespace 2

PDB 3Tablespace 3

Page 46: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential46

REFERENCESUna Introducción a "Oracle Advanced Index Compression"http://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/04/28/una-introducci-243-n-a-advanced-index-compressionOracle 12.1.0.2 y la función APPROX_COUNT_DISTINCThttp://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/07/29/oracle-12-1-0-2-y-la-funci-n-approx-count-distinctLogging Levels in Oracle 12chttp://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/08/01/logging-levels-in-oracle-12cCómo clonar una PDB desde un CDB remotohttp://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/05/13/c-243-mo-clonar-una-pdb-desde-un-cdb-remotoCómo hacer persistente el estado de una PDBhttp://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/04/30/c-243-mo-hacer-persistente-el-estado-de-una-pdbOracle Documentation 12.1.0.2http://docs.oracle.com/database/121/NEWFT/chapter12102.htm#NEWFT003

Page 47: Oracle Database 12.1.0.2: New Features

© 2014 Pythian Confidential47

Questions?Twitter: @hdeibyFacebook: /HDeibyEmail: [email protected]: www.oraclefromguatemala.com.gt

Thanks for coming!