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.
DBA COMMANDS
AND CONCEPTS
THAT EVERY
DEVELOPER
SHOULD KNOW
Alex Zaballa
Copyright © 2016 Accenture All rights reserved. | 2
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa
https://www...
Copyright © 2016 Accenture All rights reserved. | 3
Worked for 3 years in Brazil as a Clipper/Delphi Developer (15 years o...
Copyright © 2016 Accenture All rights reserved. | 4
Copyright © 2016 Accenture All rights reserved. | 5
3 Membership Tiers
• Oracle ACE Director
• Oracle ACE
• Oracle ACE Ass...
Copyright © 2016 Accenture All rights reserved. | 6
Desenvolvedores
vs
DBAs
Copyright © 2016 Accenture All rights reserved. | 7
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
Initial beta with Java...
Copyright © 2016 Accenture All rights reserved. | 8
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
Copyright © 2016 Accenture All rights reserved. | 9
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
Copyright © 2016 Accenture All rights reserved. |
JSON
Oracle Database 12.1.0.2 has now native
support for JSON.
“JSON (Ja...
Copyright © 2016 Accenture All rights reserved. |
JSON
Copyright © 2016 Accenture All rights reserved. |
JSON
Copyright © 2016 Accenture All rights reserved. |
JSON
Copyright © 2016 Accenture All rights reserved. |
JSON
Copyright © 2016 Accenture All rights reserved. |
JSON
Copyright © 2016 Accenture All rights reserved. | 16
EXPLAIN PLAN
Copyright © 2016 Accenture All rights reserved. | 17
EXPLAIN PLAN
Are you using Explain Plan ?
Copyright © 2016 Accenture All rights reserved. | 18
EXPLAIN PLAN
Explain Plan Lies
Copyright © 2016 Accenture All rights reserved. | 19
EXPLAIN PLAN
Explain Plan just try to predict the Plan.
AUTOTRACE exp...
Copyright © 2016 Accenture All rights reserved. | 20
EXPLAIN PLAN
Explain plan is blind to:
• Bind Variable Peeking
• Adap...
Copyright © 2016 Accenture All rights reserved. | 21
EXPLAIN PLAN
Now what?
• DBMS_XPLAN.DISPLAY_CURSOR
• V$SQL_PLAN%
Copyright © 2016 Accenture All rights reserved. | 22
DBMS_XPLAN.DISPLAY_CURSOR
Copyright © 2016 Accenture All rights reserved. | 23
DBMS_XPLAN.DISPLAY_CURSOR
• SQL_ID
• CURSOR_CHILD_NO (default 0)
• FO...
Copyright © 2016 Accenture All rights reserved. | 24
DBMS_XPLAN
Copyright © 2016 Accenture All rights reserved. | 25
DBMS_XPLAN
• DISPLAY (from PLAN_TABLE)
• DISPLAY_CURSOR
• DISPLAY_AWR...
Copyright © 2016 Accenture All rights reserved. | 26
DBMS_XPLAN.DISPLAY_CURSOR
By Carlos Sierra
Copyright © 2016 Accenture All rights reserved. | 27
DBMS_XPLAN.DISPLAY_CURSOR
https://blogs.oracle.com/optimizer/entry/ho...
Copyright © 2016 Accenture All rights reserved. | 28
SQL MONITOR
Copyright © 2016 Accenture All rights reserved. | 29
SQL MONITOR
Copyright © 2016 Accenture All rights reserved. | 30
SQL MONITOR
• Oracle Enterprise Manager
• EM Database Express (12c)
•...
Copyright © 2016 Accenture All rights reserved. | 31
SQL MONITOR
select dbms_sqltune.report_sql_monitor(
sql_id => 'gjabwv...
Copyright © 2016 Accenture All rights reserved. | 32
SQLT / SQLTXPLAIN
Copyright © 2016 Accenture All rights reserved. | 33
SQLT / SQLTXPLAIN
SQLT Diagnostic Tool (Doc ID 215187.1)
Pros
• Oracl...
Copyright © 2016 Accenture All rights reserved. | 34
SQLD360
Copyright © 2016 Accenture All rights reserved. | 35
SQLD360
Copyright © 2016 Accenture All rights reserved. | 36
SQLD360
Copyright © 2016 Accenture All rights reserved. | 37
SQLD360
Copyright © 2016 Accenture All rights reserved. | 38
COST OF AN INDEX
Copyright © 2016 Accenture All rights reserved. | 39
COST OF AN INDEX
Copyright © 2016 Accenture All rights reserved. | 40
FULL TABLE SCAN
Copyright © 2016 Accenture All rights reserved. | 41
FULL TABLE SCAN
https://www.slideshare.net/MauroPagano3/
full-table-s...
Copyright © 2016 Accenture All rights reserved. | 42
FULL TABLE SCAN
https://www.slideshare.net/MauroPagano3/
full-table-s...
Copyright © 2016 Accenture All rights reserved. | 43
FULL TABLE SCAN
https://richardfoote.wordpress.com/2008/05/12/index-s...
Copyright © 2016 Accenture All rights reserved. | 44
FULL TABLE SCAN
https://richardfoote.wordpress.com/2008/05/12/index-s...
Copyright © 2016 Accenture All rights reserved. | 45
FULL TABLE SCAN
https://www.slideshare.net/MauroPagano3/
full-table-s...
Copyright © 2016 Accenture All rights reserved. | 46
FULL TABLE SCAN
• Not always good
• Not always bad
Copyright © 2016 Accenture All rights reserved. | 47
ANALYZING TABLES
Copyright © 2016 Accenture All rights reserved. | 48
ANALYZING TABLES
https://docs.oracle.com/cd/B19306_01/server.102/b142...
Copyright © 2016 Accenture All rights reserved. | 49
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. | 50
PENDING STATISTICS
We have the option of keeping the newly gathered s...
Copyright © 2016 Accenture All rights reserved. | 51
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. | 52
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. | 53
PENDING STATISTICS
If it’s ok:
Or:
Copyright © 2016 Accenture All rights reserved. | 54
RESTORE STATISTICS FROM HISTORY
Copyright © 2016 Accenture All rights reserved. | 55
RESTORE STATISTICS FROM HISTORY
Check the retention:
Default is 31 da...
Copyright © 2016 Accenture All rights reserved. | 56
RESTORE STATISTICS FROM HISTORY
Statistics available for the table:
Copyright © 2016 Accenture All rights reserved. | 57
RESTORE STATISTICS FROM HISTORY
Restore:
Copyright © 2016 Accenture All rights reserved. | 58
INVISIBLE INDEXES
Copyright © 2016 Accenture All rights reserved. | 59
INVISIBLE INDEXES
Copyright © 2016 Accenture All rights reserved. | 60
INVISIBLE INDEXES
OR
Copyright © 2016 Accenture All rights reserved. | 61
DBMS_SESSION.SLEEP() - 12.2
Copyright © 2016 Accenture All rights reserved. | 62
DBMS_LOCK.SLEEP()
DECLARE
v_start date;
v_end date;
BEGIN
v_start := ...
Copyright © 2016 Accenture All rights reserved. | 63
DBMS_SESSION.SLEEP() – 12.2
DECLARE
v_start date;
v_end date;
BEGIN
v...
Copyright © 2016 Accenture All rights reserved. | 64
PARALLEL DML
Copyright © 2016 Accenture All rights reserved. | 65
PARALLEL DML
create table tab1 as select * from tab2 where 1=2;
inser...
Copyright © 2016 Accenture All rights reserved. | 66
PARALLEL DML
Copyright © 2016 Accenture All rights reserved. | 67
PARALLEL DML
Copyright © 2016 Accenture All rights reserved. | 68
ORACLE FLASHBACK QUERY
Copyright © 2016 Accenture All rights reserved. | 69
ORACLE FLASHBACK QUERY
Retrieve old versions of procedures:
Copyright © 2016 Accenture All rights reserved. | 70
DBMS_APPLICATION_INFO
Copyright © 2016 Accenture All rights reserved. | 71
DBMS_APPLICATION_INFO
Allows programs to add information to the
V$SES...
Copyright © 2016 Accenture All rights reserved. | 72
DBMS_APPLICATION_INFO – PL/SQL
BEGIN
DBMS_APPLICATION_INFO.set_action...
Copyright © 2016 Accenture All rights reserved. | 73
DBMS_APPLICATION_INFO - JAVA
Connection conn = DriverManager.getConne...
Copyright © 2016 Accenture All rights reserved. | 74
SCHEMA MANAGEMENT
DDL WAIT OPTION
Copyright © 2016 Accenture All rights reserved. | 75
SCHEMA MANAGEMENT
DDL WAIT OPTION
SQL> alter table invoice add (code ...
Copyright © 2016 Accenture All rights reserved. | 76
SCHEMA MANAGEMENT
DDL WAIT OPTION
Parameter DDL_LOCK_TIMEOUT (default...
Copyright © 2016 Accenture All rights reserved. | 77
ADDING COLUMNS WITH A DEFAULT VALUE
Copyright © 2016 Accenture All rights reserved. | 78
ADDING COLUMNS WITH A DEFAULT VALUE
The table SALES is about 400 mill...
Copyright © 2016 Accenture All rights reserved. | 79
COUNT(1) VS COUNT(*)
Copyright © 2016 Accenture All rights reserved. | 80
COUNT(1) VS COUNT(*)
What is the difference between count(1) and coun...
Copyright © 2016 Accenture All rights reserved. | 81
12.1 AND 12.2
Copyright © 2016 Accenture All rights reserved. | 82
READ OBJECT PRIVILEGE AND READ ANY TABLE
SYSTEM PRIVILEGE
Copyright © 2016 Accenture All rights reserved. | 83
READ OBJECT PRIVILEGE AND READ ANY TABLE
SYSTEM PRIVILEGE
What is the...
Copyright © 2016 Accenture All rights reserved. | 84
READ OBJECT PRIVILEGE AND READ ANY TABLE
SYSTEM PRIVILEGE
SELECT and ...
Copyright © 2016 Accenture All rights reserved. | 85
READ OBJECT PRIVILEGE AND READ ANY TABLE
SYSTEM PRIVILEGE
SQL> grant ...
Copyright © 2016 Accenture All rights reserved. | 86
READ OBJECT PRIVILEGE AND READ ANY TABLE
SYSTEM PRIVILEGE
SQL> grant ...
Copyright © 2016 Accenture All rights reserved. | 87
EXTENDED DATA TYPES
Copyright © 2016 Accenture All rights reserved. | 88
EXTENDED DATA TYPES
SQL> create table tabela_teste(campo01 varchar2(4...
Copyright © 2016 Accenture All rights reserved. | 89
EXTENDED DATA TYPES
• VARCHAR2 : 32767 bytes
• NVARCHAR2 : 32767 byte...
Copyright © 2016 Accenture All rights reserved. | 90
EXTENDED DATA TYPES
SHUTDOWN IMMEDIATE;
STARTUP UPGRADE;
ALTER SYSTEM...
Copyright © 2016 Accenture All rights reserved. | 91
PL/SQL FROM SQL
Copyright © 2016 Accenture All rights reserved. | 92
PL/SQL FROM SQL
Copyright © 2016 Accenture All rights reserved. | 93
TEMPORARY UNDO
Copyright © 2016 Accenture All rights reserved. | 94
TEMPORARY UNDO
ALTER SESSION SET TEMP_UNDO_ENABLED = TRUE;
ALTER SYST...
Copyright © 2016 Accenture All rights reserved. | 95
LONGER IDENTIFIER NAMES
Copyright © 2016 Accenture All rights reserved. | 96
LONGER IDENTIFIER NAMES
Starting with Oracle Database 12c Release 2 (...
Copyright © 2016 Accenture All rights reserved. | 97
LONGER IDENTIFIER NAMES
Copyright © 2016 Accenture All rights reserved. | 98
LONGER IDENTIFIER NAMES
Copyright © 2016 Accenture All rights reserved. | 99
LONGER IDENTIFIER NAMES
Copyright © 2016 Accenture All rights reserved. | 100
PDB LOCKDOWN PROFILES
Copyright © 2016 Accenture All rights reserved. | 101
PDB LOCKDOWN PROFILES
A security mechanism to restrict operations th...
Copyright © 2016 Accenture All rights reserved. | 102
SQLCL
http://www.oracle.com/technetwork/developer-tools/sqlcl/downlo...
Copyright © 2016 Accenture All rights reserved. | 103
QUESTIONS?
Copyright © 2016 Accenture All rights reserved. | 104
Thank You
Slides Available: http://www.slideshare.net/
Upcoming SlideShare
Loading in …5
×

DBA Commands and Concepts That Every Developer Should Know

416 views

Published on

Persentation for Oracle Developer Tour 2017

Published in: Technology
  • Be the first to comment

DBA Commands and Concepts That Every Developer Should Know

  1. 1. DBA COMMANDS AND CONCEPTS THAT EVERY DEVELOPER SHOULD KNOW Alex Zaballa
  2. 2. Copyright © 2016 Accenture All rights reserved. | 2 Alex Zaballa http://alexzaballa.blogspot.com/ @alexzaballa https://www.linkedin.com/in/alexzaballa 275 and counting…
  3. 3. Copyright © 2016 Accenture All rights reserved. | 3 Worked for 3 years in Brazil as a Clipper/Delphi Developer (15 years old) 1997-1999 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. Copyright © 2016 Accenture All rights reserved. | 4
  5. 5. Copyright © 2016 Accenture All rights reserved. | 5 3 Membership Tiers • Oracle ACE Director • Oracle ACE • Oracle ACE Associate bit.ly/OracleACEProgram 500+ Technical Experts Helping Peers Globally Connect: Nominate yourself or someone you know: acenomination.oracle.com @oracleace Facebook.com/oracleaces oracle-ace_ww@oracle.com
  6. 6. Copyright © 2016 Accenture All rights reserved. | 6 Desenvolvedores vs DBAs
  7. 7. Copyright © 2016 Accenture All rights reserved. | 7 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2 Initial beta with JavaScript Stored Procedures http://www.oracle.com/technetwork/database/multiling ual-engine/overview/index.html
  8. 8. Copyright © 2016 Accenture All rights reserved. | 8 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
  9. 9. Copyright © 2016 Accenture All rights reserved. | 9 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
  10. 10. Copyright © 2016 Accenture All rights reserved. | 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/
  11. 11. Copyright © 2016 Accenture All rights reserved. | JSON
  12. 12. Copyright © 2016 Accenture All rights reserved. | JSON
  13. 13. Copyright © 2016 Accenture All rights reserved. | JSON
  14. 14. Copyright © 2016 Accenture All rights reserved. | JSON
  15. 15. Copyright © 2016 Accenture All rights reserved. | JSON
  16. 16. Copyright © 2016 Accenture All rights reserved. | 16 EXPLAIN PLAN
  17. 17. Copyright © 2016 Accenture All rights reserved. | 17 EXPLAIN PLAN Are you using Explain Plan ?
  18. 18. Copyright © 2016 Accenture All rights reserved. | 18 EXPLAIN PLAN Explain Plan Lies
  19. 19. Copyright © 2016 Accenture All rights reserved. | 19 EXPLAIN PLAN Explain Plan just try to predict the Plan. AUTOTRACE experiences a similar "problem”, especially when the SQL statement uses bind variables.
  20. 20. Copyright © 2016 Accenture All rights reserved. | 20 EXPLAIN PLAN Explain plan is blind to: • Bind Variable Peeking • Adaptive Features • Etc
  21. 21. Copyright © 2016 Accenture All rights reserved. | 21 EXPLAIN PLAN Now what? • DBMS_XPLAN.DISPLAY_CURSOR • V$SQL_PLAN%
  22. 22. Copyright © 2016 Accenture All rights reserved. | 22 DBMS_XPLAN.DISPLAY_CURSOR
  23. 23. Copyright © 2016 Accenture All rights reserved. | 23 DBMS_XPLAN.DISPLAY_CURSOR • SQL_ID • CURSOR_CHILD_NO (default 0) • FORMAT  TYPICAL = DEFAULT  ALL = TYPICAL + QB + PROJECTION + ALIAS + REMOTE  ADVANCED = ALL + OUTLINE + BINDS  ALLSTATS = IOSTATS + MEMSTATS (all executions)  ALLSTATS LAST (last execution)  ADAPTIVE (12c)
  24. 24. Copyright © 2016 Accenture All rights reserved. | 24 DBMS_XPLAN
  25. 25. Copyright © 2016 Accenture All rights reserved. | 25 DBMS_XPLAN • DISPLAY (from PLAN_TABLE) • DISPLAY_CURSOR • DISPLAY_AWR • DISPLAY_SQL_PLAN_BASELINE • DISPLAY_SQL_SET SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('sql_id',child,'ADVANCED'));
  26. 26. Copyright © 2016 Accenture All rights reserved. | 26 DBMS_XPLAN.DISPLAY_CURSOR By Carlos Sierra
  27. 27. Copyright © 2016 Accenture All rights reserved. | 27 DBMS_XPLAN.DISPLAY_CURSOR https://blogs.oracle.com/optimizer/entry/how_do_i_know_if /*+ gather_plan_statistics */ or Alter session set statistics_level = ALL
  28. 28. Copyright © 2016 Accenture All rights reserved. | 28 SQL MONITOR
  29. 29. Copyright © 2016 Accenture All rights reserved. | 29 SQL MONITOR
  30. 30. Copyright © 2016 Accenture All rights reserved. | 30 SQL MONITOR • Oracle Enterprise Manager • EM Database Express (12c) • SQL Developer • Linha de Comando
  31. 31. Copyright © 2016 Accenture All rights reserved. | 31 SQL MONITOR select dbms_sqltune.report_sql_monitor( sql_id => 'gjabwvvr07w09', report_level=>'ALL', type => 'ACTIVE') from dual;
  32. 32. Copyright © 2016 Accenture All rights reserved. | 32 SQLT / SQLTXPLAIN
  33. 33. Copyright © 2016 Accenture All rights reserved. | 33 SQLT / SQLTXPLAIN SQLT Diagnostic Tool (Doc ID 215187.1) Pros • Oracle Support Standard • Free (requires MOS account) • Comprehensive and mature Cons • Requires installation • HTML Tables (no charts)
  34. 34. Copyright © 2016 Accenture All rights reserved. | 34 SQLD360
  35. 35. Copyright © 2016 Accenture All rights reserved. | 35 SQLD360
  36. 36. Copyright © 2016 Accenture All rights reserved. | 36 SQLD360
  37. 37. Copyright © 2016 Accenture All rights reserved. | 37 SQLD360
  38. 38. Copyright © 2016 Accenture All rights reserved. | 38 COST OF AN INDEX
  39. 39. Copyright © 2016 Accenture All rights reserved. | 39 COST OF AN INDEX
  40. 40. Copyright © 2016 Accenture All rights reserved. | 40 FULL TABLE SCAN
  41. 41. Copyright © 2016 Accenture All rights reserved. | 41 FULL TABLE SCAN https://www.slideshare.net/MauroPagano3/ full-table-scan-friend-or-foe
  42. 42. Copyright © 2016 Accenture All rights reserved. | 42 FULL TABLE SCAN https://www.slideshare.net/MauroPagano3/ full-table-scan-friend-or-foe
  43. 43. Copyright © 2016 Accenture All rights reserved. | 43 FULL TABLE SCAN https://richardfoote.wordpress.com/2008/05/12/index-scan- or-full-table-scan-the-magic-number-magic-dance/
  44. 44. Copyright © 2016 Accenture All rights reserved. | 44 FULL TABLE SCAN https://richardfoote.wordpress.com/2008/05/12/index-scan- or-full-table-scan-the-magic-number-magic-dance/ • Clustering Factor  How well ordered the rows in the table are in relation to the index. • Selectivity of the query • Number of table blocks • Effective multiblock read count • Relative cost of single vs. multiblock I/Os • Parallelism • Etc
  45. 45. Copyright © 2016 Accenture All rights reserved. | 45 FULL TABLE SCAN https://www.slideshare.net/MauroPagano3/ full-table-scan-friend-or-foe
  46. 46. Copyright © 2016 Accenture All rights reserved. | 46 FULL TABLE SCAN • Not always good • Not always bad
  47. 47. Copyright © 2016 Accenture All rights reserved. | 47 ANALYZING TABLES
  48. 48. Copyright © 2016 Accenture All rights reserved. | 48 ANALYZING TABLES https://docs.oracle.com/cd/B19306_01/server.102/b14200/ statements_4005.htm
  49. 49. Copyright © 2016 Accenture All rights reserved. | 49 PENDING STATISTICS
  50. 50. Copyright © 2016 Accenture All rights reserved. | 50 PENDING STATISTICS We have the option of keeping the newly gathered statistics in a pending state for testing purposes, until you choose to publish them. Set table preferences: begin dbms_stats.set_table_prefs ( ownname => 'SCOTT', tabname => 'EMP', pname => 'PUBLISH', pvalue => 'FALSE' ); end; Collect the statistics.
  51. 51. Copyright © 2016 Accenture All rights reserved. | 51 PENDING STATISTICS
  52. 52. Copyright © 2016 Accenture All rights reserved. | 52 PENDING STATISTICS
  53. 53. Copyright © 2016 Accenture All rights reserved. | 53 PENDING STATISTICS If it’s ok: Or:
  54. 54. Copyright © 2016 Accenture All rights reserved. | 54 RESTORE STATISTICS FROM HISTORY
  55. 55. Copyright © 2016 Accenture All rights reserved. | 55 RESTORE STATISTICS FROM HISTORY Check the retention: Default is 31 days.
  56. 56. Copyright © 2016 Accenture All rights reserved. | 56 RESTORE STATISTICS FROM HISTORY Statistics available for the table:
  57. 57. Copyright © 2016 Accenture All rights reserved. | 57 RESTORE STATISTICS FROM HISTORY Restore:
  58. 58. Copyright © 2016 Accenture All rights reserved. | 58 INVISIBLE INDEXES
  59. 59. Copyright © 2016 Accenture All rights reserved. | 59 INVISIBLE INDEXES
  60. 60. Copyright © 2016 Accenture All rights reserved. | 60 INVISIBLE INDEXES OR
  61. 61. Copyright © 2016 Accenture All rights reserved. | 61 DBMS_SESSION.SLEEP() - 12.2
  62. 62. Copyright © 2016 Accenture All rights reserved. | 62 DBMS_LOCK.SLEEP() DECLARE v_start date; v_end date; BEGIN v_start := SYSDATE; -- Sleep for 10 seconds dbms_lock.sleep(10); v_end := SYSDATE; END; • Not granted to public • There are sensitive methods
  63. 63. Copyright © 2016 Accenture All rights reserved. | 63 DBMS_SESSION.SLEEP() – 12.2 DECLARE v_start date; v_end date; BEGIN v_start := SYSDATE; -- Sleep for 10 seconds DBMS_SESSION.SLEEP(10); v_end := SYSDATE; END; • DBMS_SESSION is granted to public
  64. 64. Copyright © 2016 Accenture All rights reserved. | 64 PARALLEL DML
  65. 65. Copyright © 2016 Accenture All rights reserved. | 65 PARALLEL DML create table tab1 as select * from tab2 where 1=2; 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.
  66. 66. Copyright © 2016 Accenture All rights reserved. | 66 PARALLEL DML
  67. 67. Copyright © 2016 Accenture All rights reserved. | 67 PARALLEL DML
  68. 68. Copyright © 2016 Accenture All rights reserved. | 68 ORACLE FLASHBACK QUERY
  69. 69. Copyright © 2016 Accenture All rights reserved. | 69 ORACLE FLASHBACK QUERY Retrieve old versions of procedures:
  70. 70. Copyright © 2016 Accenture All rights reserved. | 70 DBMS_APPLICATION_INFO
  71. 71. Copyright © 2016 Accenture All rights reserved. | 71 DBMS_APPLICATION_INFO Allows programs to add information to the V$SESSION. Use SET_MODULE to set the name for the program that the user is currently executing. Optionally you can also set an action name. Use SET_ACTION for subsequent processing. Use SET_CLIENT_INFO for any additional information.
  72. 72. Copyright © 2016 Accenture All rights reserved. | 72 DBMS_APPLICATION_INFO – PL/SQL BEGIN DBMS_APPLICATION_INFO.set_action(action_name => ’Calculating…'); DBMS_APPLICATION_INFO.set_client_info(client_info => ’by User: ’||v_user); END; /
  73. 73. Copyright © 2016 Accenture All rights reserved. | 73 DBMS_APPLICATION_INFO - JAVA Connection conn = DriverManager.getConnection(dbUrl, dbUser, dbPassword); conn.setClientInfo("OCSID.CLIENTID", ”My Client"); conn.setClientInfo("OCSID.MODULE", ”My Module"); conn.setClientInfo("OCSID.ACTION", ”My Action"); Statement stmt = conn.createStatement(); stmt.execute("INSERT INTO MyTab (Col1) VALUES (?)");
  74. 74. Copyright © 2016 Accenture All rights reserved. | 74 SCHEMA MANAGEMENT DDL WAIT OPTION
  75. 75. Copyright © 2016 Accenture All rights reserved. | 75 SCHEMA MANAGEMENT DDL WAIT OPTION SQL> alter table invoice add (code number); alter table invoice add (code number) * ERROR at line 1: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
  76. 76. Copyright © 2016 Accenture All rights reserved. | 76 SCHEMA MANAGEMENT DDL WAIT OPTION Parameter DDL_LOCK_TIMEOUT (default = 0) It will wait for N seconds. In that N seconds, it continually re-tries the DDL operation until it's successful or this time expires.
  77. 77. Copyright © 2016 Accenture All rights reserved. | 77 ADDING COLUMNS WITH A DEFAULT VALUE
  78. 78. Copyright © 2016 Accenture All rights reserved. | 78 ADDING COLUMNS WITH A DEFAULT VALUE The table SALES is about 400 million rows. 10.2.0.4.0  alter table sales add tax varchar2(2) default ‘XX’ not null; Elapsed: 00:41:00.00 11.2.0.4.0  alter table sales add tax varchar2(2) default ‘XX’ not null; Elapsed: 00:00:00.03
  79. 79. Copyright © 2016 Accenture All rights reserved. | 79 COUNT(1) VS COUNT(*)
  80. 80. Copyright © 2016 Accenture All rights reserved. | 80 COUNT(1) VS COUNT(*) What is the difference between count(1) and count(*) ? Nothing!
  81. 81. Copyright © 2016 Accenture All rights reserved. | 81 12.1 AND 12.2
  82. 82. Copyright © 2016 Accenture All rights reserved. | 82 READ OBJECT PRIVILEGE AND READ ANY TABLE SYSTEM PRIVILEGE
  83. 83. Copyright © 2016 Accenture All rights reserved. | 83 READ OBJECT PRIVILEGE AND READ ANY TABLE SYSTEM PRIVILEGE What is the difference to SELECT and SELECT ANY TABLE?
  84. 84. Copyright © 2016 Accenture All rights reserved. | 84 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;
  85. 85. Copyright © 2016 Accenture All rights reserved. | 85 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.
  86. 86. Copyright © 2016 Accenture All rights reserved. | 86 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
  87. 87. Copyright © 2016 Accenture All rights reserved. | 87 EXTENDED DATA TYPES
  88. 88. Copyright © 2016 Accenture All rights reserved. | 88 EXTENDED DATA TYPES SQL> create table tabela_teste(campo01 varchar2(4001)); * ERROR at line 1: ORA-00910: specified length too long for its datatype
  89. 89. Copyright © 2016 Accenture All rights reserved. | 89 EXTENDED DATA TYPES • VARCHAR2 : 32767 bytes • NVARCHAR2 : 32767 bytes • RAW : 32767 bytes
  90. 90. Copyright © 2016 Accenture All rights reserved. | 90 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
  91. 91. Copyright © 2016 Accenture All rights reserved. | 91 PL/SQL FROM SQL
  92. 92. Copyright © 2016 Accenture All rights reserved. | 92 PL/SQL FROM SQL
  93. 93. Copyright © 2016 Accenture All rights reserved. | 93 TEMPORARY UNDO
  94. 94. Copyright © 2016 Accenture All rights reserved. | 94 TEMPORARY UNDO ALTER SESSION SET TEMP_UNDO_ENABLED = TRUE; ALTER SYSTEM SET TEMP_UNDO_ENABLED = TRUE;
  95. 95. Copyright © 2016 Accenture All rights reserved. | 95 LONGER IDENTIFIER NAMES
  96. 96. Copyright © 2016 Accenture All rights reserved. | 96 LONGER IDENTIFIER NAMES Starting with Oracle Database 12c Release 2 (12.2), the maximum length of identifier names for most types of database objects has been increased to 128 bytes.
  97. 97. Copyright © 2016 Accenture All rights reserved. | 97 LONGER IDENTIFIER NAMES
  98. 98. Copyright © 2016 Accenture All rights reserved. | 98 LONGER IDENTIFIER NAMES
  99. 99. Copyright © 2016 Accenture All rights reserved. | 99 LONGER IDENTIFIER NAMES
  100. 100. Copyright © 2016 Accenture All rights reserved. | 100 PDB LOCKDOWN PROFILES
  101. 101. Copyright © 2016 Accenture All rights reserved. | 101 PDB LOCKDOWN PROFILES A security mechanism to restrict operations that are available to local users connected to a specified PDB.
  102. 102. Copyright © 2016 Accenture All rights reserved. | 102 SQLCL http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html
  103. 103. Copyright © 2016 Accenture All rights reserved. | 103 QUESTIONS?
  104. 104. Copyright © 2016 Accenture All rights reserved. | 104 Thank You Slides Available: http://www.slideshare.net/

×