SlideShare a Scribd company logo
DBA Commands and Concepts That
Every Developer Should Know
Part 2
Alex Zaballa
DBA Commands and Concepts That
Every Developer Should Know
Part 2
Palestrante
DBA Commands and Concepts That
Every Developer Should Know
Part 2
Alex Zaballa
2
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa
https://www.linkedin.com/in/alexzaballa
275 and counting…
3
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa
https://www.linkedin.com/in/alexzaballa
275 and counting…
4
5 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
Before start….
7
Oracle Database Multilingual Engine – Beta 12.2
Initial beta with JavaScript Stored Procedures
http://www.oracle.com/technetwork/database/multilingua
l-engine/overview/index.html
8
Oracle Database Multilingual Engine – Beta 12.2
9
Oracle Database Multilingual Engine – Beta 12.2
10
http://www.oracle.com/technetwork/pt/articles/database-
performance/odb-12-2-multilingual-4394909-ptb.html
Oracle Database Multilingual Engine – Beta 12.2
11
https://livesql.oracle.com
12
13
Oracle Database 18c is NOT an Autonomous Database!
https://oracle-base.com/blog/2018/01/03/oracle-database-18c-is-not-an-autonomous-database/
14
Autonomous Database - DW
https://juliandontcheff.wordpress.com/2018/03/28/dba-internals-of-the-oracle-autonomous-database/
“You cannot create indexes on columns, you cannot partition
tables, you cannot create materialized views, etc. Not even
database links. You will get an error message: ORA-00439:
feature not enabled: Partitioning or ORA-01031: insufficient
privileges.”
15
Let’s begin….
16
count(1) vs count(*)
What is the difference between count(1) and count(*) ?
17
Nothing
count(1) vs count(*)
18
count(1) vs count(*)
19
Should you gather System Statistics?
https://blogs.oracle.com/optimizer/should-you-gather-system-statistics
20
Is this developer related?
21
Should you gather System Statistics?
22
Should you gather System Statistics?
23
Should you gather System Statistics?
“There is an exceptional case to consider. Databases supporting a pure data
warehouse workload on an Oracle Exadata Database Machine can benefit
from system statistics gathered using the EXADATA option.”
24
MBRC
Should I change DB_FILE_MULTIBLOCK_READ_COUNT?
25
Is this developer related?
26
MBRC
27
MBRC
28
MBRC
“Oracle recommends using the default unset value, which allows the
Optimizer to calculate the cost as a value of 8, but to use the maximum I/O
request size (usually 1MB) during Full Scan operations.
Starting with Oracle 10gR2, the CBO can automatically determine an
optimal value for the environment.
Setting MBRC to any value makes CBO to use such value but also limits the
number of blocks Oracle can read at once. If the parameter is unset, the
optimizer uses maximum I/O request size up to 128 (usually 1MB) during
Full Scan operations.”
29
MBRC + SYSTEM STATS + EXADATA
EXEC DBMS_STATS.GATHER_SYSTEM_STATS(‘EXADATA’);
***Most of the time the FULL TABLE SCAN is more performant than an INDEX SCAN on
Exadata
Why?
Smartscan
30
MBRC + SYSTEM STATS + EXADATA
Exadata + DW:
• Do not set MBRC
• Collect system stats in Exadata mode
Exadata + OLTP:
• Do not set MBRC
• Do not collect system stats
31
MBRC + SYSTEM STATS
Regular Database + DW:
• Do not set MBRC
• Do not collect system stats
Regular Database + OLTP :
• Do not set MBRC
• Do not collect system stats
*****
32
List of valid values for Oracle Database parameters
33
List of valid values for Oracle Database parameters
34
35
List of valid values for Oracle Database parameters
How about hidden parameters?
36
List of valid values for Oracle Database parameters
37
List of valid values for Oracle Database parameters
38
Parameter values – Another session
39
Parameter values – Another session
40
41
42
List of valid values for Oracle Database parameters
Not optimizer related?
43
List of valid values for Oracle Database parameters
44
List of valid values for Oracle Database parameters
45
46
Row-by-row
47
Row-by-row
https://blog.jooq.org/2018/04/19/the-performance-difference-between-sql-row-by-row-updating-batch-updating-and-bulk-updating/
48
Row-by-row
49
Row-by-row
50
PL/SQL FORALL
51
One Update
52
Tom Kyte
53
Analyzing Tables
54
Analyzing Tables
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4005.htm
55
Cost of an Index
56
Cost of an Index
57
How about Explain Plan?
58
Explain Plain lies!
59
Explain Plan
It does not actually execute the SQL statement.
Runtime factors can influence choice of plan:
• Dynamic Sampling
• Bind Variable Peeking
• Adaptive Features
60
Now what?
• DBMS_XPLAN.DISPLAY_CURSOR
• V$SQL_PLAN%
61
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)
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBMS_XPLAN
Display plan for the last SQL executed:
select * from table(dbms_xplan.display_cursor());
Display plan for one specific SQL
Get SQL_ID:
SQL_ID - 18C
DBA Commands and Concepts That Every Developer Should Know - Part 2
SQL MONITOR
• Introduced in Oracle Database 11g.
• Automatically started when a SQL statement either runs in
parallel or has consumed at least 5 seconds of combined CPU
and I/O.
• Hint /*+ MONITOR */
• Oracle Enterprise Manager
• EM Database Express (12c)
• SQL Developer
• Command Line
**Part of the Oracle Tuning Pack
SQL MONITOR
•select dbms_sqltune.report_sql_monitor(
• sql_id => 'gjabwvvr07w09',
• report_level=>'ALL',
• type => 'ACTIVE') from dual;
SQL MONITOR
SQL MONITOR
SQL MONITOR
72
SQLT (SQLTXPLAIN) Diagnostic Tool
(Doc ID 215187.1)
• Pros: Supported by Oracle
• Cons: Requires Installation
73
SQLT (SQLTXPLAIN) Diagnostic Tool
(Doc ID 215187.1)
74
SQLD360
• Pros: No Installation
• Cons: Might miss some information under
rare circumstances
75
SQLTXPLAIN vs SQLd360
https://mauro-pagano.com/2017/04/29/sqltxplain-vs-sqld360-differences-and-similarities/
76
SQLD360 – how to USE
• Download the free tool:
https://github.com/mauropagano/sqld360/
• Execution:
SQL> sqld360.sql <sql_id> [N|D|T]
77
SQLD360
78
SQLD360
79
SQLD360
80
SQLD360
81
If you want to know more:
https://mauro-pagano.com/category/sqld360/
SQLD360
82
Full table scan
83
Full table scan
https://www.slideshare.net/MauroPagano3/
full-table-scan-friend-or-foe
84
https://www.slideshare.net/MauroPagano3/
full-table-scan-friend-or-foe
Full table scan
85
https://richardfoote.wordpress.com/2008/05/12/index-scan-
or-full-table-scan-the-magic-number-magic-dance/
Full table scan
86
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
Full table scan
87
https://www.slideshare.net/MauroPagano3/
full-table-scan-friend-or-foe
Full table scan
88
• Not always good
• Not always bad
Full table scan
89
Pending Statistics
90
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.
91
Pending Statistics
92
Pending Statistics
93
If it’s ok:
Or:
Pending Statistics
94
Restore Statistics from History
95
Restore Statistics from History
Check the retention:
Default is 31 days.
96
Statistics available for the table:
Restore Statistics from History
97
Restore:
Restore Statistics from History
98
Invisible Indexes
99
Invisible Indexes
100
OR
Invisible Indexes
101
PARALLEL DML
102
PARALLEL DML
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.
103
PARALLEL DML
104
PARALLEL DML
105
Oracle Flashback Query
106
Oracle Flashback Query
Retrieve old versions of procedures:
107
DBMS_APPLICATION_INFO
108
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.
109
Schema Management
DDL Wait Option
110
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
111
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.
Schema Management
DDL Wait Option
112
Adding Columns with a Default Value
113
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
114
12.1 and 12.2
115
READ Object Privilege and READ ANY TABLE System
Privilege
116
READ Object Privilege and READ ANY TABLE System
Privilege
What is the difference to SELECT and SELECT ANY TABLE?
117
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;
118
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.
119
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
READ Object Privilege and READ ANY TABLE System
Privilege
120
Extended Data Types
121
Extended Data Types
SQL> create table tabela_teste(campo01 varchar2(4001));
*
ERROR at line 1:
ORA-00910: specified length too long for its datatype
122
Extended Data Types
• VARCHAR2 : 32767 bytes
• NVARCHAR2 : 32767 bytes
• RAW : 32767 bytes
123
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
124
PL/SQL From SQL
125
PL/SQL From SQL
126
Temporary Undo
127
Temporary Undo
ALTER SESSION SET TEMP_UNDO_ENABLED = TRUE;
ALTER SYSTEM SET TEMP_UNDO_ENABLED = TRUE;
128
Longer Identifier Names
129
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.
130
Longer Identifier Names
131
Longer Identifier Names
132
Longer Identifier Names
133
PDB LOCKDOWN PROFILES
134
PDB LOCKDOWN PROFILES
A security mechanism to restrict operations that are available to
local users connected to a specified PDB.
135
Questions?
136
Questions?
137
Thank You
Slides Available: http://www.slideshare.net/

