Enhancements and New Features in Oracle 12c Summarized

Similar documents
Oracle 12c Features You Should Know. Arup Nanda Longtime Oracle DBA

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM

Now, we can refer to a sequence without having to use any SELECT command as follows:

New Oracle 12c Features for Developers

Lab # 4. Data Definition Language (DDL)

Meet MariaDB Vicențiu Ciorbaru Software MariaDB Foundation * * 2017 MariaDB Foundation

Oracle 1z z0-146 Oracle Database 11g: Advanced PL/SQL. Practice Test. Version QQ:

Oracle Tables TECHGOEASY.COM

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

What s New in MariaDB Server Max Mether VP Server

Oracle 11g Virtual Column Inderpal S. Johal. Inderpal S. Johal, Data Softech Inc.

Creating and Managing Tables Schedule: Timing Topic

Full file at

Data Definition Language (DDL)

Oracle Alter Table Add Primary Key Using Index

5. Single-row function

Using SQL with SQL Developer Part II

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

Using SQL with SQL Developer 18.1 Part II

Sql Cannot Create Index On View Not Schema Bound

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com

Chapter 8: Working With Databases & Tables

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Alter Change Default Schema Oracle Sql Developer

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects

Oracle SQL Developer. Oracle TimesTen In-Memory Database Support User's Guide Release 4.0 E

Oracle Database: Program with PL/SQL

Unit 1 - Chapter 4,5

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.

Chapter 1 SQL and Data

Oracle User Administration

Oracle Database: Program with PL/SQL Ed 2

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks)

Oracle PLSQL Training Syllabus

Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days

Conditionally control code flow (loops, control structures). Create stored procedures and functions.

Using SQL with SQL Developer 18.2

Sql Server Syllabus. Overview

Oracle Login Maximum Length Of Column Name In 11g Table

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

Real Application Security Administration

PL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number

SQL: Data De ni on. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 3

Sql Server Check If Global Temporary Table Exists

Db2 Sql Alter Table Add Column Default Value

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

CO Oracle Database 12c: Advanced PL/SQL

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code:

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Configure ODBC on ISE 2.3 with Oracle Database

Oracle Database 11g: SQL and PL/SQL Fundamentals

What s New in MariaDB Server 10.3

Oracle 1Z Upgrade to Oracle Database 12c. Download Full Version :

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Oracle Database 11g: Program with PL/SQL Release 2

SQL Interview Questions

1. Using Bitvise SSH Secure Shell to login to CS Systems Note that if you do not have Bitvise ssh secure shell on your PC, you can download it from

Oracle 11g Invisible Indexes Inderpal S. Johal. Inderpal S. Johal, Data Softech Inc.

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Oracle Database 10g: Introduction to SQL

5 Integrity Constraints and Triggers

TECHNOLOGY: Ask Tom. As Published In. May/June 2011

SQL Data Definition Language: Create and Change the Database Ray Lockwood

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views

SQL Server. Lecture3 Cascading referential integrity constraint

Oracle Database 11g: Program with PL/SQL

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo

Oracle 1Z Oracle Database 11g: Advanced PL/SQL.

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering

