Professional Documents
Culture Documents
html
http://www.oracle.com/us/products/database/overview/index.html
http://www.infoworld.com/d/data-management/oracle-database-12c-review-finally-true-clouddatabase-221549
Oracle 12c optionally increases these maximum sizes. o o VARCHAR2 : 32767 bytes NVARCHAR2 : 32767 bytes RAW : 32767 bytes
The extended data types functionality is controlled using the MAX_STRING_SIZE initialization parameter The process of switching to the extended data types is a one-way operation
Identity Columns
there was no direct equivalent of the AutoNumber or Identity functionality of other database engines. this behaviour had to be implemented using a combination of sequences and triggers. Oracle 12c introduces two alternatives identity columns sequence pseudocolumns as default values
The syntax is show below. GENERATED [ ALWAYS | BY DEFAULT [ ON NULL ] ] AS IDENTITY [ ( identity_options ) ] CREATE TABLE identity_test_tab ( id NUMBER GENERATED ALWAYS AS IDENTITY, description VARCHAR2(30) );
Using BY DEFAULT allows you to use the identity if the column isn't referenced in the insert statement Using BY DEFAULT ON NULL allows the identity to be used if the identity column is referenced, but a value of NULL is specified. Not surprisingly, trigger-based test performs much worse than the others. The direct use of a sequence and the 12c identity column give comparable results, which are typically an order of magnitude faster than using a trigger to populate the ID column.
because Transact-SQL allows implicit returns of results from queries CREATE PROCEDURE Get_My_Results ( @p_id int ) AS SELECT description, created_date FROM t1 WHERE id = @p_id RETURN 0 GO
In oracle
CREATE OR REPLACE PROCEDURE get_my_results (p_id IN NUMBER DEFAULT NULL) AS
l_cursor_1 SYS_REFCURSOR; BEGIN OPEN l_cursor_1 FOR SELECT description, created_date FROM t1 WHERE id = p_id; DBMS_SQL.RETURN_RESULT(l_cursor_1); END; / SQL> EXEC get_my_results(1); PL/SQL procedure successfully completed. ResultSet #1 DESCRIPTION CREATED_DATE ------------------------------ -------------------The value 1 06-JUL-2013 21:19:45 1 row selected. ResultSet #2 COUNT(*) ---------3 1 row selected. SQL> EXEC get_my_results; PL/SQL procedure successfully completed. ResultSet #1 COUNT(*) ---------3 1 row selected.
); INSERT INTO t1 (description) VALUES ('DESCRIPTION only'); INSERT INTO t1 (id, description) VALUES (999, 'ID=999 and DESCRIPTION'); INSERT INTO t1 (id, description) VALUES (NULL, 'ID=NULL and DESCRIPTION'); SELECT * FROM t1; ID ---------1 999 DESCRIPTION -----------------------------DESCRIPTION only ID=999 and DESCRIPTION ID=NULL and DESCRIPTION
The fact we can use both the NEXTVAL and CURRVAL pseudocolumns gives us the ability to auto-populate master-detail relationships.
Oracle 11g introduced the concept of metadata-only default values. Adding a NOT NULL column with a DEFAULT clause to an existing table involved just a metadata change, rather than a change to all the rows in the table. Queries of the new column were rewritten by the optimizer to make sure the result was consistent with the default definition. Oracle 12c takes this a step further, allowing metadata-only default values of both mandatory and optional columns. As a result, adding a new column with a DEFAULT clause to an existing table will be handled as a metadata-only change, regardless of whether that column is defined as NOT NULL or not. This represents both a space saving and performance improvement.
SQL> SELECT eno,ename,sal FROM emp ORDER BY SAL DESC FETCH FIRST 10 ROWS ONLY;
The following example fetches all similar records of Nth row. For example, if the 10th row has salary of 5000 value, and there are other employees whose salary matches with the Nth value, the will also be fetched upon mentioningWITH TIES clause. SQL> SELECT eno,ename,sal FROM emp ORDER BY SAL DESC FETCH FIRST 10 ROWS ONLY WITH TIES;
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;
The CACHE, NOCACHE, ORDER or NOORDER clauses are ignored for SESSION level sequences.