SlideShare uma empresa Scribd logo
1 de 122
Oracle Database 12c
Novas Características para DBAs e
Desenvolvedores
Presented by:
Alex Zaballa, Oracle DBA
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa205 and counting…
https://www.linkedin.com/in/alexzaballa
Worked for 7 years in Brazil as an Oracle Developer.
2000 - 2007
Worked for 8 years in Angola as an Oracle DBA
for the Ministry of Finance.
2007 - 2015
Oracle Database 12c
Novas Características para DBAs e
Desenvolvedores
Documentação Oficial - 12.1.0.2
• http://docs.oracle.com/database/121/NEWFT/ch
apter12102.htm
Oracle Learning Library (OLL)
• https://apexapps.oracle.com/pls/apex/f?p=44785
:1:0
Artigos – 12c
• https://oracle-base.com/articles/12c/articles-
12c
• http://www.oracle.com/technetwork/pt/articles/
index.html
• http://profissionaloracle.com.br
“With more than 500 new features, Oracle
Database 12c is designed to give Oracle
customers exactly what they’ve told us they
need for cloud computing, big data, security,
and availability.”
Oracle Announces Beta Availability of Oracle Database 12c Release 2 - Oct 26,
2015
• PLUGGABLE DATABASES
From 252 to 4096
• HOT CLONING
Don’t need to put the source in read-only for cloning
• SHARDING
It’s like partitioning in a shared nothing database
The data is split into multiple databases
• In-Memory
In-Memory column Store on Active Data Guard
Heat Map
• APPLICATION CONTAINER
Pluggable Databases will share application objects
• More isolation, resource manager will limit the memory in addition to CPU and I/O.
• AWR will work on Active Data Guard Database: you can tune your reporting database
Availability of Oracle Database 12.2
Source: https://blogs.oracle.com/UPGRADE/entry/oracle_database_12_2_just
Oracle Database Release Status
MOS Note:742060.1
SQLcl
http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
Devo migrar para 12.1.0.2 ou
aguardar a 12.2 ?
CDB ou NON-CDB?
Multitenant
Fonte: Oracle Documentation
Multitenant
Fonte: https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle
Multitenant
Fonte: https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle
Multitenant
Fonte: https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle
In-Memory
Fonte: Oracle Documentation
SIMD Vector Processing
Fonte: http://www.oracle.com/technetwork/database/in-memory/overview/twp-
oracle-database-in-memory-2245633.html
In-Memory
In-Memory Area – Pool estático que faz parte
da SGA
In-Memory
Fonte: OracleBase.com
In-Memory
Alter table hr.EMPLOYEES inmemory;
ALTER TABLE sales MODIFY PARTITION SALES_Q1_1998
NO INMEMORY;
ALTER TABLE sales INMEMORY NO INMEMORY(prod_id);
CREATE TABLESPACE tbs_test
DATAFILE '+DG01 SIZE 100M
DEFAULT INMEMORY;
In-Memory
Fonte: http://www.oracle.com/technetwork/database/in-memory/overview/twp-
oracle-database-in-memory-2245633.html
insert /*+ append parallel */ into tab1 select /*+
parallel */ * from tab2 nologging;
15 minutes to complete.
create table tab1 as select /*+ parallel */ * from
tab2 nologging;
2 minutes to complete.
Parallel
Parallel
Source: https://docs.oracle.com/database/121/VLDBG/GUID-5EB01FA8-030B-45BB-9B16-2D13881F6010.htm
Parallel
JSON
Artigo no OTN:
http://www.oracle.com/technetwork/pt/articles
/sql/json-oracle-database-12c-2378776-
ptb.html
JSON
• No Oracle Database 12c (12.1.0.2), foi
adicionado o suporte nativo ao JavaScript
Object Notation (JSON).
• O JSON é um formato leve para intercâmbio
de dados que é relativamente fácil para o ser
humano ler e escrever, além de ser fácil para
os softwares analisarem e gerarem.
JSON
JSON
DEMO
Data Redaction
Artigo no OTN:
http://www.oracle.com/technetwork/pt/articles
/idm/funcionalidade-data-redaction-12c-
2209076-ptb.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
DEMO
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_teste
order by salario desc
FETCH FIRST 5 ROWS ONLY
SQL Query Row Limits and Offsets
select codigo, nome, salario
from tabela_teste
order by salario
FETCH FIRST 30 PERCENT ROWS ONLY
SQL Query Row Limits and Offsets
select codigo, nome, salario
from tabela_teste
order by salario desc
OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY;
DEMO
Invisible Columns
CREATE TABLE tabela_teste
(
coluna1 NUMBER,
coluna2 NUMBER,
coluna3 NUMBER INVISIBLE,
coluna4 NUMBER
);
SQL> desc tabela_teste
Name
-----------------------------------------
COLUNA1 NUMBER
COLUNA2 NUMBER
COLUNA4 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_teste
Name
-----------------------------------------
COLUNA1 NUMBER
COLUNA2 NUMBER
COLUNA4 NUMBER
COLUNA3 (INVISIBLE) NUMBER
Invisible Columns
ALTER TABLE tabela_teste MODIFY coluna3 VISIBLE;
DEMO
SQL Text Expansion
SQL> variable retorno clob
SQL> begin
dbms_utility.expand_sql_text( input_sql_text
=> 'select * from emp', output_sql_text=>
:retorno );
end;
SQL Text Expansion
• Views
• VPDs
DEMO
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;
DEMO
Session Level Sequences
Session level sequences são utilizadas para
produzir valores únicos dentro de uma sessão.
Assim que a sessão termina, a sequence é
reinicializada.
Elas são muito utilizadas para gerar valores de
Primary Keys em Global Temporary Tables.
Session Level Sequences
CREATE SEQUENCE sequence_teste
START WITH 1
INCREMENT BY 1
SESSION
/
Session Level Sequences
ALTER SEQUENCE sequence_teste
SESSION;
ALTER SEQUENCE sequence_teste
GLOBAL;
DEMO
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.sql
SHUTDOWN IMMEDIATE;
STARTUP;
**Após aumentar o tamanho máximo dos tipos de dados, não é possível desfazer
esta alteração.
DEMO
Multiple Indexes on the same set of
Columns
Pré 12c:
ORA-01408: such column list already indexed
error.
Multiple Indexes on the same set of
Columns
No 12c é possível ter vários índices em uma
mesma coluna ou lista de colunas.
A criação de um índice sobre uma coluna ou lista
de colunas que já foram indexadas é simples e
você tem que garantir que apenas um índice
será visível.
Multiple Indexes on the same set of
Columns
• Unique versus nonunique
• B-tree versus bitmap
• Different partitioning strategies
DEMO
READ Object Privilege and READ ANY
TABLE System Privilege
Qual a diferença para SELECT e SELECT ANY
TABLE?
READ Object Privilege and READ ANY
TABLE System Privilege
O privilégio de objeto SELECT e o privilégio de
sistema SELECT ANY TABLE permitem bloquear
as linhas de uma tabela através da execução das
seguintes operações:
LOCK TABLE table_name IN EXCLUSIVE MODE;
SELECT ... FROM table_name FOR UPDATE;
READ Object Privilege and READ ANY
TABLE System Privilege
SQL> grant select on scott.emp to teste;
Grant succeeded.
SQL> lock table scott.emp in exclusive mode;
Table(s) Locked.
READ Object Privilege and READ ANY
TABLE System Privilege
SQL> grant read on scott.emp to teste;
Grant succeeded.
SQL> lock table scott.emp in exclusive mode;
lock table scott.emp in exclusive mode
*
ERROR at line 1:
ORA-01031: insufficient privileges
DEMO
Session private statistics for Global
Temporary Tables
Até o 12c, as estatísticas para tabelas
temporárias globais (GTTs) eram comuns para
todas as sessões.
Session private statistics for Global
Temporary Tables
SELECT
DBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS')
Stats FROM dual;
STATS
------------------------------------------------------------------------------
SESSION
Session private statistics for Global
Temporary Tables
BEGIN
DBMS_STATS.set_global_prefs (
pname => 'GLOBAL_TEMP_TABLE_STATS',
pvalue => 'SHARED');
END;
/
BEGIN
DBMS_STATS.set_global_prefs (
pname => 'GLOBAL_TEMP_TABLE_STATS',
pvalue => 'SESSION');
END;
/
Session private statistics for Global
Temporary Tables
BEGIN
dbms_stats.set_table_prefs('SCOTT','GTT_TESTE','GLOB
AL_TEMP_TABLE_STATS','SHARED');
END;
BEGIN
dbms_stats.set_table_prefs('SCOTT','GTT_TESTE','GLOB
AL_TEMP_TABLE_STATS','SESSION');
END;
DEMO
Temporary Undo
Uma Global Temporary Table armazena seus dados
em uma temporary tablespace e estes dados são
mantidos durante a transação ou durante toda a
sessão (ON COMMIT DELETE ROWS ou ON COMMIT
PRESERVE ROWS).
Instruções DML em Global Temporary Tables não
geram REDO, devido ao fato destes dados estarem
armazenados em uma temporary tablespace, mas
geram UNDO e isto sim implicará na geração de
REDO.
Temporary Undo
alter session set temp_undo_enabled=true;
**pode ser alterado a nível de banco de dados
ou de sessão.
DEMO
Statistics During Loads
O banco de dados irá coletar estatísticas
automaticamente das tabelas durante os
seguintes tipos de operações bulk load:
- CREATE TABLE AS SELECT
- INSERT INTO ... SELECT into an empty table
using a direct path insert
DEMO
Partial Indexes for Partitioned Table
• Você pode criar os índices (globais ou locais)
para partições ou sub-partições específicas,
isto é, os índices serão criados apenas para
partições/sub-partições que você deseja.
• Este recurso não é suportado para índices
únicos, ou seja, para índices utilizados para
impor restrições exclusivas.
Partial Indexes for Partitioned Table
DEMO
SQL*Loader Express
• No modo express, não é necessário criar o
arquivo de controle.
• O objetivo principal é salvar tempo e diminuir
o esforço.
• O express mode pode ser utilizado quando
todas as colunas são do tipo character,
number ou datetime
SQL*Loader Express
[oracle@oracle01 tmp]$ cat EMPRESA.dat
1,Empresa 1
2,Empresa 2
3,Empresa 3
4,Empresa 4
5,Empresa 5
6,Empresa 6
7,Empresa 7
8,Empresa 8
9,Empresa 9
SQL*Loader Express
[oracle@oracle01 tmp]$ sqlldr teste/teste TABLE=EMPRESA
SQL*Loader: Release 12.1.0.1.0 - Production on Sat Jan 11 12:16:28 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Express Mode Load, Table: EMPRESA
Path used: External Table, DEGREE_OF_PARALLELISM=AUTO
Table EMPRESA:
9 Rows successfully loaded.
Check the log files:
EMPRESA.log
EMPRESA_%p.log_xt
for more information about the load.
DEMO
Truncate Cascade
SQL> truncate table scott.dept;
truncate table scott.dept
*
ERROR at line 1:
ORA-02266: unique/primary keys in table
referenced by enabled foreign keys
Truncate Cascade
SQL> truncate table scott.dept cascade;
Table truncated.
A constraint deve ser do tipo ON DELETE
CASCADE.
DEMO
Limit the PGA
SQL> show parameter pga
NAME TYPE VALUE
-------------------------- ------------- ----------------------
pga_aggregate_limit big integer 2G
Limit the PGA
PGA_AGGREGATE_LIMIT é setado como default
para o maior valor entre:
- 2 GB (valor default)
- 200% do valor do parâmetro
PGA_AGGREGATE_TARGET
- 3 MB multiplicado pelo valor do parâmetro
PROCESSES
Full Database Caching
Este novo recurso permite armazenar todos os
segmentos do banco de dados em memória
(quando os segmentos forem acessados).
DEMO
Recuperando Tabelas com o RMAN
• Utilizado para recuperação de tabelas/partições
de um backup realizado pelo RMAN.
• Este comando, diminui o tempo e a complexidade
da restauração, permitindo a recuperação “point-
in-time” apenas da tabela/partição, ao invés de
toda tablespace como era nas versões anteriores.
• É muito útil quando não temos informações
suficientes no UNDO para utilizar o Flashback
Table.
Recuperando Tabelas com o RMAN
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'
DEMO
In-Database Archiving
SQL> create table tabela_teste(coluna1 number)
row archival;
insert into tabela_teste values(1);
insert into tabela_teste values(2);
insert into tabela_teste values(3);
In-Database Archiving
In-Database Archiving
update tabela_teste
set ora_archive_state=DBMS_ILM.ARCHIVESTATENAME(1)
where coluna1=3;
In-Database Archiving
alter session set row archival visibility=all;
DEMO
Heat Map, Automatic Data
Optimization and ILM
OTN - Artigo do Alex Zaballa e Daniel Da Meda
http://www.oracle.com/technetwork/pt/articles
/database-performance/ilm-e-automatic-data-
optimization-2601873-ptb.html
Heat Map, Automatic Data
Optimization and ILM
• Heat Map: Oracle Database 12c feature that stores system-
generated data usage statistics at the block and segment
levels. Automatically tracks modification and query
timestamps at the row and segment levels.
• Automatic Data Optimization (ADO): automatically moves
and compresses data according to user-defined policies
based on the information collected by Heat Map
• ILM: Heat Map and Automatic Data Optimization make
Oracle Database 12c ideal for implementing ILM
Heat Map, Automatic Data
Optimization and ILM
Habilitando o Heat Map
SQL> alter system set heat_map = on;
Heat Map, Automatic Data
Optimization and ILM
As estatísticas de Heat Map visualizadas
graficamente através do EM Cloud Control:
Heat Map, Automatic Data
Optimization and ILM
Criando políticas ADO
Comprimir a tablespace USER_DATA e todos os seus
segmentos utilizando compressão OLTP após 30 dias de
baixo acesso:
ALTER TABLESPACE USER_DATA ILM ADD POLICY
ROW STORE COMPRESS ADVANCED
SEGMENT AFTER 30 DAYS OF LOW ACCESS;
Heat Map, Automatic Data
Optimization and ILM
Criando políticas ADO
Comprimir a tabela ORDER_ITEMS utilizando compressão
OLTP após 90 dias sem modificações.
ALTER TABLE ORDER_ITEMS ILM ADD POLICY
ROW STORE COMPRESS ADVANCED
GROUP AFTER 90 DAYS OF NO MODIFICATION;
DEMO
DDL LOGGING
DDL LOGGING
/u01/app/oracle/diag/rdbms/orcl/orcl/log/ddl/log.xml
DEMO
Direct SQL statement execution in
RMAN
Pré 12c:
RMAN> SQL ‘SELECT sysdate FROM dual’;
12c:
RMAN> SELECT sysdate FROM dual;
DEMO
Identity Columns
CREATE TABLE tabela_teste (
id NUMBER GENERATED ALWAYS AS IDENTITY,
coluna1 VARCHAR2(30));
Identity Columns
CREATE TABLE tabela_teste (
id NUMBER GENERATED BY DEFAULT AS IDENTITY,
coluna1 VARCHAR2(30));
Identity Columns
CREATE TABLE tabela_teste (
id NUMBER GENERATED BY DEFAULT ON NULL AS
IDENTITY,
coluna1 VARCHAR2(30));
DEMO
Obrigado
Slides disponíveis no

Mais conteúdo relacionado

Semelhante a Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs [USR12010]

Novidades do Sql Server 2016
Novidades do Sql Server 2016Novidades do Sql Server 2016
Novidades do Sql Server 2016Roberto Fonseca
 
Funcionalidades Oracle
Funcionalidades OracleFuncionalidades Oracle
Funcionalidades Oracleharlycarreiro
 
Introdução a data warehouse e olap
Introdução a data warehouse e olapIntrodução a data warehouse e olap
Introdução a data warehouse e olapFlavia Martins Bispo
 
Introdução a data warehouse e olap
Introdução a data warehouse e olapIntrodução a data warehouse e olap
Introdução a data warehouse e olapFernando Palma
 
AulaTuningProfCeliniaEquipe_Igor Paula Maisa
AulaTuningProfCeliniaEquipe_Igor Paula MaisaAulaTuningProfCeliniaEquipe_Igor Paula Maisa
AulaTuningProfCeliniaEquipe_Igor Paula MaisaMaísa Brenda
 
364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf
364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf
364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdfQuitriaSilva550
 
Mapeamento brb 2013 em videoaulas do provas de ti google drive
Mapeamento brb 2013 em videoaulas do provas de ti   google driveMapeamento brb 2013 em videoaulas do provas de ti   google drive
Mapeamento brb 2013 em videoaulas do provas de ti google driveffabii
 
Plsql - Conceitos Básicos
Plsql - Conceitos BásicosPlsql - Conceitos Básicos
Plsql - Conceitos BásicosDanilo Braga
 
Isolamento e mvcc
Isolamento e mvccIsolamento e mvcc
Isolamento e mvccLocaweb
 
PL/SQL - Conceitos Básicos
PL/SQL - Conceitos BásicosPL/SQL - Conceitos Básicos
PL/SQL - Conceitos BásicosDanilo Braga
 
ODI Tutorial - Configuração Topologia
ODI Tutorial - Configuração TopologiaODI Tutorial - Configuração Topologia
ODI Tutorial - Configuração TopologiaCaio Lima
 
Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)
Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)
Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)Igor Abade
 
