2. About me…
• Senior Database Architect at OneNeck IT
Services Corporation (www.oneneck.com)
• More than 18 years of Oracle experience
• Author of Oracle11g OCA, Co-author of
Oracle10g (New Features), Oracle9i (SQL &
Admin) and Oracle8i (SQL & Admin) certification
guides published by Sybex/Wiley
• Published articles in Oracle Magazine, Oracle
Internals and Select Journal
• Oracle 7, 8i, 9i, 10g, 11g OCP Administrator
• Oracle Database SQL Certified Expert
3. The ERP Outsourcing Experts : Provide a comprehensive,
flexible suite of outsourcing solutions designed specifically to
help mid-market and public sector organizations
Over 130 customers and 66,000 users in 45 countries on
six continents ~ Over 950 customer sites supported
worldwide
98% Contract Renewal Rate over 13 years
and 13 years of profitability (since inception)
Ranked No. 1 ERP Management Outsourcer by
the Black Book of Outsourcing
Stop by Booth #939
4. Session Objectives
• Review Oracle11gR2 features for DBA
• Highlight Oracle11gR2 and 11gR1 behaviors
that are different from 10gR2.
• Discuss out-of-the-box features that can be
implemented easily [covered in the Enterprise
Edition Install].
• These are not the top features of 11gR1 and
11gR2 release.
5. Session Outline
• 11gR2 DB Features
– Includes Features in 11.2.0.2 [patchset 1]
• Installation & ASM Changes
– ASM is now Grid Infrastructure
– Patchset Installation
– Getting Started with Grid Infrastructure
• 11gR1 Features – Quick Review
• Paper includes more info with examples and
Oracle documentation reference for further
reading.
7. On Demand Segment Creation
• New segments for tables, indexes, LOB columns
created only when row added to segment.
• Partitioned tables & indexes added to this
feature in PS1.
• Improves space usage as well as large
application install time.
• DEFERRED_SEGMENT_CREATION parameter
controls this behavior.
• New column SEGMENT_CREATED in
DBA_TABLES, DBA_INDEXES.
11gR2
8. Remove & Add Empty Segments
• DBMS_SPACE_ADMIN package includes
programs to manage empty segments.
– DROP_EMPTY_SEGMENTS
– MATERIALIZE_DEFERRED_SEGMENTS
• Three arguments – schema name, table name
and partition name.
EXEC SYS.dbms_space_admin.drop_empty_segments
(schema_name=>'BTHOMAS', table_name=>'ODSEG_T1');
11gR2
9. Drop Segment in TRUNCATE
select segment_name, bytes
from user_segments
• By default, Oracle where segment_name like 'ODSEG%'
Database deallocates all or segment_name in
(select segment_name
space used except that from user_lobs);
specified by the SEGMENT_NAME BYTES
------------------------- ----------
MINEXTENTS storage ODSEG_T1 65536
ODSEG_T1_PK 65536
parameter. SYS_LOB0000097197C00003$$ 65536
• In Oracle Database 11g truncate table odseg_t1 drop all storage;
Table truncated.
Release 2 (11.2.0.2), you select segment_name, bytes
can use TRUNCATE with from user_segments
where segment_name like 'ODSEG%'
the DROP ALL or segment_name in
STORAGE option to drop (select segment_name
from user_lobs );
entire segments. no rows selected
11gR2ps1
10. Zero-size Unusable Index
select index_name,
• If you alter any index segment_created, status
from user_indexes;
[b-tree, bitmap or INDEX_NAME SEG STATUS
-------------------- --- --------
function based] to XX_T1_I1 YES VALID
UNUSABLE, its storage alter index xx_t1_i1 unusable;
Index altered.
segments will be
select index_name ,
dropped. segment_created, status
• The parameter from user_indexes;
INDEX_NAME SEG STATUS
deferred_segment_crea -------------------- --- --------
XX_T1_I1 NO UNUSABLE
tion does not have any select segment_name
impact on this behavior. from dba_segments
where segment_name = 'XX_T1_I1';
no rows selected
11gR2
11. Change DB Link Password
• The ALTER DATABASE LINK statement can
change user password in the database link.
• ALTER DATABASE LINK privilege needed to
modify database links.
• Private, PUBLIC and SHARED database link
passwords can be changed.
create database link myownlink
connect to bthomas identified by justapwd
using 'CECORDEV';
alter database link myownlink
11gR2
connect to bthomas identified by mynewpwd1;
12. Concurrent Statistics Gather
• Oracle11gR2 11.2.0.2 includes a new global
preference setting for Optimizer statistics
gathering.
• The concurrent statistics gathering enables
Oracle to gather statistics on multiple tables and
table partitions concurrently.
• The Job Scheduler will decide how many of
these jobs will need to be run concurrently.
exec DBMS_STATS.SET_GLOBAL_PREFS
('CONCURRENT','TRUE'); 11gR2ps1
13. Audit Trail Management
• DBMS_AUDIT_MGMT package to manage DB
and OS audit trail records.
• API to move audit tables to another tablespace.
• AUDIT_TRAIL_AUD_STD constant for AUD$
table, AUDIT_TRAIL_FGA_STD for FGA_LOG$
table, AUDIT_TRAIL_DB_STD for both.
SQL>
execute DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION( -
> AUDIT_TRAIL_TYPE =>
DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, -
> AUDIT_TRAIL_LOCATION_VALUE => 'SYSAUX');
11gR2
14. Audit Trail Cleanup
• Initialize the audit cleanup infrastructure using
INIT_CLEANUP
• Optionally set the archive timestamp using
SET_LAST_ARCHIVE_TIMESTAMP. By default
records older than this timestamp are deleted
when purge job is invoked.
• Purge the records using CLEAN_AUDIT_TRAIL.
• Setup a job to clean records periodically using
CREATE_PURGE_JOB.
11gR2
16. Audit Trail Cleanup – Contd.
• Create purge job
dbms_audit_mgmt.create_purge_job(
audit_trail_type =>
dbms_audit_mgmt.audit_trail_aud_std,
audit_trail_purge_interval => 24 /* 1 day */ ,
audit_trail_purge_name => 'PURGE_DB_AUDIT_RECORDS',
use_last_arch_timestamp => true);
• Views
– DBA_AUDIT_MGMT_CONFIG_PARAMS: Shows current parameters
values.
– DBA_AUDIT_MGMT_LAST_ARCH_TS: Shows last archive timestamp
set for audit trail purges.
– DBA_AUDIT_MGMT_CLEANUP_JOBS: Shows current cleanup jobs.
– DBA_AUDIT_MGMT_CLEAN_EVENTS: Show history of purge events,
DBA needs to manually purge records from this view, if it grows too
large. 11gR2
17. Audit Trail Cleanup – Contd.
SELECT *
FROM DBA_AUDIT_MGMT_CONFIG_PARAMS;
PARAMETER_NAME PARAMETER_VALUE AUDIT_TRAIL
--------------------------- --------------- ---------------------
DB AUDIT TABLESPACE SYSAUX STANDARD AUDIT TRAIL
DB AUDIT TABLESPACE SYSAUX FGA AUDIT TRAIL
AUDIT FILE MAX SIZE 10000 OS AUDIT TRAIL
AUDIT FILE MAX SIZE 10000 XML AUDIT TRAIL
AUDIT FILE MAX AGE 5 OS AUDIT TRAIL
AUDIT FILE MAX AGE 5 XML AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE 10000 STANDARD AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE 10000 FGA AUDIT TRAIL
OS FILE CLEAN BATCH SIZE 1000 OS AUDIT TRAIL
OS FILE CLEAN BATCH SIZE 1000 XML AUDIT TRAIL
DEFAULT CLEAN UP INTERVAL 24 STANDARD AUDIT TRAIL
11gR2
18. External Table Preprocessing
• The preprocessor program converts the data to a record
format supported by the ORACLE_LOADER access
driver and then writes the converted record data to
standard output (stdout), which the access driver reads
as input.
• Very useful in situations like if the input file is
compressed format
• New EXECUTE Privilege for Directory Objects.
• Preprocess commands execute every time table is read.
• DEFAULT DIRECTORY specifies the directory location
of the data file. PREPROCESSOR specifies the
executable directory and the name of the executable.
11gR2
19. External Table Preprocessing – Contd.
create directory data_dir as '/home/biju/data_files';
create directory exec_dir as '/home/biju/exec_scripts';
grant read, write on directory data_dir to bthomas;
grant execute on directory exec_dir to bthomas;
$ pwd
/home/biju/data_files
$ ls -l
-rw-r--r-- 1 oracle dba 99 Feb 25 19:33 emp_sal.txt.gz
$ pwd
/home/biju/exec_scripts
$ ls -l
-rwxr--r-- 1 oracle dba 13 Feb 25 19:39 run_zcat.sh
$ cat run_zcat.sh
/bin/zcat $1
11gR2
20. External Table Preprocessing – Contd.
create table zx_file (empno number(5),
empname varchar2(20), salary number (10,2))
organization external (
type oracle_loader
default directory data_dir
access parameters (records delimited by newline
preprocessor exec_dir:'run_zcat.sh'
fields terminated by ',')
location ('emp_sal.txt.gz'));
select * from zx_file;
EMPNO EMPNAME SALARY
---------- -------------------- ----------
101 John King 1245.68
201 Matt Love 4567.33
345 Joshua Jacob 67533.9 11gR2
21. DataPump Legacy Mode
• If you are still using the legacy “exp” and “imp”
commands and comfortable with them, in 11gR2 data
pump recognizes the legacy parameters.
• The output file is written to default DATA_PUMP_DIR
location, not to the current directory.
• Can create a non-existent user during import.
expdp file=bthomas.dmp log=bthomas.log
owner=bthomas rows=n
impdp file=bthomas.dmp log=bthomas_imp.log
fromuser=bthomas touser=bthomas_dump
11gR2
22. Scheduler: File Watcher
• Start a job based on file arrival.
• File watcher is a scheduler object that defines its
location and other properties.
• By default file watcher checks for arrival of a file
every 10 minutes.
• DBMS_SCHEDULER.CREATE_FILE_WATCHER
procedure is used to create file watcher.
• dba_scheduler_file_watchers view lists all active
file watchers.
11gR2
24. SQL*Plus Exit Commit
• Prior to Oracle11gR2, the default behavior on
EXIT from SQL*Plus is COMMIT and exit.
• In 11gR2, you can define the behavior. The
default behavior is COMMIT on EXIT, which can
be made to ROLLBACK on EXIT using
SET EXITCOMMIT OFF
11gR2
25. 11gR2 [11.2.0.1] &
11gR2ps1 [11.2.0.2]
Features
Installation, ASM
Grid Infrastructure – Getting
Started
26. Full Install Patchsets
• Beginning 11gR2, patch set 1 [11.2.0.2], patchsets include full
software install [patch number 10098816].
• No need to download and install base version and then patch.
• Oracle recommends out of place install and upgrade. In place
upgrade still supported.
• Patchsets are still downloaded from Metalink [using wget is much
easier].
client
database
p10098816_112020_Linux-x86-64_1of7.zip : Database part 1
p10098816_112020_Linux-x86-64_2of7.zip : Database part 2 deinstall
p10098816_112020_Linux-x86-64_3of7.zip : Grid Infrastructure examples
p10098816_112020_Linux-x86-64_4of7.zip : Client gateways
p10098816_112020_Linux-x86-64_5of7.zip : Gateways
p10098816_112020_Linux-x86-64_6of7.zip : Examples
grid
p10098816_112020_Linux-x86-64_7of7.zip : DeInstall
11gR2ps1
27. Automatic Software Update
• The installer (OUI) connects to Metalink to check
for software updates and applies them.
11gR2ps1
29. Install – ASM is Grid Infrastructure
• Starting 11gR2, ASM Oracle Home is separate
from Database Oracle Home.
• ASM Oracle Home is known as Grid
Infrastructure (GI).
• Software distribution includes “database” and
“grid”.
• Grid single instance install software same for
RAC install as well. 11gR2
30. Oracle Restart
• Oracle components can be automatically
restarted after a hardware or software failure or
whenever host computer restarts.
– ASM Instance
– Mount Diskgroups
– Oracle Notification Services [if enabled]
– Listeners
– Databases
– Services
• Knows dependency
11gR2
31. Oracle Restart – Contd.
• Use srvctl to manually start/stop components.
$ srvctl start asm
$ srvctl start database -d cecordev
• Use crsctl to enable Oracle Restart
{GI_HOME}/bin/crsctl enable has
CRS-4622: Oracle High Availability Services autostart is enabled.
{GI_HOME}/bin/crsctl start has
CRS-4123: Oracle High Availability Services has been started.
• Configure components using srvctl
$ srvctl add listener -l LISTENER_ASM -p "TCP:1521" -o
$ORACLE_HOME
$ srvctl config asm
ASM home: /u01/app/oracle/grid/11.2.0.2
ASM listener: LISTENER_ASM
Spfile: /u01/app/oracle/grid/11.2.0.2/dbs/spfile+ASM.ora
ASM diskgroup discovery string:
11gR2
32. Oracle Restart – Contd.
$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER_ASM.lsnr
ONLINE ONLINE gildv248
ora.LISTENER_DB.lsnr
ONLINE ONLINE gildv248
ora.ORAARCH.dg
ONLINE ONLINE gildv248
ora.ORADATA.dg
ONLINE ONLINE gildv248
ora.asm
ONLINE ONLINE gildv248 Started
ora.ons
OFFLINE OFFLINE gildv248
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cecordev.db
1 ONLINE ONLINE gildv248 Open
ora.cefsgdev.db
1 ONLINE ONLINE gildv248 Open
ora.cssd
1 ONLINE ONLINE gildv248
ora.diskmon
1 ONLINE ONLINE gildv248
ora.evmd
1 ONLINE ONLINE gildv248 11gR2
33. SYSASM Privilege
• Improves security by separating ASM
administration from DB administration.
• Needed to stop/start ASM Instance, create
diskgroups in 11gR2.
• New OSASM group, similar to OSDBA and
OSOPER.
• Remote authentication possible using syntax
sys@"myhost.mydomain.com:1521/+ASM" AS SYSASM
11gR2
34. ASMCA – Manage ASM
• ASM Configuration • Command line using
Assistant the –silent option
• supports installing • dbca not available in
and configuring ASM GI home
instances, disk
groups, volumes
(ASMDVM), and
Oracle ASM Cluster
File System (ACFS)
11gR2
35. Rename ASM Diskgroup
• Possible to rename diskgroup when dg is not
mounted.
• Database file names must be manually
renamed.
• Old diskgroups in Oracle Restart configuration
must be removed manually.
$ srvctl stop diskgroup -g oops1
$ renamedg dgname=oops1 newdgname=good1
verbose=true
$ srvctl start diskgroup –g good1 11gR2
37. Alert log, Trace file Location
• Automatic Diagnostic Repository (ADR) keeps all the log
and trace files.
• DIAGNOSTIC_DEST parameter replaces
BACKGROUND_DUMP_DEST, USER_DUMP_DEST
and CORE_DUMP_DEST parameters.
• DIAGNOSTIC_DEST defaults to ORACLE_BASE if set,
else ORACLE_HOME/log.
• Alert log is under
DIAGNOSTIC_DEST/diag/rdbms/database/instance/trac
e. The XML version is under ../alert.
11gR1
38. Passwords are Case Sensitive
• New users created in Oracle11g have case sensitive
password.
• When upgrading from pre-11 release, case sensitivity
takes effect when you change password.
• PASSWORD_VERSIONS and PASSWORD columns in
DBA_USERS.
• Disable case sensitivity by setting
SEC_CASE_SENSITIVE_LOGON to FALSE.
• ORAPWD has a new parameter – IGNORECASE.
• For database links, the account in Oracle11g should
have password in uppercase when linking from pre-11g
database.
11gR1
39. Changes to DEFAULT Profile
• PASSWORD_LIFE_TIME is 180
• PASSWORD_LOCK_TIME is 1
• PASSWORD_GRACE_TIME is 7
• FAILED_LOGIN_ATTEMPTS is 10
• ?/rdbms/admin/utlpwdmg.sql creates
VERIFY_FUNCTION_11G, with enhanced
password complexity checking.
• $ORACLE_HOME/rdbms/admin/secconf.sql
changes DEFAULT profile, and enables default
auditing. 11gR1
40. Default Auditing
• AUDIT_TRAIL parameter is set to DB
• ALTER SYTEM, ALTER USER, ALTER
DATABASE, ALTER PROFILE actions are
audited.
• CREATE USER, DROP USER, DROP PROFILE
actions are audited.
• Logins are audited (CREATE SESSION).
• Most “ANY” privilege actions are audited.
• Delete on AUD$ is audited and such records
cannot be deleted.
41. Read-Only Table
• New ALTER TABLE clause to make a table read-only.
• If you try to perform insert or update or delete on read-
only table, you get an ORA-12081 error.
• Flashback, Truncate not allowed.
• Drop table, drop indexes, drop constraints allowed.
ALTER TABLE <table_name> READ ONLY;
ALTER TABLE <table_name> READ WRITE;
select owner, table_name, tablespace_name
from dba_tables
where read_only = 'YES';
11gR1
42. Tablespace for Temporary Tables
• In pre-Oracle11g releases, the global temporary
table segments where created in the user’s
default temporary tablespace.
• In Oracle11g, you can specify a tablespace for
global temporary tablespace segments.
create global temporary table customer_stage (
cust_name number (10),
col1 varchar2 (40),
col2 varchar2 (60))
on commit preserve rows
tablespace temp; 11gR1
43. Invisible Indexes
• If you want to test the implications of creating an
index without affecting the application, you can
make the index invisible. After testing, you may
drop the index or make it visible.
• To make the optimizer use invisible index, set
the OPTIMIZER_USE_INVISIBLE_INDEXES to
TRUE in the session.
• INVISIBLE/VISIBLE clause is added to CREATE
INDEX and ALTER INDEX statements
11gR1
44. Invisible Indexes – Contd.
SQL> create index hr.employee_test on hr.employee (first_name) invisible;
Index created.
SQL> select index_name, visibility from dba_indexes
2 where owner = 'HR' and table_name = 'EMPLOYEE';
INDEX_NAME VISIBILIT
------------------------------ ---------
PK_EMPLOYEE VISIBLE
EMPLOYEE_TEST INVISIBLE
SQL> select first_name, last_name from hr.employee
2 where first_name = 'John';
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 78 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMPLOYEE | 3 | 78 | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------
SQL> alter session set optimizer_use_invisible_indexes = true;
Session altered.
SQL> select first_name, last_name from hr.employee
2 where first_name = 'John';
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 78 | 2 (0
| 1 | TABLE ACCESS BY INDEX ROWID| EMPLOYEE | 3 | 78 | 2 (0
|* 2 | INDEX RANGE SCAN | EMPLOYEE_TEST | 3 | | 1 (0 11gR1
-------------------------------------------------------------------------------
45. DB Protection Levels
• DB_ULTRA_SAFE parameter controls the
protection level.
• OFF: Values specified for DB_BLOCK_CHECKING,
DB_BLOCK_CHECKSUM and DB_LOST_WRITE are
taken.
• DATA_ONLY: DB_BLOCK_CHECKING=MEDIUM,
DB_BLOCK_CHECKSUM=FULL,
DB_LOST_WRITE_PROTECT=TYPICAL
• DATA_AND_INDEX: DB_BLOCK_CHECKING=FULL,
DB_BLOCK_CHECKSUM=FULL,
DB_LOST_WRITE_PROTECT=TYPICAL
11gR1
46. DDL Lock Timeout
• New parameter to specify the DDL lock wait time
– DDL_LOCK_TIMEOUT
• Value specified in seconds, default is 0, max
1,000,000.
• Parameter can be changed using ALTER
SYSTEM or ALTER SESSION.
• When the timeout expires, error returned as in
previous releases.
ORA-00054: resource busy and acquire
with NOWAIT specified or timeout
expired 11gR1
47. WAIT in LOCK TABLE
• The LOCK TABLE statement is enhanced to
include a WAIT clause.
• You can now specify how many seconds you
want the database to wait before returning the
“resource busy” error.
LOCK TABLE <table_name> IN EXCLUSIVE
MODE WAIT 120;
11gR1
48. DDL Logging
• To log all DDL operations in the alert log file, set the
parameter ENABLE_DDL_LOGGING.
• The default value is FALSE, means DDL logging is
disabled.
• Can be changed using ALTER SESSION or ALTER
SYSTEM
Sun Jan 30 11:21:11 2011
create table bthomas.test_table (nn number)
Sun Jan 30 11:27:34 2011
alter table bthomas.test_table modify (nn varchar2 (10))
Sun Jan 30 11:29:43 2011
drop table bthomas.test_table
11gR1
49. Automatic Memory Configuration
• New parameters – MEMORY_TARGET and
MEMORY_MAX_TARGET.
• No need to specify SGA size (SGA_TARGET)
and PGA size (PGA_AGGREGATE_TARGET)
separately.
• If SGA and PGA parameters are not set, the
default initial allocation is 60% SGA and 40%
PGA.
• New view – V$MEMORY_TARGET_ADVICE.
11gR1
50. Automatic Memory Configuration - Contd
• The V$MEMORY_DYNAMIC_COMPONENTS view
shows the summarized information on all resize
operations and shows the current sizes of all SGA
components.
• If you set the MEMORY_TARGET to a non-zero value,
Oracle will manage memory automatically. The
MEMORY_MAX_TARGET will default to the value of
MEMORY_TARGET.
• If you have also set SGA_TARGET and
PGA_AGGREGATE_TARGET parameters, those values
will be considered the minimums.
11gR1
51. Parameter File from Memory
• In pre-Oracle11g releases, we can create pfile
from spfile or spfile from pfile.
• In Oracle11g, we can now create spfile or pfile
from memory
CREATE
PFILE='/u01/oracle/admin/DB1/pfile/initD
B1.ora' FROM MEMORY;
CREATE SPFILE FROM MEMORY;
11gR1
52. Misc: SQL*Plus Error Logging
• SQL*Plus error logging to write ORA, PLS and SP2
errors – Default table name is SPERRORLOG.
SET ERRORL[OGGING] {ON|OFF} [TABLE [schema.]tablename]
[TRUNCATE] [IDENTIFIER identifier]
SQL> desc sperrorlog
Name Null? Type
---------------------- -------- ----------------
USERNAME VARCHAR2(256)
TIMESTAMP TIMESTAMP(6)
SCRIPT VARCHAR2(1024)
IDENTIFIER VARCHAR2(256)
MESSAGE CLOB
STATEMENT CLOB
SQL> set errorlogging on
11gR1
53. Questions….???
And… Thank You For Your Time
• Please complete the session evaluation form
– Biju Thomas
– Oracle11gR2 for Oracle10gR2 DBA
– Session # 313
• Further questions, comments…
– Stop by Booth #939
– WWW.ONENECK.COM