oracle database 12.1.0.2 new features

61
Oracle Database 12.1.0.2 New Features Deiby Gómez Oracle Database Consultant Alex Zaballa Oracle DBA

Upload: alex-zaballa

Post on 15-Apr-2017

695 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Oracle Database 12.1.0.2 New Features

Oracle Database 12.1.0.2 New Features

Deiby Gómez Oracle Database Consultant

Alex Zaballa Oracle DBA

Page 2: Oracle Database 12.1.0.2 New Features

Deiby Gómez

http://www.oraclefromguatemala.com.gt

@hdeiby

Page 3: Oracle Database 12.1.0.2 New Features

Alex Zaballa

http://alexzaballa.blogspot.com/

@alexzaballa146 and counting…

Page 4: Oracle Database 12.1.0.2 New Features

Oracle Database 12.1.0.2 New FeaturesDeiby Gómez

Page 5: Oracle Database 12.1.0.2 New Features

Approximate Count Distinct

COUNT(DISTINCT expression)

Cost

Page 6: Oracle Database 12.1.0.2 New Features

6

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 7: Oracle Database 12.1.0.2 New Features

7

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 8: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 8

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 9: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 9

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

Page 10: Oracle Database 12.1.0.2 New Features

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 11: Oracle Database 12.1.0.2 New Features

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 12: Oracle Database 12.1.0.2 New Features

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 13: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 13

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 14: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 14

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 15: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 15

PDB Remote Clone

Target: 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 16: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 16

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 17: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 17

PDB Remote Clone

Target: 12.1.0.2Source: 12.1.0.2

SQL> create pluggable database pdbtarget from pdbsource@dblinktosource;

Pluggable database created.

Page 18: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 18

PDB STANDBYS Clause

PDB1

PDB2

PDB3

PDB1

PDB2

PDB3

Primary Standby

• Datafiles Offline• Unnamed

Page 19: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 19

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 20: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 20

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 21: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 21

PDB State Management Across CDB Restart

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

12.1.0.1

Page 22: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 22

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 23: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 23

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 24: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 24

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 25: Oracle Database 12.1.0.2 New Features

© 2014 Pythian Confidential 25

Database Source

PDB Subset Cloning

Tablespace 1

Tablespace 2

Tablespace 3

PDB 1Tablespace 1

PDB 2Tablespace 2

PDB 3Tablespace 3

Page 26: Oracle Database 12.1.0.2 New Features

More Oracle Database 12.1.0.2 New FeaturesAlex Zaballa

Page 28: Oracle Database 12.1.0.2 New Features

JSON

• Oracle Database 12.1.0.2 has now native support for JSON.

• “JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.”

Source: http://json.org/

Page 29: Oracle Database 12.1.0.2 New Features

JSON

Page 30: Oracle Database 12.1.0.2 New Features

JSON

Page 31: Oracle Database 12.1.0.2 New Features

More Oracle Database 12c New Features

Page 33: Oracle Database 12.1.0.2 New Features

Data Redaction

• 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 34: Oracle Database 12.1.0.2 New Features

Data Redaction

Page 35: Oracle Database 12.1.0.2 New Features

Data Redaction

Page 36: Oracle Database 12.1.0.2 New Features

SQL Query Row Limits and Offsets

Page 37: Oracle Database 12.1.0.2 New Features

SQL Query Row Limits and Offsets

create table tabela_teste (codigo number, nome varchar2(20), salario number); insert into tabela_teste values (1,'Alex' ,100);insert into tabela_teste values (2,'Joao' ,200);insert into tabela_teste values (3,'Maria' ,300);insert into tabela_teste values (4,'Pedro',400);insert into tabela_teste values (5,'Paulo',500);insert into tabela_teste values (6,'Fernando',600);insert into tabela_teste values (7,'Rafael',700);insert into tabela_teste values (8,'Samuel',700);insert into tabela_teste values (9,'Daniel',800);insert into tabela_teste values (10,'Luciano',1000);

Page 38: Oracle Database 12.1.0.2 New Features

SQL Query Row Limits and Offsets

Top-N Queries – Pré 12c

select * from ( select codigo, nome, salario from tabela_teste order by salario desc)where rownum <= 5

Page 39: Oracle Database 12.1.0.2 New Features

SQL Query Row Limits and Offsets

select codigo, nome, salario from tabela_testeorder by salario descFETCH FIRST 5 ROWS ONLY

Page 40: Oracle Database 12.1.0.2 New Features

SQL Query Row Limits and Offsets

select codigo, nome, salario from tabela_testeorder by salario FETCH FIRST 30 PERCENT ROWS ONLY

