New features in Oracle Database 12c


New features in Oracle Database 12c:

===============================================
Oracle Database 12c, c for cloud, a multi-tenant database management system, with nearly 500 new features.
  • Increased size limit for VARCHAR2, NVARCHAR2, and RAW datatypes to 32K.
  • Oracle Database 12c has new feature called "Identity Columns" which are auto-incremented at the time of insertion (like in MySQL).
  • Temporary undo (for global temporary tables) will not generate undo.
  • Oracle Database 12c Data Pump will allow turning off redo for the import operation only.
  • Enhanced statistics (Hybrid histograms for more than 254 distinct values, dynamic sampling up to eleven, and stats automatically gathered during load).
  • No need to shutdown database to take out of archive log mode.
  • Row pattern matching - "MATCH_RECOGNIZATION" (identification of patterns within a table ordered/sorted by the SQL statement).
  • Adaptive execution plans (change of the plan at runtime).
  • Duplicate Indexes - Create duplicate indexes on the same set of columns. Till Oracle 11.2, if we try to create an index using the same columns, in the same order, as an existing index, we'll get an error. In some cases, we might want two different types of index on the same data (such as in a datawarehouse where we might want a bitmap index on the leading edge of a set of columns that exists in a Btree index).
  • Centralised patching.
  • We can test patches on database copies, rolling patches out centrally once testing is complete.
  • PL/SQL inside SQL: this new feature allows to use DDL inside SQL statements (i.e.: to create a one shot function)
  • The object DEFAULT clause has been enhanced. Adding a column to an existing table with a default value (much faster with Oracle 12c and it consumes less space than before, pointer to the Oracle Data Dictionary), applies also to sequences, identity types etc...
  • Partitioning enhancements (partition truncate, cascading, global index cleanup, online moving of a partition, ...)
  • Interval-Ref Partitions - we can create a ref partition (to relate several tables with the same partitions) as a sub-partition to the interval type.
  • Oracle 12c includes database level redaction, allowing granular control of access to sensitive data.
  • Pagination query, SQL keywords (LIMIT) to replace ROWNUM records.
  • Moving and Renaming datafile is now ONLINE.
  • RMAN TABLE Point-In-Time Recovery (combination of data pump and RMAN, auxiliary instance required).
  • Oracle Enterprise Manage Express (lightweight EM Cloud Control 12c version) replaces the Oracle Database console and is installed automatically.
  • The TRUNCATE command has been enhanced with a CASCADE option which follows child records.
  • Oracle introduced the parameter PGA_AGGREGATE_LIMIT which is a real memory limit.


PL/SQL
  • PL/SQL Unit Security - A role can now be granted to a code unit. That means you can determine at a very fine grain, who can access a specific unit of code.
  • SQL WITH Clause Enhancement - In 12c, we can declare PL/SQL functions in the WITH Clause of a select statement. 
  • Implicit Result Sets - create a procedure, open a ref cursor, return the results. No types, not muss, no mess. Streamlined data access (kind of a catch up to other databases).
  • MapReduce in the Database - MapReduce can be run from PL/SQL directly in the database.
  • We can use Booleans values in dynamic PL/SQL. Still no Booleans as database types.

Compression:
Automated compression with heat map.

Optimisation can be run on live databases with no disruption. Data optimization will monitor the data usage and with policy archive old data and hot data will be compressed for faster access. Inactive data can be more aggressively compressed or archived, greatly reducing storage costs.


Advanced Row compression (for Hot Data).

Columnar Query compression (for Warm Data).
Columnar Archive compression (for Archive Data).

Data Guard:

Oracle Database 12c introduces a new redo transportation method which omits the acknowledgement (to primary) of the transaction on the standby. This feature is called "Fast Sync" redo transport.

Creating a new type of redo destination called "Far Sync Standby". A "Far Sync Standby" is composed only of the standby control files, the standby redo logs and some disk space for archive logs which shall be sent to the Standby database. Failover & Switchover operations are totally transparent as the "Far Sync Standby" cannot be used as the target.

Data Guard Broker commands have been extended. The "validate database" command to checks whether the database is ready for role transition or not.


Global Temporary Tables can now be used on an Active Guard standby database. 

Pluggable Databases:

In Oracle 12c, in a pluggable database environment, we can create a single database container, and plug multiple databases into this container. All these databases then share the exact same oracle server/background processes and memory, unlike the previous versions where each database has its own background processes and shared memory. This helps in database consolidation and reduces the overhead of managing multiple desperate databases.

Container Database (CDB): Are the core data dictionary objects that come after an Oracle database installation.

Pluggable Database (PDB): Data dictionary objects and data related to the application. We can have many PDB plugged into a single CDB.

