Oracle Database 12.1.0.2 New Features
-
Upload
alex-zaballa -
Category
Technology
-
view
695 -
download
1
Transcript of 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
Deiby Gómez
http://www.oraclefromguatemala.com.gt
@hdeiby
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa146 and counting…
Oracle Database 12.1.0.2 New FeaturesDeiby Gómez
Approximate Count Distinct
COUNT(DISTINCT expression)
Cost
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
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
© 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.
© 2014 Pythian Confidential 9
PDB CONTAINERS ClauseSELECT ename FROM CONTAINERS(scott.emp) WHERE CON_ID IN (11, 13);
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
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
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.”
© 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;
© 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;
© 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], [], [], [], [], [], [], [], [], []
© 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 ""
© 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.
© 2014 Pythian Confidential 18
PDB STANDBYS Clause
PDB1
PDB2
PDB3
PDB1
PDB2
PDB3
Primary Standby
• Datafiles Offline• Unnamed
© 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.
© 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.
© 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
© 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
© 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
© 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.
© 2014 Pythian Confidential 25
Database Source
PDB Subset Cloning
Tablespace 1
Tablespace 2
Tablespace 3
PDB 1Tablespace 1
PDB 2Tablespace 2
PDB 3Tablespace 3
More Oracle Database 12.1.0.2 New FeaturesAlex Zaballa
JSON
OTN Article by Alex Zaballa
http://www.oracle.com/technetwork/pt/articles/sql/json-oracle-database-12c-2378776-ptb.html
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/
JSON
JSON
More Oracle Database 12c New Features
Data Redaction
OTN Article in English by Alex Zaballa
http://www.oracle.com/technetwork/articles/database/data-redaction-odb12c-2331480.html
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
Data Redaction
Data Redaction
SQL Query Row Limits and Offsets
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);
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
SQL Query Row Limits and Offsets
select codigo, nome, salario from tabela_testeorder by salario descFETCH FIRST 5 ROWS ONLY
SQL Query Row Limits and Offsets
select codigo, nome, salario from tabela_testeorder by salario FETCH FIRST 30 PERCENT ROWS ONLY
SQL Query Row Limits and Offsets
select codigo, nome, salario from tabela_testeorder by salario desc OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY;
Invisible ColumnsCREATE TABLE tabela_teste( coluna1 NUMBER, coluna2 NUMBER, coluna3 NUMBER INVISIBLE, coluna4 NUMBER);
SQL> desc tabela_testeName ----------------------------------------- COLUNA1 NUMBERCOLUNA2 NUMBERCOLUNA4 NUMBER
Invisible Columns
INSERT INTO tabela_teste (coluna1,coluna2,coluna3,coluna4) VALUES (1,2,3,4);
INSERT INTO tabela_teste VALUES (1,2,4);
Invisible Columns
SET COLINVISIBLE ON
SQL> desc tabela_testeName ----------------------------------------- COLUNA1 NUMBERCOLUNA2 NUMBERCOLUNA4 NUMBERCOLUNA3 (INVISIBLE) NUMBER
Invisible Columns
ALTER TABLE tabela_teste MODIFY coluna3 VISIBLE;
SQL Text Expansion
SQL> variable retorno clobSQL> begin dbms_utility.expand_sql_text( input_sql_text => 'select * from emp', output_sql_text=> :retorno );end;
SQL Text Expansion
• Views• VPDs (Virtual Private Database)
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;
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.
Session Level Sequences
CREATE SEQUENCE sequence_teste START WITH 1 INCREMENT BY 1 SESSION/
Session Level Sequences
ALTER SEQUENCE sequence_testeSESSION;
ALTER SEQUENCE sequence_testeGLOBAL;
Extended Data Types
SQL> create table tabela_teste(campo01 varchar2(4001));*ERROR at line 1:ORA-00910: specified length too long for its datatype
Extended Data Types
- VARCHAR2 : 32767 bytes- NVARCHAR2 : 32767 bytes- RAW : 32767 bytes
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
DDL LOGGING
DDL LOGGING
/u01/app/oracle/diag/rdbms/orcl/orcl/log/ddl/log.xml
Direct SQL statement execution in RMAN
Pre - 12c:RMAN> SQL ‘SELECT sysdate FROM dual’;
12c:RMAN> SELECT sysdate FROM dual;
RMAN Table Recovery in 12c
RMAN enables you to recover one or more tables or table partitions to a specified point in time.
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'
Thank You