More Related Content

PPTX
Oracle Database 12c - Data Redaction
PPTX
Oracle Data Redaction
PPTX
Oracle Database 12.1.0.2 New Features
PPTX
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
PPT
Oracle SQL Tuning
PPTX
Oracle Data Redaction - EOUC
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PPTX
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c - Data Redaction
Oracle Data Redaction
Oracle Database 12.1.0.2 New Features
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle SQL Tuning
Oracle Data Redaction - EOUC
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...

What's hot (17)

PPTX
Oracle Database 12c - New Features for Developers and DBAs
PDF
Performance Schema for MySQL troubleshooting
PPTX
DBA Commands and Concepts That Every Developer Should Know
PPTX
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
PPTX
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PDF
Mini Session - Using GDB for Profiling
PDF
In Search of Plan Stability - Part 1
PPTX
Oracle Data Redaction
PPTX
Oracle Data Redaction - UKOUG - TECH14
PDF
MySQL Troubleshooting with the Performance Schema
PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
PDF
DOAG - Oracle Database Locking Mechanism Demystified
PPT
Using AWR for SQL Analysis
PPT
Top 10 Oracle SQL tuning tips
PDF
Think Exa!
Oracle Database 12c - New Features for Developers and DBAs
Performance Schema for MySQL troubleshooting
DBA Commands and Concepts That Every Developer Should Know
Flex Cluster e Flex ASM - GUOB Tech Day - OTN TOUR LA Brazil 2014
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
Mini Session - Using GDB for Profiling
In Search of Plan Stability - Part 1
Oracle Data Redaction
Oracle Data Redaction - UKOUG - TECH14
MySQL Troubleshooting with the Performance Schema
In Memory Database In Action by Tanel Poder and Kerry Osborne
DOAG - Oracle Database Locking Mechanism Demystified
Using AWR for SQL Analysis
Top 10 Oracle SQL tuning tips
Think Exa!
Ad