A new admin role "CDB Administrator" has been introduced in Oracle 12.1 release databases.

Multiple databases can then share a master LGWR process, but have their own dedicated LGWR process within the container.
All Oracle database options/features are available on the PDB level.
RMAN backup at CDB level.
We can unplug a PDB from a CDB to another CDB.
PDB's can be cloned inside the CDB.
Management of PDB (clone/creation/plug/unplug/drop) are implemented as SQLs.
Extremely fast PDB-provisioning (clone inside the CDB), because each CDB comes with a “PDB Seed”
.
Database patch/upgrade management very quick as CDB is a single point of installation.
Each PDB has its own data dictionary.
Data Guard configuration on CDB as whole.
RMAN point-in-time recovery at PDB level (while other PDB's remains open).

Resource Manager is extended for creating, unplugging, plugging in, and cloning, dropping or even setting up for the open mode of the PDB.
Flashback of a PDB should be available for Oracle 12c Release 2.

Entire containers can be backed up in single run, regardless of how many databases they contain.

Upgrade one container database and all pluggable databases are upgraded.

New Commands
create pluggable database ...
alter pluggable database ...
drop pluggable database ...

New Views/Packages in Oracle 12c Release1
dba_pdbs
v$pdbs
cdb_data_files

dbms_pdb

RMAN HOT CLONING


Cloning steps using Rman and hotbackup:

========================================
                          
$ cd $ORACLE_HOME/network/admin
$ vi listener.ora
MY_LIS =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.55.219)(PORT = 6261))
      )
  )
)
SID_LIST_MY_LIS =
         (SID_LIST =
         (SID_DESC =
           (ORACLE_HOME =/u01/app/oracle/product/10.2.0.1.0)
           (SID_NAME =galaxy)
         )
)
$ cd $ORACLE_HOME/network/admin
$ vi tnsnames.ora
to_galaxy =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.55.219)(PORT = 6261))
    )
  (CONNECT_DATA =
    (SERVICE_NAME =galaxy)
  )
)
SQL> create tablespace rmants datafile ‘/u05/davedb/rmants.dbf’ size 200m;
Tablespace created.
SQL>
SQL> create user rms identified by rms default tablespace rmants;
User created.
SQL>
SQL> grant connect,resource,recovery_catalog_owner to rms;
Grant succeeded.
SQL>
$ rman catalog rms/rms
Recovery Manager: Release 10.2.0.1.0 – Production on Fri Aug 3 18:28:27 2007
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to recovery catalog database
RMAN>
RMAN> create catalog;
recovery catalog created
RMAN> exit
$ rman catalog rms/rms target sys/admin@to_galaxy
Recovery Manager: Release 10.2.0.1.0 – Production on Fri Aug 3 19:00:09 2007
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: GALAXY (DBID=3423097528)
connected to recovery catalog database
RMAN>
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
RMAN> show all;
starting full resync of recovery catalog
full resync complete
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/rman/auto/%F’;
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   ‘/u01/rman/backup_%U’;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   ‘/u01/rman/backup_%U’;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM ‘AES128′; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/u01/rman/snap/snap.f’;
RMAN>
RMAN>  run {
2>         backup database;
3>         change archivelog all validate;
4>         sql’alter system archive log current’;
5>         backup archivelog all;
6>        }
Starting backup at 08-AUG-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=22 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=21 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/product/davedb/system.dbf
input datafile fno=00005 name=/u01/product/davedb/dict.dbf
channel ORA_DISK_1: starting piece 1 at 08-AUG-07
channel ORA_DISK_2: starting full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/product/davedb/sysaux.dbf
input datafile fno=00002 name=/u01/product/davedb/undotbs.dbf
input datafile fno=00004 name=/u01/product/davedb/ts11.dbf
channel ORA_DISK_2: starting piece 1 at 08-AUG-07
channel ORA_DISK_1: finished piece 1 at 08-AUG-07
piece handle=/u01/rman/backup_0mios0bk_1_1 tag=TAG20070808T093756 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_2: finished piece 1 at 08-AUG-07
piece handle=/u01/rman/backup_0nios0bk_1_1 tag=TAG20070808T093756 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07
Finished backup at 08-AUG-07
$ mkdir auxdb
$ cd auxdb
$ mkdir bdump cdump cdump
$ cd $ORACLE_HOME/dbs
$ cp initgalaxy.ora initauxdb.ora
$ vi initauxdb.ora
 Compatible=10.2.0.1.0
