Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Features for Developers and DBAs

51 views

Published on

OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Features for Developers and DBAs

Published in: Technology
  • Be the first to comment

  • Be the first to like this

OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Features for Developers and DBAs

  1. 1. Oracle Database 12c The Best Oracle Database 12c New Features for Developers and DBAs Presented by: Alex Zaballa, Oracle DBA
  2. 2. Alex Zaballa http://alexzaballa.blogspot.com/ @alexzaballa206 and counting… https://www.linkedin.com/in/alexzaballa
  3. 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. 4. Oracle Database 12c New Features for Developers and DBAs
  5. 5. Oracle Official Documentation 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
  6. 6. Articles about 12c • https://oracle-base.com/articles/12c/articles- 12c
  7. 7. “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.”
  8. 8. 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
  9. 9. Availability of Oracle Database 12.2 Source: https://blogs.oracle.com/UPGRADE/entry/oracle_database_12_2_just
  10. 10. Oracle Database Release Status MOS Note:742060.1
  11. 11. Upgrade to 12.1.0.2 or wait for 12.2 ? CDB ou NON-CDB?
  12. 12. Let’s start…
  13. 13. JSON OTN Article by Alex Zaballa http://www.oracle.com/technetwork/pt/articles /sql/json-oracle-database-12c-2378776- ptb.html
  14. 14. 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/
  15. 15. JSON
  16. 16. JSON
  17. 17. DEMO
  18. 18. Data Redaction OTN Article in English by Alex Zaballa http://www.oracle.com/technetwork/articles/d atabase/data-redaction-odb12c-2331480.html
  19. 19. 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
  20. 20. Data Redaction
  21. 21. Data Redaction
  22. 22. DEMO
  23. 23. Invisible Columns CREATE TABLE table_test_inv ( column1 NUMBER, column2 NUMBER, column3 NUMBER INVISIBLE, column4 NUMBER ); SQL> desc table_test_inv Name ----------------------------------------- COLUMN1 NUMBER COLUMN2 NUMBER COLUMN4 NUMBER
  24. 24. Invisible Columns INSERT INTO table_test_inv (column1,column2,column3,column4) VALUES (1,2,3,4); INSERT INTO table_test_inv VALUES (1,2,4);
  25. 25. Invisible Columns SET COLINVISIBLE ON SQL> desc table_test_inv Name ----------------------------------------- COLUMN1 NUMBER COLUMN2 NUMBER COLUMN4 NUMBER COLUMN3 (INVISIBLE) NUMBER
  26. 26. Invisible Columns ALTER TABLE table_test_inv MODIFY column3 VISIBLE; WHY ? You are preparing the changes on the database, but the application is not prepared yet. Select * from …... Insert into TABLE VALUES (......, ....., .....)
  27. 27. DEMO
  28. 28. 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;
  29. 29. SQL Text Expansion • Views • VPDs
  30. 30. DEMO
  31. 31. Extended Data Types SQL> create table table_test(column01 varchar2(4001)); * ERROR at line 1: ORA-00910: specified length too long for its datatype
  32. 32. Extended Data Types - VARCHAR2 : 32767 bytes - NVARCHAR2 : 32767 bytes - RAW : 32767 bytes
  33. 33. Extended Data Types SHUTDOWN IMMEDIATE; STARTUP UPGRADE; ALTER SYSTEM SET max_string_size=extended; @?/rdbms/admin/utl32k.sql SHUTDOWN IMMEDIATE; STARTUP; **Once you switch to extended data types you can't switch back
  34. 34. DEMO
  35. 35. Multiple Indexes on the same set of Columns Pre 12c: ORA-01408: such column list already indexed error.
  36. 36. Multiple Indexes on the same set of Columns Is the ability to create more than one index on the same set of columns in 12c. **Only one of these indexes can be visible at a time
  37. 37. Multiple Indexes on the same set of Columns Why would you want to do that? • Unique versus nonunique • B-tree versus bitmap • Different partitioning strategies
  38. 38. DEMO
  39. 39. READ Object Privilege and READ ANY TABLE System Privilege What is the difference to SELECT and SELECT ANY TABLE?
  40. 40. READ Object Privilege and READ ANY TABLE System Privilege SELECT and SELECT ANY TABLE provides the ability to lock rows: LOCK TABLE table_name IN EXCLUSIVE MODE; SELECT ... FROM table_name FOR UPDATE;
  41. 41. 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.
  42. 42. 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
  43. 43. DEMO
  44. 44. Statistics During Loads The ability to gather statistics automatically during bulk loads: - CREATE TABLE AS SELECT - INSERT INTO ... SELECT into an empty table using a direct path insert
  45. 45. DEMO
  46. 46. Partial Indexes for Partitioned Table • You can create local and global indexes on a subset of the partitions of a table, enabling more flexibility in index creation. • This feature is not supported for unique indexes, or for indexes used for enforcing unique constraints.
  47. 47. Partial Indexes for Partitioned Table
  48. 48. DEMO
  49. 49. SQL*Loader Express • You don't need to to write and test a SQL*Loader control file. • The benefit main is the savings for time and effort.
  50. 50. SQL*Loader Express [oracle@oracle01 tmp]$ cat EMP_TEST.dat 1,Emp 1 2,Emp 2 3,Emp 3 4,Emp 4 5,Emp 5 6,Emp 6 7,Emp 7 8,Emp 8 9,Emp 9
  51. 51. SQL*Loader Express [oracle@oracle01 tmp]$ sqlldr teste/teste TABLE=EMP_TEST 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: EMP_TEST Path used: External Table, DEGREE_OF_PARALLELISM=AUTO Table EMP_TEST: 9 Rows successfully loaded. Check the log files: EMP_TEST.log EMP_TEST_%p.log_xt for more information about the load.
  52. 52. DEMO
  53. 53. 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
  54. 54. Truncate Cascade SQL> truncate table scott.dept cascade; Table truncated. The constraint should be ON DELETE CASCADE.
  55. 55. DEMO
  56. 56. Limit the PGA SQL> show parameter pga NAME TYPE VALUE -------------------------- ------------- ---------------------- pga_aggregate_limit big integer 2G pga_aggregate_target ****
  57. 57. Limit the PGA PGA_AGGREGATE_LIMIT is set to the greater of: - 2 GB (default value) - 200% of PGA_AGGREGATE_TARGET - 3 MB times the PROCESSES parameter
  58. 58. Full Database Caching Can be used to cache the entire database in memory. It should be used when the buffer cache size of the database instance is greater than the whole database size.
  59. 59. RMAN Table Recovery in 12c RMAN enables you to recover one or more tables or table partitions to a specified point in time.
  60. 60. 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'
  61. 61. In-Database Archiving SQL> create table table_test(column1 number) row archival; insert into table_test values(1); insert into table_test values(2); insert into table_test values(3);
  62. 62. In-Database Archiving
  63. 63. In-Database Archiving update table_test set ora_archive_state=DBMS_ILM.ARCHIVESTATENAME(1) where column1=3;
  64. 64. In-Database Archiving alter session set row archival visibility=all;
  65. 65. Heat Map, Automatic Data Optimization and ILM OTN Article in Portuguese by Daniel Da Meda and Alex Zaballa http://www.oracle.com/technetwork/pt/articles /database-performance/ilm-e-automatic-data- optimization-2601873-ptb.html
  66. 66. 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
  67. 67. Heat Map, Automatic Data Optimization and ILM Enabling Heat Map SQL> alter system set heat_map = on;
  68. 68. Heat Map, Automatic Data Optimization and ILM Heat Map statistics can be viewed graphically through EM Cloud Control:
  69. 69. Heat Map, Automatic Data Optimization and ILM Creating ADO policies Compress the tablespace USER_DATA and all its residing segments at OLTP level after 30 days of low access: ALTER TABLESPACE USER_DATA ILM ADD POLICY ROW STORE COMPRESS ADVANCED SEGMENT AFTER 30 DAYS OF LOW ACCESS;
  70. 70. Heat Map, Automatic Data Optimization and ILM Creating ADO policies Compress the table ORDER_ITEMS including any SecureFile LOBs at OLTP level after 90 days of no modification: ALTER TABLE ORDER_ITEMS ILM ADD POLICY ROW STORE COMPRESS ADVANCED GROUP AFTER 90 DAYS OF NO MODIFICATION;
  71. 71. DDL LOGGING
  72. 72. DDL LOGGING /u01/app/oracle/diag/rdbms/orcl/orcl/log/ddl/log.xml
  73. 73. Direct SQL statement execution in RMAN Pre - 12c: RMAN> SQL ‘SELECT sysdate FROM dual’; 12c: RMAN> SELECT sysdate FROM dual;
  74. 74. Session private statistics for Global Temporary Tables Pre 12c, statistics gathered for global temporary tables (GTTs) were common to all sessions.
  75. 75. Session private statistics for Global Temporary Tables On 12c, by default session-private statistics are enabled SELECT DBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS') FROM dual; STATS ------------------------------------------------------------------------------ SESSION
  76. 76. Session private statistics for Global Temporary Tables How to change? Behavior pre 12c: BEGIN DBMS_STATS.set_global_prefs ( pname => 'GLOBAL_TEMP_TABLE_STATS', pvalue => 'SHARED'); END; / Back to default on 12c: BEGIN DBMS_STATS.set_global_prefs ( pname => 'GLOBAL_TEMP_TABLE_STATS', pvalue => 'SESSION'); END; /
  77. 77. Session private statistics for Global Temporary Tables How to change for one table? BEGIN dbms_stats.set_table_prefs('SCOTT','GTT_TEST', 'GLOBAL_TEMP_TABLE_STATS','SHARED'); END; BEGIN dbms_stats.set_table_prefs('SCOTT','GTT_TEST', 'GLOBAL_TEMP_TABLE_STATS’,’SESSION'); END;
  78. 78. DEMO
  79. 79. Temporary Undo Global Temporary Tables (GTT) hold the data in a temporary tablespace. The data in GTTs are either deleted after commit or kept until the session is connected depending of the definition of the GTT.(ON COMMIT PRESERVE OR DELETE ROWS ). DMLs in a Global Temporary Tables do not generate REDO, but generate UNDO and this will result in REDO generating.
  80. 80. Temporary Undo alter session set temp_undo_enabled=true; **you can change for the session or for the database.
  81. 81. DEMO
  82. 82. Identity Columns CREATE TABLE tabela_teste ( id NUMBER GENERATED ALWAYS AS IDENTITY, coluna1 VARCHAR2(30) );
  83. 83. Identity Columns CREATE TABLE tabela_teste ( id NUMBER GENERATED BY DEFAULT AS IDENTITY, coluna1 VARCHAR2(30) );
  84. 84. Identity Columns CREATE TABLE tabela_teste ( id NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY, coluna1 VARCHAR2(30) );
  85. 85. SQL Query Row Limits and Offsets
  86. 86. SQL Query Row Limits and Offsets
  87. 87. SQL Query Row Limits and Offsets Top-N Queries – Pré 12c
  88. 88. SQL Query Row Limits and Offsets
  89. 89. SQL Query Row Limits and Offsets
  90. 90. SQL Query Row Limits and Offsets
  91. 91. DEMO
  92. 92. PL/SQL From SQL with 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;
  93. 93. 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.
  94. 94. Session Level Sequences CREATE SEQUENCE sequence_test START WITH 1 INCREMENT BY 1 SESSION /
  95. 95. Session Level Sequences ALTER SEQUENCE sequence_test SESSION; ALTER SEQUENCE sequence_test GLOBAL;
  96. 96. Multitenant
  97. 97. Fonte: Oracle Documentation
  98. 98. Multitenant Fonte: https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle
  99. 99. Multitenant Fonte: https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle
  100. 100. Multitenant Fonte: https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle
  101. 101. In-Memory Fonte: Oracle Documentation
  102. 102. SIMD Vector Processing Fonte: http://www.oracle.com/technetwork/database/in-memory/overview/twp- oracle-database-in-memory-2245633.html
  103. 103. In-Memory In-Memory Area – a static pool in SGA
  104. 104. In-Memory Fonte: OracleBase.com
  105. 105. In-Memory Alter table hr.EMPLOYEES inmemory; ALTER TABLE sales MODIFY PARTITION SALES_Q1_1998 INMEMORY; ALTER TABLE sales INMEMORY NO INMEMORY(prod_id); CREATE TABLESPACE tbs_test DATAFILE '+DG01 SIZE 100M DEFAULT INMEMORY;
  106. 106. In-Memory Fonte: http://www.oracle.com/technetwork/database/in-memory/overview/twp- oracle-database-in-memory-2245633.html
  107. 107. SQLcl http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
  108. 108. Thank You Slides Available: http://www.slideshare.net/

×