Oracle Database 12c (R2) Features for 11g DBA and Developer @biju_thomas Biju Thomas Principal Solutions Architect OneNeck IT Solutions www.OneNeck.com
Oracle Database 12c (R2) Features for 11g DBAand Developer
@biju_thomas
Biju Thomas
Principal Solutions ArchitectOneNeck IT Solutionswww.OneNeck.com
OneNeck IT Solutions at a Glance• Backed by Fortune 500 strength of Telephone and Data Systems
• Hybrid IT
• Nearly 550 employees
• 8 data centers in 6 states, Coast-to-coast presence
2
About me!
Biju Thomas
3
Principal Solutions Architect with OneNeck IT Solutions Over 20 years of Oracle Database development and administration expertise Over 10 years of Oracle E-Business Suite Architecture & Tuning expertise First book published in September 2000, seventh in 2015 DBA Website since 1997 – www.bijoos.com Oracle ACE Director
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.4 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Learn features of Oracle Database 12c R2 that may not the top,
but would help in administration and development!
As a 11g DBA/Developer, what you should know when working
with 12c R1 or R2 database (changed behavior or added
functionality).
Many features at a high level – once you know what to look for,
“googling” always works! (have links on most slides to read and
learn more)
Session Objectives
Database 12.2 Features
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Optimizer Adaptive Features
6
Adaptive Query
Optimization
Adaptive Plans Adaptive Statistics
Join
Methods
Parallel Distribution
Methods
Bitmap
Pruning
Dynamic
Statistics
Automatic
Reoptimiz
ation
SQL Plan
Directives
Picture & Content Credits: Mauro Pagano – Collab 2017
OPTIMIZER_ADAPTIVE_FEATURES (12.1)
OPTIMIZER_ADAPTIVE_PLANS (12.2) OPTIMIZER_ADAPTIVE_STATISTICS (12.2)
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Adaptive Plan – How does it work?
7
Mauro @ Collab17
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Explain Plan Shows…
8
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
• Release 2 (12.2)
• For most OLTP databases, default behavior is good
• Adaptive Plan enabled (OPTIMIZER_ADAPTIVE_PLANS=TRUE), Adaptive Statistics disabled (OPTIMIZER_ADAPTIVE_STATISTICS=FALSE)
• Release 1 (12.1)
• Option 1
• Turn off adaptive features by setting optimizer_adaptive_features=FALSE
• Do not act on adaptive information collected by setting optimizer_adaptive_reporting_only=TRUE
• Do not set optimizer_features_enable=11.2.0.4 Bad Idea!
• Option 2
• Apply patch 22652097 on top of 12.1.0.2
• Provides split parameter like in 12.2
• Turn off Adaptive Statistics (OPTIMIZER_ADAPTIVE_STATISTICS=FALSE)
After 12c Upgrade…
9
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.10 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
12c Administrative Users
OS Group Admin
Privilege
Description
oinstall - Mandatory for Install (OraInventory
Owner)
dba / asmdba
oper / asmoper
asmadmin
SYSDBA
SYSOPER
SYSASM
Full admin privilege on DB
Subset of admin privileges
ASM Management
backupdba
dgdba
kmdba
SYSBACKUP
SYSDG
SYSKM
RMAN
Data Guard
Encryption Key
racdba SYSRAC RAC (12.2)
SELECT * FROM v$pwfile_users;
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.11 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Download appropriate software
Oracle Grid Infrastructure for a standalone server installation image
Oracle Grid Infrastructure for cluster installation image
Unzip to GRID_HOME directory.
Run gridSetup.sh as GI owner
Run root.sh (for new 12.2 install)
Run rootupgrade.sh (for upgrade from previous release)
GI Install is not an “install” 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.12 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
In 12.1 and earlier, create the partitions and specify the values that fall in each partition. DEFAULT partition is used to catch all (similar to MAXVALUE in range).
New AUTOMATIC keyword in list partition. Oracle automatically creates a new partition for each distinct value in the partition column.
CREATE TABLE ab1 (s1 varchar2(2), d1 varchar2 (20))
PARTITION BY LIST (s1)
AUTOMATIC (PARTITION p_az VALUES ('AZ'));
ALTER TABLE xyz SET AUTOMATIC;
Notes An automatic list-partitioned table must have at least one partition when created.
Cannot have a DEFAULT partition.
Not supported at the sub-partition level.
Automatic List Partitions 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.13 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Modify a non-partitioned table to partitioned table, online!
alter table SALES modify
partition by list (STATE)
AUTOMATIC (partition p_AZ values (‘AZ')) ONLINE;
alter table SALES modify
partition by list (owner)
AUTOMATIC (partition p_AZ values (‘AZ'))
update indexes (SALES_I1 LOCAL) ONLINE;
In versions prior to 12.2, this activity required DBMS_REDEFINITION.
Convert to Partitioned Table Online! 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.14 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
SQL> ALTER TABLE abcd MOVE ONLINE;
No “resource busy” issues
No need to manually rebuild indexes
Note: Parallel DML and direct path inserts are not allowed when an ongoing move operation is active.
Reorg Table Online 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.15 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
A partition or sub-partition can be marked as READ ONLY at the time of creation (CREATE TABLE) or later (ALTER TABLE).
Specify key word READ ONLY.
READ WRITE is the default.
Example 1: (xxt is partitioned table)
ALTER TABLE xxt READ ONLY;
All current and future created partitions will be read only.
Example 2:
ALTER TABLE xxt MODIFY PARTITION xxt_p4 READ WRITE;
All partitions except xxt_p4 are read only.
Read Only Partitions 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.16 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Automatic Password Propagation to Standby: Changing SYS password
Versions 12.1 and earlier
Change password in primary
Copy password file from primary to standby sites
Version 12.2
Change password in primary
Automatically synched to all standby sites
Data Guard Password Sync 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.17 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Multiple Instance Redo Apply (MIRA), enables redo apply on all or some standby instances with RAC configuration.
New INSTANCES [ ALL | integer] clause is available on the SQL ALTER DATABASE RECOVER MANAGED STANDBY DATABASE command.
Cannot choose specific instances, only specify how many number of instances.
Multiple Instance Redo Apply 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.19 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
SELECT property_name, property_value
FROM database_properties
WHERE property_name = 'LOCAL_UNDO_ENABLED';
To change Undo mode, outage required, and need the database in UPGRADE mode.
STARTUP UPGRADE;
ALTER DATABASE LOCAL UNDO ON/OFF;
Local Undo for Pluggable Databases
http://docs.oracle.com/database/122/ADMIN/administering-a-cdb-with-sql-plus.htm#ADMIN-GUID-8F8B2FF8-7FA7-40CD-8AA5-ACABCD3964D8
12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.20 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Flashback CDB
Shutdown
Startup Mount
FLASHBACK DATABASE TO RESTORE POINT xxx
ALTER DATABASE OPEN RESETLOGS
ALTER PLUGGABLE DATABASE ALL OPEN RESETLOGS
Flashback PDB
Local undo must be enabled
ALTER PLUGGABLE DATABASE abcd CLOSE;
FLASHBACK PLUGGABLE DATABASE abcd TO RESTORE POINT xxx;
ALTER PLUGGABLE DATABASE abcd OPEN RESETLOGS;
Flashback PDB
TO RESTOREPOINTTO [BEFORE] TIMESTAMPTO [BEFORE] SCN
12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.21 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
A PDB lockdown profile is a named set of features that control operations available to users connected to a PDB.
New parameter PDB_LOCKDOWN
CREATE LOCKDOWN PROFILE medium;
ALTER LOCKDOWN PROFILE medium DISABLE STATEMENT=('ALTER
SYSTEM');
ALTER LOCKDOWN PROFILE medium ENABLE STATEMENT=('ALTER
SYSTEM') CLAUSE=('FLUSH SHARED POOL');
Creates a profile called medium that disables all ALTER SYSTEM statements except for ALTER SYSTEM FLUSH SHARED POOL.
Alter lockdown profile XP1 disable
statement=('ALTER SESSION') clause=('SET') OPTION
ALL EXCEPT=('sql_trace','optimizer_mode')
PDB Lockdown Profile
Reference: http://docs.oracle.com/database/122/CNCPT/overview-of-the-multitenant-architecture.htm#CNCPT-GUID-B964031E-8ACE-4603-8F1E-DD173BE5BA01
12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.22 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Prior releases: Must to advise failure, before running repair failure.
RMAN> list failure;
RMAN> advise failure;
RMAN> repair failure;
Option to repair specific area without running advise
database: the whole database
database root: the CDB$ROOT container, which means all its tablespaces
pluggable database: it means all the PDB tablespaces
a specific data file
RMAN Repair Enhancements
https://blog.dbi-services.com/12cr2-rman-repair/
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.23 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
New user profile resource: INACTIVE_ACCOUNT_TIME
Automatically locks the database user account who has not logged into the database instance in a specified number of days.
Inactive Account Lock 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.24 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
In 12.1, maximum number of PDBs is 252
In 12.2 maximum number of PDBs is 4096
New parameter MAX_PDBS
In a single-tenant environment (if not licensed for multitenant), set this parameter to 1.
Maximum Number of PDBs 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.25 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Initialization parameter ALLOW_GROUP_ACCESS_TO_SGA
Determines if the Oracle Database installation owner account is the only user that can read and write to the database System Global Area (SGA), or if members of the OSDBA group can read the SGA.
The default value for this parameter is FALSE.
In Oracle Database releases prior to Oracle Database 12c Release 2 (12.2.0.1), database shared memory was created with owner and group access.
SGA Related: When SGA_MIN_SIZE is set for a PDB, it guarantees the specified SGA size for the PDB.
SGA Access Restriction 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.26 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
The maximum length for most database object names has increased from 30 bytes to 128 bytes.
If COMPATIBLE is set to a value of 12.2 or higher, then names must be from 1 to 128 bytes long with these exceptions: Names of databases are limited to 8 bytes.
Names of disk groups, pluggable databases (PDBs), rollback segments, tablespaces, and tablespace sets are limited to 30 bytes.
"schema"."table"."column“ can be up to 392 bytes (384 + each of the quotation marks and periods is a single-byte character).
New function ORA_MAX_NAME_LEN_SUPPORTED can be used to check the maximum length of identifiers allowed in the database.
If COMPATIBLE parameter is set to 12.1.0 or lower, the limit is 30 bytes.
No more abbreviations! 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.27 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
SQL*Plus command history available.
SET HIST[ORY] ON
SQL*Plus Notables 12.2
SET FEEDBACK ONLY
Returns just the number of rows returned by the query without displaying the query result.
SET MARKUP CSV
SET MARKUP command supports the display of data in CSV format. Produce output in HTML or CSV format.
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.28 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
SQL*Plus 12.2.0.1.0 Change in Behavior for Search Path of Login.sql(SQL*Plus User Profile Script) (Doc ID 2241021.1)
Old Behavior:
Prior to SQL*Plus version 12.2.0.1.0, SQL*Plus searches for the User Profile in your current directory first, and then the directories you specify with the ORACLE_PATH environment variable.
New Behavior:
From 12.2.0.1.0, SQL*Plus will only search for the User Profile in the directories you specify with the ORACLE_PATH environment variable on Linux and SQLPATH on Windows.
SQL*Plus: login.sql behavior 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.29 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Automatically diagnoses problems in the existing practices for gathering statistics.
The output of the advisor is a report of findings and recommendations.
Runs a predefined task named AUTO_STATS_ADVISOR_TASK once every day in the maintenance window.
Statistics Advisor
https://docs.oracle.com/database/122/TGSQL/optimizer-statistics-advisor.htm
12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.31 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Live SQL is Running 12.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.32 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
http://www.lakako.com/googleplus/search/db12cr2
http://www.lakako.com/twitter/search/db12cr2
More 12.2 Features… 12.2
Database 12.1 Features
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
• Prior to 12c • Create a control file for the standby database on the primary database.
• Take an incremental backup on the primary starting from the SCN# of the standby database.
• Copy the incremental backup to the standby host and catalog it with RMAN.
• Mount the standby database with newly created standby control file.
• Cancel managed recovery of the standby database and apply incremental backup to the standby database.
• Start managed recovery of standby database.
• In 12c• Startup the physical standby in NOMOUNT mode
• RMAN> RESTORE STANDBY CONTROLFILE FROM SERVICE boston;
• Mount the database
• RMAN> recover database from service boston …;
https://docs.oracle.com/database/121/BRADV/rcmadvre.htm#BRADV685
Roll Forward Physical Standby
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
• Data file on the primary database is corrupt or lost
• Easily restore the good file from standby database
RMAN> RESTORE DATAFILE '/oradata/datafiles/sales.dbf‘ FROM SERVICE standby_tns;
Restoring Data File from Standby
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.36 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
READ Object Privilege, READ ANY TABLE system privilege
SELECT privilege also includes privilege to lock LOCK TABLE <table_name> IN EXCLUSIVE MODE;
SELECT ... FROM <table_name> FOR UPDATE;
READ privilege is more secure, a true READ ONLY privilege!
Grants and Revokes work similar to SELECT grants.
No, there is no READ statement to go with the privilege, you still use the SELECT statement
SQL> GRANT READ ON XX.XXLE_CUSTOMERS_T TO smith;
SQL> GRANT READ ANY TABLE TO peter;
SQL> REVOKE READ ON XX.XXLE_SUPPLIERS_VW FROM smith;
SQL> REVOKE READ ANY TABLE FROM peter;
READ Privilege (12.1.0.2)
©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
• Allows the creation of global and local indexes on a subset of the partitions of a partitioned table.
ALTER TABLE tt1 MODIFY PARTITION p_vold1 INDEXING OFF;
ALTER TABLE tt1 MODIFY PARTITION p_vold2 INDEXING OFF;
CREATE INDEX tt1_part_idx ON tt1(x1) LOCAL INDEXING
PARTIAL;
ALTER INDEX tt1_existing1 INDEXING PARTIAL;
• Rebuild existing global indexes to regain space. Local indexes drop partitions immediately.
Partial Indexes
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.38 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
DBLINK_INFO
Returns the source of a database link session. Specifically, it returns a string of the form:
SOURCE_GLOBAL_NAME=dblink_src_global_name,
DBLINK_NAME=dblink_name,
SOURCE_AUDIT_SESSIONID=dblink_src_audit_sessionid
dblink_src_global_name is the unique global name of the source database
dblink_name is the name of the database link on the source database
dblink_src_audit_sessionid is the audit session ID of the session on the source database that initiated the connection to the remote database using dblink_name
Same information in UNIFIED_AUDIT_TRAIL view – DBLINK_INFO column.
New SYS_CONTEXT Namespace
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.39 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
File move (rename) in 11g Take tablespace offline
Use OS command to copy or move file – DBA does copy outside database
Use SQL to update the controlfile
ALTER DATABASE RENAME FILE or
ALTER TABLESPACE … RENAME DATAFILE
Bring tablespace online
To move files belonging the SYSTEM, do in MOUNT mode.
File move in 12c Just one step – no unavailability!
ALTER DATABASE MOVE DATAFILE 'x' TO 'y'
The “TO” clause is optional – if omitted, file is moved to DB_CREATE_FILE_DEST as OMF.
Online Data File Move
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.40 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Files belonging to SYSTEM tablespace can be moved using
ALTER DATABASE MOVE DATAFILE, online!
MOVE DATAFILE syntax allows only 1 file move at a time. You
can still move multiple files with ALTER DATABASE
RENAME FILE or ALTER TABLESPACE RENAME
DATAFILE options – but offline mode.
File can be moved from file system to ASM disk group, and
vice versa.
File can be moved from one diskgroup to another in ASM.
Optional KEEP clause to keep the data file at the source.
More to File Move in 12c…
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.41 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Security related values in the USER$ table are [as existed in 11gR2]:
CTIME: Date & Time when user was created
PTIME: Date & Time when user password was last changed
LTIME: Date & Time when the user account was locked
LCOUNT: Number of failed login attempts
SPARE4: Encrypted case sensitive password 11g version
PASSWORD: Encrypted case insensitive password 10g version
Added in Oracle Database 12c:
SPARE6: Last login time of the user.
Displayed when you invoke SQL*Plus
Last Login Time
$ sqlplus hr/hr
SQL*Plus: Release 12.1.0.1.0 Production on Tue Jul 9 23:34:32 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Last Successful login time: Tue Dec 09 2013 23:34:22 -05:00Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.42 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
The biggest RMAN feature is restore table from backup.
RECOVER TABLE SCOTT.EMP, SCOTT.DEPT
UNTIL TIME 'SYSDATE-1'
AUXILIARY DESTINATION '/t1/tdb'
DATAPUMP DESTINATION '/t1/dump'
DUMP FILE 'emp_dept_dump.dat'
REMAP TABLE 'HR'.'EMP':'EMP_RECVR';
--NOTABLEIMPORT;
When NOTABLEIMPORT option is used, RMAN performs the restore/recover and creates the export dump file, but does not perform the import.
RMAN Restore Table
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.45 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
New CASCADE clause for TRUNCATE
Truncates all child tables that reference truncated table.
Foreign key must be defined with ON DELETE CASCADE option
Foreign key must be in ENABLED status.
Children, grand children are truncated
Cascaded TRUNCATE
In Oracle Database 11gR2 and earlier versions, the TRUNCATE statement
had the following two restrictions along with few others.
You cannot truncate the parent table of an enabled foreign key
constraint. You must disable the constraint before truncating the table.
An exception is that you can truncate the table if the integrity
constraint is self-referential.
You cannot truncate the parent table of a reference-partitioned table.
You must first drop the reference-partitioned child table.
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.46 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
More DDL statements support ONLINE Dropping an index (DROP INDEX ... ONLINE)
Marking an index as UNUSABLE (using ALTER INDEX ... UNUSABLE ONLINE)
Marking a column as UNUSED (ALTER TABLE ... SET UNUSED ... ONLINE)
Dropping a constraint (ALTER TABLE ... DROP ... ONLINE)
Moving a table partition (ALTER TABLE ... MOVE PARTITION ... ONLINE)
Moving a table subpartition (ALTER TABLE ... MOVE SUBPARTITION ... ONLINE)
Do More w/o Waiting
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.47 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Merge Multiple Partitions
Split Multiple Partitions
Multiple Partition Management
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.48 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Add Multiple partitions
Drop Multiple Partitions
Truncate Multiple Partitions
More Partition Management
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.49 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
New parameter PGA_AGGREGATE_LIMIT
Specifies a limit on the aggregate PGA memory consumed by the instance
Default Value: Greater of
2 GB
200% of PGA_AGGREGATE_TARGET
3 MB times the PROCESSES parameter.
It will not exceed 120% of the physical memory size minus the total SGA size.
PGA_AGGREGATE_TARGET maintains the same behavior as 11g - specifies the target aggregate PGA memory available to all server processes attached to the instance.
Limit PGA
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.50 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
New mandatory background process LREG
Registers information about the database instance and dispatcher processes with the Oracle Net Listener
When an instance starts, LREG polls the listener to determine whether it is running. If the listener is running, then LREG passes it relevant parameters. If it is not running, then LREG periodically attempts to contact it.
Manual listener registration using ALTER SYSTEM REGISTER – same as in 11g.
In 11g, PMON process had this responsibility.
Listener Registration
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.51 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Can create B-Tree and Bitmap indexes on same set of columns
Partitioned and Non-partitioned indexes
Locally partitioned and Globally partitioned indexes
Indexes that differ in partitioning type (range vs hash)
Unique and Non-unique indexes
Only one index on the same set of columns can be visible at any point in time.
If you are creating a visible index, then any existing indexes on the set of columns must be invisible. Alternatively, you can create an invisible index on the same set of columns.
Multiple Indexes on Same Column
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.52 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
In #DB12c statistics are automatically created as part of a bulk load operation such as
CREATE TABLE AS SELECT operation or
INSERT INTO ... SELECT operation
Operation must be on an empty table.
Basic statistics on the table gathered, but non-default statistics such as histograms are not calculated.
Automatic Stats During Bulk Load
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.53 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
New function APPROX_COUNT_DISTINCT (<expr>)
Returns the approximate number of rows that contain distinct values of <expr>.
Alternative to the COUNT (DISTINCT <expr>) function, which returns the exact number of rows that contain distinct values of <expr>.
APPROX_COUNT_DISTINCT processes large amounts of data significantly faster than COUNT, with negligible deviation from the exact result.
SQL> SELECT APPROX_COUNT_DISTINCT (item_id) AS
"Items Ordered" FROM order_lines;
Faster (Approximate) Count – 12.1.0.2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.54 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
APPROX_COUNT_DISTINCT APPROX_COUNT_DISTINCT_DETAIL APPROX_COUNT_DISTINCT_AGG TO_APPROX_COUNT_DISTINCT APPROX_MEDIAN APPROX_PERCENTILE APPROX_PERCENTILE_DETAIL APPROX_PERCENTILE_AGG TO_APPROX_PERCENTILE
Set the approx_for_aggregation initialization parameter to TRUE for the current session or for the entire database. This parameter acts as an umbrella parameter for enabling the use of functions that return approximate results
https://docs.oracle.com/cloud/latest/exadataexpress-cloud/CSDBF/approximate-query-processing.htm#CSDBF-GUID-F8DF817F-11E0-4D39-830C-6B4D9FC6ABAB
Enhanced in 12.2 with more Functions
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.55 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
VARCHAR2 [and NVARCHAR2, RAW] column width up to 32767 bytes
Parameter MAX_STRING_SIZE = EXTENDED – must change only when the database is started in UPGRADE mode
Once enabled, no going back
Invalidates views and materialized views, compile after change.
Individual PDBs in a CDB can have different setting
Bigger VARCHAR2
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.56 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
ALTER PLUGGABLE DATABASE CLOSE [IMMEDIATE]
ALTER PLUGGABLE DATABASE OPEN UPGRADE
Change the setting of MAX_STRING_SIZE to EXTENDED
Run the ?/rdbms/admin/utl32k.sql script as SYSDBA.
ALTER PLUGGABLE DATABASE CLOSE ALTER PLUGGABLE DATABASE OPEN
Changing MAX_STRING_SIZE
Shutdown database Start the database in UPGRADE
mode Change the setting of
MAX_STRING_SIZE to EXTENDED
Run the ?/rdbms/admin/utl32k.sql script as SYSDBA.
Restart the database in normal mode.
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.57 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Columns can be invisible (ALTER TABLE, CREATE TABLE syntax – INVISIBLE)
Not supported on temporary and external tables
Specify explicitly in INSERT, SELECT clauses
SQL*Plus: SET COLINVISIBLE ON
When you make an INVISIBLE column in Oracle 12c database to VISIBLE, the COL# is assigned the highest available. Thus the column becomes the last column in the table (not storage, only display). So, if you accidentally make a column INVISIBLE and correct it by changing to VISIBLE, the column order changes. So, if the application uses "SELECT *" or "INSERT" without column names, they might break!
Invisible Columns
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.58 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
New clause in SELECT statement
Follows the ORDER BY clause
[ OFFSET offset { ROW | ROWS } ]
[ FETCH {FIRST | NEXT} [ {rowcount | percent
PERCENT} ]
{ ROW | ROWS } { ONLY | WITH TIES } ]
OFFSET clause is used to skip the specified number of rows before the limiting begins.
FETCH clause can specify the number of rows to return or a percentage of rows to return.
ONLY specifies to return exact number or percent of rows to return.
WITH TIES specifies to return all rows that have the same sort keys as the last row of the row-limited result set.
Row Limiting Clause
http://bijoos.com/oraclenotes/2013/95
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.59 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Row Limiting Examples
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.60 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
“datapatch” to run post patch scripts
Will automatically determine post scripts and actions
MOS Note “Datapatch: Database 12c Post Patch SQL Automation (Doc ID 1585822.1)”
Queryable patch inventory using DBMS_QOPATCH Package
Shows all the patch information available as part of the OPATCH LSINVENTORY -XML command.
Queryable Patch Inventory requires Oracle database instance to be open in read/write mode.
MOS Note “Oracle Database 12.1 : FAQ on Queryable Patch Inventory (Doc ID 1530108.1)”
Enhanced Patching
GET_OPATCH_LIST
PATCH_CONFLICT_DETECTION
GET_SQLPATCH_STATUS
GET_OPATCH_PREQS
GET_OPATCH_LSINVENTORY
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.61
Security Defaults
AUDIT_SYS_OPERATIONS defaults to TRUE in #Oracle 12c
AUDIT_ADMIN and AUDIT_VIEWER Security Roles
utlpwdmg.sql script creates ora12c_verify_function and ora12c_strong_verify_function
RESOURCE Role No Longer Grants the UNLIMITED TABLESPACE Privilege
Default Unified Audit Policy Enabled. Failed logins are written to UNIFIED_AUDIT_TRAIL. The ORA_LOGON_FAILURES unified audit policy for new databases, tracks failed
logons only.
AUDSYS schema will be used solely for storage of the unified audit trail data table.
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.62 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Single location, single table for audit records
Unified interface
Unified audit trail records can be read using the UNIFIED_AUDIT_TRAIL view standard auditing
SYS auditing
fine grained auditing
data pump
SQL loader,
database vault
label security
recovery manager RMAN
real application security
Unified Audit Trail
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.63
Connecting Lower Version Clients
SQLNET.ALLOWED_LOGON_VERSION_CLIENT
SQLNET.ALLOWED_LOGON_VERSION_SERVER
Replaced SQLNET.ALLOWED_LOGON_VERSION
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.64 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Import without generating archived logs TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y[:TABLE|INDEX]
Sets object to NOLOGGIG before import and reverts to original setting after import.
Choose to disable logging for tables (Y:TABLE), indexes (Y:INDEX), or both (Y).
$ impdp DIRECTORY=dump_dir DUMPFILE=ex2.dmp
LOGFILE=ex2.log SCHEMAS=ball
TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y:TABLE
$ impdp DIRECTORY=dump_dir DUMPFILE=ex1.dmp
LOGFILE=ex1.log SCHEMAS=basket
TRANSFORM=DISABLE_ARCHIVE_LOGGING:Y
TRANSFORM=DISABLE_ARCHIVE_LOGGING:N:INDEX
Data Pump NOLOGGING Import
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.65 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
Export one or more views as tables VIEWS_AS_TABLES=[schema_name.]view_name[:table_na
me], ...
table_name specifies the name of a table to serve as the source of the metadata for the exported view (mainly for RO db).
Data Pump performs a table-mode export.
Useful to get a subset of data exported.
Also available in “impdp” to use in the network mode of import.
Data Pump Export Views As Tables
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.66 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
SQL*Loader in #DB12c has a new option that does not require the user to create a SQL*Loader control file.
Instead, command-line parameters are used to specify how the data file is loaded, and SQL*Loader automatically chooses the best method with which to load the data.
Data files formatted as comma-separated values (CSV) to both SQL*Loader and external tables are supported.
The new parameter, TABLE, turns on express mode. The value of the TABLE parameter is the name of the table that SQL*Loader will load.
If no data file is specified, then looks for file named tablename.dat in the current directory
sqlldr username TABLE=EMPLOYEES
SQL*Loader Express Mode
©2014 OneNeck IT Solutions LLC. All rights reserved. All other trademarks are the property of their respective owners.67 ©2014 TDS Hosted & Managed Services, LLC. All rights reserved. All other trademarks are the property of their respective owners.
“Describe” in RMAN, similar to SQL*Plus.
Most SQL statements can be run in RMAN without the “SQL” prefix (and messing with quotes around the SQL!!).
SYSBACKUP Administration Role – Start replacing scripts where SYSDBA is used
RMAN Notables
Thank you!
Daily #oratidbit on Facebook and Twitter. Follow me!
Tweets: @biju_thomasFacebook: facebook.com/oraclenotes
Blog: bijoos.com/oraclenotes