2. Programming written ( main theme is to test our data structure knowledge, proficiency

MASTER-DETAIL FORMS. In this Chapter, you will learn about: Master-Detail Forms Page 108

ORACLE Job Placement Paper. Paper Type : General - other

Oracle - Oracle Database: Program with PL/SQL Ed 2

Oracle Database 10g Express

Oracle Database: SQL and PL/SQL Fundamentals NEW

DB2 SQL Class Outline

Module 9: Managing Schema Objects

ORACLE TRAINING. ORACLE Training Course syllabus ORACLE SQL ORACLE PLSQL. Oracle SQL Training Syllabus

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

ACCESS isn t only a great development tool it s

Oracle12c Release 1 New Features for Administrators (5 Days)

Slides by: Ms. Shree Jaswal

Question: Which statement would you use to invoke a stored procedure in isql*plus?

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Oracle SQL & PL SQL Course

In this Lecture. More SQL Data Definition. Deleting Tables. Creating Tables. ALTERing Columns. Changing Tables. More SQL

Introduction to Computer Science and Business

Oracle Database 12c. The Best Oracle Database 12c Tuning Features for Developers and DBAs. Presented by: Alex Zaballa, Oracle DBA

Structure Query Language (SQL)

CHAPTER. Oracle Database 11g Architecture Options

Slides by: Ms. Shree Jaswal

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

GridDB Advanced Edition SQL reference

Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired.

IBM DB2 UDB V7.1 Family Fundamentals.

G64DBS Database Systems. Lecture 6 More SQL Data. Creating Relations. Column Constraints. Last Lecture s Question

Transcription:

Enhancements and New Features in Oracle 12c Summarized In this blog post I would be highlighting few of the features that are now available on Oracle Database 12cRelease. Here listing below in a summarized form the features that can be used by Oracle developers: Multiple indexes on the same column Pre Oracle 12c, you can t create multiple indexes either on the same column or set of columns in any form. For example, if you have an index on column {a} or columns {a,b}, you can t create another index on the same column or set of columns in the same order. In 12c, you can have multiple indexes on the same column or set of columns as long as the index type is different. However, only one type of index is usable/visible at a given time. In order to test the invisible indexes, you need to set the optimizer_use_use_invisible_indexes=true. Here s an the example: SQL> create table t3 (col1 number, col2 number); Table created. SQL> create index in_t3 on t3(col1); Index created. SQL> create index in_t3_02 on t3(col1); create index in_t3_02 on t3(col1) * ERROR at line 1: ORA-01408: such column list already indexed SQL> create bitmap index in_t3_02 on t3(col1) invisible; Index created. Rules Different types: b-tree/bitmap Unique/NonUnique Only one is visible at a time DDL logging There was no direction option available to log the DDL action in the previous releases. In 12cR1, you can now log the DDL action into xml and log files. This will be very useful to know when the drop or create command was executed and by who. The ENABLE_DDL_LOGGING initiation parameter must be configured in order to turn on this feature. The parameter can be set at the database or session levels. When this parameter is enabled, all DDL commands are logged in an xml and a log file under the $ORACLE_BASE/diag/rdbms/DBNAME/log ddl location. An xml file contains information, such as DDL command, IP address, timestamp etc. This helps to identify when a user or table dropped or when a DDL statement is triggered. To enable DDL logging SQL> ALTER SYSTEM SESSION SET ENABLE_DDL_LOGGING=TRUE; Suryakanth Gunti Oracle 12cRelease Features Page 1

The following DDL statements are likely to be recorded in the xml/log file: CREATE ALTER DROP TRUNCATE TABLE DROP USER CREATE ALTER DROP PACKAGE FUNCTION VIEW SYNONYM SEQUENCE The XML format Output is as below: <msg time='2013-08-30t20:29:36.635-04:00' org_id='oracle' comp_id='rdbms' msg_id='opiexe:4181:2946163730' type='unknown' group='diag_adl' level='16' host_id='starupnant420b' host_addr='fe80::58b8:d0b2:f7c9:3147%27' version='1'> <txt> create table t11 (col1 number) </txt> </msg> <msg time='2013-08-30t20:32:56.719-04:00' org_id='oracle' comp_id='rdbms' msg_id='opiexe:4181:2946163730' type='unknown' group='diag_adl' level='16' host_id='starupnant420b' host_addr='fe80::58b8:d0b2:f7c9:3147%27'> <txt>drop table t11 </txt> </msg> Invisible columns In Oracle 11g R1, Oracle introduced a couple of good enhancements in the form of invisible indexes and virtual columns. Taking the legacy forward, invisible column concepts has been introduced in Oracle 12c R1. A Column defined as invisible, will not appear in generic queries (select * from). An Invisible Column needs to be explicitly referred to in the SQL statement or condition. Also invisible column must be explicitly referred in INSERT statement to insert the data into invisible columns. Example: SQL> create table my_table 2 ( 3 id number, 4 name varchar2(100), 5 email varchar2(100), 6 password varchar2(100) INVISIBLE 7 ); If you want to make the column visible again SQL> ALTER TABLE my_table MODIFY (password visible); When the columns are defined as invisible, they won t be displayed when you describe the table structure. However, you can display the information about the invisible columns by setting the following on the SQL*Plus prompt: Suryakanth Gunti Oracle 12cRelease Features Page 2

SQL> SET COLINVISIBLE ON OFF The above setting is only valid for DESCRIBE command. It has not effect on the SELECT statement results on the invisible columns. Now one would be wondering where one could use the feature of invisible. Well it could be handy when you are adding a column to your table, but you don t want any existing code to be impacted by it. Another case where it could be useful is when using audit columns. Columns as the creation_dt, update_dt, user_creation and user_update will only be of any added value when you would like to audit a certain column. Packages with inserts, updates, references to this table will not be impacted by the creation of this column. On the other hand there is also a risk that you forget that this column is in there, because you have to explicitly call for it (a describe or select * will not show this column). Most importantly it could be handy, but don t forget this column or it will pollute your table. Truncate table CASCADE In the previous releases, there wasn t a direct option provided to truncate a master table while it is referred to by the child tables and child records exist. The TRUNCATE TABLE with CASCADE option in 12c truncates the records in the master table and automatically initiates recursive truncate on child tables too, subject to foreign key reference as DELETE ON CASCADE. There is no CAP on the number of recursive levels as it will apply on all child, grand child and great grandchild etc. This enhancement gets rid of the prerequisite to truncate all child records before truncating a master table. The new CASCADE clause can also be applied on table partitions and sub-partitions etc. SQL> TRUNCATE TABLE <table_name> CASCADE; SQL> TRUNCATE TABLE <table_name> PARTITION <partition_name> CASCADE; An ORA-14705 error will be thrown if no ON DELETE CASCADE option is defined with the foreign keys of the child tables. Session level sequences A new SESSION level database sequence can be created now in 12c to support the session level sequence values. These types of sequences are most useful and suitable on global temporary tables that have session level existence. Session level sequences produce a unique range of values that are limited within the session, not across the sessions. Once the session ends, the state of the session sequences also goes away. The following example explains creating a session level sequence: SQL> CREATE SEQUENCE my_seq START WITH 1 INCREMENT BY 1 SESSION; SQL> ALTER SEQUENCE my_seq GLOBAL SESSION; Suryakanth Gunti Oracle 12cRelease Features Page 3

The CACHE, NOCACHE, ORDER or NOORDER clauses are ignored for SESSION level sequences. Extended data types In 12c, the data type VARCHAR2, NAVARCHAR2, and RAW size will support up to 32,767 bytes in contrast to 4,000 and 2,000 in the earlier releases. The extended character size will reduce the use of going for LOB data types, whenever possible. In order to enable the extended character size, you will have to set the MAX_STRING_SIZE initialization database parameter to EXTENDED. Generated as Identity/Sequence Replacement You can now create a column with 'generated as identity' clause. Thats it. Doing this is equivalent to creating a separate sequence and doing a sequence.nextval for each row. This is another handy and a neat feature which will help developer community. This is also called No Sequence Auto Increment Primary Key. Identity Column creation: SQL> create table t6 (col1 number generated always as identity); SQL> create table t7 (col1 number generated always as identity (start with 1000 increment by 10)); SQL> insert into t6 values (1); insert into t6 values (1) * ERROR at line 1: ORA-32795: cannot insert into a generated always identity column SQL> create table t9 (col1 number, col2 number generated by default as identity); SQL> insert into t9 values (9,9); SQL> insert into t9 values (10,default); SQL> insert into t9 (col1) values (11); SQL> select * from t9; COL1 COL2 ---------- ---------- 9 9 10 2 11 3 WITH clause improvements In 12c, you can have faster running PL/SQL function/procedure in SQL, that are defined and declared within the WITH clause of SQL statements. The following examples demonstrate how to define and declare a procedure or function within the WITH clause: WITH PROCEDURE FUNCTION test1 ( ) BEGIN <logic> END; SELECT <referece_your_function procedure_here> FROM table_name; Suryakanth Gunti Oracle 12cRelease Features Page 4

Although you can t use the WITH clause directly in the PL/SQL unit, it can be referred through a dynamic SQL within that PL/SQL unit. The with clause inline PLSQL feature will make it possible to create a procedure or function inside your select statement instead of having to create this in a package or function. Oracle also says that this will optimize the performance against having to call a schema procedure/function An Example: WITH FUNCTION FUNC_ADD_ONE(p_num IN NUMBER IS BEGIN RETURN p_num+1; SELECT FUNC_ADD_ONE(1) FROM Dual; ROW limiting for Top-N result queries There are various indirect approaches/methods exist to fetch Top-N query results for top/bottom rows in the previous releases. In 12c, retrieving Top-N query results for top/bottom rows simplified and become straight forward with the new FETCH FIRST NEXT PERCENT clauses. In order to retrieve top 10 salaries from EMP table, use the following new SQL statement: SQL> SELECT eno,ename,sal FROM emp ORDER BY SAL DESC FETCH FIRST 10 ROWS ONLY; The following example limits the fetch to 10 per cent from the top salaries in the EMP table: SQL> SELECT eno,ename,sal FROM emp ORDER BY SAL DESC FETCH FIRST 10 PERCENT ROWS ONLY; The following example offsets the first 5 rows and will display the next 5 rows from the table: SQL> SELECT eno,ename,sal FROM emp ORDER BY SAL DESC OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY; All these limits can be very well used within the PL/SQL block too. BEGIN SELECT sal BULK COLLECT INTO sal_v FROM EMP FETCH FIRST 100 ROWS ONLY; END; Top-N Restrictions: If you have a SELECT statement with FOR UPDATE, you can t use it. If the query of the Materialized Views has this clause, then you can t do an incremental refresh of that MV Suryakanth Gunti Oracle 12cRelease Features Page 5

DEFAULT Values for Columns on Explicit NULL Insertion The DEFAULT definition of a column can be extended to have the DEFAULT being applied for explicit NULL insertion. The DEFAULT clause has a new ON NULL clause, which instructs the database to assign a specified default column value when an INSERT statement attempts to assign a value that evaluates to NULL. SQL> create table t5 (col1 number, col2 number default on null 0); Table created. SQL> desc t5 Name Null? Type ------ --------- -------- -- COL1 NUMBER COL2 NOT NULL NUMBER SQL> insert into t5 values (1, null); SQL> insert into t5 values (2,2); SQL> select * from t5; COL1 COL2 -------- --------- 1 0 2 2 With this entire list of new enhancement available in 12cRelease, gives us a reason to start using the Oracle 12c database. Thanks and Happy Learning!!!!!!!!!!!!!!!!!!! Suryakanth Gunti Oracle 12cRelease Features Page 6