Db_name=auxdb
Control_files=/u01/product/auxdb/control01.ctl
Db_block_size=2048
User_dump_dest=/u01/product/auxdb/udump
Core_dump_dest=/u01/product/auxdb/cdump
Background_dump_dest=/u01/product/auxdb/bdump
Shared_pool_size=67232153
Undo_management=auto
Undo_tablespace=undotbs
db_file_name_convert=(‘/u01/product/davedb’,’/u01/product/auxdb’)
log_file_name_convert=(‘u01/product/davedb’,’/u01/product/auxdb’)
remote_login_passwordfile=exclusive
~
~
~
~
“initauxdb.ora” 14L, 382C
$ orapwd file=orapw$ORACLE_SID password=admin entries=5
$
$ vi listener.ora
SID_LIST_MY_LIS =
         (SID_LIST =
         (SID_DESC =
           (ORACLE_HOME =/u01/app/oracle/product/10.2.0.1.0)
           (SID_NAME =galaxy)
         )
         (SID_DESC =
          (ORACLE_HOME =/u01/app/oracle/product/10.2.0.1.0)
          (SID_NAME =auxdb)
         )
)
$ vi tnsnames.ora
auxdb =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL=TCP) (HOST=172.16.55.219)(PORT=6261))
  )
  (CONNECT_DATA =
   (SERVICE_NAME = auxdb)
 )
)
$lsnrctl
LSNRCTL for Linux: Version 10.2.0.1.0 – Production on 08-AUG-2007 08:50:53
Copyright (c) 1991, 2005, Oracle.  All rights reserved.
Welcome to LSNRCTL, type “help” for information.
LSNRCTL> stop MY_LIS
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.55.219)(PORT=6261)))
The command completed successfully
LSNRCTL> start MY_LIS
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.55.219)(PORT=6261)))
Services Summary…
Service “auxdb” has 1 instance(s).
  Instance “auxdb”, status UNKNOWN, has 1 handler(s) for this service…
Service “galaxy” has 1 instance(s).
  Instance “galaxy”, status UNKNOWN, has 1 handler(s) for this service…
