otn tour 2016 - dba commands and concepts that every developer should know
TRANSCRIPT
![Page 1: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/1.jpg)
DBA Commands and Concepts That Every Developer Should
Know
Presented by: Alex Zaballa, Oracle DBA
![Page 2: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/2.jpg)
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa206 and counting…https://www.linkedin.com/in/alexzaballa
![Page 3: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/3.jpg)
Worked for 7 years in Brazil as an Oracle Developer.2000 - 2007
Worked for 8 years in Angola as an Oracle DBAfor the Ministry of Finance.2007 - 2015
![Page 4: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/4.jpg)
![Page 5: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/5.jpg)
Availability of Oracle Database 12.2
![Page 6: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/6.jpg)
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
![Page 7: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/7.jpg)
Availability of Oracle Database 12.2
Source: https://blogs.oracle.com/UPGRADE/entry/oracle_database_12_2_just
![Page 8: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/8.jpg)
Oracle Database Release StatusMOS Note:742060.1
![Page 9: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/9.jpg)
DBA Commands and Concepts That Every Developer Should Know
![Page 10: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/10.jpg)
No DBA access to the Database?
![Page 11: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/11.jpg)
No DBA access to the Database?
eDB360 sample
![Page 12: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/12.jpg)
No DBA access to the Database?
![Page 13: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/13.jpg)
No DBA access to the Database?
SQLD360 sample
![Page 14: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/14.jpg)
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
![Page 15: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/15.jpg)
Parallel
Source: https://docs.oracle.com/database/121/VLDBG/GUID-5EB01FA8-030B-45BB-9B16-2D13881F6010.htm
![Page 16: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/16.jpg)
Parallel
![Page 17: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/17.jpg)
Parallel
Update I$_2258193201set IND_UPDATE = 1where exists (
select 1from XX Twhere I$_2258193201.X_REF_DT = T.X_REF_DTand I$_2258193201XX.X_ACCT_KEY =
T.X_ACCT_KEY);
60 minutes to complete.
![Page 18: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/18.jpg)
Parallel
Update /*+ PARALLEL */ I$_2258193201_NEW I$_2258193201set IND_UPDATE = 1where exists (
select /*+ PARALLEL */ 1from XX_NEW Twhere I$_2258193201.X_REF_DT = T.X_REF_DTand I$_2258193201XX.X_ACCT_KEY =
T.X_ACCT_KEY);
3 minutes to complete.
***Duplicate tables “_NEW”
![Page 19: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/19.jpg)
Parallel
Update /*+ PARALLEL */ I$_2258193201set IND_UPDATE = 1where exists (
select /*+ PARALLEL */ 1from XX Twhere I$_2258193201.X_REF_DT = T.X_REF_DTand I$_2258193201XX.X_ACCT_KEY =
T.X_ACCT_KEY);
240 minutes to complete.
![Page 20: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/20.jpg)
Parallel
Full Table Scan: db file scattered read
![Page 21: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/21.jpg)
Parallel
![Page 22: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/22.jpg)
Parallel
![Page 23: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/23.jpg)
Parallel
![Page 24: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/24.jpg)
Row chaining/Migration
"A migrated row is a row that was moved to another block due to an update making it too large to fit on its original block with the other rows there”
"Any table with a long/long raw will have chained rows”
"Any table with more than 255 columns will have chained rows”
"Any table whose rowsize exceeds the blocksize will have chained rows"
Increasing PCTFREE can help to avoid migrated rows.
![Page 25: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/25.jpg)
Explain Plan
How many people are using Explain Plan ?
![Page 26: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/26.jpg)
Explain Plan
Explain Plan Lies
![Page 27: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/27.jpg)
Explain Plan
Explain Plan just try to predict the Plan.
AUTOTRACE experiences a similar "problem”, especially when the SQL statement uses bind variables.
![Page 28: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/28.jpg)
Explain Plan
Solution ?
DBMS_XPLAN.DISPLAY_CURSOR
![Page 29: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/29.jpg)
DEMO
![Page 30: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/30.jpg)
Oracle Flashback Query
• Flashback Query (SELECT AS OF) AS OF TIMESTAMP
• Flashback Version Query VERSIONS BETWEEN { SCN | TIMESTAMP } start
AND end
• Flashback Transaction Query SELECT FROM flashback_transaction_query
![Page 31: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/31.jpg)
DEMO
![Page 32: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/32.jpg)
• Retrieve old versions of procedures:
select text from dba_source as of timestamp systimestamp - interval '5' minute where name='MY_PROC' order by line;
Oracle Flashback Query
![Page 33: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/33.jpg)
DEMO
![Page 34: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/34.jpg)
Oracle Flashback Query
The maximum available versions are dependent on the UNDO_RETENTION parameter.
The default is 900 seconds (15 minutes).
![Page 35: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/35.jpg)
Oracle Flashback Table
Reinstating an accidentally dropped table.
Parameter recyclebin = on (default).
![Page 36: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/36.jpg)
SELECT OWNER,OBJECT_NAME, ORIGINAL_NAME, TYPE, DROPTIMEFROM DBA_RECYCLEBIN WHERE ORIGINAL_NAME='TAB_TEST';
FLASHBACK TABLE TAB_TEST TO BEFORE DROP;
Oracle Flashback Table
![Page 37: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/37.jpg)
DEMO
![Page 38: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/38.jpg)
RMAN Table Recovery in 12c
RMAN enables you to recover one or more tables or table partitions to a specified point in time.
![Page 39: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/39.jpg)
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'
![Page 40: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/40.jpg)
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
![Page 41: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/41.jpg)
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.
![Page 42: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/42.jpg)
DEMO
![Page 43: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/43.jpg)
Schema ManagementAdding Columns with a Default Value
Table T1 3 millions rows
10.2.0.4.0 > alter table t1 add C_DDL number default 42 not null;Table altered.Elapsed: 00:00:48.53
11.2.0.3.0> alter table t1 add C_DDL number default 42 not null;Table altered.Elapsed: 00:00:00.04
http://www.oracle.com/technetwork/pt/articles/sql/otimizacao-comandos-ddl-oracle-11g-2226731-ptb.html
![Page 44: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/44.jpg)
DEMO
![Page 45: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/45.jpg)
Rollback
How much longer?
select * from v$session_longopswhere sid = sid_of_the_session_doing_rollback
![Page 46: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/46.jpg)
Rollback
Source: https://docs.oracle.com/cloud/latest/db121/REFRN/refrn30227.htm#REFRN30227
![Page 47: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/47.jpg)
RollbackSID : 26SERIAL# : 30832OPNAME : Transaction RollbackTARGET :TARGET_DESC : xid:0x000e.01c.00000012SOFAR : 1211TOTALWORK : 21244UNITS : BlocksSTART_TIME : 15-nov-2015 16:20:07LAST_UPDATE_TIME : 15-nov-2015 16:21:24TIME_REMAINING : 55ELAPSED_SECONDS : 5CONTEXT : 0MESSAGE : Transaction Rollback: .... USERNAME : alex_zaballaSQL_ADDRESS : 00000000DF79A840SQL_HASH_VALUE : 72257521SQL_ID : 4wv9a0h24x3zj
![Page 48: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/48.jpg)
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.
![Page 49: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/49.jpg)
Pending Statistics
select num_rows, to_char(last_analyzed,'dd/mm/rrrr hh24:mi:ss')from all_tab_pending_statswhere table_name = 'EMP';
![Page 50: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/50.jpg)
Pending Statistics
alter session set optimizer_use_pending_statistics = true;
Test the queries.
![Page 51: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/51.jpg)
Pending Statistics
If it’s ok:
dbms_stats.publish_pending_stats('SCOTT', 'EMP');
Or:
dbms_stats.delete_pending_stats(’SCOTT',’EMP');
![Page 52: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/52.jpg)
Restore Statistics from History
Check the retention:
select DBMS_STATS.GET_STATS_HISTORY_RETENTION from dual;
Default is 31 days.
![Page 53: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/53.jpg)
Restore Statistics from History
Statistics available for the table:
SELECT OWNER, TABLE_NAME, STATS_UPDATE_TIME FROM dba_tab_stats_historyWHERE table_name='MY_TABLE';
![Page 54: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/54.jpg)
Restore Statistics from History
Begin dbms_stats.restore_table_stats( 'SCOTT', 'EMP', ‘08-NOV-15 11.38.05.015640 AM +08:00’);End;
![Page 55: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/55.jpg)
Export and Import schema statisticsbegin dbms_stats.CREATE_STAT_TABLE( ownname=>user , stattab=>'MY_STATS_TABLE' );end;
begin dbms_stats.export_schema_stats( ownname=>user , stattab=>'MY_STATS_TABLE' , statid=>'CURRENT_STATS' );End;
EXPDP / IMPDP
begin dbms_stats.import_schema_stats( ownname=>user , stattab=>'MY_STATS_TABLE' , statid=>'CURRENT_STATS' );End;
![Page 56: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/56.jpg)
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.
![Page 57: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/57.jpg)
DEMO
![Page 58: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/58.jpg)
Row-by-Row Processing vs Bulk Processing
Instead of fetching a single row at a time it is possible to use the bulk features.
![Page 59: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/59.jpg)
DEMO
![Page 60: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/60.jpg)
Oracle Virtual Private Database (VPD)
• VPD enables you to create security policies to control database access at the row and column level.
• VPD adds a dynamic WHERE clause to a SQL statement.
• VPD enforces security directly on database tables, views, or synonyms.
![Page 61: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/61.jpg)
Oracle Virtual Private Database (VPD)
Original Select:
SELECT * FROM ORDERS;
VPD policy dynamically appends:
SELECT * FROM ORDERS WHERE COMPANY_ID = 1;
![Page 62: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/62.jpg)
DEMO
![Page 63: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/63.jpg)
More on 12c
![Page 64: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/64.jpg)
Extended Data Types
SQL> create table tabela_teste(campo01 varchar2(4001));*ERROR at line 1:ORA-00910: specified length too long for its datatype
![Page 65: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/65.jpg)
Extended Data Types
- VARCHAR2 : 32767 bytes- NVARCHAR2 : 32767 bytes- RAW : 32767 bytes
![Page 66: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/66.jpg)
Extended Data Types
SHUTDOWN IMMEDIATE;STARTUP UPGRADE;ALTER SYSTEM SET max_string_size=extended;@?/rdbms/admin/utl32k.sqlSHUTDOWN IMMEDIATE;STARTUP;
**Once you switch to extended data types you can't switch back
![Page 67: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/67.jpg)
SQL Text Expansion
SQL> variable retorno clobSQL> begin dbms_utility.expand_sql_text( input_sql_text => 'select * from emp', output_sql_text=> :retorno );end;
![Page 68: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/68.jpg)
SQL Text Expansion
• Views• VPDs
![Page 69: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/69.jpg)
DEMO
![Page 70: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/70.jpg)
Identity ColumnsCREATE TABLE tabela_teste ( id NUMBER GENERATED ALWAYS AS IDENTITY, coluna1 VARCHAR2(30));
![Page 71: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/71.jpg)
Identity Columns
CREATE TABLE tabela_teste ( id NUMBER GENERATED BY DEFAULT AS IDENTITY, coluna1 VARCHAR2(30));
![Page 72: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/72.jpg)
DEMO
![Page 73: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/73.jpg)
READ Object Privilege and READ ANY TABLE System Privilege
What is the difference to SELECT and SELECT ANY TABLE?
![Page 74: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/74.jpg)
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;
![Page 75: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/75.jpg)
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.
![Page 76: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/76.jpg)
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
![Page 77: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/77.jpg)
DEMO
![Page 78: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/78.jpg)
Virtual Columns
“Virtual columns appear to be normal table columns, but their values are derived rather than being stored on disc.”
![Page 79: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/79.jpg)
DEMO
![Page 80: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/80.jpg)
UTL_CALL_STACK
This package allow programmatic access to the call stack and error stack.
Before 12c: DBMS_UTILITY.FORMAT_CALL_STACK
![Page 81: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/81.jpg)
DEMO
![Page 82: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/82.jpg)
Online Table Redefinition (DBMS_REDEFINITION)
You can change the structure of a table that is already in use and is impossible to get a maintenance downtime.
![Page 83: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/83.jpg)
DEMO
![Page 84: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/84.jpg)
SQLcl
http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
![Page 85: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/85.jpg)
![Page 86: OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know](https://reader031.vdocument.in/reader031/viewer/2022022203/5872e7101a28abfa548b62f3/html5/thumbnails/86.jpg)
Thank You
Slides Available: http://www.slideshare.net/