Page 41: Oracle Database 12.1.0.2 New Features

SQL Query Row Limits and Offsets

select codigo, nome, salario from tabela_testeorder by salario desc OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY;

Page 42: Oracle Database 12.1.0.2 New Features

Invisible ColumnsCREATE TABLE tabela_teste( coluna1 NUMBER, coluna2 NUMBER, coluna3 NUMBER INVISIBLE, coluna4 NUMBER);

SQL> desc tabela_testeName ----------------------------------------- COLUNA1 NUMBERCOLUNA2 NUMBERCOLUNA4 NUMBER

Page 43: Oracle Database 12.1.0.2 New Features

Invisible Columns

INSERT INTO tabela_teste (coluna1,coluna2,coluna3,coluna4) VALUES (1,2,3,4);

INSERT INTO tabela_teste VALUES (1,2,4);

Page 44: Oracle Database 12.1.0.2 New Features

Invisible Columns

SET COLINVISIBLE ON

SQL> desc tabela_testeName ----------------------------------------- COLUNA1 NUMBERCOLUNA2 NUMBERCOLUNA4 NUMBERCOLUNA3 (INVISIBLE) NUMBER

Page 45: Oracle Database 12.1.0.2 New Features

Invisible Columns

ALTER TABLE tabela_teste MODIFY coluna3 VISIBLE;

Page 46: Oracle Database 12.1.0.2 New Features

SQL Text Expansion

SQL> variable retorno clobSQL> begin dbms_utility.expand_sql_text( input_sql_text => 'select * from emp', output_sql_text=> :retorno );end;

Page 47: Oracle Database 12.1.0.2 New Features

SQL Text Expansion

• Views• VPDs (Virtual Private Database)

Page 48: Oracle Database 12.1.0.2 New Features

PL/SQL From SQLwith function Is_Number (x in varchar2) return varchar2 is Plsql_Num_Error exception; pragma exception_init(Plsql_Num_Error, -06502); begin if (To_Number(x) is NOT null) then return 'Y'; else return ''; end if; exception when Plsql_Num_Error then return 'N'; end Is_Number;select rownum, x, is_number(x) is_num from t;

Page 49: Oracle Database 12.1.0.2 New Features

Session Level Sequences

Session level sequences are used to produce unique values in a session. Once the session ends, the sequence is reset. Generating Primary Keys for a Global Temporary Table would be a field where those kinds of sequences could be used.

Page 50: Oracle Database 12.1.0.2 New Features

Session Level Sequences

CREATE SEQUENCE sequence_teste START WITH 1 INCREMENT BY 1 SESSION/

Page 51: Oracle Database 12.1.0.2 New Features

Session Level Sequences

ALTER SEQUENCE sequence_testeSESSION;

ALTER SEQUENCE sequence_testeGLOBAL;

Page 52: Oracle Database 12.1.0.2 New Features

Extended Data Types

SQL> create table tabela_teste(campo01 varchar2(4001));*ERROR at line 1:ORA-00910: specified length too long for its datatype

Page 53: Oracle Database 12.1.0.2 New Features

Extended Data Types

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

Page 54: Oracle Database 12.1.0.2 New Features

Extended Data Types

SHUTDOWN IMMEDIATE;STARTUP UPGRADE;ALTER SYSTEM SET max_string_size=extended;@?/rdbms/admin/utl32k.sqlSHUTDOWN IMMEDIATE;STARTUP;

**Once you switch to extended data types you can't switch back

Page 55: Oracle Database 12.1.0.2 New Features

DDL LOGGING

Page 56: Oracle Database 12.1.0.2 New Features

DDL LOGGING

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

Page 57: Oracle Database 12.1.0.2 New Features

Direct SQL statement execution in RMAN

Pre - 12c:RMAN> SQL ‘SELECT sysdate FROM dual’;

12c:RMAN> SELECT sysdate FROM dual;

Page 58: Oracle Database 12.1.0.2 New Features

RMAN Table Recovery in 12c

RMAN enables you to recover one or more tables or table partitions to a specified point in time.

Page 59: Oracle Database 12.1.0.2 New Features

RMAN Table Recovery in 12c

RMAN> RECOVER TABLE HR.REGIONS UNTIL TIME "TO_DATE('01/10/2013 09:33:39','DD/MM/RRRR HH24:MI:SS')"AUXILIARY DESTINATION '/tmp/backups'

Page 60: Oracle Database 12.1.0.2 New Features
Page 61: Oracle Database 12.1.0.2 New Features

Thank You