L'esprit de l'escalier
L'esprit de l'escalierL'esprit de l'escalier
L'esprit de l'escalierGleicon Moraes
 

Semelhante a Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs [USR12010] (20)

Novidades do Sql Server 2016
Novidades do Sql Server 2016Novidades do Sql Server 2016
Novidades do Sql Server 2016
 
Funcionalidades Oracle
Funcionalidades OracleFuncionalidades Oracle
Funcionalidades Oracle
 
Introdução a data warehouse e olap
Introdução a data warehouse e olapIntrodução a data warehouse e olap
Introdução a data warehouse e olap
 
Introdução a data warehouse e olap
Introdução a data warehouse e olapIntrodução a data warehouse e olap
Introdução a data warehouse e olap
 
Sql proficiente
Sql proficienteSql proficiente
Sql proficiente
 
AulaTuningProfCeliniaEquipe_Igor Paula Maisa
AulaTuningProfCeliniaEquipe_Igor Paula MaisaAulaTuningProfCeliniaEquipe_Igor Paula Maisa
AulaTuningProfCeliniaEquipe_Igor Paula Maisa
 
364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf
364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf
364722271-Modulo-III-Linguagem-SQL-Versao-Final.pdf
 
Mapeamento brb 2013 em videoaulas do provas de ti google drive
Mapeamento brb 2013 em videoaulas do provas de ti   google driveMapeamento brb 2013 em videoaulas do provas de ti   google drive
Mapeamento brb 2013 em videoaulas do provas de ti google drive
 