The command completed successfully
LSNRCTL>
$ export ORACLE_SID=auxdb
$ sqlplus “/as sysdba”
SQL*Plus: Release 10.2.0.1.0 – Production on Wed Aug 8 08:59:59 2007
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initauxdb.ora
ORACLE instance started.
Total System Global Area  155189248 bytes
Fixed Size                  1218220 bytes
Variable Size              96471380 bytes
Database Buffers           50331648 bytes
Redo Buffers                7168000 bytes
SQL>
$ rman catalog rms/rms target sys/admin@to_galaxy auxiliary sys/admin@auxdb
Recovery Manager: Release 10.2.0.1.0 – Production on Tue Aug 7 18:09:32 2007
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: GALAXY (DBID=3423097528)
connected to recovery catalog database
connected to auxiliary database: AUXDB (not mounted)
RMAN>duplicate target database to auxdb pfile=$ORACLE_HOME/dbs/initauxdb.ora;
Starting Duplicate Db at 07-AUG-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=35 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=34 devtype=DISK
contents of Memory Script:
{
   set until scn  313251;
   set newname for datafile  1 to
 ”/u01/product/auxdb/system.dbf”;
   set newname for datafile  2 to
 ”/u01/product/auxdb/undotbs.dbf”;
   set newname for datafile  3 to
 ”/u01/product/auxdb/sysaux.dbf”;
   set newname for datafile  4 to
 ”/u01/product/auxdb/ts11.dbf”;
   set newname for datafile  5 to
 ”/u01/product/auxdb/dict.dbf”;
   restore
   check readonly
   clone database
   ;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 07-AUG-07
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_2
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/product/auxdb/system.dbf
restoring datafile 00005 to /u01/product/auxdb/dict.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman/backup_0fioq9kk_1_1
channel ORA_AUX_DISK_2: starting datafile backupset restore
channel ORA_AUX_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/product/auxdb/undotbs.dbf
restoring datafile 00003 to /u01/product/auxdb/sysaux.dbf
restoring datafile 00004 to /u01/product/auxdb/ts11.dbf
channel ORA_AUX_DISK_2: reading from backup piece /u01/rman/backup_0gioq9kk_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/rman/backup_0fioq9kk_1_1 tag=TAG20070807T180403
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_2: restored backup piece 1
piece handle=/u01/rman/backup_0gioq9kk_1_1 tag=TAG20070807T180403
channel ORA_AUX_DISK_2: restore complete, elapsed time: 00:00:07
Finished restore at 07-AUG-07
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “AUXDB” RESETLOGS ARCHIVELOG
  MAXLOGFILES      5
  MAXLOGMEMBERS      5
  MAXDATAFILES      100
  MAXINSTANCES     1
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( ‘/u01/product/auxdb/redolog1a.dbf’ ) SIZE 10 M  REUSE,
  GROUP  2 ( ‘/u01/product/auxdb/redolog2b.dbf’ ) SIZE 10 M  REUSE
 DATAFILE
  ‘/u01/product/auxdb/system.dbf’
 CHARACTER SET US7ASCII
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
released channel: ORA_AUX_DISK_2
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=630007813 filename=/u01/product/auxdb/undotbs.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=630007813 filename=/u01/product/auxdb/sysaux.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=630007813 filename=/u01/product/auxdb/ts11.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=630007813 filename=/u01/product/auxdb/dict.dbf
contents of Memory Script:
{
   set until scn  313251;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-AUG-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=35 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=37 devtype=DISK
starting media recovery
archive log thread 1 sequence 77 is already on disk as file /u01/product/davedb/arch/1_77_629394680.dbf
archive log thread 1 sequence 78 is already on disk as file /u01/product/davedb/arch/1_78_629394680.dbf
archive log filename=/u01/product/davedb/arch/1_77_629394680.dbf thread=1 sequence=77
archive log filename=/u01/product/davedb/arch/1_78_629394680.dbf thread=1 sequence=78
media recovery complete, elapsed time: 00:00:02
Finished recover at 07-AUG-07
contents of Memory Script:
{
   shutdown clone;
   startup clone nomount pfile= ‘$ORACLE_HOME/dbs/initauxdb.ora’;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area     155189248 bytes
Fixed Size                     1218220 bytes
Variable Size                 96471380 bytes
Database Buffers              50331648 bytes
Redo Buffers                   7168000 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “AUXDB” RESETLOGS ARCHIVELOG
  MAXLOGFILES      5
  MAXLOGMEMBERS      5
  MAXDATAFILES      100
  MAXINSTANCES     1
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( ‘/u01/product/auxdb/redolog1a.dbf’ ) SIZE 10 M  REUSE,
  GROUP  2 ( ‘/u01/product/auxdb/redolog2b.dbf’ ) SIZE 10 M  REUSE
 DATAFILE
  ‘/u01/product/auxdb/system.dbf’
 CHARACTER SET US7ASCII
contents of Memory Script:
{
   set newname for tempfile  1 to
 ”/u01/product/auxdb/temp01.dbf”;
   switch clone tempfile all;
   catalog clone datafilecopy  “/u01/product/auxdb/undotbs.dbf”;
   catalog clone datafilecopy  “/u01/product/auxdb/sysaux.dbf”;
   catalog clone datafilecopy  “/u01/product/auxdb/ts11.dbf”;
   catalog clone datafilecopy  “/u01/product/auxdb/dict.dbf”;
   switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/product/auxdb/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/undotbs.dbf recid=1 stamp=630007823
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/sysaux.dbf recid=2 stamp=630007823
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/ts11.dbf recid=3 stamp=630007823
cataloged datafile copy
datafile copy filename=/u01/product/auxdb/dict.dbf recid=4 stamp=630007823
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=630007823 filename=/u01/product/auxdb/undotbs.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=630007823 filename=/u01/product/auxdb/sysaux.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=630007823 filename=/u01/product/auxdb/ts11.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=630007823 filename=/u01/product/auxdb/dict.dbf
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
 database opened
Finished Duplicate Db at 07-AUG-07
RMAN>
 =========================================================================
using hot backup steps
Posted by yathish k s on March 26, 2010
Below steps helps you in performing database cloning using hot backup
Assumptions:
1. directory structure is different in both source and target servers
2. Oracle version : 10.2.0.4
3. OS version : Linux 5
4. target database name is same as source database name
step 1 :  Take the hot backup of source database
sql> alter database begin backup;
$ copy datafiles to backup location
sql> alter database end backup;
step 2 : Take controlfile trace and pfile or spfile (that was using by the source database)
step 3 : Install Oracle software on another machine (choose “Install only” option in OUI). Don’t create any database
step 4 : Copy all the files (including trace file and pfile or spfile) from source server to target server either using FTP or rcp
Note: Not necessary in copying control files and redologfiles
step 5 : Place pfile or spfile in “dbs” directory on target
step 6 : Copy the remaining files to their respective locations (If any directories are missing, do create them)
step 7 : Connect as sysdba and Startup the database in nomount stage
step 8 : Edit the trace file (that was copied) and generate a create controlfile script from it. Modify the script and specify the new locations of  the files.
step 9 : Execute the controlfile script which will create controlfiles in the location specified in CONTROL_FILES parameter. Once control files are created, database will be forwarded to MOUNT state.
sql> @create_controlfile.sql
step 10 : Finally, Open the database with resetlogs option
sql> alter database open resetlogs;