H.Tonguç Yılmaz - tonguc.yilmaz@gmail.com Veritabanı geliştiricileri için Oracle 11g yeni özellikleri TROUG Oracle Day etkinliği Lütfi Kırdar Kongre Merkezi 04/11/2010 http://www.troug.org H.Tonguç Yılmaz - tonguc.yilmaz@gmail.com http://friendfeed.com/TongucY
http://tonguc.wordpress.com/about/ H.Tonguç Yılmaz: Oracle veritabanı uzmanı - iyi bir Fenerbahçe taraftarı - Metal müzik sever - Bol bol DVD izler vs. Fethiye Lisesi, İTÜ Bilgisayar Müh., Bilgi MBA C Developer, Informix DBA-Hp Unix Admin, Oracle DBA, Oracle ETL Developer, DW Development Team Leader 1996 Tekstilbank, 2000 Turkcell, 2008 Turkcell Teknoloji 10+ sene Oracle veritabanı tecrübesi, Oracle 8i,9i,10g OCP & 2007 Oracle ACE, 2005 Oracle blogger 2002 Turkcell Akademi Oracle veritabanı iç eğitmeni & 2002 TTech Paf koçu 1999 OracleTurk moderatör, 2010 TROUG kurucu üye http://tonguc.wordpress.com/about/
Her yeni sürüm ile birlikte ilk göz atılacak ilk yer
Bu oturum veritabanı geliştiricileri içindir SQL iyileştirmeleri: Native Support for Pivot and Unpivot, Recursive WITH clause, Nth value for inter-row calculation, New aggregate function LISTAGG, Hash based DISTINCT aggregation, NULL-aware anti join, GROUP BY aggregation improvements PL/SQL iyileştirmeleri: Transparent performance: Fine Grained Dependency Tracking, Parameterized Performance: Real native compilation, Usability of the language: Sequence in a PL/SQL expression, PL/Scope, PL/SQL Hierarchical Profiler, When others then null warning, Named and Mixed Notation in SQL Şema yönetimi iyileştirmeleri Virtual Columns, Faster Add Not Null Column with Default Value, Read Only table, Invisible indexes, DDL can now wait, Segment creation on demand Sorgu çalıştırma iyileştirmeleri Guaranteed plan stability with controlled plan evolution: SQL Plan Management, Collect more statistics – better, faster, Multi-column statistics, Faster calculation of NDV, Control and manage new statistics propagation: Separate statistic discovery and publication, Enhanced bind peeking: Properly address data skew, Multi-Predicate Pruning Real Time SQL Monitor Flashback Data Archive, Total Data Recall Cube Organized Materialized Views Real Application Testing: Database Replay & SQL Performance Analyzer (SPA) Partitioning, Advanced Compression, Parallel Query, Resource Manager Unstructured Data & Application Development : Securefiles, Multimedia, Spatial, XML DB Java & PHP Exadata V2: Hybrid columnar compression, Storage indexes, Enhanced offloading capabilities, data mining model scoring Online application upgrade with edition based redefinition Sadece Db Developer’lar için 11gNF kapsam dahilinde bu sunumda, bu kısımda zaman el verdiği kadar DB Developer’lar dışındaki Developer’lar kapsam dışı DBA’ler için 11gNF kapsam dışı DW için 11gNF kapsam dışı ExadataV2 kapsam dışı Resimler Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
Oracle kısa tarihçe 1978 Oracle V1; pazardaki ilk *satış* amaçlı ilişkisel SQL veritabanı yönetim sistemi ... 7.3 1996 8.0 1997 Oracle 8 8.1.5 1999 Oracle 8i Release 1 8.1.6 1999 Oracle 8i Release 2 8.1.7 2000 Oracle 8i Release 3 9.1 2001 Oracle 9i Release 1 9.2 2002 Oracle 9i Release 2 10.1 2004 Oracle 10g Release 1 10.2 2005 Oracle 10g Release 2 ( XE ! ) 11.1 2007 Oracle 11g Release 1 11.2 2009 Oracle 11g Release 2 http://www.oracle.com/timeline/index.html
Artık Apex & OWB standart kurulumun parçası http://download.oracle.com/docs/cd/E11882_01/owb.112/e10581/whatsnew.htm#WBCON4378 http://www.oracle.com/technetwork/developer-tools/apex/application-express/4-155207.html Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan Apex ve OWB standart ETL özellikleri veritabanı lisansının içindedir, ek maliyet yaratmazlar
Güle güle SQL*Plus, hoş geldin SQL Developer Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan SQL*Plus komut satırı hala bizimle, panik yok SQL*Plus 11g ile BLOB ile BFILE kolonları da artık gösterebiliyor.
Asynchronous Change Data Capture LOB'leri artık destekliyor Asynchronous Change Data Capture henüz desteklenmeyen veri tipleri: BFILE LONG ROWID UROWID object types (XMLType gibi) virtual columns Asynchronous Change Data Capture desteklenmeyen tablo yapıları: temporary tables object tables Desteklenmeyen veri tipleri içeren(LOB kolonlar dahil) veya overflow segments sahibi olan Index-organized tables http://tonguc.wordpress.com/2009/01/26/improvements-with-111-for-the-datatypes-and-table-structures-supported-for-asynchronous-change-data-capture-option http://tonguc.wordpress.com/2008/03/21/oracle-change-data-capture-under-magnifier-async-cdc-with-10gr2
Şifrelerde küçük-büyük harf kullanımı CONN / AS SYSDBA CREATE USER test2 IDENTIFIED BY Test2; GRANT CONNECT TO test2; SQL> CONN test2/Test2 Connected. SQL> CONN test2/test2 ERROR: ORA-01017: invalid username/password; logon denied SQL> SHOW PARAMETER SEC_CASE_SENSITIVE_LOGON NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ sec_case_sensitive_logon boolean TRUE ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE; 11g ile artık Audit özeliği kurulum ile birlikte açık ve AUDIT_TRAIL değeri DB ön tanımlı. http://tonguc.wordpress.com/2009/02/28/on-some-111-security-features-and-enhancements
SQL*Plus ERRORLOGGING özelliği SQL, PL/SQL veya SQL*Plus hataları artık SPERRORLOG tablosunda kaydediliyor. create table tong.tong_sperrorlog(username varchar(256), timestamp TIMESTAMP, script varchar(1024), identifier varchar(256), message CLOB, statement CLOB); set errorlogging on table tong_sperrorlog create table tong ( c1 number ) ; set errorlogging off select timestamp, statement, message from tong_sperrorlog; TIMESTAMP 22-JUN-08 07.00.27.000000 PM STATEMENT create table tong ( c1 number ) MESSAGE ORA-01031: insufficient privileges 11g istemci 9i veya 10g sunuculara bağlanarak da kullanılabiliyor, detaylar $ORACLE_HOME/sqlplus/doc/elgsetup.txt dosyasında. http://tonguc.wordpress.com/2008/06/22/some-usefull-oracle-database-utilities-and-errorlogging-feature-of-11gs-sqlplus
ALTER TABLE .. ADD COLUMN iyileştirmeleri 11g öncesinde DEFAULT değerli yeni bir kolon ve NOT NULL constraint eklemek tablo üzerinde exclusive kilit alıyordu ve varsayılan değer tablodaki tüm satırlara güncellenmesi gerektiriyordu. 11g sonrasında varsayılan değer data dictionary kaydediliyor ve büyük tablolar için tüm kayıtların güncellenmesi işleminden kurtulunuyor. Ek olarak alttaki ADD COLUMN operasyonları artık DML cümleleri ile birlikte problemsiz çalışabiliyor: Varsayılan değerli NOT NULL kolon ekleme Varsayılan değeri olmayan bir nullable kolon ekleme Virtual kolon ekleme -- 10.2 create table tst_source nologging as select rownum id, text from dba_source; set timing on ALTER TABLE tst_source ADD (name VARCHAR2(16) DEFAULT 'N' NOT NULL); Elapsed: 00:00:30.43 -- 11.1 create table tst_source nologging as select rownum id, text from dba_source; Elapsed: 00:00:00.10 http://tonguc.wordpress.com/2008/09/28/11g-enhancement-for-alter-table-add-column-functionality https://metalink.oracle.com/CSP/main/article?cmd=show&type=NOT&id=602327.1 http://www.oracle.com/technetwork/articles/sql/11g-schemamanagement-089869.html
Sanal Kolonlar Var olan kolon değerlerinden hesaplanan yeni kolonlar, DML göremezler, indeksler üzerindeki function based index olarak yönetilir, Index-organized, external, object, cluster, veya temporary tablolar için desteklenmiyor henüz. CREATE TABLE employees ( id NUMBER, first_name VARCHAR2(10), last_name VARCHAR2(10), salary NUMBER(9,2), comm1 NUMBER(3), comm2 NUMBER(3), salary1 AS (ROUND(salary*(1+comm1/100),2)), salary2 NUMBER GENERATED ALWAYS AS (ROUND(salary*(1+comm2/100),2)) VIRTUAL, CONSTRAINT employees_pk PRIMARY KEY (id) ); INSERT INTO employees (id, first_name, last_name, salary, comm1, comm2) VALUES (1, 'JOHN', 'DOE', 100, 5, 10); INSERT INTO employees (id, first_name, last_name, salary, comm1, comm2) VALUES (2, 'JAYNE', 'DOE', 200, 10, 20); COMMIT; SELECT * FROM employees; ID FIRST_NAME LAST_NAME SALARY COMM1 COMM2 SALARY1 SALARY2 ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 1 JOHN DOE 100 5 10 105 110 2 JAYNE DOE 200 10 20 220 240 SELECT column_name, data_default FROM user_tab_columns WHERE table_name = 'EMPLOYEES'; COLUMN_NAME DATA_DEFAULT ------------------------------ -------------------------------------------------- ... SALARY1 ROUND("SALARY"*(1+"COMM1"/100),2) SALARY2 ROUND("SALARY"*(1+"COMM2"/100),2) http://www.oracle-base.com/articles/11g/VirtualColumns_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-schemamanagement-089869.html
DDL bekletme opsiyonu (DDL_LOCK_TIMEOUT) DDL_LOCK_TIMEOUT parametresi bir DDL komutunun kaç saniye bekleyeceğini ilgili aktif işlemi belirliyor, ALTER SYSTEM veya ALTER SESSION ile kullanılabiliyor. Var sayılan değer 0 saniye. -- session 1 CREATE TABLE lock_tab ( id NUMBER ); INSERT INTO lock_tab VALUES (1); -- session 2 ALTER TABLE lock_tab ADD ( description VARCHAR2(50) ); ALTER TABLE lock_tab ADD ( * ERROR at line 1: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired ALTER SESSION SET ddl_lock_timeout=30; ALTER TABLE lock_tab ADD ( description VARCHAR2(50) ); COMMIT; Table altered. http://www.oracle-base.com/articles/11g/DdlLockTimeout_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-schemamanagement-089869.html
Görünmez Indeksler CBO'nun indeksiz davranmasına zorlamak amacı ile, arkada indeks bakimi devam ediyor aslında. VISIBILITY kolonu [DBA|ALL|USER]_INDEXES görüntülerinde değeri görmek için kullanılabilir. DROP INDEX etkisi testi için kullanışlı olabilir. CREATE TABLE ii_tab ( id NUMBER ); BEGIN FOR i IN 1 .. 10000 LOOP INSERT INTO ii_tab VALUES (i); END LOOP; COMMIT; END; / CREATE INDEX ii_tab_id ON ii_tab(id) INVISIBLE; EXEC DBMS_STATS.gather_table_stats(USER, 'ii_tab', cascade=> TRUE); SET AUTOTRACE ON SELECT * FROM ii_tab WHERE id = 9999; ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | | 0 | SELECT STATEMENT | | 1 | 3 | 7 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| II_TAB | 1 | 3 | 7 (0)| 00:00:01 | ALTER SESSION SET OPTIMIZER_USE_INVISIBLE_INDEXES=TRUE; ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | | 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 | |* 1 | INDEX RANGE SCAN| II_TAB_ID | 1 | 3 | 1 (0)| 00:00:01 | http://www.oracle-base.com/articles/11g/InvisibleIndexes_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-schemamanagement-089869.html
Salt okunur tablolar 11g öncesinde bir tabloyu sahibi dışında GRANT'ler üzerinden salt okunur kılmak mümkündü, bu yeni özellikle sahibi dahil tüm kullanıcılara DML/DDL işlemler tablo üzerinde yasaklanabiliyor. READ_ONLY kolon [DBA|ALL|USER]_TABLES görüntülerinde durumu gösteriyor. CREATE TABLE ro_tab ( id NUMBER ); INSERT INTO ro_tab VALUES (1); ALTER TABLE ro_tab READ ONLY; SQL> INSERT INTO ro_tab VALUES (2); SQL> UPDATE ro_tab SET id = 2; SQL> DELETE FROM ro_tab; SQL> TRUNCATE TABLE ro_tab; SQL> ALTER TABLE ro_tab ADD (description VARCHAR2(50)); ORA-12081: update operation not allowed on table "TEST"."RO_TAB“ ALTER TABLE ro_tab READ WRITE; http://www.oracle-base.com/articles/11g/ReadOnlyTables_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-schemamanagement-089869.html
SEQUENCE kullanımı declare l_seq number; begin select orders_seq.nextval into l_seq from dual; ... end; http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php#sequences_in_plsql_expressions http://www.oracle.com/technetwork/articles/sql/11g-efficient-coding-093640.html Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan declare l_seq number := orders_seq.nextval; begin ... end;
SQL motorundan PL/SQL işlev çağırımı iyileştirmesi function f_get_cnt (p_deptno in dept.deptno%type := null ,p_loc in dept.loc%type := null ) return number SQL> select ename 2 , f_get_cnt (p_loc => ‘NEW YORK’) 3 from emp 4 / http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php#named_and_mixed_notation_in_sql Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan 17
CONTINUE begin for i in 1..3 loop dbms_output.put_line ('i= '||to_char(i)); if i = 2 then null; else dbms_output.put_line ('Only if i is not equal to 2'); end if; end loop; end; i= 1 Only if i is not equal to 2 i= 2 i= 3 http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php#continue_statement Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan begin for i in 1..3 loop dbms_output.put_line ('i= '||to_char(i)); continue when i = 2; dbms_output.put_line ('Only if i is not equal to 2'); end loop; end;
Trigger tetiklenme sırası yönetimi Hangisi daha önce çalışacak? create or replace trigger emp_bir_1 before insert on emp for each row begin ... end emp_bir_1; create or replace trigger emp_bir_1 before insert on emp for each row begin ... end emp_bir_1; create or replace trigger emp_bir_2 before insert on emp for each row follows emp_bir_1 begin ... end emp_bir_2; create or replace trigger emp_bir_2 before insert on emp for each row begin ... end emp_bir_2; http://www.oracle-base.com/articles/11g/TriggerEnhancements_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-efficient-coding-093640.html Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan DISABLED Trigger yaratma CREATE OR REPLACE TRIGGER trigger_control_test_trg BEFORE INSERT ON trigger_control_test FOR EACH ROW DISABLE BEGIN DBMS_OUTPUT.put_line('TRIGGER_CONTROL_TEST_TRG - Executed'); END; /
INVALID Bağımlılık takibi 10g create table t (x int ,y int ); create package body pkg is procedure only_on_y begin for rec in (select y from t ) loop ... end loop; end; end pkg; alter table t add z int http://www.oracle.com/technetwork/articles/sql/11g-schemamanagement-089869.html INVALID
VALID Bağımlılık takibi 11g create table t (x int ,y int ); create package body pkg is procedure only_on_y begin for rec in (select y from t ) loop ... end loop; end; end pkg; alter table t add z int http://www.oracle-base.com/articles/11g/EnhancedFinerGrainedDependencyManagement_11gR1.php VALID
WHEN OTHERS derleme uyarısı http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php#new_plsql_compiler_warning Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
SIMPLE_INTEGER PLS_INTEGER tipinden daha etkin NOT NULL constraint nedeni ile ön değer atanmalı declare cnt simple_integer := 0; begin cnt := cnt + 1; end; declare cnt $if dbms_db_version.ver_le_10_2 $then pls_integer not null $else simple_integer $end := 0; begin cnt := cnt + 1; end; http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php#simple_integer http://www.oracle.com/technetwork/articles/sql/11g-plsql-091775.html Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
SQL Operatörleri ve İşlevleri için Metadata bilgisi V$SQLFN_METADATA ve V$SQLFN_ARG_METADATA isimli yeni görüntüler üzerinden erişilebiliniyor, özellikle 3. parti ürünler için kullanışlı görüntüler. SQL> set linesize 2500 SQL> SELECT * FROM v$sqlfn_metadata where name = 'REGEXP_SUBSTR' ; FUNC_ID NAME MINARGS MAXARGS DATATYPE VERSION ANA AGG DISP_TYPE USAGE DESCR ---------- ------------------------------ ---------- ---------- -------- ------------ --- --- ------------- ------------------------------ ------------------------------ 526 REGEXP_SUBSTR 2 5 STRING V10 Oracle NO NO NORMAL SQL> SELECT * FROM v$sqlfn_arg_metadata WHERE func_id = 526 ; FUNC_ID ARGNUM DATATYPE DESCR ---------- ---------- -------- ------------------------------ 526 1 STRING 526 2 STRING 526 3 NUMERIC 526 4 NUMERIC 526 5 STRING http://tonguc.wordpress.com/2008/09/29/11gs-metadata-information-for-sql-built-in-operators-and-functions
Güle güle Outline’lar [ metalink 11g Upgrade Companion ] Oracle highly recommends the use of SQL plan baselines instead of the stored outlines after 11gR1. With Oracle Database 11g using the SQL Plan Management (SPM) the optimizer automatically manages plans and ensures that only verified or known plans are used. SQL Plan Management allows controlled plan evolution by only using a new plan after it has been verified to be perform better than the current plan. You should also use SQL Plan Management as part of your upgrade strategy. Please see the best practices section for more information. [ /metalink 11g Upgrade Companion ] Başka ‘güle güle’ler de var: Oracle Ultra Search, Java Development Kit(JDK) 1.4, CTXXPATH index http://tonguc.wordpress.com/2008/08/01/stored-outlines-are-deprecated-in-oracle-database-11g
DBMS_COMPARISON 1/2 Tablo ve görüntüleri kıyaslamak için bir hazır paket, dblink üzerinden de çalışabiliyor Paketin arkasında 10g ile gelen ORA_HASH SQL işlevi kıyaslama amacı ile kullanılıyor. conn hr/hr DROP TABLE depts PURGE ; CREATE TABLE depts NOLOGGING AS SELECT * FROM departments ; CREATE UNIQUE INDEX ui_depts ON depts(department_id) NOLOGGING ; DELETE FROM depts WHERE department_id = 10; COMMIT; exec dbms_comparison.create_comparison(comparison_name=>'compare_test', schema_name=>'HR', object_name=>'DEPTS', dblink_name=>NULL, remote_schema_name=>'HR', remote_object_name=>'DEPARTMENTS', scan_percent=>90); set serveroutput on DECLARE retval dbms_comparison.comparison_type; BEGIN IF dbms_comparison.compare('compare_test', retval, perform_row_dif=>TRUE) THEN dbms_output.put_line('No Differences'); ELSE dbms_output.put_line('Differences Found'); END IF; END; / Differences Found PL/SQL procedure successfully completed. http://tonguc.wordpress.com/2008/03/06/10gs-ora_hash-function-to-determine-if-two-oracle-tables-data-are-equal/ http://tonguc.wordpress.com/2008/10/04/dbms_comparison-supplied-package-after-11g-release-1
DBMS_COMPARISON 2/2 set null @ set colsep | set linesize 2500 select * FROM user_comparison_row_dif ; COMPARISON_NAME | SCAN_ID|LOCAL_ROWID |REMOTE_ROWID INDEX_VALUE STA|LAST_UPDATE_TIME COMPARE_TEST | 4|@ |AAARADAAFAAAAA3AAA 10 DIF|04-OCT-08 02.58.03.306182 PM exec dbms_comparison.drop_comparison( comparison_name=>'compare_test') ; SELECT .. FROM USER_COMPARISON_COLUMNS c , USER_COMPARISON_ROW_DIF r , USER_COMPARISON_SCAN s WHERE c.COMPARISON_NAME = 'COMP_EMP_N_CLONE' AND r.SCAN_ID = s.SCAN_ID AND s.scan_id = &scan_id AND r.STATUS = 'DIF' AND c.INDEX_COLUMN = 'Y' AND c.COMPARISON_NAME = r.COMPARISON_NAME DECLARE scan_info DBMS_COMPARISON.COMPARISON_TYPE; BEGIN DBMS_COMPARISON.CONVERGE ( comparison_name => 'compare_emp_and_clone' , scan_id => &scan_id , scan_info => scan_info , converge_options => DBMS_COMPARISON.CMP_CONVERGE_REMOTE_WINS ); DBMS_OUTPUT.PUT_LINE('Remote Rows Merged: ' ||scan_info.rmt_rows_merged); DBMS_OUTPUT.PUT_LINE('Remote Rows Deleted: ' ||scan_info.rmt_rows_deleted); END; http://tonguc.wordpress.com/2008/03/06/10gs-ora_hash-function-to-determine-if-two-oracle-tables-data-are-equal/ http://tonguc.wordpress.com/2008/10/04/dbms_comparison-supplied-package-after-11g-release-1 http://technology.amis.nl/blog/?p=2420 http://technology.amis.nl/blog/?p=2422 Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
Global temporary table’larınız için başka bir TEMP Tablespace belirtme SQL> create temporary tablespace etl_temp 2> tempfile '+DG1/etl_temp_01.dbf' 3> size 1G; Tablespace created. SQL> create global temporary table data_load ( 2> input_line varchar2 (2000) 3> ) 4> on commit preserve rows 5> tablespace etl_temp; Table created. GTT kullanıcının default temporary tablespace'i TEMP yerine ETL_TEMP tablespace’i altında yaratılır.
LISTAGG SELECT deptno, LISTAGG(ename, '; ') WITHIN GROUP (order by ename) FROM emp GROUP BY deptno; DEPTNO LISTAGG(ENAME,';')WITHINGROUP(ORDERBYENAME) ------ ------------------------------------------- 10 CLARK; KING; MILLER 20 ADAMS; FORD; JONES; SCOTT; SMITH 30 ALLEN; BLAKE; JAMES; MARTIN; TURNER; WARD 29
Pivot select * from sales_by_quarter pivot (sum(revenue) SALESREP QU REVENUE ---------- -- ---------- 100 Q1 230 100 Q2 240 100 Q3 160 100 Q4 90 100 Q3 100 100 Q4 140 100 Q4 70 101 Q1 200 101 Q2 220 101 Q3 250 101 Q4 260 102 Q1 260 SALESREP 'Q1' 'Q2' 'Q3' 'Q4' ---------- ----- ----- ----- ----- 100 230 240 260 300 101 200 220 250 260 102 260 280 265 310 http://www.oracle-base.com/articles/11g/PivotAndUnpivotOperators_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-pivot-097235.html select * from sales_by_quarter pivot (sum(revenue) for quarter in ('Q1','Q2','Q3','Q4')) order by salesrep ;
Unpivot select * from quarterly_sales unpivot include nulls SALESREP QU REVENUE ---------- -- ---------- 100 Q1 230 100 Q2 240 100 Q3 260 100 Q4 300 101 Q1 200 101 Q2 220 101 Q3 250 101 Q4 260 102 Q1 260 102 Q2 280 102 Q3 265 102 Q4 310 QUARTERLY_SALES SALESREP Q1 Q2 Q3 Q4 ---------- ----- ----- ----- ----- 100 230 240 260 300 101 200 220 250 260 102 260 280 265 310 http://www.oracle-base.com/articles/11g/PivotAndUnpivotOperators_11gR1.php http://www.oracle.com/technetwork/articles/sql/11g-pivot-097235.html select * from quarterly_sales unpivot include nulls (revenue for quarter in (q1,q2,q3,q4)) order by salesrep, quarter ;
SQL Result Cache Kavramı Select deptno , avg(sal) from huge_emp group by deptno; 2 sn. (parse & fetch) Select deptno , avg(sal) from huge_emp group by deptno; 1.23 sn. (parse yok ama yine fetch) Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan Select deptno , avg(sal) from huge_emp group by deptno; 1.22 sn. (yine sadece fetch)
Result Cache Hint select /*+ result_cache */ deptno , avg(sal) from super_emp group by deptno; Execution Plan ---------------------------------------------------------- Plan hash value: 3044997086 -------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | | 0 | SELECT STATEMENT | | 3 | 21 | 4 (25)| 00:00:01 | | 1 | RESULT CACHE | 7nvxyd4t2fu8rc25rh5w5p922n | | | | | | 2 | HASH GROUP BY | | 3 | 21 | 4 (25)| 00:00:01 | | 3 | TABLE ACCESS FULL| SUPER_EMP | 14 | 98 | 3 (0)| 00:00:01 | Result Cache Information (identified by operation id): ------------------------------------------------------ 1 - column-count=2; dependencies=(SCOTT.SUPER_EMP); name="SELECT /*+ result_cache */ deptno, avg(sal) Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
PL/SQL Result Cache Kavramı create or replace function test_result_cache ( p_in in number) return number is begin dbms_lock.sleep (5); return p_in; end; declare l_num number; begin l_num:= test_result_cache(1); l_num:= test_result_cache(1); l_num:= test_result_cache(1); end; 15.13 sn. Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
PL/SQL Result Cache Kavramı create or replace function test_result_cache (p_in in number) return number result_cache is begin dbms_lock.sleep (5); return p_in; end; declare l_num number; begin l_num:= test_result_cache(1); l_num:= test_result_cache(1); l_num:= test_result_cache(1); end; 5,02 sn. Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
Result Cache Invalidasyonu create or replace function test_result_cache (p_in in number) return number result_cache is retval number; begin select rn into retval from t where rn = p_in ; dbms_lock.sleep (1); return retval; end; Referans edilen tablo içeriği değişse bile hep aynı sonucu döndürür Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
Result Cache Invalidasyonu create or replace function test_result_cache (p_in in number) return number result_cache relies_on (T) is retval number; begin select rn into retval from t where rn = p_in ; dbms_lock.sleep (1); return retval; end; Referans edilen tablolar değiştiğinde Result Cache de kullanılmaz duruma geçsin.. Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS sunumundan
Kıyamadıklarım REGEXP_COUNT yeni Regular Expression SQL işlevi aranan paternin kaç kez kaynak string içinde geçtiğini döndürüyor. 11g ile artık cidden online index rebuild ONLINE: exclusive lock artık oluşmuyor ve DML’ler etkilenmiyor. DBMS_SCHEDULER Lightweight Jobs, Email Notification, File Watcher, Remote Database Jobs DBMS_HPROF PL/SQL Hierarchical Profiler DBMS_PARALLEL_EXECUTE http://www.oracle-base.com/articles/11g/AppendValuesHint_11gR2.php http://www.oracle-base.com/articles/11g/OnlineTableRedefinitionEnhancements_11gR1.php http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR2.php http://www.oracle-base.com/articles/11g/PlsqlHierarchicalProfiler_11gR1.php http://www.oracle-base.com/articles/11g/dbms_parallel_execute_11gR2.php http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR1.php
Kıyamadığım birkaç tane daha Yeni V$OSSTAT ve V$STATISTICS_LEVEL istatistikleri, ve bir çok ilginç yeni görüntü: V$SQL_CS_HISTOGRAM, V$SQL_CS_SELECTIVITY, V$SQL_CS_STATISTICS, V$SQL_FEATURE, V$SQL_HINT, V$SQL_MONITOR, V$SQL_PLAN_MONITOR, V$IOSTAT_* PL/SQL Bulk Insert ve APPEND_VALUES hint FORALL i IN l_tab.first .. l_tab.last INSERT /*+ APPEND_VALUES */ INTO forall_test VALUES l_tab(i); tkprof artık SQL ID değerini başlıkta gösteriyor. DBMS_REDEFINITION online table redefinition bağımlı nesneleri(PL/SQL, views, synonyms) INVALID durumuna artık düşürmüyor “Bağlantımdan oluşan Trace dosyası ne isimde” artık çok kolay: select value from v$diag_info where name = 'Default Trace File' ; VALUE ---------------------------------------------------------------------------- /u01/app/oracle/diag/rdbms/tong/tong/trace/tong_ora_4402_IDENTIFIER.trc http://www.oracle-base.com/articles/11g/AppendValuesHint_11gR2.php http://www.oracle-base.com/articles/11g/OnlineTableRedefinitionEnhancements_11gR1.php http://www.oracle-base.com/articles/11g/PlsqlNewFeaturesAndEnhancements_11gR1.php http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR2.php http://www.oracle-base.com/articles/11g/PlsqlHierarchicalProfiler_11gR1.php http://www.oracle-base.com/articles/11g/dbms_parallel_execute_11gR2.php http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR1.php
Oku, dene, sorgula, geliştir, *paylaş* .. Kaynakça – Tim Hall's Oracle 11g Articles: http://oracle-base.com/articles/11g/Articles11g.php Oracle 11g for Developers: Lucas Jellema & Alex Nuijten, AMIS 11g The Perfection of a Masterpiece: Christo Kutrovsky, Pythian Top 10, no – make that 11, things about Oracle Database 11g: Thomas Kyte, http://asktom.oracle.com Oracle Database 11g For Developers: New Features Documentation @ http://tahiti.oracle.com Oracle® Database New Features Guide 11g Release 1 (11.1): http://download.oracle.com/docs/cd/B28359_01/server.111/b28279/toc.htm Oracle® Database New Features Guide 11g Release 2 (11.2): http://download.oracle.com/docs/cd/E11882_01/server.112/e17128/toc.htm Daniel Morgan’s Oracle Cheatsheet Library: http://www.morganslibrary.org/library.html Arup Nanda's Oracle Database 11g The Top New Features for DBAs and Developers OTN Series: http://www.oracle.com/technetwork/articles/sql/index-099021.html
Sorularınız ve/veya yorumlarınız TTECH & Oracle Türkiye’ye destekleri için çok teşekkürler ? ? ? ? ? Sorularınız ve/veya yorumlarınız ? ? ? ? H.Tonguç Yılmaz - tonguc.yilmaz@gmail.com http://friendfeed.com/TongucY
TROUG @ Oracle Day TROUG Stand DBA'ler için Oracle veritabanı 11g yeni özellikleri: Zekeriya Beşiroğlu, Bilginç Akademi Veritabanı geliştiricileri için Oracle veritabanı 11g yeni özellikleri: H.Tonguç Yılmaz, ACE, Turkcell Teknoloji Veri ambarı ve Exadata Oracle veritabanı 11g yeni özellikleri: Hüsnü Şensoy, ACE Director, Global Maksimum Panel: TROUG Roundtable