Plsql - Conceitos Básicos
Plsql - Conceitos BásicosPlsql - Conceitos Básicos
Plsql - Conceitos Básicos
 
Isolamento e mvcc
Isolamento e mvccIsolamento e mvcc
Isolamento e mvcc
 
PL/SQL - Conceitos Básicos
PL/SQL - Conceitos BásicosPL/SQL - Conceitos Básicos
PL/SQL - Conceitos Básicos
 
ODI Tutorial - Configuração Topologia
ODI Tutorial - Configuração TopologiaODI Tutorial - Configuração Topologia
ODI Tutorial - Configuração Topologia
 
Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)
Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)
Gestão de ciclo de vida de Banco de Dados: Já passou da hora! (TDC POA 2016)
 
Introdução ao BD Postgre
Introdução ao BD PostgreIntrodução ao BD Postgre
Introdução ao BD Postgre
 
Aula 05 acessando o mysql
Aula 05   acessando o mysqlAula 05   acessando o mysql
Aula 05 acessando o mysql
 
Tdc2015
Tdc2015Tdc2015
Tdc2015
 
Modulo 15 PSI
Modulo 15 PSIModulo 15 PSI
Modulo 15 PSI
 
L'esprit de l'escalier
L'esprit de l'escalierL'esprit de l'escalier
L'esprit de l'escalier
 