Similar to DBA Commands and Concepts That Every Developer Should Know - Part 2 (20)

PPTX
DBA Commands and Concepts That Every Developer Should Know
PPTX
DBA Commands and Concepts That Every Developer Should Know
PPTX
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
PPTX
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
PDF
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
PPTX
Advanced Database Administration 10g
PDF
Advanced tips for making Oracle databases faster
PPTX
SQL TUNING 101
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PPTX
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
PPTX
Oracle Query Optimizer - An Introduction
PPTX
Oracle database 12.2 new features
PDF
31063115_1679409488310Developer_Tuning_Tips_-_UTOUG_Mar_2023.pdf
PDF
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
PPTX
OpenWorld 2018 - 20 years of hints and tips
PPTX
Oracle performance tuning_sfsf
PDF
O_Need-for-Speed_Top-Five-Oracle-Performance-Tuning-Tips_NYOUG.pdf
PPTX
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
PPTX
Oracle database performance tuning
PDF
Optimizer Statistics
DBA Commands and Concepts That Every Developer Should Know
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
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
Advanced Database Administration 10g
Advanced tips for making Oracle databases faster
SQL TUNING 101
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Understanding Query Optimization with ‘regular’ and ‘Exadata’ Oracle
Oracle Query Optimizer - An Introduction
Oracle database 12.2 new features
31063115_1679409488310Developer_Tuning_Tips_-_UTOUG_Mar_2023.pdf
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
OpenWorld 2018 - 20 years of hints and tips
Oracle performance tuning_sfsf
O_Need-for-Speed_Top-Five-Oracle-Performance-Tuning-Tips_NYOUG.pdf
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle database performance tuning
Optimizer Statistics
Ad

More from Alex Zaballa (6)

PDF
Oracle SQL Tuning
PDF
Moving your Oracle Databases to the Oracle Cloud
PPTX
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
PDF
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
PDF
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
PPTX
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...
Oracle SQL Tuning
Moving your Oracle Databases to the Oracle Cloud
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
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...
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Electronic commerce courselecture one. Pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Modernizing your data center with Dell and AMD
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Sensors and Actuators in IoT Systems using pdf
Electronic commerce courselecture one. Pdf
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reach Out and Touch Someone: Haptics and Empathic Computing
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Modernizing your data center with Dell and AMD

DBA Commands and Concepts That Every Developer Should Know - Part 2

Editor's Notes

  • #78: No installation Free
  • #83: Injustiça
  • #108: Especialmente para aplicações WEB
  • #114: Alguns desenvolvedores continuam adicionando como null, depois fazer update e depois colocam not null