Apostila ib
Apostila ibApostila ib
Apostila ib
 
Db2
Db2Db2
Db2
 

Mais de Alex Zaballa

DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2Alex Zaballa
 
Moving your Oracle Databases to the Oracle Cloud
Moving your Oracle Databases to the Oracle CloudMoving your Oracle Databases to the Oracle Cloud
Moving your Oracle Databases to the Oracle CloudAlex Zaballa
 
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata  Expr...Oracle Database 12c Release 2 - New Features On Oracle Database Exadata  Expr...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...Alex Zaballa
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...Alex Zaballa
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 

Mais de Alex Zaballa (10)

DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
Moving your Oracle Databases to the Oracle Cloud
Moving your Oracle Databases to the Oracle CloudMoving your Oracle Databases to the Oracle Cloud
Moving your Oracle Databases to the Oracle Cloud
 
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata  Expr...Oracle Database 12c Release 2 - New Features On Oracle Database Exadata  Expr...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 

Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs [USR12010]

  • 1. Oracle Database 12c Novas Características para DBAs e Desenvolvedores Presented by: Alex Zaballa, Oracle DBA
  • 2. Alex Zaballa http://alexzaballa.blogspot.com/ @alexzaballa205 and counting… https://www.linkedin.com/in/alexzaballa
  • 3. Worked for 7 years in Brazil as an Oracle Developer. 2000 - 2007 Worked for 8 years in Angola as an Oracle DBA for the Ministry of Finance. 2007 - 2015
  • 4.
  • 5.
  • 6. Oracle Database 12c Novas Características para DBAs e Desenvolvedores
  • 7. Documentação Oficial - 12.1.0.2 • http://docs.oracle.com/database/121/NEWFT/ch apter12102.htm Oracle Learning Library (OLL) • https://apexapps.oracle.com/pls/apex/f?p=44785 :1:0
  • 8. Artigos – 12c • https://oracle-base.com/articles/12c/articles- 12c • http://www.oracle.com/technetwork/pt/articles/ index.html • http://profissionaloracle.com.br
  • 9. “With more than 500 new features, Oracle Database 12c is designed to give Oracle customers exactly what they’ve told us they need for cloud computing, big data, security, and availability.”
  • 10. Oracle Announces Beta Availability of Oracle Database 12c Release 2 - Oct 26, 2015 • PLUGGABLE DATABASES From 252 to 4096 • HOT CLONING Don’t need to put the source in read-only for cloning • SHARDING It’s like partitioning in a shared nothing database The data is split into multiple databases • In-Memory In-Memory column Store on Active Data Guard Heat Map • APPLICATION CONTAINER Pluggable Databases will share application objects • More isolation, resource manager will limit the memory in addition to CPU and I/O. • AWR will work on Active Data Guard Database: you can tune your reporting database
  • 11. Availability of Oracle Database 12.2 Source: https://blogs.oracle.com/UPGRADE/entry/oracle_database_12_2_just
  • 12. Oracle Database Release Status MOS Note:742060.1
  • 14. Devo migrar para 12.1.0.2 ou aguardar a 12.2 ? CDB ou NON-CDB?
  • 21. SIMD Vector Processing Fonte: http://www.oracle.com/technetwork/database/in-memory/overview/twp- oracle-database-in-memory-2245633.html
  • 22. In-Memory In-Memory Area – Pool estático que faz parte da SGA
  • 24. In-Memory Alter table hr.EMPLOYEES inmemory; ALTER TABLE sales MODIFY PARTITION SALES_Q1_1998 NO INMEMORY; ALTER TABLE sales INMEMORY NO INMEMORY(prod_id); CREATE TABLESPACE tbs_test DATAFILE '+DG01 SIZE 100M DEFAULT INMEMORY;
  • 26. insert /*+ append parallel */ into tab1 select /*+ parallel */ * from tab2 nologging; 15 minutes to complete. create table tab1 as select /*+ parallel */ * from tab2 nologging; 2 minutes to complete. Parallel
  • 30. JSON • No Oracle Database 12c (12.1.0.2), foi adicionado o suporte nativo ao JavaScript Object Notation (JSON). • O JSON é um formato leve para intercâmbio de dados que é relativamente fácil para o ser humano ler e escrever, além de ser fácil para os softwares analisarem e gerarem.
  • 31. JSON
  • 32. JSON
  • 33. DEMO
  • 34. Data Redaction Artigo no OTN: http://www.oracle.com/technetwork/pt/articles /idm/funcionalidade-data-redaction-12c- 2209076-ptb.html
  • 35. 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
  • 38. DEMO
  • 39. SQL Query Row Limits and Offsets
  • 40. 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);
  • 41. 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
  • 42. SQL Query Row Limits and Offsets select codigo, nome, salario from tabela_teste order by salario desc FETCH FIRST 5 ROWS ONLY
  • 43. SQL Query Row Limits and Offsets select codigo, nome, salario from tabela_teste order by salario FETCH FIRST 30 PERCENT ROWS ONLY
  • 44. SQL Query Row Limits and Offsets select codigo, nome, salario from tabela_teste order by salario desc OFFSET 2 ROWS FETCH NEXT 2 ROWS ONLY;
  • 45. DEMO
  • 46. Invisible Columns CREATE TABLE tabela_teste ( coluna1 NUMBER, coluna2 NUMBER, coluna3 NUMBER INVISIBLE, coluna4 NUMBER ); SQL> desc tabela_teste Name ----------------------------------------- COLUNA1 NUMBER COLUNA2 NUMBER COLUNA4 NUMBER
  • 47. Invisible Columns INSERT INTO tabela_teste (coluna1,coluna2,coluna3,coluna4) VALUES (1,2,3,4); INSERT INTO tabela_teste VALUES (1,2,4);
  • 48. Invisible Columns SET COLINVISIBLE ON SQL> desc tabela_teste Name ----------------------------------------- COLUNA1 NUMBER COLUNA2 NUMBER COLUNA4 NUMBER COLUNA3 (INVISIBLE) NUMBER
  • 49. Invisible Columns ALTER TABLE tabela_teste MODIFY coluna3 VISIBLE;
  • 50. DEMO
  • 51. SQL Text Expansion SQL> variable retorno clob SQL> begin dbms_utility.expand_sql_text( input_sql_text => 'select * from emp', output_sql_text=> :retorno ); end;
  • 52. SQL Text Expansion • Views • VPDs
  • 53. DEMO
  • 54. 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;
  • 55. DEMO
  • 56. Session Level Sequences Session level sequences são utilizadas para produzir valores únicos dentro de uma sessão. Assim que a sessão termina, a sequence é reinicializada. Elas são muito utilizadas para gerar valores de Primary Keys em Global Temporary Tables.
  • 57. Session Level Sequences CREATE SEQUENCE sequence_teste START WITH 1 INCREMENT BY 1 SESSION /
  • 58. Session Level Sequences ALTER SEQUENCE sequence_teste SESSION; ALTER SEQUENCE sequence_teste GLOBAL;
  • 59. DEMO
  • 60. Extended Data Types SQL> create table tabela_teste(campo01 varchar2(4001)); * ERROR at line 1: ORA-00910: specified length too long for its datatype
  • 61. Extended Data Types - VARCHAR2 : 32767 bytes - NVARCHAR2 : 32767 bytes - RAW : 32767 bytes
  • 62. Extended Data Types SHUTDOWN IMMEDIATE; STARTUP UPGRADE; ALTER SYSTEM SET max_string_size=extended; @?/rdbms/admin/utl32k.sql SHUTDOWN IMMEDIATE; STARTUP; **Após aumentar o tamanho máximo dos tipos de dados, não é possível desfazer esta alteração.
  • 63. DEMO
  • 64. Multiple Indexes on the same set of Columns Pré 12c: ORA-01408: such column list already indexed error.
  • 65. Multiple Indexes on the same set of Columns No 12c é possível ter vários índices em uma mesma coluna ou lista de colunas. A criação de um índice sobre uma coluna ou lista de colunas que já foram indexadas é simples e você tem que garantir que apenas um índice será visível.
  • 66. Multiple Indexes on the same set of Columns • Unique versus nonunique • B-tree versus bitmap • Different partitioning strategies
  • 67. DEMO
  • 68. READ Object Privilege and READ ANY TABLE System Privilege Qual a diferença para SELECT e SELECT ANY TABLE?
  • 69. READ Object Privilege and READ ANY TABLE System Privilege O privilégio de objeto SELECT e o privilégio de sistema SELECT ANY TABLE permitem bloquear as linhas de uma tabela através da execução das seguintes operações: LOCK TABLE table_name IN EXCLUSIVE MODE; SELECT ... FROM table_name FOR UPDATE;
  • 70. READ Object Privilege and READ ANY TABLE System Privilege SQL> grant select on scott.emp to teste; Grant succeeded. SQL> lock table scott.emp in exclusive mode; Table(s) Locked.
  • 71. READ Object Privilege and READ ANY TABLE System Privilege SQL> grant read on scott.emp to teste; Grant succeeded. SQL> lock table scott.emp in exclusive mode; lock table scott.emp in exclusive mode * ERROR at line 1: ORA-01031: insufficient privileges
  • 72. DEMO
  • 73. Session private statistics for Global Temporary Tables Até o 12c, as estatísticas para tabelas temporárias globais (GTTs) eram comuns para todas as sessões.
  • 74. Session private statistics for Global Temporary Tables SELECT DBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS') Stats FROM dual; STATS ------------------------------------------------------------------------------ SESSION
  • 75. Session private statistics for Global Temporary Tables BEGIN DBMS_STATS.set_global_prefs ( pname => 'GLOBAL_TEMP_TABLE_STATS', pvalue => 'SHARED'); END; / BEGIN DBMS_STATS.set_global_prefs ( pname => 'GLOBAL_TEMP_TABLE_STATS', pvalue => 'SESSION'); END; /
  • 76. Session private statistics for Global Temporary Tables BEGIN dbms_stats.set_table_prefs('SCOTT','GTT_TESTE','GLOB AL_TEMP_TABLE_STATS','SHARED'); END; BEGIN dbms_stats.set_table_prefs('SCOTT','GTT_TESTE','GLOB AL_TEMP_TABLE_STATS','SESSION'); END;
  • 77. DEMO
  • 78. Temporary Undo Uma Global Temporary Table armazena seus dados em uma temporary tablespace e estes dados são mantidos durante a transação ou durante toda a sessão (ON COMMIT DELETE ROWS ou ON COMMIT PRESERVE ROWS). Instruções DML em Global Temporary Tables não geram REDO, devido ao fato destes dados estarem armazenados em uma temporary tablespace, mas geram UNDO e isto sim implicará na geração de REDO.
  • 79. Temporary Undo alter session set temp_undo_enabled=true; **pode ser alterado a nível de banco de dados ou de sessão.
  • 80. DEMO
  • 81. Statistics During Loads O banco de dados irá coletar estatísticas automaticamente das tabelas durante os seguintes tipos de operações bulk load: - CREATE TABLE AS SELECT - INSERT INTO ... SELECT into an empty table using a direct path insert
  • 82. DEMO
  • 83. Partial Indexes for Partitioned Table • Você pode criar os índices (globais ou locais) para partições ou sub-partições específicas, isto é, os índices serão criados apenas para partições/sub-partições que você deseja. • Este recurso não é suportado para índices únicos, ou seja, para índices utilizados para impor restrições exclusivas.
  • 84. Partial Indexes for Partitioned Table
  • 85. DEMO
  • 86. SQL*Loader Express • No modo express, não é necessário criar o arquivo de controle. • O objetivo principal é salvar tempo e diminuir o esforço. • O express mode pode ser utilizado quando todas as colunas são do tipo character, number ou datetime
  • 87. SQL*Loader Express [oracle@oracle01 tmp]$ cat EMPRESA.dat 1,Empresa 1 2,Empresa 2 3,Empresa 3 4,Empresa 4 5,Empresa 5 6,Empresa 6 7,Empresa 7 8,Empresa 8 9,Empresa 9
  • 88. SQL*Loader Express [oracle@oracle01 tmp]$ sqlldr teste/teste TABLE=EMPRESA SQL*Loader: Release 12.1.0.1.0 - Production on Sat Jan 11 12:16:28 2014 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. Express Mode Load, Table: EMPRESA Path used: External Table, DEGREE_OF_PARALLELISM=AUTO Table EMPRESA: 9 Rows successfully loaded. Check the log files: EMPRESA.log EMPRESA_%p.log_xt for more information about the load.
  • 89. DEMO
  • 90. Truncate Cascade SQL> truncate table scott.dept; truncate table scott.dept * ERROR at line 1: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
  • 91. Truncate Cascade SQL> truncate table scott.dept cascade; Table truncated. A constraint deve ser do tipo ON DELETE CASCADE.
  • 92. DEMO
  • 93. Limit the PGA SQL> show parameter pga NAME TYPE VALUE -------------------------- ------------- ---------------------- pga_aggregate_limit big integer 2G
  • 94. Limit the PGA PGA_AGGREGATE_LIMIT é setado como default para o maior valor entre: - 2 GB (valor default) - 200% do valor do parâmetro PGA_AGGREGATE_TARGET - 3 MB multiplicado pelo valor do parâmetro PROCESSES
  • 95. Full Database Caching Este novo recurso permite armazenar todos os segmentos do banco de dados em memória (quando os segmentos forem acessados).
  • 96. DEMO
  • 97. Recuperando Tabelas com o RMAN • Utilizado para recuperação de tabelas/partições de um backup realizado pelo RMAN. • Este comando, diminui o tempo e a complexidade da restauração, permitindo a recuperação “point- in-time” apenas da tabela/partição, ao invés de toda tablespace como era nas versões anteriores. • É muito útil quando não temos informações suficientes no UNDO para utilizar o Flashback Table.
  • 98. Recuperando Tabelas com o RMAN 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'
  • 99. DEMO
  • 100. In-Database Archiving SQL> create table tabela_teste(coluna1 number) row archival; insert into tabela_teste values(1); insert into tabela_teste values(2); insert into tabela_teste values(3);
  • 102. In-Database Archiving update tabela_teste set ora_archive_state=DBMS_ILM.ARCHIVESTATENAME(1) where coluna1=3;
  • 103. In-Database Archiving alter session set row archival visibility=all;
  • 104. DEMO
  • 105. Heat Map, Automatic Data Optimization and ILM OTN - Artigo do Alex Zaballa e Daniel Da Meda http://www.oracle.com/technetwork/pt/articles /database-performance/ilm-e-automatic-data- optimization-2601873-ptb.html
  • 106. Heat Map, Automatic Data Optimization and ILM • Heat Map: Oracle Database 12c feature that stores system- generated data usage statistics at the block and segment levels. Automatically tracks modification and query timestamps at the row and segment levels. • Automatic Data Optimization (ADO): automatically moves and compresses data according to user-defined policies based on the information collected by Heat Map • ILM: Heat Map and Automatic Data Optimization make Oracle Database 12c ideal for implementing ILM
  • 107. Heat Map, Automatic Data Optimization and ILM Habilitando o Heat Map SQL> alter system set heat_map = on;
  • 108. Heat Map, Automatic Data Optimization and ILM As estatísticas de Heat Map visualizadas graficamente através do EM Cloud Control:
  • 109. Heat Map, Automatic Data Optimization and ILM Criando políticas ADO Comprimir a tablespace USER_DATA e todos os seus segmentos utilizando compressão OLTP após 30 dias de baixo acesso: ALTER TABLESPACE USER_DATA ILM ADD POLICY ROW STORE COMPRESS ADVANCED SEGMENT AFTER 30 DAYS OF LOW ACCESS;
  • 110. Heat Map, Automatic Data Optimization and ILM Criando políticas ADO Comprimir a tabela ORDER_ITEMS utilizando compressão OLTP após 90 dias sem modificações. ALTER TABLE ORDER_ITEMS ILM ADD POLICY ROW STORE COMPRESS ADVANCED GROUP AFTER 90 DAYS OF NO MODIFICATION;
  • 111. DEMO
  • 114. DEMO
  • 115. Direct SQL statement execution in RMAN Pré 12c: RMAN> SQL ‘SELECT sysdate FROM dual’; 12c: RMAN> SELECT sysdate FROM dual;
  • 116. DEMO
  • 117. Identity Columns CREATE TABLE tabela_teste ( id NUMBER GENERATED ALWAYS AS IDENTITY, coluna1 VARCHAR2(30));
  • 118. Identity Columns CREATE TABLE tabela_teste ( id NUMBER GENERATED BY DEFAULT AS IDENTITY, coluna1 VARCHAR2(30));
  • 119. Identity Columns CREATE TABLE tabela_teste ( id NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY, coluna1 VARCHAR2(30));
  • 120. DEMO
  • 121.