173
New Features for Administrators (Oracle8i) April, 2001 CloudBox Jang Kyung Sang

Oracle History #5

Embed Size (px)

DESCRIPTION

Oracle New Features for Version 8i

Citation preview

Page 1: Oracle History #5

New Features for Administrators (Oracle8i)

April, 2001

CloudBox

Jang Kyung Sang

Page 2: Oracle History #5

[email protected] - 2 -

Oracle8i New Features http://www.ggola.com/

Oracle8i New Features for Administrators

Course

1. Java in the database

2. Optimizer and Query Improvements

3. Summary Management

4. Indexes and Index-Organized Tables

5. Basic Partition

6. Partition Maintenance

7. Composite Partitioning

8. Added New Features for partition

9. Universal Installer Migration and Upgrade

10. Tablespace Management

11. Database Resource Manager

12. Manageability Features

13. Availability and Recoverability

14. Features of Net8

15. SQL*Plus, PL/SQL and National Language Support

16. Database Security

17. Partial addition for Oracle8i

Page 3: Oracle History #5

[email protected] - 3 -

Oracle8i New Features http://www.ggola.com/

1. Java in the database

What does Oracle8i support for java?

.

Open, portable, productive, internet computing language

Oracle8i enterprise class java server - Java Virtual Machine integrated with Database - use java anywhere PL/SQL used - productive programming tools - industry standard components

Oracle8i java application server platform application java solution

.

Supported three products for building java database application

- standards-compliant JDBC drivers to access Oracle from JAVA applications

- precompiler(SQLJ) for embedding SQL in java applications

- Oracle JDeveloper (JDBC, SQLJ, complete development environment)

CF. Oracle8i JVM(Java virtual machine) . EJB(Enterprise java bean) transaction server CORBA clients

.

Five major components that integrated JVM with Oracle8i

- Oracle JVM Javasoft JDK specification Oracle architecture optimizing .

- Embedded JDBC Driver JVM server locally SQL and PL/SQL access .

- SQL and PL/SQL Inter-Language Method Services mechanism JAVA call . SQL PL/SQL call

C language external procedure ‘call out’ standard mechanism .

, calling mechanism Oracle8i SQL and PL/SQL Java call .

Page 4: Oracle History #5

[email protected] - 4 -

Oracle8i New Features http://www.ggola.com/

- Net8 java program SQL ‘publishes’ SQL Java access

.

- CORBA IIOP(Internet Inter-ORB Protocol) . RDBMS access second protocol ( Net8( SQL*Net) first protocol ) Oracle8i java CORBA2.0-compliant object request broker embed CORBA RDBMS call in and call out . CF. java stored program ORB ‘published’ clients RDBMS java program access alternate mechanism .

Major components of JVM

- SQLJ Translator : JAVA and SQL program .

- Object Memory Management : allocate and free memory in standard chunks called object memories.

- Memory manager/Garbage collector : Oracle database environment manager JVM memory heaps, allocating and collecting object memories

manage .

- Java class loader : Standard “.class” format and in a compressed form Oracle VM other systems java binaries interchange . (both export and import)

- Bytecode compiler : “.class” java binary standard java program translate .

- Interpretation/run-time : execute standard java binaries.

- Native compilation : C language java program execution performance .

- Library manager : java program manage .

- Standard library : java API specification(java.lang, java.io, java.math, and java.util) standard libraries Oracle Java VM support .

CF. The java interpreters and compilers are based on the JDK 1.1.6 standards

Page 5: Oracle History #5

[email protected] - 5 -

Oracle8i New Features http://www.ggola.com/

Using JAVA

Integrated Java, SQL, and PL/SQL

- Integration : Java SQL and PL/SQL call ? SQL and PL/SQL Java call ?

Java call SQL and PL/SQL

- Java standard JDBC interface database SQL and PL/SQL CALL .

- Java VM OCI thin JDBC drivers interface standard JDBC driver embed .

- , outside database JDBC java application code Oracle Java VM .

- architecture outside or within RDBMS java and SQL same interface application partitioning flexibility and efficiency

.

SQL and PL/SQL call java

- SQL and PL/SQL java call SQL PL/SQL call mechanism .

- Oracle8i java stored procedure PL/SQL automatic dependency-checking mechanisms

java call .

- Oracle8i new DDL extensions “create procedure as java” java stored procedure, function, and triggers .

- Oracle8i PL/SQL namespace java stored procedure any PL/SQL

.

Page 6: Oracle History #5

[email protected] - 6 -

Oracle8i New Features http://www.ggola.com/

What is JDBC?

JDBC(Java Database Connectivity)

- JDBC java RDB access standard set of java classes .

- JDBC javasoft SQL92 syntax and types . mechanisms java client database automatic data streaming .

- JDBC Oracle performance improvement array interface vendor-specific extensions .

JDBC drivers

- JDBC Thin driver : web browser applets . (means thin client) driver RDBMS directly

communicating java sockets client installation .

- JDBC OCI : driver Oracle Call Interface Net8 RDBMS engine communicating client OCI library .

- JDBC KPRB : driver java stored procedure server side OCI Oracle KPRB library

.

- drivers the same syntax and APIs and oracle extensions java application very portable . , connect string minor modification application 3

.

Features in JDBC Drivers

- 3 JDBC drivers Javasoft JDBC 1.22 specification JDBC 2.0 specification

. , JDBC 2.0 specification client side XA support . CF. server side driver XA specification

JDBC 2.0 specification .

- Oracle JDBC drivers standard JDBC driver Oracle specification extensions important features . 1. access to Oracle7 types (like ROWIDs and REFCURSORs) 2. access to Oracle8i object-relational extensions, REFs, Lobs, and BFILEs

Page 7: Oracle History #5

[email protected] - 7 -

Oracle8i New Features http://www.ggola.com/

3. performance enhancement with operation to prefetch rows and the array interface 4. access to PL/SQL stored procedures with Oracle7 and 8 5. access to java stored procedures with Oracle8i 6. access across all Net8 certified firewalls

SQLJ

SQLJ Oracle Pro*C precompilers Java application embedded SQL

.

Preprocessor embedded SQL statements SQLJ Java code(with JDBC call) translate .

SQLJ generated code 100% compliant with Javasoft JDBC specification .

Improve developer productivity

- smaller, cleaner, simpler code than JDBC

- SQL syntax errors and identification of SQL/Java type mismatches detection code quality improvement

- JDeveloper Java tool integration

- Standard language specification, compatible translators

- Oracle Translator standard compliant

- SQLJ applications binary portability (property) platforms different vendor’s database

portable .

SQLJ supports

- SQLJ JDBC application programs . (concise more than JDBC. easier to write

or maintain)

- 3 SQLJ . 1. JDBC (character string, prepare and execute statements, and bind and define variables) directly embed SQL statements

. 2. SQL statements Java bind variables and expressions

.

Page 8: Oracle History #5

[email protected] - 8 -

Oracle8i New Features http://www.ggola.com/

3. application simple default connection and other syntactic elements features .

- During the translation phase, SQLJ detects SQL semantic errors and Java and SQL type mismatches.

- SQLJ provides strong typed queries through the use of SQLJ Iterators.(first-class java types for cursors)

- SQLJ SQL precompilation techniques run-time execution more efficient . precompiling

Oracle SQLJ executions .

Code example JDBC VS SQLJ

- JDBC

- SQLJ

Using SQLJ with Oracle

- SQLJ JDBC run-time environment deployed configuration deployed . CF. SQLJ run-time : Java + JDBC driver

- SQLJ applications deploy JDBC driver . Oracle or users JDBC/OCI/thin JDBC driver .

- Oracle8i Java VM embedded SQLJ translator Oracle SQLJ java

stored procedures and triggers .

- Write program in SQLJ --> SQLJ translator : converts to java + JDBC --> run the program

Java.sql.CallableStatement stmt; Connection conn; ResultSet results; Conn = DriverManager.getConnection 9”jdbc:default”); stmt = conn.prepareStatement

(“select ename from emp where sal > ? and deptno = ?”); stmt.setInteger(1, salparm); stmt.setInteger(2, deptnoparm); results = stmt.executeQuery();

ResultSet results ; #sql results = { select ename from emp

where sal > :salparm and deptno = :deptnopark} ;

Page 9: Oracle History #5

[email protected] - 9 -

Oracle8i New Features http://www.ggola.com/

Java program

Java stored programs

- open alternative complementing PL/SQL

- java is fully functional. PL/SQL Java .

- PL/SQL SQL-intensive SQLJ java stored procedure .

- Java stored procedures 3 run-time contexts .

1. stored functions and procedures (java program SQL )

2. all triggers java . 3. java object-relational methods .

Developing

1. write java stored programs

2. Java VM load java code. Java classes load .

- SQL*Plus “create java ddl”command - standard Oracle utility “LOADJAVA”

3. publish the java procedure to SQL. - expose the top-level java entrypoint - map parameters and SQL and PL/SQL datatypes - set up appropriate user privileges

4. SQL or PL/SQL call java program CF. Oracle PL/SQL call SQL or PL/SQL java program call syntax

.

Example (java installation . Refer to page 11)

create or replace java source named "NewJava" as public class JavaMaster { static public String Msg(String guys) { return "Good morning " + guys ; } } / create or replace function JavaFunc (str varchar2) return varchar2 as language java name 'JavaMaster.Msg (java.lang.String) return java.lang.String' ; / SQL> select JavaFunc('girls') from dual ; JAVAFUNC('GIRLS') -------------------------------------------------------------------------------- Good morning girls

Page 10: Oracle History #5

[email protected] - 10 -

Oracle8i New Features http://www.ggola.com/

Components

Develop server-side business logic as distributed components

- components improve developer productivity in following ways.

1. reuse server-side business logic

2. improve application design as reusable modules

3. simplify deployment in a multitier environment

Support java component programming models

- Oracle8i traditional CORBA servers Java implemented . , ORB Java VM java applications .

- EJB(the industry standard enterprise javabeans) component model database java

. Simple declarative transaction commit or rollback transaction operations .

CF. Java or EJBs implemented CORBA servers Oracle8i MTS .

Server-side ORB (on MTS)

- IIOP listener : Oracle8i standard CORBA/IIOP binding protocol extended .(Net8)

- IIOP dispatcher : Oracle8i IIOP-based method invocations extened .

- Oracle8i integrates a CORBA 2.0 ORB.

- MTS platforms : Java VM MTS . MTS .

Enterprise JavaBeans (EJBs)

- EJBs is a server-oriented component model for Java. Oracle8i EJBs transaction server platforms EJB 1.0 specification .

- Significant advantages using EJBs 1. developers advanced system programming skills . 2. Pure Java definition D/COM, CORBA

Page 11: Oracle History #5

[email protected] - 11 -

Oracle8i New Features http://www.ggola.com/

dependency . 3. platform vendors EJB

.

Java Configuration

Java VM classes installation

- Java VM manually initialize script .

- $ORACLE_HOME/javavm/install/initjvm.sql (user by “SYS”) CF. test 1 .

- script 4000 java classes initial package .

- DBMS_JAVA package only used internally by Oracle .

- Needed initial parameter values for executing initjvm.sql : shared_pool_size 50M java_pool_size 50M rollback segment 100M

Java-related initial parameter

- shared_pool_size : static java variables UGA space

- java_pool_size : shared java objects space java class loading .

large java application system 50M java stored procedure 20M .

- java_soft_sessionspace_limit : size user’s session java memory usage RDBMS trace file

. default 1M.

- java_max_sessionspace_size : size out-of-memory failure session kill . Default 4G

invisible java programs memory usage

.

CF. java-related memory application system java setting .

Page 12: Oracle History #5

[email protected] - 12 -

Oracle8i New Features http://www.ggola.com/

Internet File System

iFS Windows OS directories database access .

Oracle8i Oracle8i Java VM Java application .

Oracle iFS several different protocols access .

- SMB : MS windows95, 98, NT protocol

- HTTP : Web browser and network computer

- FTP : FTP clients command line

- SMTP, IMAP4, POP3 : e-mail protocol

Data integration

- iFS application developers 3 APIs , Java, CORBA, and PL/SQL .

- iFS document system document automatically decompose(parse) document recompose(render) .

- XML(Extended markup language) .

CF. iFS application .

Page 13: Oracle History #5

[email protected] - 13 -

Oracle8i New Features http://www.ggola.com/

2. Optimizer and Query Improvements

Stored Outline

Optimizer plan stability

- Optimizer feature Oracle8i well-tuned applications SQL hints

(good access path) SQL .

- Plan Equivalence : plan 1. SQL Statement text must match 2. Plans are maintained through : - new oracle versions - new statistics on objects - init.ora parameter changes - database reorganization - schema changes

CF. table index stored outline index .

Creating stored outlines

- Outline oracle automatic or SQL creation rule-based or cost-based optimizers .

oracle outline cost-based optimize .

- Session init.ora parameter create_stored_outlines parameter true default category category name category stored outlines .

- Test initial parameter database restart error parameter

create_stored_outlines

SVRMGRL> show parameter SQL> select name from v$parameter

. Oracle8.1.5 Reference parameter session level test .

CF. system user “create any outline” privilege outline user grant .

Page 14: Oracle History #5

[email protected] - 14 -

Oracle8i New Features http://www.ggola.com/

- Session category name default

category name .

- category DEFAULT category . outline name system default

.

- Outline parameter false select * from outlines stored outline .

- outline category shared_pool pinning execution plan .

SQL> alter session set create_stored_outlines = true ; Session altered. SQL> select d.dname, e.ename from emp e, dept d 2 where e.deptno = d.deptno ; DNAME ENAME -------------- ---------- RESEARCH12 SMITH SALES12 ALLEN .............. ACCOUNTING12 MILLER 14 rows selected.……….. SQL> alter session set create_stored_outlines = false ; SQL> select * from user_outlines ; NAME CATEGORY USED TIMESTA VERSION SQL_TEXT ---------------------------------------------------------------------------------------------------------------- SYS_OUTLINE_0107311031050000 DEFAULT UNUSED 31Jul01 8.1.6.2.0 select d.dname, e.ename from emp e, dept d where e.deptno = d.deptno SQL> alter session set create_stored_outlines = cat_emp ; Session altered. SQL> select e.ename, d.loc from emp e, dept d where e.deptno = d.deptno ; ENAME LOC -------------- ---------- SMITH DALLAS189 ALLEN CHICAGO189 .............. MILLER NEW YORK189 14 rows selected.……….. SQL> select * from user_outlines ; NAME CATEGORY USED TIMESTA VERSION SQL_TEXT -------------------------------------------------------------------------------- ------------------------------- SYS_OUTLINE_0107311031050000 DEFAULT UNUSED 31Jul01 8.1.6.2.0 select d.dname, e.ename from emp e, dept d where e.deptno = d.deptno SYS_OUTLINE_0107311026420001 CAT_EMP UNUSED 31Jul01 8.1.6.2.0 select e.ename, d.loc from emp e, dept d where e.deptno = d.deptno SYS_OUTLINE_0107311024590000 CAT_EMP UNUSED 31Jul01 8.1.6.2.0 select * from user_outlines SQL> alter session set create_stored_outlines = false ;

Page 15: Oracle History #5

[email protected] - 15 -

Oracle8i New Features http://www.ggola.com/

- stored outline .

- outline name outline sys name . category

.

category .

Using stored outlines

- outline command .

SQL> alter session set use_stored_outlines = true or category_name ;

- create category name true outline .

- Category category default category text match .

, category match outline default category outline outline

.

- To determine a SQL statement’s execution plan 1. shared pool matching text and outline category 2. 1 data dictionary outline query 3. 2 SQL outline execution plan . 4. 2 normal methods(non-outline) .

- , outline hints outline user_outlines user_outline_hints

view .

SQL> create or replace outline emp_join for category cat_emp on select /*+ FULL(DEPT) */ d.dname, e.ename from emp e, dept d where e.deptno = d.deptno order by 1, 2 ;

Outline created. SQL> select * from user_outlines ; NAME CATEGORY USED TIMESTA VERSION SQL_TEXT ---------------------------------------------------------------------------------------------------------------- SYS_OUTLINE_0107311031050000 DEFAULT UNUSED 31Jul01 8.1.6.2.0 select d.dname, e.ename from emp e, dept d where e.deptno = d.deptno SYS_OUTLINE_0107311026420001 CAT_EMP UNUSED 31Jul01 8.1.6.2.0 select e.ename, d.loc from emp e, dept d where e.deptno = d.deptno SYS_OUTLINE_0107311024590000 CAT_EMP UNUSED 31Jul01 8.1.6.2.0 select * from user_outlines EMP_JOIN CAT_EMP UNUSED 31Jul01 8.1.6.2.0 select /*+ FULL(DEPT) */ d.dname, e.ename from emp e, dept d where e.deptno = d.deptno order by 1, 2

Page 16: Oracle History #5

[email protected] - 16 -

Oracle8i New Features http://www.ggola.com/

Maintaining stored outlines

- Package ‘OUTLN_PKG’ 1. drop_unused : drop unused outline 2. drop_by_cat : drops categories of outlines 3. update_by_cat : rename categories

- ALTER OUTLINE outline_name command 1. rename to new_outline_name ; (outline name ) 2. rebuild ; (outline execution path ) 3. change category to new_category_name ; (category )

- Stored outlines in tables in schema OUTLN 1. OL$ : outline name, category, timestamp, statement text 2. OL$HINTS : hints for the outlines in OL$

- Data dictionary view 1. DBA/ALL/USER_OUTLINES 2. DBA/ALL/USER_OUTLINE_HINTS

DBMS_STATS

This package enables you to generate and manage statistics for cost-based optimization. The statistics can reside in the data dictionary or in a table created in the user’s schema. Only statistics stored in the dictionary itself will have an impact on the cost-based optimizer. (but cannot gather cluster statistics)

Generating statistics

- Gathering sub-procedure 1. gather_index_stats : index 2. gather_table_stats : table, column and index 3. gather_schema_stats : all objects in a schema 4. gather_database_stats : all objects in a database

- usage for table statistic

- How can you gather the statistics ? 1. statistics serially or in parallel index statistics only serially 2. random sampling or computed 3. block sampling faster than row sampling 4. column lists 5. table index statistics 6. statistics tables can hold statistics to enable you to experiment with different sets of statistics.

DBMS_STATS.GATHER_TABLE_STATS ( schema, table, partition, sample size(%), block sample?(or row), columns, parallelism degree, table and all partitions, cascade to indexes) ;

Database creation automatically schema OUTLN

tables outlines . (system tablespace )

Page 17: Oracle History #5

[email protected] - 17 -

Oracle8i New Features http://www.ggola.com/

Moving statistics

scott emp table export file dump database import statistic import source database target database

.

1. table statistics . usage : dbms_stats. gather_table_stats(schema, table, partition, sample size(%), block sample?(or row), columns, parallelism degree, table and all partitions, cascade to indexes) meaning : table statistic . (index statistics

cascade to indexes TRUE ) example : SQL> exec dbms_stats.gather_table_stats( 'SCOTT', 'EMP', NULL, 20, FALSE, 'FOR ALL COLUMNS', 4, 'DEFAULT', TRUE) ;

2. Statistics table schema . usage : dbms_stats. create_stat_table(‘SCOTT’, ’stat_tab_name’, ’tablespace_name’) meaning : data dictionary statistics export table . example : SQL> exec dbms_stats.create_stat_table('SCOTT', 'STAT_SCOTT', 'USERS') ;

3. Statistics data table copy . usage : dbms_stats. export_table_stats(‘SCOTT’, ‘EMP’, NULL(partition ), ‘stat_tab_name’, ‘stat_id’(ID ), TRUE(index stat) ) ; meaning : statistics user’s table export .

table export backup or copy . example : SQL> exec dbms_stats.export_table_stats('SCOTT', 'EMP', NULL, 'STAT_SCOTT', 'Stat 20010731', TRUE) ;

4. database table file dump export table import database link copy table ,

stat_scott table database data data dictionary

. usage : dbms_stat. import_table_stat (export_table_stas argument) meaning : schema table data dictionary

. example : SQL> exec dbms_stats.import_table_stats('SCOTT', 'EMP', NULL, 'STAT_SCOTT', 'STAT 20010731', TRUE) ;

Source Database

Target Database

File dump exp/imp

OR

Database link copy

Page 18: Oracle History #5

[email protected] - 18 -

Oracle8i New Features http://www.ggola.com/

5. user schema table drop . usage : dbms_stats. drop_stat_table(‘SCOTT’, ‘stat_tab_name’) meaning : table drop . example : SQL> exec dbms_stats.drop_stat_table ('SCOTT', 'STAT_SCOTT') ;

Top-N SQL

Now Oracle8i supports ordering of views and in-line views.

Sorts only the required number of rows

- Oracle8i in-line view order by .

- Oracle rownum < 3 2 value memory rows

2 value .

- Example : order by

- Query (searching for the top few values) run considerably faster in Oracle8i.

SQL> select * from (select empno, deptno, hiredate from emp order by hiredate desc) where rownum < 3 ; EMPNO DEPTNO HIREDAT

---------- ---------- ------- 7876 20 12Jan83 7788 20 09Dec82 SQL> select * from (select empno, deptno, hiredate from emp) where rownum < 3 ; EMPNO DEPTNO HIREDAT

---------- ---------- ------- 7369 20 17Dec80 7499 30 20Feb81

Page 19: Oracle History #5

[email protected] - 19 -

Oracle8i New Features http://www.ggola.com/

ROLLUP and CUBE

Aggregate operators

group by rollup and cube crosstab report .

1 2 3 Total 1 2 3 6 1 2 3 6

Total 2 4 6 12

Rollup operation

SQL> select , , sum(year) from emp group by rollup( , ) ;

- group by total grand total .

- function data result rows n types( ) m status( ) ROLLUP group by (n X (m+1)) + 1 = ? rows .

- (2 X (3+1)) + 1 = 9 rows .

sum(year)

1 1 2 2 3 3 6 1 1

……………….. ………………..

6 ……………….. 12

Page 20: Oracle History #5

[email protected] - 20 -

Oracle8i New Features http://www.ggola.com/

Cube operation

SQL> select , , sum(year) from emp group by cube( , ) order by , ;

- function data result rows n types( ) m status( ) CUBE group by ((n+1) X (m+1)) + 1 = ? rows

.

- . , (type + 1) X (status + 1) .

(2 + 1) X (3 + 1) = 12 .

Grouping function

Rollup and cube total value null . data value null

null . new function grouping .

- grouping(column_name) decode 0 value null 1 rollup or cube

null .

- , . decode(grouping(column),1,’null of total’,’value’)

sum(year)

1 1 2 2 3 3 6 1 1 2 2 3 3 6

1 2 2 4 3 6 12

ROLLUP

GRAND

+ CUBE

Page 21: Oracle History #5

[email protected] - 21 -

Oracle8i New Features http://www.ggola.com/

TRIM

New function trim ltrim rtrim .

ANSI .

Using function

SQL> select last_name, trim(leading ‘X’ from last_name) as trimmed from emp where last_name like ‘X%’ ;

- TRIM(leading ‘X’ from column) : LTRIM

- TRIM(trailing ‘X’ from column) : RTRIM

- TRIM(both ‘X’ from column) : L + R (default)

- TRIM( ‘X’ from column) : both .

- TRIM(last_name) : character space trim characters .

CF. trim character . trim character only one character .

New and Obsolete

Obsolete parameter : sort_direct_writes, sort_write_buffers, sort_write_buffer_size, sort_read_fac

New parameter : sort_multiblock_read_count this parameter define the number of blocks read from temporary segments during sorts. (db_multiblock_read_count )

Page 22: Oracle History #5

[email protected] - 22 -

Oracle8i New Features http://www.ggola.com/

3. Summary Management

Materialized Views

In general, this will be used for Data Warehouse, Distributed Computing, Mobile Computing

Summary and aggregate data

- View view base table data view , summary and aggregate data(pre-computed)

data segment view .

- , expensive and complex joins view .

- M-View SQL base table M-View

.( query rewrite ) CF. The process of modifying a query to use the view rather than the base table is called a query rewrite.

- Create materialized view is synonym for create snapshot.

- M-View SQL> create materialized view view_name build deferred refresh …. as select …..

“build” clause M-View . Build clause “immediate or

deferred” option . 1. immediate 2. deferred refresh . CF. build clause default “build immediate” .

CF. remote tables .

CF. M-View order by clause creation

refresh . , order by clause M-View query definition . query performance order by clause

column M-View select list column index recommend .

Create materialized view day_of_booking as Select bkg_no, sum(amt) as total_amount From booking Where bkg_dt = sysdate Group by bkg_no ;

Page 23: Oracle History #5

[email protected] - 23 -

Oracle8i New Features http://www.ggola.com/

Materialized view refresh option

Base table M-View base table sync . ‘Refresh’ .

- Complete : Base table M-View

M-View query data .

- Fast : last refresh 1. M-View log 2.Direct loader log (direct loads new rows rowid M-Views refresh)

- Force : . complete fast . (This is default refresh type.)

- Never : Refresh .

CF. M-View system user user grant ‘create materialized view’ privilege .

Refresh mode : Refresh .

- ON DEMAND Manually DBMS_MVIEW package procedure . 1 …REFRESH(‘BOOKING’,PARALLELISM => 3); >> specified M-View 2 …REFRESH_DEPENDENT(VN_FAIL_CNT, ‘EMP’) ; >> M-Views on based 1 base tables (number_of_failures out variable ) 3 …REFRESH_ALL_MVIEWES ; >> all M-Views

- Automatic Refresh 1. ON COMMIT ( synchronous) : base table

commit . 2. START WITH-NEXT(asynchronous) : specified time

supported complete mode only. (must initiate job processes)

CF. , ON COMMIT M-View join or aggregate views Oracle8.1.5 manual

only join view single table aggregate . ( Nested M-View join and aggregate view fast on commit

)

Page 24: Oracle History #5

[email protected] - 24 -

Oracle8i New Features http://www.ggola.com/

Materialized view types (UNION set operation )

- joins and aggregates type M-View fast refresh

new data direct path method add fast refresh . The where clause can contain inner equi-joins only.(no outer joins) 1. group by column select list . 2. function : sum, count(x), count(*), count(distinct x), avg, variance, stddev, min, max

- single table aggregate M-View log fast refresh count sum count count or sum group function count sum

. count(*) where clause . 1. function : count, sum, avg, variance, stddev

- only joins : fast refresh 1. each detail tables M-View log 2. select list detail table rowid . 3. outer join inner table column unique constraint . CF. M-View log rowid column

speed up refresh M-View rowid column index recommend . CF. detail tables rowid tables

tables DML fast refresh .

Test M-View

- Test Oracle8.1.6.2 M-View . Oracle Manual

.

- , Oracle version Oracle9i fixed Test

.

- Refresh complete . dbms_mview package refresh M-View

.

- Refresh fast on commit on demand M-View log Test

Query Rewrite Usage .

Page 25: Oracle History #5

[email protected] - 25 -

Oracle8i New Features http://www.ggola.com/

Example

- complete on demand (joins and aggregates)

CF. M-View performance M-View partitioning parallel operation

.

SQL> sho user USER is "SYSTEM" SQL> grant create materialized view to scott ; Grant succeeded. SQL> conn scott/tiger Connected. SQL> set timing on SQL> set serveroutput on SQL> create materialized view mv_emp_sales refresh complete on demand 2 as select e.empno, d.deptno, sum(sal) from emp e, dept d 3 where e.deptno = d.deptno group by e.empno, d.deptno ; Materialized view created. Elapsed: 00:00:46.95 SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL)

---------- ---------- ---------- 7369 20 52428800 .................... 9022 95 6553600 21 rows selected. SQL> update emp set sal = 10 where empno = 9022; 256 rows updated. SQL> commit ; Commit complete. SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL)

---------- ---------- ---------- 7369 20 52428800 .................... 9022 95 6553600 21 rows selected. SQL> exec dbms_mview.refresh('MV_EMP_SALES') ; PL/SQL procedure successfully completed. Elapsed: 00:00:48.04 SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL)

---------- ---------- ---------- 7369 20 52428800 .................... 9022 95 655360 21 rows selected.

EMPNO SAL update

.

Refresh procedure

.

MV creation refresh

.

Page 26: Oracle History #5

[email protected] - 26 -

Oracle8i New Features http://www.ggola.com/

- fast on commit (single table aggregate)

SQL> update emp set sal = 100 where empno = 9022 ; 256 rows updated. SQL> commit ; Commit complete. SQL> declare 2 vn_fail_cnt BINARY_INTEGER; 3 begin 4 dbms_mview.refresh_dependent(vn_fail_cnt, 'EMP'); 5 dbms_output.put_line(vn_fail_cnt); 6 end; 7 / 0 PL/SQL procedure successfully completed. Elapsed: 00:00:47.74 SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL)

---------- ---------- ---------- 7369 20 52428800 .................... 9022 95 6553600 21 rows selected.

refresh_dependent procedure

.

SQL> create materialized view log on emp 2 with rowid(empno, ename, job, mgr, hiredate, sal, comm, deptno) 3 including new values ; Materialized view log created. SQL> create materialized view mv_emp_sales refresh fast on commit 2 as select count(*), empno, sum(sal), count(sal) 3 from emp 4 group by empno ; Materialized view created. SQL> select * from mv_emp_sales ; COUNT(*) EMPNO SUM(SAL) COUNT(SAL)

---------- ---------- ---------- ---------- 256 7369 204800 256 ........................... 256 9022 25600 256 21 rows selected. SQL> update emp set sal = 10 where empno = 9022 ; 256 rows updated. SQL> commit; Commit complete. SQL> select * from mv_emp_sales ; COUNT(*) EMPNO SUM(SAL) COUNT(SAL)

---------- ---------- ---------- ---------- 256 7369 204800 256 ........................... 256 9022 2560 256 21 rows selected.

log M-View . base table

refresh commit refresh

data .

Page 27: Oracle History #5

[email protected] - 27 -

Oracle8i New Features http://www.ggola.com/

- fast on demand (single table aggregate)

CF. M-View table prebuilt table M-View .

query rewrite . (start with-next refresh M-View query rewrite )

CF. Nested Materialized Views : M-View fact(/detail/base) table M-View user request

Nested Materialized View . join only M-View base

table single-table aggregate M-View refresh fast on commit join and aggregate M-View performance . ,

space .

SQL> drop materialized view log on emp ; Materialized view log dropped. SQL> drop materialized view mv_emp_sales ; Materialized view dropped. SQL> create materialized view log on emp 2 with rowid(empno, ename, job, mgr, hiredate, sal, comm, deptno) 3 including new values ; Materialized view log created. SQL> create materialized view mv_emp_sales refresh fast on demand 2 as select count(*), empno, sum(sal), count(sal) 3 from emp 4 group by empno ; Materialized view created. SQL> select * from mv_emp_sales ; COUNT(*) EMPNO SUM(SAL) COUNT(SAL) ---------- ---------- ---------- ---------- 256 7369 204800 256 ......................... 256 9022 2560 256 21 rows selected. SQL> update emp set sal = 1000 where empno = 9022 ; 256 rows updated. SQL> commit; Commit complete. SQL> exec dbms_mview.refresh('MV_EMP_SALES') ; PL/SQL procedure successfully completed. SQL> select * from mv_emp_sales ; COUNT(*) EMPNO SUM(SAL) COUNT(SAL) ---------- ---------- ---------- ---------- 256 7369 204800 256 ......................... 256 9022 256000 256 21 rows selected.

log MV . base table

refresh procedure

MV

data .

Test join and aggregate M-View

M-View log error fast refresh

refresh data

.

Page 28: Oracle History #5

[email protected] - 28 -

Oracle8i New Features http://www.ggola.com/

Query Rewrite

M-View base table performance . Oracle8i M-View statement ‘Query Rewrite’ mechanism M-View query query .

Query Rewrite Attributes

- M-View index transparent to applications .

- Base table privileges M-View M-View enable,

disable M-View control .

- Initial parameter : QUERY_REWRITE_ENABLED=TRUE ”QUERY REWRITE” privilege M-View enable . DBMS_OLAP package has options to use M-Views

CF. Query Rewrite : grant query rewrite to username ; “global query rewrite” for outside schema “explicit select privilege” for M-View using different schema

Usage : create materialized view mview_name tablespace ts_name --> skip user default tablespace parallel (degree 4) --> option build immediate/deferred --> skip default immediate refresh complete/fast/force/never --> skip default force on demand/on commit/start with .… next …. enable/disable query rewrite --> query rewrite as select count(*), count(sal), sum(sal) from emp; --> query restriction : join equip only aggregate operator outermost part . (AVG(AVG(x))

) sequence, user, sys owner objects, subquery order by, remote table, pl/sql function, having, connect by, inline views, nested subquery, sysdate, rownum, bind variable, raw or long raw .

case 1) select count(*), count(sal), sum(sal) from emp ; ==> Oracle M-View

mview_name execution plan performance .

case 2) select /*+ NOREWRITE */ count(),count(sal),sum(sal) from emp ; ==> Case 1 norewrite hint

M-View base table execution plan full table scan .

Page 29: Oracle History #5

[email protected] - 29 -

Oracle8i New Features http://www.ggola.com/

Example

- Creation materialized view for query rewrite

SQL> create materialized view mv_emp_sales tablespace users 2 parallel(degree 4) build immediate 3 refresh complete start with sysdate+1/6/24 next sysdate+1/6/24 4 enable query rewrite as select e.empno, d.deptno, sum(sal) from emp e, dept d 5 where e.deptno = d.deptno group by e.empno, d.deptno ; Materialized view created. Elapsed: 00:01:02.80 SQL> select job, what, last_date, next_date from user_jobs ; JOB WHAT ---- ----------------------------------------------- 243 dbms_refresh.refresh('"SCOTT"."MV_EMP_SALES"'); LAST_DATE NEXT_DATE ----------------- ----------------- 20010802 14:35:31 20010802 14:45:31 SQL> select sysdate from dual ; SYSDATE ----------------- 20010802 14:36:41 SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL) ---------- ---------- ---------- 7369 20 52428800 ................ 9022 95 6553600 21 rows selected. SQL> update emp set sal = 10 where empno = 9022 ; 256 rows updated. SQL> commit ; Commit complete. SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL) ---------- ---------- ---------- 7369 20 52428800 ................ 9022 95 6553600 21 rows selected. SQL> select sysdate from dual ; SYSDATE ----------------- 20010802 14:38:20 SQL> select sysdate from dual ; SYSDATE ----------------- 20010802 14:46:41 SQL> select * from mv_emp_sales ; EMPNO DEPTNO SUM(SAL) ---------- ---------- ---------- 7369 20 52428800 ................ 9022 95 655360 21 rows selected.

start and next time 10 query

rewrite enable MV

user_jobs last date, next date 10

.

14 36 empno 9022 sal 10

update . MV query

. user_jobs next date

.

38 refresh . 45

refresh MV

( 1 ) 46 40 query

data .

, refresh MV query

“no rows selected” return .

Page 30: Oracle History #5

[email protected] - 30 -

Oracle8i New Features http://www.ggola.com/

- Query rewrite

SQL> select e.empno, d.deptno, sum(sal) from emp e, dept d 2 where e.deptno = d.deptno group by e.empno, d.deptno ; EMPNO DEPTNO SUM(SAL) ---------- ---------- ---------- 7369 20 52428800 ................ 9022 95 655360 21 rows selected. Elapsed: 00:00:00.08 SQL> select /*+ NOREWRITE */ 2 e.empno, d.deptno, sum(sal) from emp e, dept d 3 where e.deptno = d.deptno group by e.empno, d.deptno ; EMPNO DEPTNO SUM(SAL) ---------- ---------- ---------- 7369 20 52428800 ................ 9022 95 655360 21 rows selected. Elapsed: 00:00:49.50 SQL> explain plan for select e.empno, d.deptno, sum(sal) from emp e, dept d 2 where e.deptno = d.deptno group by e.empno, d.deptno ; Explained. SQL> select substr(lpad(' ',2*(level-1))||operation||' '||options 2 ||' '||object_name,1,79) "Plan View" 3 from plan_table 4 start with id=0 5 connect by prior id = parent_id 6 order by id; Plan View ------------------------------------------------------------------------------- SELECT STATEMENT TABLE ACCESS FULL MV_EMP_SALES SQL> delete plan_table; 2 rows deleted. SQL> commit; Commit complete. SQL> explain plan for select /*+ NOREWRITE */ 2 e.empno, d.deptno, sum(sal) from emp e, dept d 3 where e.deptno = d.deptno group by e.empno, d.deptno ; Explained. SQL> select substr(lpad(' ',2*(level-1))||operation||' '||options 2 ||' '||object_name,1,79) "Plan View" 3 from plan_table 4 start with id=0 5 connect by prior id = parent_id 6 order by id; Plan View ------------------------------------------------------------------------------- SELECT STATEMENT SORT GROUP BY NESTED LOOPS TABLE ACCESS FULL EMP INDEX RANGE SCAN XPKDEPT

MV SQL

. , query rewrite .

hint query rewrite

.

plan query rewrite

MV execution plan hint

execution plan

.

Page 31: Oracle History #5

[email protected] - 31 -

Oracle8i New Features http://www.ggola.com/

Control Rewrite

- optimizer mode cost-based only . (rule base )

- QUERY_REWRITE_ENABLED : FALSE setting query rewrite . dynamically instance level(initial parameter) or session level(alter session command) .

- QUERY_REWRITE_INTEGRITY : this parameter reset dynamically for instance and session level. 1. ENFORCED(default) : consistency query rewrite . (updated M-view and validated constraints only) 2. TRUSTED : All updated M-Views and dimensions and constraints with RELY flag are used for query rewrites. (RELY flag constraint new features

invalid constraint valid )

3. STALE_TOLERATED : last DML and relationships(are declared) refresh all M-Views rewrite .(data M-View validate )

CF. register M-View QUERY_REWRITE_INTEGRITY parameter value

.

Support utility & System privileges

- SQL*Loader : Rowid range M-View reference table direct path loading HWMK data incremental refresh

.

- Export/Import : 1. M-View definition export & import (full mode or user mode) 2. MVDATA=Y export & import data in M-Views MVDATA=N table ROWS=N . ( , M-View data segment object ) 3. MVBUILDDEFERRED=Y export all M-Views definition and created for deferred refresh

- M-Views privileges . create materialized view . create/drop/alter any materialized view . query rewrite (enable and disable of own schema) . global query rewrite (enable and disable of in the grantee’s schema for query rewrite)

Page 32: Oracle History #5

[email protected] - 32 -

Oracle8i New Features http://www.ggola.com/

Registration of an Existing Materialized View

- Data Warehouse system ordinary user tables summary and aggregate data tables

. tables table build cost

. , data .

- table Query Rewrite incremental refresh tables M-View .

- M-View base table M-View .( name table name ) SQL> create materialized view ….name on prebuilt table …

- prebuilt table M-View query rewrite parameter query_rewrite_integrity

“TRUSTED” set .

- QUERY_REWRITE_INTEGRITY : (Oracle 8.1.6 ) enforced : M-View data relationship query rewrite . trusted : prebuilt table M-View data and RELY constraint (17 constraints ) correct trust query rewrite . stale_tolerated : M-View valid query rewrite

maximum rewrite capability . , query rewrite wrong result . CF. Oracle 8.1.5 enforce/no_enforce/use_stale .

- , prebuilt table M-View drop table drop .

Data dictionary for M-Views

- ALL_REFRESH_DEPENDENCIES : dependent or container tables in the current schema

- DBA_MVIEW_AGGREGATES : grouping functions in an aggregated M-Views

- DBA_MVIEW_ANALYSIS : M-Views information

- DBA_MVIEW_DETAIL_RELATIONS : the named detail relations (base(fact) tables information)

- DBA_MVIEW_JOINS : information about the joined columns of base tables

- DBA_MVIEW_KEYS : detail columns information about the relations of DBA_MVIEW_DETAIL_RELATIONS

Page 33: Oracle History #5

[email protected] - 33 -

Oracle8i New Features http://www.ggola.com/

Dimension

Additional query rewrites are possible if summaries are created at the lowest level of aggregation, supported with dimensions.

What is a Dimension ?

- data dictionary structures that define hierarchical relationship between pairs of columns and column sets. based on existing columns(M-View segment )

- dimension optional highly recommended 1. enable additional query rewrite possibilities (without use of constraints, M-Views ) 2. hierarchies( ) summary . 3. can be used by OLAP tools ( DBMS_OLAP )

- level dimension . date month month quarter quarter year

level query rewrite . CF. create dimension attribute level

level value column . ( “ ” level

“ ” )

SQL> conn system/manager Connected. SQL> grant create dimension to dimuser ; Grant succeeded. SQL> conn dimuser/dimuser Connected. SQL> create table emp (

2 hiredate date, 3 month varchar2(2),

4 month_name varchar2(10), 5 quarter varchar2(1),

6 year varchar2(4)) ; Table created. SQL> Create dimension emp_dim 2 Level hiredate is emp.hiredate 3 Level month is emp.month 4 Level qtr is emp.quarter 5 Level yr is emp.year 6 Hierarchy calendar_rollup ( 7 Hiredate child of 8 Month child of 9 Qtr child of yr ) 10 Attribute month determines month_name ;

Dimension created.

Page 34: Oracle History #5

[email protected] - 34 -

Oracle8i New Features http://www.ggola.com/

- 3 multiple hierarchies time dimension .

CF. time level, category level, location level . ( , , )

SQL> create table sales ( 2 sal_date date, 3 month varchar2(2), 4 quarter varchar2(1), 5 year varchar2(4), 6 season varchar2(6), 7 week varchar2(1), 8 dayweek_name varchar2(3), 9 month_name varchar2(3)) ; Table created. SQL> create dimension sales_dim 2 level sal_date is sales.sal_date 3 level month is sales.month 4 level quarter is sales.quarter 5 level year is sales.year 6 level season is sales.season 7 level week is sales.week 8 hierarchy cal_rollup ( 9 sal_date child of 10 month child of 11 quarter child of 12 year ) 13 hierarchy week_rollup ( 14 sal_date child of 15 week ) 16 hierarchy season_rollup ( 17 sal_date child of 18 season ) 19 attribute sal_date determines sales.dayweek_name 20 attribute month determines sales.month_name ; Dimension created. SQL> select * from user_dimensions ; OWNER DIMENSION_NAME INVALID REVISION ---------- -------------------- - ---------- DIMUSER EMP_DIM N 1 DIMUSER SALES_DIM N 1

Page 35: Oracle History #5

[email protected] - 35 -

Oracle8i New Features http://www.ggola.com/

- Based on multiple tables : 2 table 1. Keys and attributes correspond to columns 2. All attributes and keys for one level must belong to one table 3. child columns FK define

.

Query Rewrite Situations

- Exact match : selected columns and join conditions match

- Aggregate rollup : summary grouping “lower than” query grouping

- Aggregate to all : more dimensions in summary

- Summary joinback : a column not in summary, but derivable used by query

CF. exact match dimension query rewrite .

Data dictionary for Dimensions

- DBA_DIMENSIONS : dimension objects

- DBA_DIM_LEVELS : dimension levels

- DBA_DIM_LEVEL_KEY : column and position of dimension level

- DBA_DIM_ATTRIBUTES : relationships between a dimension level and a functionally dependent column

- DBA_DIM_HIERARCHIES : dimension hierarchies

- DBA_DIM_CHILD_OF : hierarchical relationships (a pair of levels in a dimension)

- DBA_DIM_JOIN_KEY : information between two dimension tables

Create dimension nation_dim Level goo_cd is goo.goo_cd Level city_cd is city.city_cd Level do_cd is dochung.do_cd

Hierarchy nation_analysis ( Goo_cd child of

City_cd child of Do_cd

Join key goo.city_cd references city.city_cd Join key city.do_cd references do_cd)

Attribute city_cd determines (city.city_name, city.city_mayor) ;

Page 36: Oracle History #5

[email protected] - 36 -

Oracle8i New Features http://www.ggola.com/

DBMS_OLAP

Verifying relationships in a dimension

Satisfy the 1:n relationships along each hierarchy.

DBMS_OLAP.VALIDATE_DIMENSION

- Argument : dimension, owner, check rows, check level

- (‘TIME_DIM’, ’SCOTT’, FALSE, TRUE) .

1. dimension name ‘TIME_DIM’ 2. dimension owner ‘SCOTT’ 3. checking all rows 4. check that levels are all non-NULL

- 3 TURE : check rows stored by direct path loads 4 FALSE : no check levels

- It will update MVIEW$_EXECPTIONS with type of relationship and rowids of violating rows

Evaluate the use of summaries

DBMS_OLAP.EVALUATE_UTILIZATION ;

- uses hypothetical workload statistics ( )

- MVIEW$_EVALUTAIONS .

DBMS_OLAP.EVALUATE_UTILIZATION_W ;

- uses workload statistics collected through Oracle Trace in WORK$_IDEAL_MVIEW, WORK$_MVIEW_USAGE

- MVIEW$_EVALUTAIONS .

MVIEW$_EVALUTAIONS :

- summary name, storage used by summary in bytes

- frequency of use, rank based on cost-benefit ratio

- cumulative benefit computed by adding the benefit or net reduction factor

- benefit to cost ratio computed as the cumulative benefit to storage in bytes

Page 37: Oracle History #5

[email protected] - 37 -

Oracle8i New Features http://www.ggola.com/

Obtaining summary recommendations

M-Views . (summary advisor)

DBMS_OLAP.RECOMMEND_MV_W

- Argument : table, M-Views bytes maximum, retain M-View list, retention percent(cumulative space this percent threshold retain .)

- (‘SALES’,102400000, NULL, 80) 1. table SALES 2. maximum 100M for storing M-view 3. retain M-Views 4. cumulative space 80% .

- MVIEW$_RECOMMENDATIONS action .

Estimating storage requirements for a summary or M-Views

DBMS_OLAP.ESTIMATE_SUMMARY_SIZE (space requirement)

- Argument : statement id(in), query(in), estimated rows(out), estimated bytes(out)

- (‘TRY1’, ‘select * from emp where dept_id = 7843’, erows, ebytes) 1. statement id for explain : TRY1 2. query emp 3. estimated rows erows return 4. estimated bytes ebytes return

- out argument erows, ebytes print storage requirements

.

- Query query string .

Select recommended_action, mview_name, group_by_columns, measures_list From mview$_recommendations ; RECOMM MVIEW_NAME GROUP_BY MEASURE

RETAIN SALES_SUM DROP GRP_SUM RETAIN BRANCH_SUM, ….. …. CREATE EMPNO,PRO_CD SUM(SALARY)

Page 38: Oracle History #5

[email protected] - 38 -

Oracle8i New Features http://www.ggola.com/

4. Indexes and Index-Organized Tables

Bitmap Index

Improvement

- The bitmap is compressed before it is stored in the index.

- compression : value change uncompress and change bitmap and compress .

- ”alter table table_name minimize records_per_block” this command block records (nominimize . This is default) bitmap index compress .

, empty table IOT nested table bitmap index

.

- Local Index bitmap index partition .

Example

- bitmap index and normal index

SQL> sho user USER is "SCOTT" SQL> select count(*) from emp ; COUNT(*) ---------- 172032 SQL> create index xakemp_deptno on emp (deptno) ; Index created. SQL> select sum(bytes)/1024/1024,sum(blocks) from user_extents 2 where segment_name = 'XAKEMP_DEPTNO' ; SUM(BYTES)/1024/1024 SUM(BLOCKS) -------------------- -----------

2.6484375 339

SQL> drop index XAKEMP_DEPTNO ; Index dropped. SQL> create bitmap index xakemp_deptno on emp (deptno) ; Index created. SQL> select sum(bytes)/1024/1024,sum(blocks) from user_extents 2 where segment_name = 'XAKEMP_DEPTNO' ; SUM(BYTES)/1024/1024 SUM(BLOCKS) -------------------- ----------- .3515625 45

index bitmap index storage

. bitmap index compress .

2.5M 339block

0.3M 45block

Page 39: Oracle History #5

[email protected] - 39 -

Oracle8i New Features http://www.ggola.com/

New Index

Reverse-Key Indexes (Oracle8 New Features )

- Last leaf block .

- , data 10, 11, 12, 13, 14…. delete leaf block

. (skewed index) reverse index . alter command

. (01, 11, 21, 31, 41…. )

- cannot support bitmap index and IOT

- “=” index range scan index full scan .

- Example

SQL> drop index XAKEMP_DEPTNO ; Index dropped. SQL> alter table emp minimize records_per_block ; Table altered. SQL> create bitmap index xakemp_deptno on emp (deptno) ; Index created. SQL> select sum(bytes)/1024/1024,sum(blocks) from user_extents 2 where segment_name = 'XAKEMP_DEPTNO' ; SUM(BYTES)/1024/1024 SUM(BLOCKS) -------------------- ----------- .3515625 45

Minimize command . data

compress .

SQL> create index xakemp_empno_rvs on emp (empno) reverse ; Index created. SQL> explain plan for select /*+ INDEX(EMP) */ distinct empno, ename from emp 2 where empno > 7800 and empno < 7900 ; Explained. SQL> select substr(lpad(' ',2*(level-1))||operation||' '||options 2 ||' '||object_name,1,79) "Plan View" 3 from plan_table 4 start with id=0 5 connect by prior id = parent_id 6 order by id; Plan View ------------------------------------------------------------------------------- SELECT STATEMENT SORT UNIQUE TABLE ACCESS BY INDEX ROWID EMP INDEX FULL SCAN XAKEMP_EMPNO_RVS

“=” Range Scan

Index Full Scan .

Page 40: Oracle History #5

[email protected] - 40 -

Oracle8i New Features http://www.ggola.com/

SQL> delete plan_table; 2 rows deleted. SQL> commit; Commit complete. SQL> select /*+ INDEX(EMP) */ distinct empno, ename from emp 2 where empno > 7800 and empno < 7900 ; EMPNO ENAME ---------- ---------- 7839 KING 7844 TURNER 7876 ADAMS SQL> alter index xakemp_empno_rvs rebuild noreverse ; Index altered. SQL> explain plan for select /*+ INDEX(EMP) */ distinct empno, ename from emp 2 where empno > 7800 and empno < 7900 ; Explained. SQL> select substr(lpad(' ',2*(level-1))||operation||' '||options 2 ||' '||object_name,1,79) "Plan View" 3 from plan_table 4 start with id=0 5 connect by prior id = parent_id 6 order by id; Plan View ------------------------------------------------------------------------------- SELECT STATEMENT SORT UNIQUE TABLE ACCESS BY INDEX ROWID EMP INDEX RANGE SCAN XAKEMP_EMPNO_RVS SQL> delete plan_table; 2 rows deleted. SQL> commit; Commit complete.

rebuild index Range Scan

.

Page 41: Oracle History #5

[email protected] - 41 -

Oracle8i New Features http://www.ggola.com/

Function-Based Indexes

- Index where dramatic performance

.

- , “ salary – tax “ function based index

select acct_cd from tax_org where (salary – tax) > 100000 ; data .

- Enabling Function-Based Indexes alter session set query_rewrite_enabled = TRUE ; alter session set query_rewrite_integrity = TRUSTED ;

- Example

Descending Indexes

- order index .

- city city index , deptno descending index sort .

- Index : create index city_margin_dsc on emp (city asc, (revenue – cost) desc ) ; Query : select city, deptid, ordid, (revenue – cost) margin from emp order by city , margin desc ;

SQL> set timing on SQL> select sum(sal-comm) from emp where (sal-comm) > 3000 ; SUM(SAL-COMM) ------------- 391577600 Elapsed: 00:00:03.46 SQL> create index xakemp_salcnt_fnc on emp ( sal - comm ) ; Index created. SQL> select sum(sal-comm) from emp where (sal-comm) > 3000 ; SUM(SAL-COMM) ------------- 391577600 Elapsed: 00:00:00.55 SQL> alter session set query_rewrite_enabled=false ; Session altered. SQL> select sum(sal-comm) from emp where (sal-comm) > 3000 ; SUM(SAL-COMM) ------------- 391577600 Elapsed: 00:00:03.18

Function based index

query rewrite

. data performance

.

index order by clause .

Page 42: Oracle History #5

[email protected] - 42 -

Oracle8i New Features http://www.ggola.com/

- Example

Rebuild and compute index

Rebuild and Create Index Online

- Oracle8i index rebuild or create online option DML . lock

time DML . .

- Parallel rebuild index 2 space .

- PREPARE : create index structure and place entries in the data dictionary lock time . (very short locking)

- BUILD : index rebuild changes journal table . (no locking)

- MERGE : rebuild index journal table merge . , journal table

(commit or rollback ) table lock journal

SQL> select ename, sum(sal-comm) from emp where ename like 'K%' 2 and sal-comm > 3000 group by ename

3 order by 1 asc, 2 desc ; ENAME SUM(SAL-COMM) ---------- ------------- KANG 39321600 KIM 80281600 KING 32768000 Elapsed: 00:00:06.27 SQL> create index xakemp_name_salcnt_desc on emp

2 (ename asc, (sal - comm) desc) ; Index created. SQL> select ename, sum(sal-comm) from emp where ename like 'K%'

2 and sal-comm > 3000 group by ename 3 order by 1 asc, 2 desc ; ENAME SUM(SAL-COMM) ---------- ------------- KANG 39321600 KIM 80281600 KING 32768000 Elapsed: 00:00:00.94

ename sal-comm index

. , function based index index

order by index

.

2 data order by desc order by . ,

order by clause 2 asc order

by 1, 2 .

Page 43: Oracle History #5

[email protected] - 43 -

Oracle8i New Features http://www.ggola.com/

table and index online . (waiting for transaction and locking for merge)

- Index online DML transaction journal table index online option

parallel DML , bitmap/cluster/IOT secondary index .

- Index block block Oracle8i coalesce command coalesces leaf blocks within the same branch of the tree free block free lists .

- Example

Computing statistics on indexes

- statistics generation create index and alter index rebuild analyze . create index …… compute statistics ; alter index …….. rebuild compute statistics ;

- non-partitioned index : gather table, column, and index statistics concatenated index : refer only to the first column (index composite leading column ) partitioned index : only index statistics .

- Example

CF. test Index build or rebuild online option compute statistics option

.

CF. rebuild reverse option online option 8108 error return . (… noreverse online ; )

SQL> alter index xakemp_name_salcnt_desc rebuild online ; Index altered. SQL> create index xakemp_mgr on emp (mgr) online ; Index created. SQL> alter index XAKEMP_NAME_SALCNT_DESC coalesce ; Index altered.

SQL> alter index xakemp_name_salcnt_desc rebuild compute statistics ; Index altered. SQL> create index xakemp_mgrdept on emp (mgr, deptno)

2 compute statistics ; Index created.

Page 44: Oracle History #5

[email protected] - 44 -

Oracle8i New Features http://www.ggola.com/

Index-Organized Tables

Basic concept Oracle8 New Features

IOT & Logical ROWIDs(Oracle8i New Features)

- IOT index table , PK index value + non-key value permanent physical rowid . (leaf block row header, key column, nonkey column ) Oracle8 secondary index Oracle8i Logical Rowid concept . CF. PK index rowid .

, PK value index .

- user_segments view table name emp_iot segment .

, pctthreshold overflow SYS_IOT table type overflow segment

.

- Secondary Index : PK column column index

data ? IOT permanent physical rowid index

physical rowid rowid . secondary index PK values

8i NF ‘Universal Rowid’ , Urowid index .

SQL> create table emp_iot ( 2 empno number not null, 3 ename varchar2(10), 4 deptno number, 5 emp_desc varchar2(20), 6 constraint xpkemp_iot primary key (empno)) 7 organization index tablespace tools 8 pctthreshold 30 9 overflow tablespace users ; Table created SQL> select segment_name, segment_type, tablespace_name

2 from user_segments 3 where segment_name like ('%IOT%') ; SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME --------------------------------------------------------------------------------------------- SYS_IOT_OVER_40973 TABLE USERS XPKEMP_IOT INDEX TOOLS

7. table default organization heap 8. 1 block 1 row 30%

nonkey column data overflow

9. pctthreadshold data tablespace

( user default tablespace

.

Page 45: Oracle History #5

[email protected] - 45 -

Oracle8i New Features http://www.ggola.com/

- Data search using secondary index : Physical Guess : indexing index statistics physical rowid physical rowid access . Without guess or after incorrect guess : PK values

logical rowid access . CF. UROWID compatible 8.1 . CF. PL/SQL fully supports the ‘UROWID’ datatype.

- Unchanged Restrictions : 1. must have a primary key 2. cannot use unique constraints 3. cannot be clustered 4. cannot contain LONG columns 5. cannot support distribution and replication 6. cannot support object types 7. can contain LOB columns and nested table types(varray), but only if the table is not partitioned 8. IOT rowid datatype (rowid ) 9. (like index rebuild command) can use move command for reorganizing data(not overflow segment) CF. IOT PK index rebuild secondary index rebuild .

SQL> explain plan for select ename from emp_iot 2 where deptno = 10 ; Explained. SQL> select substr(lpad(' ',2*(level-1))||operation||' '||options 2 ||' '||object_name,1,79) "Plan View" 3 from plan_table 4 start with id=0 5 connect by prior id = parent_id 6 order by id; Plan View ------------------------------------------------------------------------------- SELECT STATEMENT INDEX FAST FULL SCAN XPKEMP_IOT SQL> create index xakempiot_deptno on emp_iot (deptno) ; Index created. SQL> explain plan for select ename from emp_iot 2 where deptno = 10 ; Explained. SQL> select substr(lpad(' ',2*(level-1))||operation||' '||options 2 ||' '||object_name,1,79) "Plan View" 3 from plan_table 4 start with id=0 5 connect by prior id = parent_id 6 order by id; Plan View ------------------------------------------------------------------------------- SELECT STATEMENT INDEX UNIQUE SCAN XPKEMP_IOT INDEX RANGE SCAN XAKEMPIOT_DEPTNO

Secondary index execution plan

.

Snapshot M-View

.

Page 46: Oracle History #5

[email protected] - 46 -

Oracle8i New Features http://www.ggola.com/

5. Basic Partition

HASH Partition

Oracle8 New Features range range partition Oracle8i range partition hash partition . concept Oracle8

.

tablespace (ts_emp1 ~ 6) create tablespace command .

Partitioned key update

- update command partition key ( partition range value ) row movement

.

- : alter table table_name ENABLE row movement ; default value DISABLE partitioned key update

ENABLE setting .

- Example

SQL> create table emp_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 JOB VARCHAR2(9), 5 MGR NUMBER(4), 6 HIREDATE DATE, 7 SAL NUMBER(7,2), 8 COMM NUMBER(7,2), 9 DEPTNO NUMBER(2)) 10 partition by range (hiredate) 11 ( partition p_emp_1980 values less than 12 (to_date('01-JAN-1981','DD-MON-YYYY')) tablespace ts_emp1, 13 partition p_emp_1981 values less than 14 (to_date('01-JAN-1982','DD-MON-YYYY')) tablespace ts_emp2, 15 partition p_emp_1982 values less than 16 (to_date('01-JAN-1983','DD-MON-YYYY')) tablespace ts_emp3, 17 partition p_emp_1983 values less than 18 (to_date('01-JAN-1984','DD-MON-YYYY')) tablespace ts_emp4, 19 partition p_emp_1984 values less than 20 (to_date('01-JAN-1985','DD-MON-YYYY')) tablespace ts_emp5, 21 partition p_emp_1985 values less than 22 (MAXVALUE) tablespace ts_emp6 ) ; Table created. SQL> insert into emp_part select * from emp ; 162034 rows created. SQL> commit ; Commit complete.

ts_emp1 ~6 6 tablespace hiredate range 6

partition partition table emp table data insert

.

Page 47: Oracle History #5

[email protected] - 47 -

Oracle8i New Features http://www.ggola.com/

Hash function

- table data hash function partition . ( , I/O )

- It controls the physical placement of data across a fixed number of partitions and gives you a highly tunable method of data placement.

- Does not support LONG, LONG RAW, ROWID, UROWID, LOB datatypes

- Hash partition key column list 16 .

SQL> select distinct(to_char(hiredate, 'YYYY-MM-DD')) 2 from emp_part partition(p_emp_1980) ; (TO_CHAR(H ---------- 1980-12-17 SQL> select distinct(to_char(hiredate, 'YYYY-MM-DD')) 2 from emp_part partition(p_emp_1985) ; (TO_CHAR(H ---------- 1985-10-01 SQL> update emp_part partition(p_emp_1985) 2 set empno = 0, hiredate = to_date('19801231', 'YYYYMMDD') 3 where rownum = 1 ; update emp_part partition(p_emp_1985) * ERROR at line 1: ORA-14402: updating partition key column would cause a partition change SQL> alter table emp_part enable row movement ; Table altered. SQL> update emp_part partition(p_emp_1985) 2 set empno = 0, hiredate = to_date('19801231', 'YYYYMMDD') 3 where rownum = 1 ; 1 row updated. SQL> commit ; Commit complete. SQL> alter session set nls_date_format = 'YYYYMMDD' ; Session altered. SQL> select empno, ename, hiredate from emp_part partition(p_emp_1980) 2 where empno = 0 ; EMPNO ENAME HIREDATE

---------- ---------- -------- 0 LEE 19801231

Partition select1 data partition insert

.

Partition key update enable row

movement partition key update

select .

Page 48: Oracle History #5

[email protected] - 48 -

Oracle8i New Features http://www.ggola.com/

Hash partition

- partition data . , Number of partitions should be a power of 2 (2, 4, 6, …)

(2 ) CF. test 2 error

. , 2 data

. CF. 2 partition tablespace

tablespace partition .

- parallel DML performance .

- deptno column value 6 tablespace 12 partition data

. tablespace 2 partition .

SQL> create table emp_hash_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 JOB VARCHAR2(9), 5 MGR NUMBER(4), 6 HIREDATE DATE, 7 SAL NUMBER(7,2),COMM NUMBER(7,2), 8 DEPTNO NUMBER(2)) 9 storage ( initial 64k next 64k pctincrease 0) 10 partition by hash (deptno) partitions 12 11 store in (ts_emp1, ts_emp2, ts_emp3, ts_emp4, ts_emp5, ts_emp6) ; Table created. SQL> set pagesize 100 SQL> col table_name for a15 SQL> col partition_name for a15 SQL> col tablespace_name for a10 SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name like '%HASH%' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE --------------- --------------- ---------- EMP_HASH_PART SYS_P19 TS_EMP1 EMP_HASH_PART SYS_P13 TS_EMP1 EMP_HASH_PART SYS_P14 TS_EMP2 EMP_HASH_PART SYS_P20 TS_EMP2 EMP_HASH_PART SYS_P15 TS_EMP3 EMP_HASH_PART SYS_P21 TS_EMP3 EMP_HASH_PART SYS_P16 TS_EMP4 EMP_HASH_PART SYS_P22 TS_EMP4 EMP_HASH_PART SYS_P17 TS_EMP5 EMP_HASH_PART SYS_P23 TS_EMP5 EMP_HASH_PART SYS_P18 TS_EMP6 EMP_HASH_PART SYS_P24 TS_EMP6 12 rows selected.

storage partition

hash partition disk stripping tablespace

, .

Hash partition name default

SYS_Pnn .

Page 49: Oracle History #5

[email protected] - 49 -

Oracle8i New Features http://www.ggola.com/

- Range partition user partition hash partition hash method Oracle

data .(no logical meaning to the users) select command .

select * from PARTITION(part_name) where…….. ; CF. test partition select

. , hash function partition partition return

.

- tablespace partition hash partition naming . Storage range partition table level storage partition and tablespace .

Partitioned index restriction

- Bitmap index on the partitioned table must be local.

- Global Index range partitioned table only. , hash partitioned table global index .

SQL> insert into emp_hash_part select * from emp ; 162034 rows created. SQL> commit ; Commit complete. SQL> select count(*) from emp_hash_part partition (SYS_P19) ; COUNT(*)

---------- 46291

SQL> create table emp_name_hash_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 HIREDATE DATE, 5 DEPTNO NUMBER(2)) 6 storage (initial 32k) 7 partition by hash (hiredate) 8 ( partition hp_h1 tablespace ts_emp1, 9 partition hp_h2 tablespace ts_emp2, 10 partition hp_h3 tablespace ts_emp2)

Table created. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_HASH_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_HASH_PART HP_H1 TS_EMP1 EMP_NAME_HASH_PART HP_H2 TS_EMP2 EMP_NAME_HASH_PART HP_H3 TS_EMP2

Page 50: Oracle History #5

[email protected] - 50 -

Oracle8i New Features http://www.ggola.com/

6. Partition Maintenance

8i New Maintenance Function

Basic Partition Maintenance Oracle8 New Features .

Add hash partition

- hash partition CF. partitioned table

.

- partition name and tablespace partition name SYS_Pnn tablespace

table’s default tablespace .

CF. Other attributes are always inherited from table-level defaults. (add partition table )

- Example

SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_HASH_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_HASH_PART HP_H1 TS_EMP1 EMP_NAME_HASH_PART HP_H2 TS_EMP2 EMP_NAME_HASH_PART HP_H3 TS_EMP2 SQL> insert into emp_name_hash_part 2 select empno, ename, hiredate, deptno from emp ; 162034 rows created. SQL> commit ; Commit complete. SQL> select count(*) from emp_name_hash_part partition(hp_h1) ; COUNT(*) ---------- 7718 SQL> select count(*) from emp_name_hash_part partition(hp_h2) ; COUNT(*) ---------- 115728 SQL> select count(a.empno) from emp_name_hash_part partition(hp_h3) a ; COUNT(A.EMPNO) -------------- 38588

Hash function partition data

. SQL partition alias .

Page 51: Oracle History #5

[email protected] - 51 -

Oracle8i New Features http://www.ggola.com/

SQL> alter table emp_name_hash_part add partition ; Table altered. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_HASH_PART'

4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_HASH_PART SYS_P42 TOOLS EMP_NAME_HASH_PART HP_H1 TS_EMP1 EMP_NAME_HASH_PART HP_H2 TS_EMP2 EMP_NAME_HASH_PART HP_H3 TS_EMP2 SQL> select count(*) from emp_name_hash_part partition(hp_h1) ; COUNT(*) ---------- 7718 SQL> select count(*) from emp_name_hash_part partition(hp_h2) ; COUNT(*) ---------- 84865 SQL> select count(*) from emp_name_hash_part partition(hp_h3) ; COUNT(*) ---------- 38588 SQL> select count(*) from emp_name_hash_part partition(SYS_P42) ; COUNT(*) ---------- 30863 SQL> alter table emp_name_hash_part add 2 partition hp_h4 tablespace ts_emp4 ; Table altered. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_HASH_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_HASH_PART SYS_P42 TOOLS EMP_NAME_HASH_PART HP_H1 TS_EMP1 EMP_NAME_HASH_PART HP_H2 TS_EMP2 EMP_NAME_HASH_PART HP_H3 TS_EMP2 EMP_NAME_HASH_PART HP_H4 TS_EMP4

Partition name tablespace hash partition

tablespace user default tablespace tools partition name SYS_P42

.

Partition hp_h2 data new partition sys_p42

.

Data partition

.

Partition name tablespace

new partition .

Page 52: Oracle History #5

[email protected] - 52 -

Oracle8i New Features http://www.ggola.com/

- parallel partition data redistribute .

data overhead partition partition redistribution .

- , data skew current partition 2 hash partition .

- Index add partition .

CF. , 2 hash partition 1 data distribution rate 1:1 2:1:1 . ,

2 1:1:1:1 .

CF. test data hash function

.

SQL> select count(*) from emp_name_hash_part partition(hp_h1) ; COUNT(*) ---------- 0 SQL> select count(*) from emp_name_hash_part partition(hp_h2) ; COUNT(*) ---------- 84865 SQL> select count(*) from emp_name_hash_part partition(hp_h3) ; COUNT(*) ---------- 38588 SQL> select count(*) from emp_name_hash_part partition(SYS_P42) ; COUNT(*) ---------- 30863 SQL> select count(*) from emp_name_hash_part partition(hp_h4) ; COUNT(*) ---------- 7718

Partition data hp_h1 hp_h4

. Hash function

.

Page 53: Oracle History #5

[email protected] - 53 -

Oracle8i New Features http://www.ggola.com/

Merge partition

- Oracle8 partition merge . , .

- Range partition partition merge . (hash partition or IOT )

- new tablespace and storage table default .

- partition partition tablespace partition new data

segment .

CF. new partition segment partition drop tablespace

data .

- The new index is placed in the default tablespace specified at the index level. (merge partition index unusable )

SQL> create index xakemp_part_hdt on emp_part (hiredate) local ; Index created. SQL> select index_name, partition_name, tablespace_name 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE ------------------------------ --------------- ---------- XAKEMP_PART_HDT P_EMP_1980 TS_EMP1 XAKEMP_PART_HDT P_EMP_1981 TS_EMP2 XAKEMP_PART_HDT P_EMP_1982 TS_EMP3 XAKEMP_PART_HDT P_EMP_1983 TS_EMP4 XAKEMP_PART_HDT P_EMP_1984 TS_EMP5 XAKEMP_PART_HDT P_EMP_1985 TS_EMP6 SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_PART P_EMP_1980 TS_EMP1 EMP_PART P_EMP_1981 TS_EMP2 EMP_PART P_EMP_1982 TS_EMP3 EMP_PART P_EMP_1983 TS_EMP4 EMP_PART P_EMP_1984 TS_EMP5 EMP_PART P_EMP_1985 TS_EMP6

Test tablespace local index

table index partition table

partition tablespace

.

Page 54: Oracle History #5

[email protected] - 54 -

Oracle8i New Features http://www.ggola.com/

SQL> alter table emp_part merge partitions p_emp_1980, p_emp_1982 2 into partition p_emp_1980_2 ; alter table emp_part merge partitions p_emp_1980, p_emp_1982 * ERROR at line 1: ORA-14274: partitions being merged are not adjacent SQL> alter table emp_part merge partitions p_emp_1980, p_emp_1981 2 into partition p_emp_1980_1 ; Table altered. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_PART P_EMP_1980_1 TOOLS EMP_PART P_EMP_1982 TS_EMP3 EMP_PART P_EMP_1983 TS_EMP4 EMP_PART P_EMP_1984 TS_EMP5 EMP_PART P_EMP_1985 TS_EMP6 SQL> alter table emp_part merge partitions p_emp_1983, p_emp_1984 2 into partition p_emp_1983_4 tablespace ts_emp2 3 storage ( initial 64k next 64k pctincrease 0 ) ; Table altered. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_PART P_EMP_1980_1 TOOLS EMP_PART P_EMP_1983_4 TS_EMP2 EMP_PART P_EMP_1982 TS_EMP3 EMP_PART P_EMP_1985 TS_EMP6 SQL> select index_name, partition_name, tablespace_name 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' 4 order by tablespace_name ; SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS ------------------------------ --------------- ---------- -------- XAKEMP_PART_HDT P_EMP_1980_1 TOOLS UNUSABLE XAKEMP_PART_HDT P_EMP_1983_4 TS_EMP2 UNUSABLE XAKEMP_PART_HDT P_EMP_1982 TS_EMP3 USABLE XAKEMP_PART_HDT P_EMP_1985 TS_EMP6 USABLE

(adjacent) partition merge

partition merge

user default tablespace .

Partition merge new

merge partition .

Local index table merge

. Index

partition unusable . rebuild

.

Page 55: Oracle History #5

[email protected] - 55 -

Oracle8i New Features http://www.ggola.com/

Hash partition coalesce

- hash partition range partition merge operation . (Removes a single hash partition and redistributes the data)

- Hash function dissolution partition drop and redistribution .(parallel )

- Merge local index rebuild .

SQL> alter index xakemp_part_hdt rebuild partition 2 p_emp_1980_1 tablespace ts_emp1 ; Index altered. SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS ------------------------ --------------- ---------- -------- XAKEMP_PART_HDT P_EMP_1980_1 TS_EMP1 USABLE XAKEMP_PART_HDT P_EMP_1983_4 TS_EMP2 UNUSABLE XAKEMP_PART_HDT P_EMP_1982 TS_EMP3 USABLE XAKEMP_PART_HDT P_EMP_1985 TS_EMP6 USABLE SQL> alter table emp_part modify partition p_emp_1983_4 2 rebuild unusable local indexes ; Table altered. SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS ------------------------ --------------- ---------- -------- XAKEMP_PART_HDT P_EMP_1980_1 TS_EMP1 USABLE XAKEMP_PART_HDT P_EMP_1983_4 TS_EMP2 USABLE XAKEMP_PART_HDT P_EMP_1982 TS_EMP3 USABLE XAKEMP_PART_HDT P_EMP_1985 TS_EMP6 USABLE

Rebuild partition command index

Modify partition command index

SQL> create index xakempname_hash_hdt 2 on emp_name_hash_part (hiredate) local ;

Index created. SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMPNAME_HASH_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS ------------------------------ --------------- ---------- -------- XAKEMPNAME_HASH_HDT SYS_P42 TOOLS USABLE XAKEMPNAME_HASH_HDT HP_H1 TS_EMP1 USABLE XAKEMPNAME_HASH_HDT HP_H2 TS_EMP2 USABLE XAKEMPNAME_HASH_HDT HP_H3 TS_EMP2 USABLE XAKEMPNAME_HASH_HDT HP_H4 TS_EMP4 USABLE

Test local index index status

Page 56: Oracle History #5

[email protected] - 56 -

Oracle8i New Features http://www.ggola.com/

SQL> alter table emp_name_hash_part add 2 partition hp_h5 tablespace ts_emp5 ;

Table altered. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_HASH_PART'

4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_HASH_PART SYS_P42 TOOLS EMP_NAME_HASH_PART HP_H1 TS_EMP1 EMP_NAME_HASH_PART HP_H2 TS_EMP2 EMP_NAME_HASH_PART HP_H3 TS_EMP2 EMP_NAME_HASH_PART HP_H4 TS_EMP4 EMP_NAME_HASH_PART HP_H5 TS_EMP5 SQL> alter table emp_name_hash_part coalesce partition ; Table altered. SQL> select table_name, PARTITION_NAME, TABLESPACE_NAME 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_HASH_PART' 4 order by tablespace_name ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_HASH_PART SYS_P42 TOOLS EMP_NAME_HASH_PART HP_H1 TS_EMP1 EMP_NAME_HASH_PART HP_H2 TS_EMP2 EMP_NAME_HASH_PART HP_H3 TS_EMP2 EMP_NAME_HASH_PART HP_H4 TS_EMP4 SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMPNAME_HASH_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS ------------------------------ --------------- ---------- -------- XAKEMPNAME_HASH_HDT SYS_P42 TOOLS USABLE XAKEMPNAME_HASH_HDT HP_H1 TS_EMP1 USABLE XAKEMPNAME_HASH_HDT HP_H2 TS_EMP2 UNUSABLE XAKEMPNAME_HASH_HDT HP_H3 TS_EMP2 USABLE XAKEMPNAME_HASH_HDT HP_H4 TS_EMP4 USABLE SQL> alter index xakempname_hash_hdt rebuild partition hp_h2 ; Index altered. SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMPNAME_HASH_HDT' 4 order by tablespace_name ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS ------------------------------ --------------- ---------- -------- XAKEMPNAME_HASH_HDT SYS_P42 TOOLS USABLE XAKEMPNAME_HASH_HDT HP_H1 TS_EMP1 USABLE XAKEMPNAME_HASH_HDT HP_H2 TS_EMP2 USABLE XAKEMPNAME_HASH_HDT HP_H3 TS_EMP2 USABLE XAKEMPNAME_HASH_HDT HP_H4 TS_EMP4 USABLE

Hash partition hp_h5 partition

coalesce command hp_h5 partition

. , hash function dissolution

partition hp_h5 hp_h2 index partition unusable data

redistribution hp_h2 .

Rebuild hp_h2 index partition

Page 57: Oracle History #5

[email protected] - 57 -

Oracle8i New Features http://www.ggola.com/

General operation

- Oracle8 .

SQL> alter table emp_part rename partition p_emp_1983_4 to p_emp_old ; Table altered. SQL> alter index xakempname_hash_hdt rename

2 partition SYS_P42 to hp_h5 ; Index altered. SQL> alter table emp_part move partition p_emp_1980_1

2 tablespace ts_emp1 ; Table altered. SQL> alter table emp_part add partition p_emp_1986

2 values less than 3 (to_date('01-JAN-1987','DD-MON-YYYY')) tablespace ts_emp1 ;

alter table emp_part add partition p_emp_1986 * ERROR at line 1: ORA-14074: partition bound must collate higher than that of the last partition SQL> alter table emp_part split partition p_emp_1985 2 at (to_date('01-JAN-1986','DD-MON-YYYY')) 3 into ( partition p_emp_1985 tablespace ts_emp4, 4 partition p_emp_1986 tablespace ts_emp5) ; Table altered. SQL> set long 2000 SQL> select table_name, partition_name, high_value 2 from user_tab_partitions 3 where table_name = 'EMP_PART' 4 order by 2 ; TABLE_NAME PARTITION_NAME HIGH_VALUE ---------------------------------------------------------------- EMP_PART P_EMP_1980_1 TO_DATE('1982-01-01 00:00:00'...) EMP_PART P_EMP_1982 TO_DATE('1983-01-01 00:00:00'...) EMP_PART P_EMP_OLD TO_DATE('1985-01-01 00:00:00'...) EMP_PART P_EMP_1985 TO_DATE('1986-01-01 00:00:00'...) EMP_PART P_EMP_1986 MAXVALUE SQL> select index_name, partition_name, status from user_ind_partitions 2 where INDEX_NAME = 'XAKEMP_PART_HDT' ; INDEX_NAME PARTITION_NAME STATUS --------------- --------------- -------- XAKEMP_PART_HDT P_EMP_1983_4 USABLE XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1980_1 UNUSABLE XAKEMP_PART_HDT P_EMP_1985 UNUSABLE XAKEMP_PART_HDT P_EMP_1986 USABLE

Partition rename : table, index .

Move partition : partition tablespace

.

Add partition : hash partition range partition

range value

partition .

highest partition range maxvalue error return split command

.

Split p_emp_1986 range maxvalue

.

P_EMP_OLD rename local index p_emp_1983_4 status .

Move or Split command local index

unusable .

Page 58: Oracle History #5

[email protected] - 58 -

Oracle8i New Features http://www.ggola.com/

Modify default attributes

- Table or index default attribute partition attribute .

- , partition partition explicitly storage attribute

default attribute override .

- manual hash partitioned table index default

attribute tablespace test storage clause Oracle8.1.6.2 .

SQL> alter table emp_part drop partition p_emp_old ; Table altered. SQL> select index_name, partition_name, status from user_ind_partitions 2 where INDEX_NAME = 'XAKEMP_PART_HDT' ; INDEX_NAME PARTITION_NAME STATUS --------------- --------------- -------- XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1980_1 UNUSABLE XAKEMP_PART_HDT P_EMP_1985 UNUSABLE XAKEMP_PART_HDT P_EMP_1986 USABLE SQL> alter index xakemp_part_hdt drop partition p_emp_1980_1 ; alter index xakemp_part_hdt drop partition p_emp_1980_1 * ERROR at line 1: ORA-14076: DROP/SPLIT PARTITION may not be applied to a LOCAL index partition SQL> alter table emp_part modify partition p_emp_1986 2 storage ( next 1m ) ; Table altered. SQL> alter index xakemp_part_hdt modify partition p_emp_1980_1 2 storage ( next 1m ) ; Index altered. SQL> alter index xakempname_hash_hdt modify partition hp_h5 2 storage ( next 1m ) ; alter index xakempname_hash_hdt modify partition hp_h5 * ERROR at line 1: ORA-14192: cannot modify physical index attributes of a Hash index partition

Drop partition : table partition drop local index p_emp_1983_4 drop

. Hash partitioned table .

Index partition drop error return . , table partition drop local index partition drop

. global index drop index partition

highest partition drop .

Modify partition : table or index partition storage

. , index global or

local partitioned index .

Hash partition : hash partition

storage table level modify command

error return .

Page 59: Oracle History #5

[email protected] - 59 -

Oracle8i New Features http://www.ggola.com/

- table table

.

SQL> drop table emp_part ; Table dropped. SQL> create table emp_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 JOB VARCHAR2(9), 5 MGR NUMBER(4), 6 HIREDATE DATE, 7 SAL NUMBER(7,2), 8 COMM NUMBER(7,2), 9 DEPTNO NUMBER(2)) 10 partition by range (hiredate) 11 ( partition p_emp_1980 values less than 12 (to_date('01-JAN-1981','DD-MON-YYYY')) tablespace ts_emp1, 13 partition p_emp_1981 values less than 14 (to_date('01-JAN-1982','DD-MON-YYYY')) tablespace ts_emp2, 15 partition p_emp_1982 values less than 16 (to_date('01-JAN-1983','DD-MON-YYYY')) tablespace ts_emp3, 17 partition p_emp_1983 values less than 18 (to_date('01-JAN-1984','DD-MON-YYYY')) tablespace ts_emp4, 19 partition p_emp_1984 values less than 20 (to_date('01-JAN-1985','DD-MON-YYYY')) tablespace ts_emp5, 21 partition p_emp_1985 values less than 22 (MAXVALUE) tablespace ts_emp6 ) ; Table created. SQL> create index xakemp_part_hdt on emp_part (hiredate) local ; Index created. SQL> drop table emp_name_hash_part ; Table dropped. SQL> create table emp_name_hash_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 HIREDATE DATE, 5 DEPTNO NUMBER(2)) 6 storage (initial 32k) 7 partition by hash (hiredate) 8 ( partition hp_h1 tablespace ts_emp1, 9 partition hp_h2 tablespace ts_emp2, 10 partition hp_h3 tablespace ts_emp3) Table created. SQL> create index xakempname_hash_hdt 2 on emp_name_hash_part (hiredate) local ; Index created. SQL> break on table_name

Page 60: Oracle History #5

[email protected] - 60 -

Oracle8i New Features http://www.ggola.com/

- table attribute modify .

- emp_part p_emp_1985 partition .

SQL> select table_name, partition_name, max_extent 2 from user_tab_partitions

3 where table_name in ('EMP_PART', 'EMP_NAME_HASH_PART') 4 order by 1 ; TABLE_NAME PARTITION_NAME MAX_EXTENT -------------------- --------------- ------------------------------------------------ EMP_NAME_HASH_PART HP_H2 505 HP_H3 505 HP_H1 505 EMP_PART P_EMP_1981 505 P_EMP_1982 505 P_EMP_1980 505 P_EMP_1985 505 P_EMP_1983 505 P_EMP_1984 505 SQL> alter table emp_part modify default attributes 2 storage ( maxextents 1024 ) ; Table altered. SQL> alter table emp_name_hash_part modify default attributes 2 storage ( maxextents 1024 ) ; Table altered. SQL> select table_name, partition_name, max_extent

2 from user_tab_partitions 3 where table_name in ('EMP_PART', 'EMP_NAME_HASH_PART') 4 order by 1 ; TABLE_NAME PARTITION_NAME MAX_EXTENT -------------------- --------------- ---------- EMP_NAME_HASH_PART HP_H2 505 HP_H3 505 HP_H1 505 EMP_PART P_EMP_1981 505 P_EMP_1982 505 P_EMP_1980 505 P_EMP_1985 505 P_EMP_1983 505 P_EMP_1984 505 SQL> alter table emp_part split partition p_emp_1985 2 at (to_date('01-JAN-1987','DD-MON-YYYY')) 3 into ( partition p_emp_1985 tablespace ts_emp1, 4 partition p_emp_1987 tablespace ts_emp2) ; Table altered.

Table default attribute maxextents 1024

.

partition max extent

. ( 505 )

Page 61: Oracle History #5

[email protected] - 61 -

Oracle8i New Features http://www.ggola.com/

SQL> select table_name, partition_name, max_extent 2 from user_tab_partitions

3 where table_name = 'EMP_PART'; TABLE_NAME PARTITION_NAME MAX_EXTENT -------------------- --------------- ---------- EMP_PART P_EMP_1981 505 P_EMP_1982 505 P_EMP_1983 505 P_EMP_1984 505 P_EMP_1985 505 P_EMP_1980 505 P_EMP_1986 505 SQL> alter table emp_part drop partition p_emp_1986 ; Table altered. SQL> alter table emp_part add partition p_emp_1986 2 values less than ( maxvalue ) tablespace ts_emp6 ; Table altered. SQL> alter table emp_name_hash_part add partition ; Table altered. SQL> select table_name, partition_name, max_extent

2 from user_tab_partitions 3 where table_name in ('EMP_PART', 'EMP_NAME_HASH_PART') 4 order by 1 ; TABLE_NAME PARTITION_NAME MAX_EXTENT -------------------- --------------- ---------- EMP_NAME_HASH_PART HP_H2 505 HP_H3 505 SYS_P47 1024 HP_H1 505 EMP_PART P_EMP_1981 505 P_EMP_1982 505 P_EMP_1986 1024 P_EMP_1980 505 P_EMP_1985 505 P_EMP_1983 505 P_EMP_1984 505

Split command partition

default attribute . , split

partition new partition

.

Maxvalue partition drop new partition hash partitioned table add partition new partition .

partition default attribute

.

Page 62: Oracle History #5

[email protected] - 62 -

Oracle8i New Features http://www.ggola.com/

- index default attribute test extent .

- hash partitioned index .

SQL> break on index_name SQL> select index_name, partition_name, next_extent 2 from user_ind_partitions

3 where index_name in 4 ('XAKEMP_PART_HDT','XAKEMPNAME_HASH_HDT')

5 order by 1 ; INDEX_NAME PARTITION_NAME NEXT_EXTENT ------------------------------ --------------- ----------- XAKEMPNAME_HASH_HDT HP_H1 40960 HP_H2 40960 HP_H3 40960 SYS_P47 40960 XAKEMP_PART_HDT P_EMP_1981 40960 P_EMP_1982 40960 P_EMP_1980 40960 P_EMP_1985 40960 P_EMP_1983 40960 P_EMP_1984 40960 P_EMP_1986 40960 SQL> alter index xakemp_part_hdt modify default attributes 2 maxtrans 10 storage ( next 5M ) ; Index altered. SQL> alter index xakempname_hash_hdt modify default attributes 2 maxtrans 10 storage ( next 5M ) ; Index altered. SQL> select index_name, partition_name, next_extent 2 from user_ind_partitions

3 where index_name in 4 ('XAKEMP_PART_HDT','XAKEMPNAME_HASH_HDT')

5 order by 1 ; INDEX_NAME PARTITION_NAME NEXT_EXTENT ------------------------------ --------------- ----------- XAKEMPNAME_HASH_HDT HP_H1 40960 HP_H2 40960 HP_H3 40960 SYS_P47 40960 XAKEMP_PART_HDT P_EMP_1981 40960 P_EMP_1982 40960 P_EMP_1980 40960 P_EMP_1985 40960 P_EMP_1983 40960 P_EMP_1984 40960 P_EMP_1986 40960

index partition default attribute

.

partition attribute

.

Page 63: Oracle History #5

[email protected] - 63 -

Oracle8i New Features http://www.ggola.com/

SQL> alter table emp_part drop partition p_emp_1986 ; Table altered. SQL> alter table emp_part add partition p_emp_1986 2 values less than ( maxvalue ) tablespace ts_emp6 ; Table altered. SQL> alter table emp_name_hash_part add partition ; Table altered. SQL> select index_name, partition_name, next_extent 2 from user_ind_partitions

3 where index_name in 4 ('XAKEMP_PART_HDT','XAKEMPNAME_HASH_HDT')

5 order by 1 ; INDEX_NAME PARTITION_NAME NEXT_EXTENT ------------------------------ --------------- ----------- XAKEMPNAME_HASH_HDT SYS_P48 5242880 HP_H1 40960 HP_H3 40960 SYS_P47 40960 HP_H2 40960 XAKEMP_PART_HDT P_EMP_1981 40960 P_EMP_1986 5242880 P_EMP_1980 40960 P_EMP_1985 40960 P_EMP_1982 40960 P_EMP_1983 40960 P_EMP_1984 40960

Add partition local index next extent default attribute 5M

.

partition default attribute

.

Page 64: Oracle History #5

[email protected] - 64 -

Oracle8i New Features http://www.ggola.com/

Unusable local index data insert

- local index status unusable partition data . data insert index

.

- alter session command .

- , index unique index index partition query

error .

SQL> col index_name for a15 SQL> col partition_name for a15 SQL> select index_name, partition_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' ; INDEX_NAME PARTITION_NAME STATUS --------------- --------------- -------- XAKEMP_PART_HDT P_EMP_1981 USABLE XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1983 USABLE XAKEMP_PART_HDT P_EMP_1984 USABLE XAKEMP_PART_HDT P_EMP_1985 USABLE XAKEMP_PART_HDT P_EMP_1980 USABLE XAKEMP_PART_HDT P_EMP_1986 USABLE SQL> insert into emp_part select * from emp ; 162034 rows created. SQL> commit ; Commit complete. SQL> alter table emp_part move partition 2 p_emp_1981 tablespace tools ; Table altered. SQL> select index_name, partition_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' ; INDEX_NAME PARTITION_NAME STATUS --------------- --------------- -------- XAKEMP_PART_HDT P_EMP_1981 UNUSABLE XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1983 USABLE XAKEMP_PART_HDT P_EMP_1984 USABLE XAKEMP_PART_HDT P_EMP_1985 USABLE XAKEMP_PART_HDT P_EMP_1980 USABLE XAKEMP_PART_HDT P_EMP_1986 USABLE

Data insert data partition

p_emp_1981 tablespace move local index status unusable

.

Page 65: Oracle History #5

[email protected] - 65 -

Oracle8i New Features http://www.ggola.com/

SQL> insert into emp_part select * from emp 2 where to_char(hiredate, 'YYYYMMDD') like '1981%' 3 and rownum = 1 ; insert into emp_part select * from emp * ERROR at line 1: ORA-01502: index 'SCOTT.XAKEMP_PART_HDT' or partition of such index is in unusable state SQL> alter session set skip_unusable_indexes = true ; Session altered. SQL> insert into emp_part select * from emp 2 where to_char(hiredate, 'YYYYMMDD') like '1981%' 3 and rownum = 1 ; 1 row created. SQL> commit ; Commit complete. SQL> alter table emp_part modify partition 2 p_emp_1981 rebuild unusable local indexes ; Table altered. SQL> select index_name, partition_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' ; INDEX_NAME PARTITION_NAME STATUS --------------- --------------- -------- XAKEMP_PART_HDT P_EMP_1981 USABLE XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1983 USABLE XAKEMP_PART_HDT P_EMP_1984 USABLE XAKEMP_PART_HDT P_EMP_1985 USABLE XAKEMP_PART_HDT P_EMP_1980 USABLE XAKEMP_PART_HDT P_EMP_1986 USABLE

Move partition p_emp_1981 1980

data insert error .

index unusable .

Alter session command data

insert .

index rebuild

index .

Page 66: Oracle History #5

[email protected] - 66 -

Oracle8i New Features http://www.ggola.com/

Review command

- general operation Oracle8 partition Oracle8 sample

exchange command truncate command .

- table creation .

SQL> drop table emp_part ; Table dropped. SQL> create table emp_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 JOB VARCHAR2(9), 5 MGR NUMBER(4), 6 HIREDATE DATE, 7 SAL NUMBER(7,2), 8 COMM NUMBER(7,2), 9 DEPTNO NUMBER(2)) 10 partition by range (hiredate) 11 ( partition p_emp_1980 values less than 12 (to_date('01-JAN-1981','DD-MON-YYYY')) tablespace ts_emp1, 13 partition p_emp_1981 values less than 14 (to_date('01-JAN-1982','DD-MON-YYYY')) tablespace ts_emp2, 15 partition p_emp_1982 values less than 16 (to_date('01-JAN-1983','DD-MON-YYYY')) tablespace ts_emp3, 17 partition p_emp_1983 values less than 18 (to_date('01-JAN-1984','DD-MON-YYYY')) tablespace ts_emp4, 19 partition p_emp_1984 values less than 20 (to_date('01-JAN-1985','DD-MON-YYYY')) tablespace ts_emp5, 21 partition p_emp_1985 values less than 22 (MAXVALUE) tablespace ts_emp6 ) ; Table created. SQL> create index xakemp_part_hdt on emp_part (hiredate) local ; Index created. SQL> select count(*) from emp ; COUNT(*) ---------- 162034 SQL> select count(*) from emp 2 where to_char(hiredate, 'YYYYMMDD') like '1981%' ; COUNT(*) ---------- 77161 SQL> insert into emp_part select * from emp ; 162034 rows created. SQL> commit ; Commit complete.

Table test 1981 data

77161 . data

partitioned table insert test .

Page 67: Oracle History #5

[email protected] - 67 -

Oracle8i New Features http://www.ggola.com/

SQL> col table_name for a10 SQL> col index_name for a15 SQL> col partition_name for a10 SQL> col tablespace_name for a10 SQL> set pagesize 100 SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_PART' ; TABLE_NAME PARTITION_ TABLESPACE ---------- ---------- ---------- EMP_PART P_EMP_1981 TS_EMP2 EMP_PART P_EMP_1982 TS_EMP3 EMP_PART P_EMP_1983 TS_EMP4 EMP_PART P_EMP_1984 TS_EMP5 EMP_PART P_EMP_1985 TS_EMP6 EMP_PART P_EMP_1980 TS_EMP1 SQL> select count(*) from emp_part partition(p_emp_1981) ; COUNT(*) ---------- 77161 SQL> col segment_name for a10 SQL> select segment_name, partition_name, extents 2 from user_segments 3 where segment_name = 'EMP_PART' ; SEGMENT_NA PARTITION_ EXTENTS ---------- ---------- ---------- EMP_PART P_EMP_1981 11 EMP_PART P_EMP_1982 7 EMP_PART P_EMP_1983 5 EMP_PART P_EMP_1984 8 EMP_PART P_EMP_1985 7 EMP_PART P_EMP_1980 5 SQL> alter table emp_part truncate partition p_emp_1981 2 drop storage ; Table truncated. SQL> select count(*) from emp_part partition(p_emp_1981) ; COUNT(*) ---------- 0 SQL> alter table emp_part truncate partition p_emp_1982 2 reuse storage ; Table truncated. SQL> alter table emp_part truncate partition p_emp_1980 ; Table truncated.

data partition p_emp_1981 select

emp 1981 . partition

.

Partition truncate 3 . Truncate

partition data .

Page 68: Oracle History #5

[email protected] - 68 -

Oracle8i New Features http://www.ggola.com/

SQL> select segment_name, partition_name, extents 2 from user_segments 3 where segment_name = 'EMP_PART' ; SEGMENT_NA PARTITION_ EXTENTS ---------- ---------- ---------- EMP_PART P_EMP_1981 1 EMP_PART P_EMP_1982 7 EMP_PART P_EMP_1983 5 EMP_PART P_EMP_1984 8 EMP_PART P_EMP_1985 7 EMP_PART P_EMP_1980 1 SQL> create table emp_history as select * from emp 2 where to_char(hiredate, 'YYYYMMDD') like '1981%' ; Table created. SQL> select count(*) from emp_history ; COUNT(*) ---------- 77161 SQL> alter table emp_part exchange partition p_emp_1981 2 with table emp_history ; Table altered. SQL> select count(*) from emp_history ; COUNT(*) ---------- 0 SQL> select count(*) from emp_part partition(p_emp_1981) ; COUNT(*) ---------- 77161 SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_PART' ; TABLE_NAME PARTITION_ TABLESPACE ---------- ---------- ---------- EMP_PART P_EMP_1981 TOOLS EMP_PART P_EMP_1982 TS_EMP3 EMP_PART P_EMP_1983 TS_EMP4 EMP_PART P_EMP_1984 TS_EMP5 EMP_PART P_EMP_1985 TS_EMP6 EMP_PART P_EMP_1980 TS_EMP1

Partition truncate drop storage option extent 1 space

reuse option p_emp_1982

partition storage .

Exchange partition test emp table emp_history table

. table data 1981

.

truncate p_emp_1981 partition emp_history exchange table partition

. , physical segment

.

Page 69: Oracle History #5

[email protected] - 69 -

Oracle8i New Features http://www.ggola.com/

SQL> select segment_name, partition_name, extents 2 from user_segments 3 where segment_name = 'EMP_PART' ; SEGMENT_NA PARTITION_ EXTENTS ---------- ---------- ---------- EMP_PART P_EMP_1981 93 EMP_PART P_EMP_1982 7 EMP_PART P_EMP_1983 5 EMP_PART P_EMP_1984 8 EMP_PART P_EMP_1985 7 EMP_PART P_EMP_1980 1 SQL> select index_name, partition_name, status 2 from user_ind_partitions

3 where index_name = 'XAKEMP_PART_HDT' ;

INDEX_NAME PARTITION_NAME STATUS ------------------- --------------- -------- XAKEMP_PART_HDT P_EMP_1981 UNUSABLE XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1983 USABLE XAKEMP_PART_HDT P_EMP_1984 USABLE XAKEMP_PART_HDT P_EMP_1985 USABLE XAKEMP_PART_HDT P_EMP_1980 USABLE SQL> alter table emp_part move partition p_emp_1981 2 tablespace ts_emp2 ; Table altered. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_PART' ; TABLE_NAME PARTITION_ TABLESPACE ---------- ---------- ---------- EMP_PART P_EMP_1981 TS_EMP2 EMP_PART P_EMP_1982 TS_EMP3 EMP_PART P_EMP_1983 TS_EMP4 EMP_PART P_EMP_1984 TS_EMP5 EMP_PART P_EMP_1985 TS_EMP6 EMP_PART P_EMP_1980 TS_EMP1 SQL> alter table emp_part modify partition 2 p_emp_1981 rebuild unusable local indexes ; Table altered. SQL> select index_name, partition_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMP_PART_HDT' ; INDEX_NAME PARTITION_NAME STATUS ------------------------------ --------------- -------- XAKEMP_PART_HDT P_EMP_1981 USABLE XAKEMP_PART_HDT P_EMP_1982 USABLE XAKEMP_PART_HDT P_EMP_1983 USABLE XAKEMP_PART_HDT P_EMP_1984 USABLE XAKEMP_PART_HDT P_EMP_1985 USABLE XAKEMP_PART_HDT P_EMP_1980 USABLE SQL> drop table emp_history ; Table dropped.

Exchange data

p_emp_1981 partition extents .

index unusable .

Partition move rebuild partitioned table

table .

emp_history drop

.

Page 70: Oracle History #5

[email protected] - 70 -

Oracle8i New Features http://www.ggola.com/

Execution PLAN : ITERATOR and INLIST

- emp_part data .

- partitioned table emp_part hiredate partition key . 6 partition

1980 1985 data key .

- hiredate column local prefixed index .

- hiredate SQL Oracle8i execution plan

SQL> truncate table emp_part ; Table truncated. SQL> insert into emp_part select * from emp ; 162034 rows created. SQL> commit ; Commit complete. SQL> alter session set nls_date_format = 'YYYYMMDD HH24:MI:SS' ; Session altered. SQL> select distinct(hiredate) from emp_part ; HIREDATE ----------------- 19801217 00:00:00 19810220 00:00:00 19810222 00:00:00 19810402 00:00:00 19810501 00:00:00 19810609 00:00:00 19810908 00:00:00 19810928 00:00:00 19811117 00:00:00 19811203 00:00:00 19820123 00:00:00 19821209 00:00:00 19830112 00:00:00 19840918 00:00:00 19851001 00:00:00 SQL> set pagesize 100 SQL> set long 2000 SQL> select table_name, partition_name, high_value 2 from user_tab_partitions 3 where table_name = 'EMP_PART' 4 order by 2 ; TABLE_NAME PARTITION_NAME HIGH_VALUE ---------------------------------------------------------- EMP_PART P_EMP_1980 TO_DATE(' 1981-01-01 00:00:00'… EMP_PART P_EMP_1981 TO_DATE(' 1982-01-01 00:00:00'… EMP_PART P_EMP_1982 TO_DATE(' 1983-01-01 00:00:00'… EMP_PART P_EMP_1983 TO_DATE(' 1984-01-01 00:00:00'… EMP_PART P_EMP_1984 TO_DATE(' 1985-01-01 00:00:00'… EMP_PART P_EMP_1985 MAXVALUE

test emp table Oracle emp table

row insert sample

162034 row hiredate 15

.

Page 71: Oracle History #5

[email protected] - 71 -

Oracle8i New Features http://www.ggola.com/

SQL> col operation format a16 SQL> col options format a20 SQL> col start format a12 SQL> col stop format a12 SQL> col distribution format a10 SQL> col object_name format a15 SQL> set numwidth 7 SQL> select distinct ename, hiredate from emp_part 2 where hiredate = to_date('19810501 00:00:00', 'YYYYMMDD HH24:MI:SS') ; ENAME HIREDATE ---------- -------- BLAKE 19810501 SQL> explain plan for select distinct ename, hiredate 2 from emp_part 3 where hiredate = to_date('19810501 00:00:00', 'YYYYMMDD HH24:MI:SS') ; Explained. SQL> select operation, options, object_name, 2 partition_start "start", partition_stop "stop", 3 bytes, cardinality as "#" 4 from plan_table 5 order by id ; OPERATION OPTIONS OBJECT_NAME start stop BYTES # ------------------------------------------------------------------------------------------------------------------ SELECT STATEMENT 16 1 SORT UNIQUE 16 1 TABLE ACCESS BY LOCAL INDEX ROWID EMP_PART 2 2 16 1 INDEX RANGE SCAN XAKEMP_PART_HDT 2 2 1 SQL> select distinct ename, hiredate from emp_part

2 where hiredate in 3 ( to_date('19810501 00:00:00', 'YYYYMMDD HH24:MI:SS'), 4 to_date('19840918 00:00:00', 'YYYYMMDD HH24:MI:SS')) ;

ENAME HIREDATE ---------- -------- BLAKE 19810501 JANG 19840918 JUN 19840918 KIM 19840918 LEE 19840918 SQL> delete from plan_table ; 10 rows deleted. SQL> commit ; Commit complete.

Index 2 partition data

return execution plan .

partition data select .

partition partition data select .

Page 72: Oracle History #5

[email protected] - 72 -

Oracle8i New Features http://www.ggola.com/

- Oracle8 version “in” partition 2

partition partition range access . Oracle8 Test

ITERATOR KEY(INLIST) Oracle8i

.

- full table scan ( hiredate index ) Oracle8 “in” partition partition ITERATOR( ) range scan(partition full scan) (“in”

table full scan ) Oracle8i INLIST partition full scan

. , full scan scan

.

SQL> explain plan for select distinct ename, hiredate 2 from emp_part

3 where hiredate in 4 ( to_date('19810501 00:00:00', 'YYYYMMDD HH24:MI:SS'), 5 to_date('19840918 00:00:00', 'YYYYMMDD HH24:MI:SS')) ;

Explained. SQL> select operation, options, object_name, 2 partition_start "start", partition_stop "stop", 3 bytes, cardinality as "#" 4 from plan_table 5 order by id ; OPERATION OPTIONS OBJECT_NAME start stop BYTES # -------------------------------------------------------------------------------------------------------------------------------------------------- SELECTSTATEMENT 80 5 INLIST ITERATOR PARTITION RANGE ITERATOR KEY(INLIST) KEY(INLIST) SORT UNIQUE 80 5 TABLE ACCESS BY LOCAL INDEX ROWID EMP_PART KEY(INLIST) KEY(INLIST) 80 5 INDEX RANGE SCAN XAKEMP_PART_HDT KEY(INLIST) KEY(INLIST)

Execution plan KEY(INLIST) select “in”

partition .

, partition partition access

.

Page 73: Oracle History #5

[email protected] - 73 -

Oracle8i New Features http://www.ggola.com/

Export

- export table partition export query data export

.

- filesize option export dump file dump file import

.

CF. FILESIZE option defatul(B:bytes), K(Kbytes), M(Mbytes), G(Gbytes) .

- .

SQL> select count(*) from emp_part partition(p_emp_1981) ; COUNT(*) -------- 77161 SQL> select count(*) from emp_part partition(p_emp_1981) 2 where deptno = 20 ; COUNT(*) -------- 15441 $ exp scott/tiger file=emp1980_1.dmp tables=emp_part:p_emp_1981 query='"where deptno=20"' filesize=256K Export: Release 8.1.6.2.0 - Production on Mon Aug 13 16:42:28 2001 (c) Copyright 1999 Oracle Corporation. All rights reserved. Connected to: Oracle8i Enterprise Edition Release 8.1.6.2.0 - Production With the Partitioning option JServer Release 8.1.6.2.0 - Production Export done in US7ASCII character set and US7ASCII NCHAR character se About to export specified tables via Conventional Path ... . . exporting table EMP_PART . . exporting partition P_EMP_1981 Export file: expdat.dmp > emp1980_2.dmp continuing export into file emp1980_2.dmp Export file: expdat.dmp > emp1980_3.dmp continuing export into file emp1980_3.dmp 15441 rows exported Export terminated successfully without warnings. $ ls -l *.dmp -rw-r--r-- 1 oracle dba 262144 Aug 13 16:42 emp1980_1.dmp -rw-r--r-- 1 oracle dba 262144 Aug 13 16:43 emp1980_2.dmp -rw-r--r-- 1 oracle dba 221184 Aug 13 16:43 emp1980_3.dmp

emp_part partition p_emp_1981 data 77161

deptno 20 15441 .

Oracle8i new export option partition, query, filesize

export .

emp1980_1.dmp 256K

interactive mode export dump filename

. 256K data export

. ls command export file size 256K

.

Page 74: Oracle History #5

[email protected] - 74 -

Oracle8i New Features http://www.ggola.com/

7. Composite Partitioning

Subpartition

Composite partition

- range partition + hash partition

- Composite partition range partition hash function range partition hash partition

. hash partition subpartition .

- Range high availability and manageability data placement performance for parallel DML and supports partition-wise joins

. (hash partition )

- physical data segment range partition subpartition(hash partition)

. partition segment range partition subpartition .

CF. range partition 4 subpartition 4 16 subpartition segment .

- partition segment .

SQL> alter session set nls_date_format = 'DD-MON-YYYY' ; Session altered. SQL> create table emp_comp_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 JOB VARCHAR2(9), 5 MGR NUMBER(4), 6 HIREDATE DATE, 7 SAL NUMBER(7,2), 8 COMM NUMBER(7,2), 9 DEPTNO NUMBER(2)) 10 partition by range (hiredate) 11 subpartition by hash(empno) subpartitions 4 12 ( partition p_emp_1980 values less than 13 ('01-JAN-1981') tablespace ts_emp1, 14 partition p_emp_1981 values less than 15 ('01-JAN-1982') tablespace ts_emp2, 16 partition p_emp_1982 values less than 17 ('01-JAN-1983') tablespace ts_emp3, 18 partition p_emp_1984 values less than 19 (MAXVALUE) tablespace ts_emp4 ) ; Table created.

alter session command

range partition key date type

partition . Subpartition

empno 4 range partition

tablespace composite partitioning

.

Page 75: Oracle History #5

[email protected] - 75 -

Oracle8i New Features http://www.ggola.com/

SQL> select segment_name, partition_name, tablespace_name 2 from user_segments 3 where segment_NAME = 'EMP_COMP_PART' 4 order by 3 ; SEGMENT_NAME PARTITION_NAME TABLESPACE --------------- --------------- ---------- EMP_COMP_PART SYS_SUBP94 TS_EMP1 EMP_COMP_PART SYS_SUBP95 TS_EMP1 EMP_COMP_PART SYS_SUBP93 TS_EMP1 EMP_COMP_PART SYS_SUBP96 TS_EMP1 EMP_COMP_PART SYS_SUBP97 TS_EMP2 EMP_COMP_PART SYS_SUBP98 TS_EMP2 EMP_COMP_PART SYS_SUBP99 TS_EMP2 EMP_COMP_PART SYS_SUBP100 TS_EMP2 EMP_COMP_PART SYS_SUBP101 TS_EMP3 EMP_COMP_PART SYS_SUBP102 TS_EMP3 EMP_COMP_PART SYS_SUBP103 TS_EMP3 EMP_COMP_PART SYS_SUBP104 TS_EMP3 EMP_COMP_PART SYS_SUBP105 TS_EMP4 EMP_COMP_PART SYS_SUBP106 TS_EMP4 EMP_COMP_PART SYS_SUBP107 TS_EMP4 EMP_COMP_PART SYS_SUBP108 TS_EMP4 SQL> create table emp_name_comp_part ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 JOB VARCHAR2(9), 5 MGR NUMBER(4), 6 HIREDATE DATE, 7 SAL NUMBER(7,2), 8 COMM NUMBER(7,2), 9 DEPTNO NUMBER(2)) 10 partition by range (hiredate) 11 subpartition by hash(empno) subpartitions 4 12 store in (ts_emp1, ts_emp2, ts_emp3, ts_emp4) 13 ( partition p_emp_1980 values less than 14 ('01-JAN-1981') storage(maxextents 512), 15 partition p_emp_1981 values less than 16 ('01-JAN-1982') pctfree 40, 17 partition p_emp_1982 values less than 18 ('01-JAN-1983') store in (ts_emp5), 19 partition p_emp_1984 values less than 20 (MAXVALUE) subpartitions 6 store in (ts_emp6)) ; Table created. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_COMP_PART' 4 order by 3 ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_COMP_PART P_EMP_1980 TOOLS EMP_NAME_COMP_PART P_EMP_1981 TOOLS EMP_NAME_COMP_PART P_EMP_1982 TOOLS EMP_NAME_COMP_PART P_EMP_1984 TOOLS

user_segments query tablespace

subpartition .

4 X 4 = 16 subpartitions

range partition subpartition

attribute control

.

user_tab_partitions range partition query , 4 range partition

logical structure .

Page 76: Oracle History #5

[email protected] - 76 -

Oracle8i New Features http://www.ggola.com/

SQL> select segment_name, partition_name, tablespace_name 2 from user_segments 3 where segment_NAME = 'EMP_NAME_COMP_PART' 4 order by 3 ; SEGMENT_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_COMP_PART SYS_SUBP109 TS_EMP1 EMP_NAME_COMP_PART SYS_SUBP113 TS_EMP1 EMP_NAME_COMP_PART SYS_SUBP110 TS_EMP2 EMP_NAME_COMP_PART SYS_SUBP114 TS_EMP2 EMP_NAME_COMP_PART SYS_SUBP111 TS_EMP3 EMP_NAME_COMP_PART SYS_SUBP115 TS_EMP3 EMP_NAME_COMP_PART SYS_SUBP112 TS_EMP4 EMP_NAME_COMP_PART SYS_SUBP116 TS_EMP4 EMP_NAME_COMP_PART SYS_SUBP117 TS_EMP5 EMP_NAME_COMP_PART SYS_SUBP118 TS_EMP5 EMP_NAME_COMP_PART SYS_SUBP119 TS_EMP5 EMP_NAME_COMP_PART SYS_SUBP120 TS_EMP5 EMP_NAME_COMP_PART SYS_SUBP121 TS_EMP6 EMP_NAME_COMP_PART SYS_SUBP122 TS_EMP6 EMP_NAME_COMP_PART SYS_SUBP123 TS_EMP6 EMP_NAME_COMP_PART SYS_SUBP124 TS_EMP6 EMP_NAME_COMP_PART SYS_SUBP125 TS_EMP6 EMP_NAME_COMP_PART SYS_SUBP126 TS_EMP6 SQL> insert into emp_name_comp_part select * from emp ; 162034 rows created. SQL> commit ; Commit complete. SQL> select count(*) 2 from emp_name_comp_part partition(p_emp_1984) ; COUNT(*) ---------- 61721 SQL> select distinct hiredate 2 from emp_name_comp_part partition(p_emp_1984) ; HIREDATE ----------- 12-JAN-1983 18-SEP-1984 01-OCT-1985 SQL> select distinct hiredate 2 from emp_name_comp_part subpartition(SYS_SUBP125) ; HIREDATE ----------- 12-JAN-1983 SQL> update emp_name_comp_part subpartition(SYS_SUBP125) es 2 set es.hiredate = sysdate ; 7713 rows updated.

user_segments query composite partition emp_name_comp_part table

18 hash partition segment

. , composite partition hash partition

data . (4 X 2) +

4 + 6 = 18 subpartitions

emp table data p_emp_1984 partition 61721 row data

3 hiredate . p_emp_1984

subpartition sys_subp125 hiredate

.

subpartition alias DML .

subpartition .

Page 77: Oracle History #5

[email protected] - 77 -

Oracle8i New Features http://www.ggola.com/

SQL> select distinct hiredate 2 from emp_name_comp_part subpartition(SYS_SUBP125) ; HIREDATE ----------- 14-AUG-2001 SQL> commit ; Commit complete. SQL> select distinct hiredate 2 from emp_name_comp_part partition(p_emp_1984) ; HIREDATE ----------- 18-SEP-1984 01-OCT-1985 14-AUG-2001 SQL> create table emp_name_sub_part ( 2 EMPNO NUMBER(4) not null, 3 HIREDATE DATE, 4 SAL NUMBER(7,2), 5 DEPTNO NUMBER(2)) 6 partition by range (hiredate) 7 subpartition by hash(empno) subpartitions 4 8 store in (ts_emp1, ts_emp2, ts_emp3, ts_emp4) 9 ( partition p_emp_1980 values less than ('01-JAN-1981'), 10 partition p_emp_1981 values less than ('01-JAN-1982'), 11 partition p_emp_1982 values less than (MAXVALUE) 12 ( subpartition sp_1982_h1 tablespace ts_emp5, 13 subpartition sp_1982_h2 tablespace ts_emp6)) ; Table created. SQL> select segment_name, partition_name, tablespace_name 2 from user_segments 3 where segment_NAME = 'EMP_NAME_SUB_PART' 4 order by 3 ; SEGMENT_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_SUB_PART SYS_SUBP127 TS_EMP1 EMP_NAME_SUB_PART SYS_SUBP131 TS_EMP1 EMP_NAME_SUB_PART SYS_SUBP128 TS_EMP2 EMP_NAME_SUB_PART SYS_SUBP132 TS_EMP2 EMP_NAME_SUB_PART SYS_SUBP129 TS_EMP3 EMP_NAME_SUB_PART SYS_SUBP133 TS_EMP3 EMP_NAME_SUB_PART SYS_SUBP130 TS_EMP4 EMP_NAME_SUB_PART SYS_SUBP134 TS_EMP4 EMP_NAME_SUB_PART SP_1982_H1 TS_EMP5 EMP_NAME_SUB_PART SP_1982_H2 TS_EMP6

update subpartition hiredate

range partition p_emp_1984 hiredate 1983 data

2001 data .

composite partition hash partition

.

Page 78: Oracle History #5

[email protected] - 78 -

Oracle8i New Features http://www.ggola.com/

Composite partitioned indexes

- composite partitioned indexes always local index tablespace default table subpartition tablespace .

- , composite partitioned table range partitioned global index . composite partitioned global index . (hash syntax .)

SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_NAME_SUB_PART' ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- --------------- ---------- EMP_NAME_SUB_PART P_EMP_1980 TOOLS EMP_NAME_SUB_PART P_EMP_1981 TOOLS EMP_NAME_SUB_PART P_EMP_1982 TOOLS SQL> create index xakempnmsubpt_hdempno 2 on emp_name_sub_part (hiredate, empno) local ; Index created. SQL> select index_name, partition_name, tablespace_name, status 2 from user_ind_partitions 3 where index_name = 'XAKEMPNMSUBPT_HDEMPNO' ; INDEX_NAME PARTITION_NAME TABLESPACE STATUS --------------------- --------------- ---------- -------- XAKEMPNMSUBPT_HDEMPNO P_EMP_1980 N/A XAKEMPNMSUBPT_HDEMPNO P_EMP_1981 N/A XAKEMPNMSUBPT_HDEMPNO P_EMP_1982 N/A SQL> select segment_name, partition_name, tablespace_name 2 from user_segments 3 where segment_NAME = 'XAKEMPNMSUBPT_HDEMPNO' 4 order by 3 ; SEGMENT_NAME PARTITION_NAME TABLESPACE --------------------- --------------- ---------- XAKEMPNMSUBPT_HDEMPNO SYS_SUBP127 TS_EMP1 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP131 TS_EMP1 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP128 TS_EMP2 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP132 TS_EMP2 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP129 TS_EMP3 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP133 TS_EMP3 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP130 TS_EMP4 XAKEMPNMSUBPT_HDEMPNO SYS_SUBP134 TS_EMP4 XAKEMPNMSUBPT_HDEMPNO SP_1982_H1 TS_EMP5 XAKEMPNMSUBPT_HDEMPNO SP_1982_H2 TS_EMP6

composite partitioned table range partition logical structure

. table local index index

.

local index partition tablespace logical structure .

composite partitioned local index STATUS “N/A” .

local index underlying table

subpartition .

Page 79: Oracle History #5

[email protected] - 79 -

Oracle8i New Features http://www.ggola.com/

CF. user_ind_partitions index status “USABLE” “N/A” bug Oracle8.1.7

Oracle8i dictionary( ) subpartition

“N/A” subpartition subpartition “UNUSABLE”

user_ind_partitions .

CF. , composite partition subpartitions dictionary

.

.

SQL> select index_name, partition_name, subpartition_name, status 2 from user_ind_subpartitions 3 where index_name = 'XAKEMPNMSUBPT_HDEMPNO' ; INDEX_NAME PARTITION_ SUBPARTITION_NA STATUS ----------------------- ---------- --------------- -------- XAKEMPNMSUBPT_HDEMPNO P_EMP_1980 SYS_SUBP127 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1980 SYS_SUBP128 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1980 SYS_SUBP129 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1980 SYS_SUBP130 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1981 SYS_SUBP131 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1981 SYS_SUBP132 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1981 SYS_SUBP133 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1981 SYS_SUBP134 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1982 SP_1982_H1 USABLE XAKEMPNMSUBPT_HDEMPNO P_EMP_1982 SP_1982_H2 USABLE SQL> select table_name, partition_name, subpartition_name, tablespace_name 2 from user_tab_subpartitions 3 where table_name = 'EMP_NAME_SUB_PART' ; TABLE_NAME PARTITION_ SUBPARTITION_NA TABLESPACE -------------------- ---------- --------------- ---------- EMP_NAME_SUB_PART P_EMP_1980 SYS_SUBP127 TS_EMP1 EMP_NAME_SUB_PART P_EMP_1980 SYS_SUBP128 TS_EMP2 EMP_NAME_SUB_PART P_EMP_1980 SYS_SUBP129 TS_EMP3 EMP_NAME_SUB_PART P_EMP_1980 SYS_SUBP130 TS_EMP4 EMP_NAME_SUB_PART P_EMP_1981 SYS_SUBP131 TS_EMP1 EMP_NAME_SUB_PART P_EMP_1981 SYS_SUBP132 TS_EMP2 EMP_NAME_SUB_PART P_EMP_1981 SYS_SUBP133 TS_EMP3 EMP_NAME_SUB_PART P_EMP_1981 SYS_SUBP134 TS_EMP4 EMP_NAME_SUB_PART P_EMP_1982 SP_1982_H1 TS_EMP5 EMP_NAME_SUB_PART P_EMP_1982 SP_1982_H2 TS_EMP6

Page 80: Oracle History #5

[email protected] - 80 -

Oracle8i New Features http://www.ggola.com/

Different partition maintenance operation

- subpartition operation subpartition .

- Alter table modify partition add/coalesce subpartition … Alter table/index modify subpartition … Alter index rebuild subpartition … Alter table modify subpartition… Alter table/index rename subpartition… Alter table move subpartition… Alter table exchange subpartition… Alter table truncate subpartition… Alter table modify subpartition unusable local indexes… Alter table modify subpartition rebuild unusable local indexes.

- composite partitioned table subpartition default attributes . SQL> alter table emp_name_sub_part 2 modify default attributes for partition p_emp_1982 3 tablespace ts_emp6 ; Table altered. CF. partition .

New dictionary and columns

- DBA/USER/ALL_TAB_SUBPARTITIONS : subpartition information

- DBA/USER/ALL_SUBPART_KEY_COLUMNS : subpartition key information

- DBA/USER/ALL_IND_SUBPARTITIONS : subpartition index information

- DBA/USER/ALL_SUBPART_COL_STATISTICS : subpartition column statistics

- DBA/USER/ALL_SUBPART_HISTOGRAMS : subpartition histogram

- object data dictionary subpartition columns .

Others

- partition subpartition subpartition export/import . (6 export )

- subpartition analyze . SQL> analyze table emp_name_sub_part subpartition (sp_1982_h1) compute statistics ;

Page 81: Oracle History #5

[email protected] - 81 -

Oracle8i New Features http://www.ggola.com/

8. Added New Features for partition

Large Objects

Partition

- CF

Part/Type LOB Object Type IOT

RANGE O O O

HASH O O X

COMPOSITE O O X

CF. collection type IOT partition IOT partitioning partition key primary key column subset .

LOB (Large Objects)

- LOB column partition key LOB column table partitioning . , LOB data table partition keys partition .

- Lob partition tablespace “tablespace default” table partition

tablespace . , table partition tablespace table partition user default tablespace lob partition

.

- Lob index lob partition tablespace . lob index storage

.

- Alter command LOB storage tablespace move command

. Move command lob partition table partition . table partition move lob partition

.

- Lob data partitioned table tablespace “drop tablespace including contents” drop

all table partition tablespace , tablespace LOB partition

Page 82: Oracle History #5

[email protected] - 82 -

Oracle8i New Features http://www.ggola.com/

partition drop . , 1 table partition drop tablespace tablespace ORA-22868 error return

.

- LOB partition .

SQL> create table emp_lob ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 HIREDATE DATE, 5 SAL BLOB, 6 DEPTNO NUMBER(2)) 7 partition by range (hiredate) 8 ( partition p_emp_1984 values less than 9 (to_date('01-JAN-1985','DD-MON-YYYY')) tablespace ts_emp1 10 LOB(sal) store as (tablespace ts_emp6), 11 partition p_emp_1985 values less than 12 (MAXVALUE) tablespace ts_emp2 13 LOB(sal) store as (tablespace ts_emp5)) ; Table created. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_LOB' ; TABLE_NAME PARTITION_NA TABLESPACE ---------- ------------ ---------- EMP_LOB P_EMP_1984 TS_EMP1 EMP_LOB P_EMP_1985 TS_EMP2 SQL> select table_name, partition_name, lob_partition_name, tablespace_name 2 from user_lob_partitions 3 where table_name = 'EMP_LOB' ; TABLE_NAME PARTITION_NA LOB_PARTITIO TABLESPACE ---------- ------------ ------------ ---------- EMP_LOB P_EMP_1984 SYS_LOB_P137 TS_EMP6 EMP_LOB P_EMP_1985 SYS_LOB_P138 TS_EMP5 SQL> create table emp_lob2 ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 HIREDATE DATE, 5 SAL BLOB, 6 DEPTNO NUMBER(2)) 7 LOB(sal) store as (tablespace default) 8 partition by range (hiredate) 9 ( partition p_emp_1984 values less than 10 (to_date('01-JAN-1985','DD-MON-YYYY')) tablespace ts_emp3 11 LOB(sal) store as (tablespace ts_emp4), 12 partition p_emp_1985 values less than (MAXVALUE)) ; Table created.

LOB column table lob partition

lob tablespace lob

partition .

Lob partition system generated name SYS_LOB_Pnn

.

Table level lob partition level

lob partitioned table

.

Page 83: Oracle History #5

[email protected] - 83 -

Oracle8i New Features http://www.ggola.com/

SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA TABLESPACE ---------- ------------ ---------- EMP_LOB2 P_EMP_1984 TS_EMP3 EMP_LOB2 P_EMP_1985 TOOLS SQL> select table_name, partition_name, lob_partition_name, tablespace_name 2 from user_lob_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA LOB_PARTITIO TABLESPACE ---------- ------------ ------------ ---------- EMP_LOB2 P_EMP_1984 SYS_LOB_P141 TS_EMP4 EMP_LOB2 P_EMP_1985 SYS_LOB_P142 TOOLS SQL> alter table emp_lob2 move partition 2 p_emp_1985 tablespace ts_emp5 ; Table altered. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA TABLESPACE ---------- ------------ ---------- EMP_LOB2 P_EMP_1984 TS_EMP3 EMP_LOB2 P_EMP_1985 TS_EMP5 SQL> select table_name, partition_name, lob_partition_name, tablespace_name 2 from user_lob_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA LOB_PARTITIO TABLESPACE ---------- ------------ ------------ ---------- EMP_LOB2 P_EMP_1984 SYS_LOB_P141 TS_EMP4 EMP_LOB2 P_EMP_1985 SYS_LOB_P142 TOOLS SQL> alter table emp_lob2 move partition p_emp_1985 2 lob(sal) store as (tablespace ts_emp5) ; Table altered. SQL> select table_name, partition_name, lob_partition_name, tablespace_name 2 from user_lob_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA LOB_PARTITIO TABLESPACE ---------- ------------ ------------ ---------- EMP_LOB2 P_EMP_1985 SYS_LOB_P145 TS_EMP5 EMP_LOB2 P_EMP_1984 SYS_LOB_P141 TS_EMP4

Partition level p_emp_1985

user default tablespace tools table level lob

tablespace default lob partition table partition .

Move partition partition lob partition .

lob partition move

.

Page 84: Oracle History #5

[email protected] - 84 -

Oracle8i New Features http://www.ggola.com/

LOB Operation

- lob partition move partition partition lob

.

- , lob storage lob . SQL> alter table emp_lob2 modify lob (sal) (storage (next 1m maxextents 512)) ;

SQL> alter table emp_lob2 move partition p_emp_1984 2 tablespace ts_emp1 lob(sal) store as (tablespace ts_emp1) ; Table altered. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA TABLESPACE ---------- ------------ ---------- EMP_LOB2 P_EMP_1984 TS_EMP1 EMP_LOB2 P_EMP_1985 TS_EMP5 SQL> select table_name, partition_name, lob_partition_name, tablespace_name 2 from user_lob_partitions 3 where table_name = 'EMP_LOB2' ; TABLE_NAME PARTITION_NA LOB_PARTITIO TABLESPACE ---------- ------------ ------------ ---------- EMP_LOB2 P_EMP_1985 SYS_LOB_P145 TS_EMP5 EMP_LOB2 P_EMP_1984 SYS_LOB_P147 TS_EMP1 SQL> create index xakemplob2_hdtemp on emp_lob2 2 (hiredate, empno) local ; Index created. SQL> select table_name, partition_name, lob_partition_name, 2 lob_indpart_name, tablespace_name 3 from user_lob_partitions 4 where table_name = 'EMP_LOB2'; TABLE_NAME PARTITION_NA LOB_PARTITIO LOB_INDPART_NAM TABLESPACE ---------- ------------ ------------ --------------- ---------- EMP_LOB2 P_EMP_1985 SYS_LOB_P145 SYS_IL_P146 TS_EMP5 EMP_LOB2 P_EMP_1984 SYS_LOB_P147 SYS_IL_P148 TS_EMP1 SQL> connect internal Connected. SQL> drop tablespace ts_emp1 including contents ; drop tablespace ts_emp1 including contents * ERROR at line 1: ORA-22868: table with LOBs contains segments in different tablespaces

Move partition table partition lob partition

.

Index lob index partition lob partition

. Lob index partition

name SYS_IL_Pnn .

Table partition lob partition

tablespace tablespace drop

tablespace table partition

tablespace drop .

Page 85: Oracle History #5

[email protected] - 85 -

Oracle8i New Features http://www.ggola.com/

New/Changed dictionary and columns

- DBA/USER/ALL_PART_LOBS : table level lob information

- DBA/USER/ALL_LOB_PARTITIONS : lob partition information (including lob index partition)

- DBA/USER/ALL_LOB_SUBPARTITIONS : lob subpartition information

- DBA/USER/ALL_IND_PARTITIONS, OBJECTS, SEGMENTS : type index name lob information

CF. system generated partition name rule comparison table partition : SYS_Pnn table subpartition : SYS_SUBPnn lob partition : SYS_LOB_Pnn lob index partition : SYS_IL_Pnn iot partition : SYS_IOT_TOP_Pnn iot overflow partition : SYS_IOT_OVER_Pnn CF. IOT system generated partition name SYS_…_Pnn ‘P’

.

Index Organized Table

IOT

- Only range partition partition key IOT primary key subset . CF. , overflow segment table partition range . (equipartitioned with the table partition)

- Secondary index partitioning local, global index .

- General IOT partitioned IOT LOB or varray type .

- partition maintenance partition command . , LOB IOT

partition tablespace ‘move’ command .

- Tablespace drop LOB partition tablespace overflow tablespace drop table partition

tablespace error return . ORA-14404 : partitioned table contains partitions in a different tablespace

Page 86: Oracle History #5

[email protected] - 86 -

Oracle8i New Features http://www.ggola.com/

- IOT partition

SQL> drop table emp_iot ; Table dropped. SQL> alter session set nls_date_format = 'DD-MON-YYYY' ; Session altered. SQL> create table emp_of_iot ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 HIREDATE DATE, 5 DEPTNO NUMBER(2), 6 constraint xpkemp_of_iot primary key(empno, hiredate)) 7 organization index including hiredate 8 compress 1 9 overflow tablespace ts_emp6 10 partition by range(hiredate) 11 ( partition p_iot1 values less than ('01-JAN-1999') tablespace ts_emp1 12 overflow tablespace ts_emp5, 13 partition p_iot2 values less than ('01-JAN-2000') tablespace ts_emp2) ; Table created. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name in (select table_name from user_tables 4 where iot_name = 'EMP_OF_IOT') 5 or table_name = 'EMP_OF_IOT' ; TABLE_NAME PARTITION_NAME TABLESPACE -------------------- -------------------- ---------- SYS_IOT_OVER_42916 P_IOT2 TS_EMP6 SYS_IOT_OVER_42916 P_IOT1 TS_EMP5 EMP_OF_IOT P_IOT1 EMP_OF_IOT P_IOT2 SQL> select index_name, partition_name, tablespace_name 2 from user_ind_partitions 3 where index_name = 'XPKEMP_OF_IOT' ; INDEX_NAME PARTITION_NAME TABLESPACE --------------- -------------------- ---------- XPKEMP_OF_IOT P_IOT2 TS_EMP2 XPKEMP_OF_IOT P_IOT1 TS_EMP1 SQL> select segment_name, segment_type, tablespace_name 2 from user_segments 3 where segment_name in ( 4 select table_name from user_tables 5 where iot_name = 'EMP_OF_IOT' 6 union 7 select index_name from user_ind_partitions 8 where index_name = 'XPKEMP_OF_IOT') SEGMENT_NAME SEGMENT_TYPE TABLESPACE -------------------- ------------------ ---------- SYS_IOT_OVER_42916 TABLE PARTITION TS_EMP6 SYS_IOT_OVER_42916 TABLE PARTITION TS_EMP5 XPKEMP_OF_IOT INDEX PARTITION TS_EMP2 XPKEMP_OF_IOT INDEX PARTITION TS_EMP1

Test IOT drop.

Primary key name . including

hiredate overflow . Compress option

PK value . (prefix

PK columns PK columns –1 ) Default nocompress

compress default PK column –1 .

SYS_IOT_OVER_ overflow partition

. EMP_OF_IOT tablespace

IOT Table .

Index partition table partition

.

IOT table storage segment overflow partition IOT partition

.

P_iot1 partition tablespace ts_emp5

overflow table level ts_emp6 .

Page 87: Oracle History #5

[email protected] - 87 -

Oracle8i New Features http://www.ggola.com/

- IOT partition maintenance partition command .

SQL> create table emp_of_iot2 ( 2 EMPNO NUMBER(4) not null, 3 ENAME VARCHAR2(10), 4 HIREDATE DATE, 5 DEPTNO NUMBER(2), 6 primary key(empno, hiredate)) 7 organization index 8 overflow tablespace ts_emp3 9 partition by range(hiredate) 10 ( partition p_iot1 values less than ('01-JAN-1999') tablespace ts_emp1 11 overflow tablespace ts_emp4, 12 partition p_iot2 values less than ('01-JAN-2000') tablespace ts_emp2) ; Table created. SQL> select index_name, partition_name, tablespace_name 2 from user_ind_partitions 3 where index_name in ( select index_name 4 from user_indexes 5 where table_name = 'EMP_OF_IOT2') ; INDEX_NAME PARTITION_NAME TABLESPACE -------------------- -------------------- ---------- SYS_IOT_TOP_42934 P_IOT1 TS_EMP1 SYS_IOT_TOP_42934 P_IOT2 TS_EMP2 SQL> select segment_name, segment_type, tablespace_name 2 from user_segments 3 where segment_name in ( 4 select table_name from user_tables 5 where iot_name = 'EMP_OF_IOT2' 6 union 7 select index_name from user_indexes 8 where table_name = 'EMP_OF_IOT2') ; SEGMENT_NAME SEGMENT_TYPE TABLESPACE -------------------- ------------------ ---------- SYS_IOT_OVER_42934 TABLE PARTITION TS_EMP4 SYS_IOT_OVER_42934 TABLE PARTITION TS_EMP3 SYS_IOT_TOP_42934 INDEX PARTITION TS_EMP1 SYS_IOT_TOP_42934 INDEX PARTITION TS_EMP2 SQL> connect internal Connected SQL> drop tablespace ts_emp2 including contents ; drop tablespace ts_emp2 including contents * ERROR at line 1: ORA-14404: partitioned table contains partitions in a different tablespace

PK name IOT . System generated index name SYS_IOT_TOP_Pnn

.

LOB IOT

partition ts_emp2 drop tablespace

command overflow partition ts_emp3, ts_emp4

drop .

IOT partition ts_emp1, ts_emp2

error return

.

Page 88: Oracle History #5

[email protected] - 88 -

Oracle8i New Features http://www.ggola.com/

Object Type

Object type partitioning

- Oracle8i object table partitioning

- object type partitioning restriction : nested partitioned table . object type , REF, nested table or VARRAY partition key .

- VARRAY LOB tablespace . VARRAY

LOB tablespace . , table partition

.

- .

SQL> create type emp_type as object ( 2 empno number(4), ename varchar2(10), hiredate date) ; 3 / Type created. SQL> select type_name, typecode from user_types ; TYPE_NAME TYPECODE --------------- ---------- EMP_TYPE OBJECT SQL> desc emp_type Name Null? Type ------------ ------ ------------- EMPNO NUMBER(4) ENAME VARCHAR2(10) HIREDATE DATE SQL> create table emp_obj_tp of emp_type 2 partition by range (empno) 3 (partition p_7000 values less than (8000) tablespace ts_emp1, 4 partition p_8000 values less than (9000) tablespace ts_emp2, 5 partition p_9000 values less than (maxvalue) tablespace ts_emp3) ; Table created. SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_OBJ_TP' ; TABLE_NAME PARTITION_NAME TABLESPACE --------------- -------------------- ---------- EMP_OBJ_TP P_7000 TS_EMP1 EMP_OBJ_TP P_8000 TS_EMP2 EMP_OBJ_TP P_9000 TS_EMP3

Type partitioned object table

.

Page 89: Oracle History #5

[email protected] - 89 -

Oracle8i New Features http://www.ggola.com/

SQL> select object_name, object_type, status 2 from user_objects 3 where object_id in ( select referenced_object_id 4 from public_dependency where object_id in ( select object_id 5 from user_objects where object_name = 'EMP_OBJ_TP')) ; OBJECT_NAME OBJECT_TYPE STATUS -------------------- -------------------- ------- EMP_TYPE TYPE VALID SQL> create type emp_va_php_type as varray(10) of number(15) ; 2 / Type created. SQL> select type_name, typecode from user_types ; TYPE_NAME TYPECODE ---------------- ------------ EMP_TYPE OBJECT EMP_VA_PHP_TYPE COLLECTION SQL> desc emp_va_php_type emp_va_php_type VARRAY(10) OF NUMBER(15) SQL> create type emp_va_profile as varray(1000) of varchar2(4000) ; 2 / Type created. SQL> select type_name, typecode from user_types ; TYPE_NAME TYPECODE ---------------- ----------- EMP_TYPE OBJECT EMP_VA_PHP_TYPE COLLECTION EMP_VA_PROFILE COLLECTION SQL> desc emp_va_profile emp_va_profile VARRAY(1000) OF VARCHAR2(4000) SQL> create table emp_obj_coll_tp ( 2 empno number(4), 3 ename varchar2(10), 4 hiredate date, 5 emp_phone emp_va_php_type, 6 emp_profile emp_va_profile) 7 varray emp_profile store as lob (storage (initial 1m next 1m)) 8 partition by range(empno) 9 (partition p_7000 values less than (8000) tablespace ts_emp1 10 varray emp_profile store as lob (storage (maxextents 1024)), 11 partition p_8000 values less than (9000) tablespace ts_emp3 12 varray emp_profile store as lob (storage (maxextents 2048)), 13 partition p_9000 values less than (maxvalue) tablespace ts_emp5) ; Table created.

Sys user view public_dependency

object table dependency object type

.

Collection type varray

partitioned object table . type

lob .

Page 90: Oracle History #5

[email protected] - 90 -

Oracle8i New Features http://www.ggola.com/

- partition maintenance partition command .

- Partitioned table tablespace drop partitioned table tablespace partition drop ORA-

14404 error return .

SQL> select table_name, partition_name, tablespace_name 2 from user_tab_partitions 3 where table_name = 'EMP_OBJ_COLL_TP' ; TABLE_NAME PARTITION_NAME TABLESPACE --------------- --------------- ---------- EMP_OBJ_COLL_TP P_8000 TS_EMP3 EMP_OBJ_COLL_TP P_9000 TS_EMP5 EMP_OBJ_COLL_TP P_7000 TS_EMP1 SQL> select table_name, partition_name, lob_partition_name, tablespace_name 2 from user_lob_partitions 3 where table_name = 'EMP_OBJ_COLL_TP' ; TABLE_NAME PARTITION_NAME LOB_PARTITION_NAME TABLESPACE --------------- --------------- -------------------- ---------- EMP_OBJ_COLL_TP P_7000 SYS_LOB_P217 TS_EMP1 EMP_OBJ_COLL_TP P_8000 SYS_LOB_P218 TS_EMP3 EMP_OBJ_COLL_TP P_9000 SYS_LOB_P219 TS_EMP5 SQL> select object_name, object_type, status 2 from user_objects 3 where object_id in ( select referenced_object_id 4 from public_dependency where object_id in ( select object_id 5 from user_objects where object_name = 'EMP_OBJ_COLL_TP')) ; OBJECT_NAME OBJECT_TYPE STATUS -------------------- -------------------- ------- EMP_VA_PHP_TYPE TYPE VALID EMP_VA_PROFILE TYPE VALID

Table partition lob partition tablespace

. dependency table object type

.

Page 91: Oracle History #5

[email protected] - 91 -

Oracle8i New Features http://www.ggola.com/

Parallel processing

Oracle8i parallel processing .

basic parallel processing Oracle8 New Features .

Default degree of parallelism

- Oracle parallel degree .

- SQL hint parallel degree degree .

- table or index parallelism .

- default degree .

1. Number of CPU X parallel_threads_per_cpu(parameter) 2. OPS number of OPS instances in an MPP system 3. Number of partitions to be accessed

CF. , parallel_max_servers degree .

Enable parallel DML/DDL

- parallel processing initial parameter parallel DML enabling . session

level .

- SQL> alter session ENABLE/DISABLE/FORCE parallel DML/DDL (parallel n) ; CF. parallel query . parallel query DML DDL .

- FORCE : parallel clause default parallel degree .

- Oracle8 parallel DML commit or rollback parallel

Oracle8i parallel DML object parallel DML .

, parallel DML object read or modify .

Page 92: Oracle History #5

[email protected] - 92 -

Oracle8i New Features http://www.ggola.com/

Check Data dictionary

- V$SESSION : PDML_ENABLED column parallel enabling session level

.

- V$PQ_SYSSTAT : DML_INITATED query Select * From V$PQ_SYSSTAT; initialized parallel DML

- V$PQ_SESSTAT : DML_PARALLELIZED query Select * From V$PQ_SESSTAT; current session parallel

Review general restriction of parallel processing

- nonpartitioned table parallel update or delete (error return serially )

- You cannot read or modify the same tables after modifying it in parallel.

- You cannot read or modify the same tables after a serial direct load INSERT.

- Parallel DML issues exclusive locks. (no lock table or select for update statement can be in the same transaction as the parallel DML statement)

- There is limited integrity constraint support. 1. no self-referential integrity 2. no delete cascade 3. no deferred integrity

- LOB or object type or IOT table clustered table parallel DML .

- Replication . Trigger enable Parallel DML statement serially

parallel DML trigger disable . trigger replication

functionality .

- Distributed transaction . (serially )

- Initial parameter ROW_LOCKING . DML row locking

default always default DML row level lock intent

table level lock . intent table lock parallel DML

serial .

Page 93: Oracle History #5

[email protected] - 93 -

Oracle8i New Features http://www.ggola.com/

Parallel transaction recovery

- parallel DML rollback parallel . user rollback recovery . , parallel DML rollback parallel transaction rollback .

- , system or instance recovery large transaction recovery

. PARALLEL_TRANSACTION_RECOVERY dynamic initialization parallel

transaction recovery .

- PARALLEL_TRANSACTION_RECOVERY= HIGH/LOW/FALSE (LOW is default)

- parameter LOW or HIGH SMON recovery large transaction parallel recovery candidate . parallel transaction recovery SMON coordinator parallel recovery processes slave

.

- parameter Oracle BETA release version(8.1.3, 8.1.4) .

CF. 13 Fast-Start parallel rollback .

- parallel transaction failed process recovery Oracle8 .

1. Single slave fail PMON rollback slave rollback .

2. Multiple slave fail PMON serially rollback .

3. Coordinator process fail PMON coordinator recover all slave processes parallel

rollback . 4. Process recovery time the forward work

2 .

Page 94: Oracle History #5

[email protected] - 94 -

Oracle8i New Features http://www.ggola.com/

Partition-Wise join in parallel

Prior Oracle8i, parallel 2 tables join query step pieces scan and redistributed join column CPU or memory(or temporary tablespace) .

Oracle8i join key partition table join (redistribution) skip performance . ,

temporary storage memory performance . (

setting Oracle .)

parallel execution .

Full partition-wise join

- Equip partitioned tables join join columns partitioned key table partition join

.

- tablespace equipartition local disk .

Partial partition-wise join

- join column table partition . ( partition table or original table )

- join column partition key table redistribution .

CF. Oracle supports partition-wise joins on range, hash or composite partitioned tables

Page 95: Oracle History #5

[email protected] - 95 -

Oracle8i New Features http://www.ggola.com/

Added parallel information

New parameter

- PARALLEL_AUTOMATIC_TUNING=TRUE/FALSE parallel execution default degree Oracle automatically control ’TRUE’ setting . , Default degree Oracle .

parameter TRUE 1. A load balancing algorithm will be used which will evenly distributed load across nodes in a multi-instance PQ environment. 2. Oracle allocates parallel execution buffers from the large pool. (FALSE allocates memory from the shared pool)

- PARALLEL_ADAPTIVE_MULTI_USER=TRUE/FALSE parameter enables adaptive setting of the degree of

parallelism. parallel_automatic_tuning ‘TRUE’

parameter ‘TRUE’ system load degree of parallelism .

- PARALLEL_THREADS_PER_CPU=n parameter default degree of parallelism

parallel adoptive algorithm .

- Profile DEGREE_OF_PARALLELISM database resource limit .

user maximum degree of parallelism . ( )

Dynamic performance views

- V$PX_PROCESS : running parallel execution session process information

- V$PX_PROCESS_SYSSTAT : v$px_process parallel statistic

- V$PX_SESSION : running parallel execution session information

- V$PX_SESSTAT : v$px_session and v$sesstat table joined information for parallel execution

Page 96: Oracle History #5

[email protected] - 96 -

Oracle8i New Features http://www.ggola.com/

9. Universal Installer Migration and Upgrade

Universal Installer

Oracle8i New Features .

Universal Installer

- platform JAVA based installer GUI install .

- Any customer can use the Software Packager to create installable third-party components for oracle.

- Performing install from one location to several geographical regions : Web Install Feature

Database Configuration Assistant

- Database configuration assistant

- Database creation(remote machine ) database creation scripts easy parameter setting

- This is very useful for creating multiple database with the same configuration.

- Run in silent mode 1. GUI OS command line batch script 2. allows easy creation of multiple identical database

- Hardware detection and interview 1. File system, RAM 2. number of users, 3. database processing environment : OLTP, DSS..

Migration

Oracle8i New Features Review .

What is changed ?

- migration upgrade 1. modify, add base tables and v$tables : data dictionary and structures

Page 97: Oracle History #5

[email protected] - 97 -

Oracle8i New Features http://www.ggola.com/

2. modify datafile header blocks 3. change rollback segment format 4. control file recreation

Migration basic step

- Migration type 1. export / import 2. copy command 3. migration utility 3.1 command line migration utility 3.2 GUI data migration assistant

- Steps 1. prepare to migrate : migration type , system resource 2. secure the required resources : resource 3. build a test plan : (OUTLN user or role drop) migration test, minimal test, functional test, integration test, performance test, volume/load stress test 4. preserve the source database : database normal shutdown cold backup 5. migrate the source database : Oracle8i install parameter or migration ( migration type ) 6. postmigration task : shutdown normal oracle8i cold backup script (.sql file, recompile invalid objects ) startup

CF. Migration utility database . ( database rebuild)

CF. $ORACLE_HOME/rdbms/admin/utlrp.sql upgrade invalid PL/SQL block modules recompile .

Upgrade 8 to 8i

1. 8.0.4S --> upgrade 8.0.5 and upgrade 8.1

2. 8.0.3, 8.0.4, 8.0.5, 8.0.6 --> upgrade 8.1 directly

Page 98: Oracle History #5

[email protected] - 98 -

Oracle8i New Features http://www.ggola.com/

10. Tablespace Management

Extended Rowid

Oracle8 New Features review .

files rowid ( rowid files )

1022 tablespace 1022

partition object data object id

Rowid Type

- Restricted : BBBBBBBB.RRRR.FFFF (Block Row File) 16 6 bytes

- Extended : OOOOOO.FFF.BBBBBB.SSS (data Object relative File Block Slot) 64 10 bytes

DBMS_ROWID package check

Functions :

- ROWID_TO_EXTENDED : old rowid new rowid

- ROWID_TO_RESTRICTED : new rowid old rowid

- ROWID_VERIFY : old rowid ROWID_TO_EXTENDED convert

- ROWID_TYPE : rowid old type new type

- ROWID_TO_ABSOLUTE_FNO : relative file number

- ROWID_OBJECT : object id return

- Others : ROWID_RELATIVE_FNO, ROWID_BLOCK_NUMBER, ROWID_ROW_NUMBER

Procedures :

- ROWID_INFO : rowid

- ROWID_CREATE : rowid test

Page 99: Oracle History #5

[email protected] - 99 -

Oracle8i New Features http://www.ggola.com/

Locally-Managed tablespaces

tablespace dictionary managed tablespace extent DD .

extent allocation DD update system tablespace access rollback segment

.

Locally Managed (Oracle8i New Features)

- tablespace extent local datafile bitmaps datafile .

DD access (system tablespace access reduced) uniform size fragmentation

.

- Space management data dictionary datafile bitmaps . 1. extent allocation resources DD access bitmaps database-wide contention 2. SYSTEM tablespace system tablespace 3. rollback segment

- SYSTEM tablespace tablespaces .

Locally managed general tablespace

SQL> create tablespace ts_local_nis_d datafile '/u01/local/data/nis_fin01.dbf' size 50M extent management local uniform size 2M ;

Tablespace created.

- AUTOALLOCATE keyword UNIFORM ( autoallocate default

) storage initial size (initial extent must be at least 64KB) other extents system automatically size system-managed space

.

CF. Locally default storage . , tablespace permanent/temporary

option temporary option . ( create temporary tablespace command

)

CF. UNIFORM size default 1M .

Page 100: Oracle History #5

[email protected] - 100 -

Oracle8i New Features http://www.ggola.com/

Locally managed temporary tablespace

SQL> create temporary tablespace ts_temp tempfile ’ /u01/local/temp/nis_temp01.dbf' size 100M extent management local uniform size 1M ;

Tablespace created.

- Oracle recommend locally management tablespace temporary tablespace .

- temporary tablespace temporary option locally managed temporary tablespace

‘create temporary tablespace’ command . Command “tempfile” option .

CF. tablespace locally managed tablespace .

CF. Oracle 8.1.5 Manual System tablespace locally managed tablespace dictionary managed tablespace . , rollback segment

tablespace locally managed . ( , RBS extent system

tablespace )

CF. Oracle “Locally managed system tablespaces are simply not yet possible.”

Page 101: Oracle History #5

[email protected] - 101 -

Oracle8i New Features http://www.ggola.com/

Data transportation

Transportable tablespaces

- OLTP staging area (or DW) DW Data marts data point-in time recovery, distributed relational data, archive historical data

.

- Export / Import tablespaces copy .

Procedure

1. tablespace read-only

2. export metadata

3. copy data files

4. transfer export dump file

5. import metadata

6. tablespace read-write (if you want)

Checking factors

1. Datafile O/S .

2. Oracle version 8.1 .

3. LOB table .

4. Block size and character set .

5. tablespace object tablespace object move or exchange partition command tablespace

. (all partition tablespace )

6. Table nested tables or varray bitmap index transport .

Checking availability

- Tablespace transportable package .

- DBMS_TTS.TRANSPORT_SET_CHECK command . (example )

Page 102: Oracle History #5

[email protected] - 102 -

Oracle8i New Features http://www.ggola.com/

Example

- tablespace transportation .

- transport_set_check tablespace transport_set_violations view

row session level . ( session )

VIOLATIONS --------------------------------------------------------------------------------Partitioned table SCOTT.EMP_OBJ_COLL_TP is partially contained in the transportable set: check table partitions by querying sys.dba_tab_partitions ……..

O/S System_A $ sqlplus internal Connected. SQL> create tablespace ts_trans datafile '/u01/trans/ts_trans01.dbf' size 10M ; Tablespace created. SQL> conn scott/tiger Connected. SQL> create table emp_trans tablespace ts_trans 2 as select * from emp where rownum < 100 ; Table created. SQL> select table_name, tablespace_name from user_tables 2 where table_name = 'EMP_TRANS' ; TABLE_NAME TABLESPACE_NAME ------------------------- ------------------------------ EMP_TRANS TS_TRANS SQL> select count(*) from emp_trans ; COUNT(*) ---------- 99 SQL> connect internal Connected. SQL> exec dbms_tts.transport_set_check('TS_TRANS',TRUE) ; PL/SQL procedure successfully completed. SQL> select * from transport_set_violations ; no rows selected SQL> alter tablespace ts_trans read only ; Tablespace altered. SQL> exit

Package check tablespace

.

Page 103: Oracle History #5

[email protected] - 103 -

Oracle8i New Features http://www.ggola.com/

- export system import

$ exp file=/u01/trans/exp_tbs_trans.dmp \ > log=/u01/trans/exp_tbs_trans.log tablespaces=ts_trans \ > transport_tablespace=y Export: Release 8.1.6.2.0 - Production on Thu Aug 23 16:03:31 2001 (c) Copyright 1999 Oracle Corporation. All rights reserved. Username: sys as sysdba Password: change_on_install Connected to: Oracle8i Enterprise Edition Release 8.1.6.2.0 - Production …….. . exporting cluster definitions . exporting table definitions . . exporting table EMP_TRANS ……. Export terminated successfully without warnings. O/S System_B $ ftp system_A Connected to system_A. …. ftp> bi 200 Type set to I. ftp> get exp_tbs_trans.dmp … 226 Transfer complete. ftp> get ts_trans01.dbf … 226 Transfer complete. ftp> quit 221 Goodbye. $ imp file=exp_tbs_trans.dmp \ > log=/u01/trans/imp_tbs_trans.log transport_tablespace=y \ > datafiles=/u01/trans/ts_trans01.dbf Import: Release 8.1.6.2.0 - Production on Thu Aug 23 16:17:43 2001 (c) Copyright 1999 Oracle Corporation. All rights reserved. Username: sys as sysdba Password: change_on_install Connected to: Oracle8i Enterprise Edition Release 8.1.6.2.0 – Production … . importing SYS's objects into SYS . importing SCOTT's objects into SCOTT . . importing table "EMP_TRANS" Import terminated successfully without warnings.

Datafile export dump file ftp import .

Page 104: Oracle History #5

[email protected] - 104 -

Oracle8i New Features http://www.ggola.com/

- import .

- System B emp_trans table write tablespace

.

CF. import fromuser, touser options schema that owns the object in transported tablespace another schema

.

Read-Only tablespace

- read only tablespace active transaction

.

- , current transaction waiting read-only .

CF. shutdown normal .

$ sqlplus internal SQL> select tablespace_name, file_name from dba_data_files 2 where tablespace_name = 'TS_TRANS' ; TABLESPACE FILE_NAME ---------- ------------------------------ TS_TRANS /u01/trans/ts_trans01.dbf SQL> conn scott/tiger Connected. SQL> select table_name, tablespace_name from user_tables 2 where table_name = 'EMP_TRANS' ; TABLE_NAME TABLESPACE --------------------------- ---------- EMP_TRANS TS_TRANS SQL> select count(*) from emp_trans ; COUNT(*) ---------- 99 SQL> connect internal Connected. SQL> alter tablespace ts_trans read write ; Tablespace altered.

Import System B tablespace ts_trans

creation tablespace object data System A System B

.

Page 105: Oracle History #5

[email protected] - 105 -

Oracle8i New Features http://www.ggola.com/

11. Database resource manager

Resource management

DBA resource management resource control resource .

DBA resource plan plan consumer group, resource allocation method, resource plan directives resource

.

Oracle user resource Oracle8i New Features .

EX. daytime resource plan

Resource consumer group Allocation method parameters OLTP CPU=70%

Degree of parallelism = 0 DW CPU=30%

Degree of parallelism = 18

Resource management factors

- resource consumer group : plan resource user group

- resource plan : CPU time parallel query resources . resource plan resource plan

. DBA DB shutdown plan switch . EX. daytime plan nighttime plan switch

database restart .

- resource plan directives : 1. assign consumer groups or subplans to resource plans 2. allocate resources among consumer groups or subplans

Resource allocation method

- CPU usage : 1. level 1 to level 8 2. percentages specifying how to partition CPU at each level

- Degree of parallelism : maximum degree of parallelism

Page 106: Oracle History #5

[email protected] - 106 -

Oracle8i New Features http://www.ggola.com/

Resource consumer groups

- session group active .

- Users consumer groups .

- Default group login .

- Session level user or DBA can switch consumer group

Steps in Database Resource Management

Steps for database resource management creation

1. create resource plan

2. create resource consumer groups

3. create resource plan directives

4. assign users to consumer groups

5. specify plan to be used by an instance

Packages for DB resource manager

- DBMS_RESOURCE_MANAGER : 1. define plans and classes, plan entries 2. define the default class for a user 3. alter the class for currently connected user

- DBMS_RESOURCE_MANAGER_PRIVS 1. grant and revoke classes to users 2. switch the class for a session

Create resource plan

- DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA ; pending area : 1. store new resource manager plans, consumer groups and resource plan directives 2. changes before they are committed.

- DBMS_RESOURCE_MANAGER.CREATE_PLAN ( ’daytime’, ‘from 15 to 19’) ; ==> ‘plan name’, ‘comment for this plan’ CF. database creation default SYSTEM_PLAN plan .

Page 107: Oracle History #5

[email protected] - 107 -

Oracle8i New Features http://www.ggola.com/

- Privileges needed to manage resources 1. administer_resource_manager : package for dbms_resource_manager 2. grant_system_privilege and revoke_system_privilege . EX. DBMS_RESOURCE_MANAGER_PRIVS. GRANT_SYSTEM_PRIVILEGE(‘scott’, admin_option => TRUE) ; ==> ‘username’, with ADMIN_OPTION

Creating resource consumer groups

- DBMS_RESOURCE_MANAGER. CREATE_CONSUMER_GROUP (‘oltp’, ‘online job working’) ; ==> ‘group name’, ‘comment for group’

- Database group 1. SYS_GROUP : SYSTEM_PLAN high priority for ‘SYS’ and ‘SYSTEM’ users 2. LOW_GROUP : low priority group in SYSTEM_PLAN 3. DEFAULT_CONSUMER_GROUP : assigned to all users(PUBLIC) by default 4. OTHER_GROUPS : a part of every plan group plan other_groups directives

. plan each top-plan other_groups directive .

( example .)

Create resource plan directives

- DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (‘daytime’, ‘olpt’, ‘rule for oltp job’, cpu_p1 => 70, parallel_degree_limit_p1 => 18) ; ==> ‘plan name’, ‘group name’, ‘comment for directive’, ‘CPU level 1’, ‘parallel degree’

- cpu_p2 multi level CPU ?

- , level1 OLTP DW 70:30 level2 DSS Web 40:60

. Level2 CPU .

- system load cpu 80% . level2 20% level2 cpu

. , CPU level %

. Priority level % .

Page 108: Oracle History #5

[email protected] - 108 -

Oracle8i New Features http://www.ggola.com/

Confirming resource management

- resource factors pending area validate and confirm resource

factors .

- : DBMS_RESOURCE_MANAGER. VALIDATE_PENDING_AREA ; 1. all consumer groups referred to in the plans created or changed exist 2. plans have directives that reference other plans or consumer groups 3. plans do not reference themselves either directly or indirectly 4. the sum of CPU percentages defined for a specific level within a plan do not exceed 100 5. a plan that is currently used is not deleted

- implicitly validate and commit : DBMS_RESOURCE_MANAGER. SUBMIT_PENDING_AREA ;

Assign users to consumer groups

- assign user or role to consumer group ( package user or role consumer group

) DBMS_RESOURCE_MANAGER_PRIVS. GRANT_SWITCH_CONSUMER_GROUP (‘scott’, ‘oltp’, FALSE) ==> ‘user or role’, ‘group name’, with GRANT option

- scott user consumer group . user group

session active group . , application

DBA Initial consumer group for users ( group assign user default group)

session level group .

- scott user oltp group .

DBMS_RESOURCE_MANAGER. SET_INITIAL_CONSUMER_GROUP(‘scott’,’oltp’) ;

- session level consumer group .

Page 109: Oracle History #5

[email protected] - 109 -

Oracle8i New Features http://www.ggola.com/

Changing consumer group within a session

- group session user .

- user or application level (PL/SQL block ) DBMS_SESSION.SWITCH_CURRENT_CONSUMER_GROUP (‘oltp’, old_group) ; ==> ‘new group’, old group (output variable)

- DBA DBMS_RESOURCE_MANAGER. SWITCH_CONSUMER_GROUP_FOR_SESS (453, 23412, ‘oltp’) ; ==> sid, serial#, ‘group name’

- DBA all sessions for a user DBMS_RESOURCE_MANAGER. SWITCH_CONSUMER_GROUP_FOR_USER (‘scott’, ‘oltp’) ; ==> ‘username’, ‘group name’

How to set resource plan for an instance

- Specify plan for initial parameter : resource_manager_plan=daytime

- Change plan without shutdown and restart : alter system set resource_manager_plan=nighttime

- Initial parameter setting plan database open error return .

resource plan parameter shutdown and restart . parameter

default value null .

Data dictionary

>> RESOURCE MANAGER INFORMATION

- DBA_RSRC_PLANS : resource plans and status

- DBA_RSRC_PLAN_DIRECTIVES : resource plan directives and status

- DBA_RSRC_CONSUMER_GROUPS : consumer groups and status

- DBA_RSRC_CONSUMER_GROUP_PRIVS : users granted consumer groups

- DBA_USERS : new column ‘initial_rsrc_consumer_group’

Page 110: Oracle History #5

[email protected] - 110 -

Oracle8i New Features http://www.ggola.com/

>> CURRENT SETTINGS

- V$SESSION : new column ‘resource_consumer_group’

- V$RSRC_PLAN : showing the active resource plan

- V$RSRC_CONSUMER_GROUP : showing the number of active sessions by consumer group and wait/yield statistics

Example

- plan, group, directive resource management .

$ sqlplus internal SQL> select plan, group_or_subplan, type from dba_rsrc_plan_directives ; PLAN GROUP_OR_SUBPLAN TYPE --------------- ------------------------------ -------------- SYSTEM_PLAN SYS_GROUP CONSUMER_GROUP SYSTEM_PLAN OTHER_GROUPS CONSUMER_GROUP SYSTEM_PLAN LOW_GROUP CONSUMER_GROUP SQL> select * from dba_rsrc_consumer_group_privs ; GRANTEE GRANTED_GROUP GRA INI ---------- ------------------------------ --- --- PUBLIC DEFAULT_CONSUMER_GROUP YES NO PUBLIC LOW_GROUP NO NO SYSTEM SYS_GROUP NO YES SQL> exec dbms_resource_manager.create_pending_area ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.create_plan('daytime', 'oltp from 15 to 19') ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.create_consumer_group('oltp', 'online job working') ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.create_plan_directive('daytime', 'oltp', 'rule for oltp job', cpu_p1 => 70, parallel_degree_limit_p1 => 18 ) ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.validate_pending_area ; BEGIN dbms_resource_manager.validate_pending_area ; END; * ERROR at line 1: ORA-29382: validation of pending area failed ORA-29377: consumer group OTHER_GROUPS is not part of top-plan DAYTIME ORA-06512: at "SYS.DBMS_RMIN", line 55 ORA-06512: at "SYS.DBMS_RESOURCE_MANAGER", line 254 ORA-06512: at line 1

6 plan set .

Pending area --> Plan --> Group --> Directive --> Check(validate) --> Commit(submit) ;

plan other_groups

.

Page 111: Oracle History #5

[email protected] - 111 -

Oracle8i New Features http://www.ggola.com/

SQL> exec dbms_resource_manager.create_plan_directive('daytime', 'other_groups', 'other groups for daytime users', cpu_p1 => 0, parallel_degree_limit_p1 => 0 ) ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.validate_pending_area ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.submit_pending_area ; PL/SQL procedure successfully completed. SQL> select plan, group_or_subplan, type from dba_rsrc_plan_directives ; PLAN GROUP_OR_SUBPLAN TYPE --------------- ------------------------------ -------------- DAYTIME OTHER_GROUPS CONSUMER_GROUP SYSTEM_PLAN SYS_GROUP CONSUMER_GROUP SYSTEM_PLAN OTHER_GROUPS CONSUMER_GROUP SYSTEM_PLAN LOW_GROUP CONSUMER_GROUP DAYTIME OLTP CONSUMER_GROUP SQL> exec dbms_resource_manager_privs.grant_switch_consumer_group('scott', 'oltp', FALSE) ; PL/SQL procedure successfully completed. SQL> exec dbms_resource_manager.set_initial_consumer_group('scott', 'oltp') ; PL/SQL procedure successfully completed. SQL> select username, initial_rsrc_consumer_group from dba_users 2 where username = 'SCOTT' ; USERNAME INITIAL_RSRC_CONSUMER_GROUP ----------------------------------------- SCOTT OLTP $ sqlplus scott/tiger Connected. SQL> select sid, serial#, username, resource_consumer_group 2 from v$session where username= 'SCOTT' ; SID SERIAL# USERNAME RESOURCE_C ---------- ---------- --------- ---------- 11 18058 SCOTT OLTP SQL> set serveroutput on SQL> declare 2 v_old_group varchar2(30) ; 3 begin 4 dbms_session.switch_current_consumer_group('default_consumer_group', v_old_group, false) ; 5 dbms_output.put_line(v_old_group) ; 6* end;

7 / declare * ERROR at line 1: ORA-29373: resource manager is not on ORA-06512: at "SYS.DBMS_SESSION", line 74 ORA-06512: at line 4

other_groups commit

. OLTP group

other_groups .

Grant scott user consumer group

. ( .)

Scott user session B .

Internal session A .

session A

session B

session B

Session group . Resource

manager off .

Page 112: Oracle History #5

[email protected] - 112 -

Oracle8i New Features http://www.ggola.com/

- Session level group dbms_session package error .

- initial parameter resource_manager_plan resource manager off .

alter system command plan parameter resource manager on

.

- .

1. alter system set resource_manager_plan = ‘’ ; 2. dbms_resource_manager_privs.revoke_switch_consumer_group ('scott', 'oltp') ; 3. dbms_resource_manager.create_pending_area ; 4. dbms_resource_manager.delete_plan_cascade('daytime') ; 5. dbms_resource_manager.submit_pending_area ;

CF. plan drop package update_plan, update_consumer_group, update_plan_directive, delete_consumer_group, delete_plan_directive .

SQL> select * from v$rsrc_plan ; no rows selected SQL> SQL> alter system set resource_manager_plan = 'daytime' ; System altered. SQL> select * from v$rsrc_plan ; NAME -------------------------------- daytime SQL> set serveroutput on SQL> declare 2 v_old_group varchar2(30) ; 3 begin 4 dbms_session.switch_current_consumer_group('default_consumer_group', v_old_group, false) ; 5 dbms_output.put_line(v_old_group) ; 6* end;

7 / OLTP PL/SQL procedure successfully completed. SQL> select sid, serial#, username, resource_consumer_group 2 from v$session where username= 'SCOTT' ; SID SERIAL# USERNAME RESOURCE_C ---------- ---------- --------- ---------- 11 18058 SCOTT DEFAULT_CONSUMER_GROUP

session B

session A

session B

session A

Resource manager turned on

Current session consumer group

. session

group .

New Group Name

group

delete_plan procedure subplan or

consumer groups .

delete_plan_cascade

drop . (plan, directives, subplan, consumer group) delete_plan plan directives delete .

Page 113: Oracle History #5

[email protected] - 113 -

Oracle8i New Features http://www.ggola.com/

12. Manageability Features

Database limits

Oracle8 and Oracle8i database limits

- Oracle8 New Features review

Columns per table 1,000

Columns per index 32

CAHR, NCHAR 2,000 bytes

VARCHAR2, NVARCHAR2 4,000 bytes

CLOB, BLOB, BFILE 4GB

Tablespaces per database 65,533

Datafiles per tablespace 1,022

Datafiles per database 65,533

- only one LONG column per table

- index define column total size database block 40% bitmapped index

index 30 .

- Tablespace limit 65,533 tablespace 1 datafile .

- Tablespace datafile O/S 1,022 .

- Datafile initial parameter DB_FILES .

Page 114: Oracle History #5

[email protected] - 114 -

Oracle8i New Features http://www.ggola.com/

Move Table

Relocating and Reorganizing a Table

SQL> alter table emp move tablespace ts_new_emp ;

- builds new segments and drops old segments

- used to move table to a different tablespace or reorganize extents

- limits 1. non-partitioned table only (partitioned table error) 2. move only select available and no DML 3. index, constraints and grant data

index status UNUSABLE .

4. new segment export and import table 2 space .

Remove Column

Marking a column as unused

SQL> alter table table_name set unused column column_name ;

- table column command users column data

disk space .

- unused column physically remove .

- user unused column column .

- Unused column table export drop and import table unused column

.

SQL> select * from dba_unused_col_tabs ; unused column information .

Page 115: Oracle History #5

[email protected] - 115 -

Oracle8i New Features http://www.ggola.com/

Removing a column from table

SQL> alter table table_name drop column column_name [cascade constraints] ;

- command unused mark column drop .( space release) , large table command

.

- column ‘UNUSED’ mark column command drop .

- cascade constraints : drop column all constraints drop .

SQL> alter table table_name drop unused columns ;

- table removes all currently marked as unused

CF. dropped column object , views, triggers and stored procedure units status invalidate .

CF. dropped column index always drop automatically

Minimizing rollback segment usage

SQL> alter table table_name drop column columns_name [ checkpoint 1000 ] ;

- DDL rollback segment checkpoint option row commit

.

- 1000 row checkpoint .

- Checkpoint table drop rollback space .

- instance failure table INVALID state .

- command . SQL> alter table table_name drop columns continue ;

Page 116: Oracle History #5

[email protected] - 116 -

Oracle8i New Features http://www.ggola.com/

Example

- emp table test emp_test .

SQL> desc emp_test Name Null? Type ------------ -------- ----------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) SQL> alter table emp_test drop column deptno 2 cascade constraints checkpoint 1000 ; Table altered. SQL> desc emp_test Name Null? Type ------------ -------- ----------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) SAL NUMBER(7,2) COMM NUMBER(7,2) SQL> alter table emp_test set unused column comm ; Table altered. SQL> select * from user_unused_col_tabs ; TABLE_NAME COUNT ----------------------- EMP_TEST 1 SQL> desc emp_test Name Null? Type ------------ -------- ----------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) SAL NUMBER(7,2) SQL> alter table emp_test drop unused columns ; Table altered. SQL> select * from user_unused_col_tabs ; no rows selected

constraints drop 1000 row

commit column

unused unused columns

Page 117: Oracle History #5

[email protected] - 117 -

Oracle8i New Features http://www.ggola.com/

Temporary tables

Application global temporary table

- temporary table data (DML ) session visible truncate command . , table

transaction or session termination data drop .

CF. , session instance crash data drop . (temporary )

- transaction or session data . (index index Index data )

- Table definition definition all session . (definition export/import )

- Session sort space data user’s temporary tablespace .

- Permanent tables view temporary table triggers .

- Recovery data redo entries DML rollback segment .

Creating and Monitoring with sample

SQL> create global temporary table table_name (empno number, ename varchar2(10), sal number) on commit delete rows ;

- on commit delete rows : transaction transaction session temporary table data .

- on commit preserve rows : session (transaction session )

SQL> select table_name, tablespace_name, temporary, duration from dba_tables where table_name = ‘TABLE_NAME’ ;

- dba_tables table temporary transaction session

.

Page 118: Oracle History #5

[email protected] - 118 -

Oracle8i New Features http://www.ggola.com/

Example

- scott user

SQL> create global temporary table emp_temp_sess 2 (empno number, ename varchar2(10), sal number) 3 on commit preserve rows ; Table created. SQL> create global temporary table emp_temp_trans 2 (empno number, ename varchar2(10), sal number) 3 on commit delete rows ; Table created. SQL> connect system/manager Connected. SQL> select table_name, tablespace_name , temporary, duration 2 from dba_tables 3 where table_name like '%TEMP%' and owner = 'SCOTT' ; TABLE_NAME TABLESPACE T DURATION -------------------- ---------- - --------------- EMP_TEMP_SESS Y SYS$SESSION EMP_TEMP_TRANS Y SYS$TRANSACTION SQL> connect scott/tiger Connected. SQL> insert into emp_temp_sess values ( 1000, 'KS JANG', 100000) ; 1 row created. SQL> insert into emp_temp_trans values ( 1000, 'KS JANG', 100000) ; 1 row created. SQL> select * from emp_temp_sess ; EMPNO ENAME SAL ---------- ---------- ---------- 1000 KS JANG 100000 SQL> select * from emp_temp_trans ; EMPNO ENAME SAL ---------- ---------- ---------- 1000 KS JANG 100000 SQL> commit ; Commit complete. SQL> select * from emp_temp_sess ; EMPNO ENAME SAL ---------- ---------- ---------- 1000 KS JANG 100000 SQL> select * from emp_temp_trans ; no rows selected SQL> connect scott/tiger Connected. SQL> select * from emp_temp_sess ; no rows selected SQL> select * from emp_temp_trans ; no rows selected

type global temporary table system user type temporary table

.

Scott user table data insert data

.

Commit select emp_temp_trans table

transaction data

emp_temp_sess session data .

Page 119: Oracle History #5

[email protected] - 119 -

Oracle8i New Features http://www.ggola.com/

SQL*Loader

Enhancements

- TERMINATED BY clause 1 character strings . (multiple delimited field available)

- New variable length field : VARCHARC, VARRAWC EX. VARCHARC(3,200) : ‘ 3 value

. 4 character character read 200

’ . CF. VARRAWC data RAW type .

- record size 64K . However, a logical record must fit entirely in client memory.

EX. enhancements .

Kate::Seoul::015Shi is actress;Bill::Pusan::024He is the best actor

LOAD DATA INFILE ‘emp_data.dat’ RECSEPARATOR ‘;’ FIELDS TERMINATED BY ‘::’ (emp_name, location NULLIF

(emp_name=BLANKS AND location=BLANKS) comment VARCHARC(3) )

Record Field Multiple New field type

Page 120: Oracle History #5

[email protected] - 120 -

Oracle8i New Features http://www.ggola.com/

Monitoring Long-Running Operations

V$SESSION_LONGOPS

- dynamic performance view monitoring

- monitoring operation .

1. arching 2. RMAN backup and restore 3. parallel query 4. recovery 5. full table scan 6. sort operation 7. analyze using DBMS_STAT 8. hash cluster creation

EX. monitoring . SQL> connect system/manager Connected. SQL> select sid, serial#, opname, 2 to_char(start_time, 'HH24:MI:SS') startt, 3 (sofar/totalwork)*100 "complete(%)" 4 from v$session_longops 5 where totalwork > 0 ;

- DBMS_APPLICATION_INFO package SET_SESSION_LONGOPS procedure application view populate .

- PL/SQL Block dbms_application_info.set_session_longops(v_rindex, v_slno) ;

session v$session_longops row . , v_rindex, v_slno IN/OUT variable

declare PL/SQL Block .

CF. package application operating information v$session_longops . , row creation . session

session termination delete .

CF. package application monitoring .

SID SERIAL# OPNAME STARTT complete(%) 13 238 TABLE SCAN 11:00:09 49.8434 45 342 ANALYZE 11:03:29 21.3433

Page 121: Oracle History #5

[email protected] - 121 -

Oracle8i New Features http://www.ggola.com/

13. Availability and Recoverability

Archive Enhancements

Multiple archive logs

- Oracle7 Oracle archive log 1 destination Oracle8 log_archive_duplex_dest

. , parameter remote instance destination .

- Oracle8i Oracle8 archive dest parameter log_archive_dest_n

(n 1 ~ 5 ) 5 archive dest remote instance .

remote backup system standby database . , remote instance remote

instance 1 log_archive_dest_n .

- log_archive_dest log_archive_dest_n . log_archive_dest_n

Oracle Enterprise Edition install Oracle8.1.5 Reference Manual log_archive_duplex_dest .

CF. ( ) Oracle Version 8.1.6.2 “Enterprise Edition” test Enterprise Edition log_archive_duplex_dest .

- 1. 2 archive dest , 2. standby database 3. remote archive destination log_archive_dest_n .

CF. standby database 2 local archive destination 1 remote archive destination

.

- Oracle8i remote archive destination log_archive_dest_n session level dynamic parameter

Page 122: Oracle History #5

[email protected] - 122 -

Oracle8i New Features http://www.ggola.com/

Multiple archive log processes

- Oracle8i multiple archive process . log_archive_start=true setting log_archiv_max_processes

archive process start .

CF. instance start alter system command . (10 )

alter system set log_archive_max_processes=2 ;

- archiving throughput (multiple archive processes archive ) Oracle

version manual archives performance .

Multiple archive Options

- , standby database 1 local archive dest 1 backup local archive dest

.

log_archive_dest_1 = “location=/a01/oracle1/arch/arch mandatory reopen” log_archive_dest_2 = “location=/a02/oracle2/arch/arch optional” log_archive_dest_3 = “service=standby_db2 mandatory reopen=500”

- dest #1 original archive dest dest #2 archive backup dest dest #3 standby database .

- dest #1 dest #3 mandatory archive .

reopen archive default 300 dest #3

500 . second .

- dest #2 optional redo log reused .

- dest #3 tnsnames.ora service name standby database archive . standby database ‘RFS’ process primary database

.

CF. as mandatory / optional optional default value .

Page 123: Oracle History #5

[email protected] - 123 -

Oracle8i New Features http://www.ggola.com/

When is the online redo log reused?

- online redo log reused .

1. archive all mandatory locations

2. log_archive_min_succeed_dest local location archived (all local mandatory archive

)

- standby database archive destination mandatory archive

local archived log_archive_min_succeed_dest archive

online redo log reuse .

- log_archive_min_succeed_dest total archive destination local mandatory archive destination . ,

.

- 3 local archive destination mandatory 2 standby database archive mandatory 1 optional 2 online redo log reuse .

- 3 mandatory archive 2 local archive destination 1 optional .

CF. , log_archive_dest log_archive_duplex_dest parameter 1 2 .

- log_archive_min_succeed_dest parameter session or system level . alter session set log_archive_min_succeed_dest=2 ;

alter system set log_archive_min_succeed_dest=3 ; CF. log_archive_dest log_archive_duplex_dest

alter session command .

- parameter log_archive_dest_state_n _n archive destination disable .

default ‘ENABLE’ session or system level . ‘DEFER’ destination archive ‘ENABLE’ archive .

Page 124: Oracle History #5

[email protected] - 124 -

Oracle8i New Features http://www.ggola.com/

- , ‘DEFER’ ‘ENABLE’ archive destination manual copy .

alter system set log_archive_dest_state_3 = defer ; alter system set log_archive_dest_state_1 = enable ; (log_archive_dest_n destination log_archive_dest_state_n matching .

CF. Anyway, log_archive_min_succeed_dest ‘ENABLE’ log_archive_dest_state_n .

Related data dictionary

- V$ARCHIVE_DEST : archive destination BINDING, STATUS, TARGET, FAIL_SEQUENCE……

- V$ARCHIVE_PROCESSES : archive process PROCESS, STATUS, LOG_SEQUENCE, STATE

Page 125: Oracle History #5

[email protected] - 125 -

Oracle8i New Features http://www.ggola.com/

Standby database

Automatic Archival

- primary site archive log automatically shipped to standby site archive manual copy

.

- Primary site archive ‘RFS’ (Remote File Server) process .

process standby database instance start remote node file save control file

update .

- If multiple ARCH processes are used at the primary site, each ARCH process spawns and communicates with its own RFS process.

Sustained Recovery

- Optionally, RFS primary site log standby database . (Sustained Recovery)

primary failure standby open .

- Primary archive destination standby_archive_dest=/primary_site/a01/arch…..

- Sustained recovery command 1. mount . 2. alter database recover managed standby database ; [timeout 60] ==> primary log

. (minutes )

Read only database

- select database open . standby database production .

- Read only database 1. query . 2. order by sort , locally managed tablespace sort . 3. datafile online or offline .

- Standby read only open sustained recovery 1. alter database recover managed standby database cancel ; 2. alter database open read only ; 3. alter database recover managed standby database ; (active user sessions )

Page 126: Oracle History #5

[email protected] - 126 -

Oracle8i New Features http://www.ggola.com/

Redo log Enhancements

LogMiner : PL/SQL interface redo log files read, analyzed, interpreted using

standard SQL .

Analyzing redo log files

- database changes tracking without auditing overhead time or SCN base , point-in-time recovery

.

- Performing granular logical recovery application transaction undoing specific changes .

- Tuning and capacity planning data growth patterns usage patterns

.

LogMiner (install ‘SYS’ user )

- Oracle8 redo log . 1. same platform 2. same character set

- Log file dictionary file .

- dbms_logmnr_d.build(‘file_name’,’file_path’) ;

CF. Oracle8 log analyzing , Oracle8i $ORACLE_HOME/rdbms/admin/dbmslogmnrd.sql Oracle8 copy ‘SYS’ user .

CF. Oracle 8.1.6.2 dbmslmd.sql . (dbmslogmnrd.sql )

- file_path initial parameter UTL_FILE_DIR .

- procedure data dictionary information file object

. , object .

- procedure log table index, data scripts . file target database

Page 127: Oracle History #5

[email protected] - 127 -

Oracle8i New Features http://www.ggola.com/

database log .

- dbms_lomnr_d.build log object

name data hexa value .

- Log file log .

- dbms_logmnr.add_logfile(‘/a01/oracle/arch/arch_log1’, dbms_logmnr.NEW) ;

LOG

- dbms_logmnr.add_logfile(‘/a01/oracle/arch/arch_log2’, dbms_logmnr.ADDFILE) ;

LOG LOG

- dbms_logmnr.add_logfile(‘/a01/oracle/arch/arch_log2’, dbms_logmnr.REMOVEFILE) ;

LOG LOG

CF. test log file .

- log file log initiate .

- Log SCN Number .

(dbms_logmnr_d.build file dictfilename path )

- dbms_logmnr.start_logmnr( dictfilename=>’/app/oracle/logmnr/ logmnr.ora’, - start_scn => 350128, - end_scn => 352286) ;

dbms_logmnr.start_logmnr( dictfilename => ‘/app/oracle/logmnr/logmnr.ora’, - starttime => to_date(‘31/05/2001:11:35’, ‘DD/MM/YYYY:HH24:MI’), - endtime => to_date(‘31/05/2001:14:18’, ‘DD/MM/YYYY:HH24:MI’) ) ; CF. line ‘-‘ . CF. SCN or time range addfile log file

procedure error .” time or SCN range not fully contained in the listed

logfiles” . CF. , dictfilename log file

Page 128: Oracle History #5

[email protected] - 128 -

Oracle8i New Features http://www.ggola.com/

. starttime endtime default value 1988 1 1 2988 1 1

.

- LogMiner start V$LOGMNR_CONTENTS View .

- ‘AKCDFILE’ Table insert, delete 2 commit 2 transaction

.

CF. SQL REDO user SQL UNDO . , SQL_REDO

SQL_UNDO recovery .

- log end_logmnr resource release .

- dbms_logmnr.end_logmnr ;

- log . , log session .

- dbms_logmnr.procedure session PGA

dbms_logmnr.end_logmnr PGA .

- Other information : 1. V$LOGMNR_DICTIONARY - tiemstamp, filename 2. V$LOGMNR_LOGS - log id, log filename, low-high scn, log-high time 3. V$LOGMNR_PARAMETERS : arguments - start-end date, start-end scn, info, status

SQL> select scn, timestamp, username, sql_redo, sql_undo from v$logmnr_contents where seg_name = 'AKCDFILE' ; SCN TIMESTAMP USERNAME SQL_REDO

350128 20010531 11:35:21 AKMANAGER insert into AKMANAGER.AKCDFILE (FILE_TP,FILE_RUN) values ('AVI','audio file');

SQL_UNDO delete from AKMANAGER.AKCDFILE where FILE_TP = 'AVI' and FILE_RUN = 'audio file' and ROWID = 'AAAA2PAAHAAAACFAAE';

350138 20010531 11:36:14 AKMANAGER delete from AKMANAGER.AKCDFILE where FILE_TP = 'AVI' and

FILE_RUN = 'audio file' and ROWID = 'AAAA2PAAHAAAACFAAE'; SQL_UNDO insert into AKMANAGER.AKCDFILE (FILE_TP,FILE_RUN) values ('AVI','audio file');

Page 129: Oracle History #5

[email protected] - 129 -

Oracle8i New Features http://www.ggola.com/

Limitation

- PGA session .

- 1 row per record (1 row sel_undo row sql undo

rowid ) , row return .

- DDL oracle , data dictionary DML .

- Chained rows DML reconstruct .

- Data dictionary file clustered tables changes hexa values . ,

dictionary file hexa values .

CF. DDL sample ‘xx’ table create and drop log

.

- drop table xx …. sql_redo : delete from SYS.OBJ$ where OBJ# = 3501 and DATAOBJ# = 3501 and OWNER# = 0 and NAME = 'XX' and NAMESPACE = 1 and SUBNAME IS NULL and TYPE# = 2 and CTIME = TO_DATE('31-MAY-2001 15:36:10', 'DD-MON-YYYY HH24:MI:SS') and MTIME = TO_DATE('31-MAY……………….

sql_undo : insert into SYS.OBJ$ (OBJ#,DATAOBJ#,OWNER#,NAME,NAMESPACE,SUBNAME,TYPE#,CTIME,MTIME,STIME,STATUS, REMOTEOWNER,LINKNAME,FLAGS,OID$,SPARE1) values (3501,3501,0,'XX',1,NULL,2, TO_DATE('31-MAY-2001 15:36:10', 'DD-MON-YYYY HH24:MI:SS'),TO_DATE('31- ……………..

Page 130: Oracle History #5

[email protected] - 130 -

Oracle8i New Features http://www.ggola.com/

Fast_Start Recovery

Instance Recovery

- Prior to oracle8i instance recovery time . failure transaction load

.

- fast_start_io_target parameter : instance recovery (read and write) maximum number of

datafile blocks . ( parameter target redo blocks , redo generation ) system level dynamic parameter instance running alter system command .

- Recovery time datafile I/O instance average I/O time .

Fast-Start Checkpointing

- crash or instance recover recovery position. buffer cache earliest buffer to be dirtied gets written first (oldest dirty block buffer) roll forward DB blocks

. , feature media recovery .

- If fast_start_io_target = 10000 10000 blocks checkpoint position .

- parameter recovery performance checkpoint

transaction overhead .

Factors affecting checkpointing

- A : fast_start_io_target parameter value

- B : 90% of size of smallest redo log

- C : end of the log_checkpoint_timeout seconds ago

- D : log_checkpoint_interval blocks from the end

DBWn 4 redo log point satisfy all the criteria defined.

CF. redo ‘A’ point .

Redo Log blocks end of the redo

A B C D

Page 131: Oracle History #5

[email protected] - 131 -

Oracle8i New Features http://www.ggola.com/

Factors influencing time to recover

- estimated recovery time . recovery time .

- Checkpoint target changed only at specific time intervals (maybe time recovery?)

- Additional recovery activities such as reading logs and lock remastering . (typically recovery activities 5% )

- Recovery time may be faster if parallel recovery is used

Define and monitor bounded recover time

- Users V$FILESTAT AVGIOTIM column FAST_START_IO_TARGET .

( column TIMED_STATISTICS initial parameter TRUE 1/100 file I/O

)

- V$INSTANCE_RECOVERY impact of parameters check . 1. RECOVERY_ESTIMATED_IOS : fast-start checkpoint

. 2. ACTUAL_READ_BLKS : recovery current actual redo blocks 3. TARGET_READ_BLKS : 4 minimum value recovery current target redo blocks . the number of redo blocks. 4. LOG_FILE_SIZE_REDO_BLKS : checkpoint complete log switch 5. LOG_CHKPT_TIMEOUT_REDO_BLKS : log_checkpoint_timeout parameter 6. LOG_CHKPT_INTERVAL_REDO_BLKS : log_checkpoint_interval parameter 7. FAST_START_IO_TARGET_REDO_BLKS : fast_start_io_target parameter

CF. DB_BLOCK_MAX_DIRTY_TARGET FAST_START_IO_TARGET 0 DBMDT trigger checkpoint . FAST_START_IO_TARGET parameter DBMDT override .

CF. FSIT recovery blocks DBWn dirty buffers write

.

Page 132: Oracle History #5

[email protected] - 132 -

Oracle8i New Features http://www.ggola.com/

Fast-Start parallel rollback

Rolling back

- Oracle fast start Oracle7 warm start , deferred rollback .

- Rolling back 1. SMON periodically scans all rollback segments and rolls back aborted transactions as needed 2. user process dead transaction held row lock recovers transaction and continues processing.

- Oracle8i instance recovery SMON query slave query slave process 1

rollback parallel rollback .

- Parallel transaction system crash recovery .

10 10 parallel instance crash rollback 100

.

- SMON parallel query slaves parallel rollback operation .

- , SMON dead transaction large number of rollback blocks generate (rollback blocks 100 ) .

Controlling fast-start parallel rollback

- Oracle 8.1.4 Beta Release PARALLEL_TRANSACTION_RECOVERY parameter

parameter . (8 parallel processing parallel transaction rollback )

- FAST_START_PARALLEL_ROLLBACK dynamic parameter(initial parameter or alter system) parallel rollback .

- maximum parallel recovery servers processes . 1. FALSE : . 2. LOW : 2 * CPU_COUNT 3. HIGH : 4 * CPU_COUNT

Page 133: Oracle History #5

[email protected] - 133 -

Oracle8i New Features http://www.ggola.com/

Monitoring parallel rollback

- V$FAST_START_SERVERS : fast start parallel rollback query slaves information

- V$FAST_START_TRANSACTIONS : fast start rollback transactions status information (Transaction ID, Undo blocks done, Undo blocks total, CPU time in seconds)

Fast-Start On-demand rollback

- dead transaction lock held SMON parallel rollback transaction

rollback data block access users waiting .

- On-demand block recovery user access data block initiate rollback (immediately recover data blocks accessed by user transactions) the remainder of the blocks background recover .

CF. , Fast-Start Rollback Enable .

Page 134: Oracle History #5

[email protected] - 134 -

Oracle8i New Features http://www.ggola.com/

Block detection and Repair

Oracle Support .

Some facilities for detecting and recovering from block corruptions

- DB_VERIFY utility : offline file check both online and backup datafiles

online performance . (from Oracle7)

- DB_BLOCK_CHECKING : initial parameter setting blocks check . (new from Oracle8i)

- ANALYZE command : SQL command analyze table validate structure syntax invalid rows in partitioned tables check . (changed from Oracle8i)

- DBMS_REPAIR : new package PL/SQL interface block corruptions detect and repair . package install . (by ‘SYS’) $ORACLE_HOME/rdbms/admin/dbmsrpr.sql $ORACLE_HOME/rdbms/admin/prvtrpr.plb (new from oracle8i)

DBMS_REPAIR

1. connect as user ‘SYS’

2. block corruption check result table DBMS_REPAIR.ADMIN_TABLE( ‘REPAIR_TABLE’, DBMS_REPAIR.REPAIR_TABLE, DBMS_REPAIR.CREATE_ACTION, ’TS_REPAIR_DAT’); >> check table name >> table data repair_table, index data orphan_table >> action : table . (purge_action : delete data from objects, drop_action : drop the table) >> table tablespace

3. check corruptions ( 3 parameters ) DBMS_REPAIR.CHECK_OBJECT (‘SCOTT’, ’EMP’, CORRUPT_COUNT=>:ccnt) ; >> schema name >> object name >> corrupted blocks return

Page 135: Oracle History #5

[email protected] - 135 -

Oracle8i New Features http://www.ggola.com/

Others

- initial parameter DB_BLOCK_CHECKING=TRUE block corruption ORA-1578 error trace files dump .

- Performance reading check .

- Analyze table valid structure command partitioned tables invalid rows check

Making Objects Usable

- DBMS_REPAIR.FIX_CORRUPT_BLOCKS(’SCOTT’, ‘EMP’, FIX_COUNT=>:fcnt) software corruption block mark ( REPAIR_TABLE )

- DBMS_REPAIR.SKIP_CORRUPT_BLOCKS(’SCOTT’, ‘EMP) ; corruption marked blocks data read

. (DBA_TABLES SKIP_CORRUPT )

- Skipping blocks ? 1. inaccessible 2. marked blocks point indexes corrupt 3. referential integrity constraints may be violated disable and re-enable constraints to identify violations 4. freelist corrupt dbms_repair.rebuild_freelists

freelist initialize .

Checking index entries pointing to rows in corrupt data blocks

1. check table DBMS_REPAIR.ADMIN_TABLES( ’ORPHAN_TAB’, DBMS_REPAIR.ORPHAN, DBMS_REPAIR.CREATE_ACTION’, ‘TS_REPAIR_IND’) ; >> corrupt data table >> index data check >> table >> table tablespace

2. check index for orphan keys DBMS_REPAIR.DUMP_ORPHAN_KEYS(‘SCOTT’, ‘EMP’, ORPHAN_TABLE_NAME=>’ORPHAN_TAB’, KEY_COUNT=> :kcnt) ; >> schema name >> object name >> table name >> number of keys identified

3. table corrupt index rebuild select index_name from orphan_tab where table_name = ‘EMP’ ;

Page 136: Oracle History #5

[email protected] - 136 -

Oracle8i New Features http://www.ggola.com/

Limitations of DBMS_REPAIR

- out-of-line columns ignored

- IOT and LOB indexes

- Bitmap and function-based indexes

- Key values 3,950 bytes

Page 137: Oracle History #5

[email protected] - 137 -

Oracle8i New Features http://www.ggola.com/

14. Features of Net8

Oracle8 New Features .

Net8 and the listener

Net8 and the listener : new parameters

- Oracle8i default listener listener.ora file . listener start

instance start PMON listener service handler .

, instance listener start ( , listener.ora file instance listener.ora file )

(every 1 minute) . CF. listener.ora file

. , listener port location listener.ora file .

- New initial parameter INSTANCE_NAME = NIS8I (default SID) SERVICE_NAMES = NIS8I_A1, NIS8I_B1

- instance name instance name multiple instances common services share uniquely instance name identify .

- instance service names listener service name .

, random listener access service name .

NIS8I listener , NIS8I_A 1 listener NIS8I_B 1 listener 2 listener

client .

CF. instance NIS8I connect (connection request ) client tnsnames.ora

connection information SERVICE_NAME initial parameter service_names . , service_names default (typically global database name) db_name.db_domain db_domin parameter default ‘WROLD’ Oracle8.1.5 manual

Oracle8.1.6.2 parameter setting null . , SID = INSTANCE_NAME = DB_NAME

SERVICE_NAMES default SID .

Page 138: Oracle History #5

[email protected] - 138 -

Oracle8i New Features http://www.ggola.com/

Load balancing

- connection load balancing .

1. number of active connections among various instances 2. dispatchers for the same service

- load balancing order 1. client load balancing and failover : random listener available next available listener

. 2. listener all available nodes information least CPU usage nodes . 3. listener (MTS ) connection

dispatcher information route .

- Oracle Meta link “Note:75712.1”

1. Client load balancing and failover tnsnames.ora : client listener

FAILOVER LOAD_BALANCE listener . load_balance on

listener random off sequential . CF. LOAD_BALACE=ON FAILOVER=OFF

listener address random 1 failover .

NIS8I = (DESCRIPTION = (FAILOVER=on) (LOAD_BALANCE=on) (ADDRESS = (PROTOCOL = tcp) (HOST = 203….106) (PORT = 1521)) (ADDRESS = (PROTOCOL = tcp) (HOST = 203….104) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = NIS8I_A)) ) CF. Version “ADDRESS_LIST =” parameter

.

- tnanames.ora listener listener 1. 2. instance 3. instance down , listener process

failover error return .

Page 139: Oracle History #5

[email protected] - 139 -

Oracle8i New Features http://www.ggola.com/

- OPS SID SERVICE_NAME, INSTANCE_NAME . NIS8I = (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp) (HOST = 203….106) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = NIS8I_A) (INSTANCE_NAME = NIS8I)) ) CF. instance_name parameter parallel server .

, OPS instance_name parameter .

2. Connection and Node load balancing (MTS only)

- listener . instance OPS

instance listener connection load balancing .

- , instance local remote listener client connection request

. >> connection load balancing

- client random listener service name or sid connection request listener CPU usage server(instance) connect

. >> node load balancing

CF. listener listener process start . , listener.ora file .

CF. service handlers mts_dispatchers dispatcher .

CF. Test remote listener dispatcher local listener dispatchers + local server dedicated

. , local server dispatcher 6 7 service

handlers .

CF. >> $ lsnrctl services listener_name

Page 140: Oracle History #5

[email protected] - 140 -

Oracle8i New Features http://www.ggola.com/

3. dispatcher routing

- MTS listener instance listener listener .

- Multiple node instance SID SERVICE_NAMES .

- instance MTS instance listener

connection load balancing initial parameter MTS_DISPATCHERS listener information listener connection

listener current status information setting . listener CPU

usage node connection dispatcher process connection

.

CF. instance start PMON dispatcher information listener register (monitor the system every 30 seconds by default) information 10 update . ( , 1 check 10 node heavy transaction update )

CF. Oracle8 connection dispatcher connection Oracle8i active connection

node dispatcher .

>> 3 load balancing connection client server side process dispatcher process load balancing .

Page 141: Oracle History #5

[email protected] - 141 -

Oracle8i New Features http://www.ggola.com/

Scalability

New parameters

- PMON default listener service initial parameter local_listener default value

.

- LOCAL_LISTENER default local host port 1521, protocol tcp ipc . port

default value parameter .

1. * 1522 port ?” listener.ora : LISTENER = (ADDRESS_LIST = (ADDRESS= (PROTOCOL= TCP) (Host= 203.246.130.104) (Port= 1522)))

init$SID.ora : local_listener = "(address = (protocol=tcp) (host=203.246.130.104) (port=1522)) "

2. server side tnsnames.ora alias init$SID.ora local_listener = lsn_local

tnsnames.ora : lsn_local = (address = (protocol = tcp)(host = 203.246.130.104)(port=1522))

CF. init$SID.ora local_listener parameter multiple local listener .

- MTS_DISPATCHERS connection load balancing listener

mts_dispatchers . 1. mts_dispatchers=”(protocol=tcp)(dispatchers=2)” local listener . 2. mts_dispatchers= ”(protocol=tcp)(dispatchers=2)(listener=lsn_remote)” server side tnsnames.ora lsn_remote remote listener .

- LARGE_POOL_SIZE= ? parameter Dedicated Server

process session memory sort UGA MTS Shared server large pool

.

Page 142: Oracle History #5

[email protected] - 142 -

Oracle8i New Features http://www.ggola.com/

Multiple instance configuration step on MTS

- instance 'NIS8I' 203.111.111.104 local listener 203.111.111.106 remote listener

.

Step1. Server side tnsnames.ora listener alias MLTNIS8I = (ADDRESS = (PROTOCOL = tcp) (HOST = 203.111.111.106) (PORT = 1521))

Step 2. initial parameter mts_dispatchers (remote and local). mts_dispatchers = "(PROTOCOL=TCP)(DISPATCHERS=3)(listener=MLTNIS8I)" mts_dispatchers = "(PROTOCOL=TCP) (DISPATCHERS=3)"

Step 3. optional : SID service name service_names = NIS8I_A

Step 4. local server listener start Step 5. remote server (203.111.111.106) listener start Step 6. database startup Step 7. client tnsnames.ora setting NIS8I = (DESCRIPTION = (FAILOVER=on) (LOAD_BALANCE=on) (ADDRESS = (PROTOCOL = tcp) (HOST = 203.111.111.104) (PORT = 1521)) (ADDRESS = (PROTOCOL = tcp) (HOST = 203.111.111.106) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = NIS8I_A)))

Step 8. “$ lsnrctl services” command listener .

CF. listener port 1521 port local listener server side tnsnames.ora mts_dispatchers . CF. 203.111.111.106 instance multiple instance node load balancing (service_names SID

) 203.111.111.106 instance .

, listener port . listener port multiple instance instance remote listener .

CF. node load balancing listener process start instance instance

listener start listener process instance service handler .

Page 143: Oracle History #5

[email protected] - 143 -

Oracle8i New Features http://www.ggola.com/

Multiple presentation support

- IIOP, HTTP protocol MTS . Dedicated protocol .

- MTS provides the ability to configure a dispatcher for each presentation.

- JAVA support : 1. default TTC presentation ( standard Net8 clients and java stored procedures) 2. Enterprise Java Beans : GIOP presentation 3. CORBA servers : GIOP presentation

- Oracle standard presentation TTC(Two Task Common) default MTS dispatcher multiple presentation

.

- GIOP(General Inter-Orb Protocol) IIOP(Internet Inter-Orb Protocol) EJB and CORBA Server connections

presentation protocol .

- Java stored procedures MTS Dedicated server mode EJB and CORBA server

CORBA IIOP MTS .

- presentation layer setting TTC GIOP setting mts_dispatchers parameter .

- Initial parameter init$SID.ora mts_dispatchers = “(PROTOCOL=TCP)(PORT=1820) (DISPATCHERS=1)(PRE=ttc)" mts_dispatchers = "(PROTOCOL=TCP)(PORT=2332) (DISPATCHERS=1) (PRE=oracle.aurora.server.SGiopServer)"

Connection pooling (MTS only)

- Oracle8 New Features connection pooling resource idle session resource new session resource

“physical network connection” resource utilization feature .

- MTS_DISPATCHERS=”(PRO=tcp) (CON=10) (DIS=3) (POO=on) (TIC=3)(SESS=30)”

- CON=10 : dispatcher connection POO=on : connection pooling enable TIC=3 : idle session * 10 , 30 SESS=30 : idle session session

Page 144: Oracle History #5

[email protected] - 144 -

Oracle8i New Features http://www.ggola.com/

Connection concentration (MTS only)

- client connect request listener connection manager listener

dispatchers 1 physical link multiple logical sessions . (Multiplexing)

CF. connection manager MTS Dedicated mode .

connection concentration .

- Connection manager 1. tnsnames.ora sample for client connection NIS8I = (DESCRIPTION = (SOURCE_ROUTE=yes) (ADDRESS = (PROTOCOL = TCP) (HOST = 203.111.111.104) (PORT = 1630)) (ADDRESS = (PROTOCOL = TCP) (HOST =203.111.111.106)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME=NIS8I_A)) 2. cman.ora sample for server configuration cman = (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST= 203.111.111.104) (PORT=1630) (QUEUESIZE=32))) cman_admin = (ADDRESS=(PROTOCOL=tcp)(HOST= 203.111.111.104) (PORT=1830)) cman_profile = (parameter_list= (MAXIMUM_RELAYS=1024) (LOG_LEVEL=1) (TRACING=no) (RELAY_STATISTICS=yes) (SHOW_TNS_INFO=yes) (USE_ASYNC_CALL=yes) (AUTHENTICATION_LEVEL=0) (REMOTE_ADMIN=FALSE)) 3. initial parameter mts_dispatcher sample mts_dispatchers=”(protocol=tcp) (dis=3) (mul=on)” CF. multiplex=on setting connection concentration enable .

- lsnrctl command cmctl command . $ cmctl start connection manager connection request cmadmin process register ‘cmgw’ process cmgw registration cmgw, listener information names server oracle names server address information names server update ‘cmadmin’ process .

option .

Connection manager address Listener address

Page 145: Oracle History #5

[email protected] - 145 -

Oracle8i New Features http://www.ggola.com/

Multi protocol interchange(MPI)

- client/server different type protocol . TCP/IP client SPX Oracle

server connect TCP Oracle connection manager connect Oracle connection manager SPX database server connect client

.

- tnsnames.ora for multi protocol interchange NIS8I = (DESCRIPTION = (SOURCE_ROUTE=yes) (ADDRESS = (PROTOCOL = TCP) (HOST = 203.111.111.104) (PORT = 1610)) (ADDRESS = (PROTOCOL = SPX) (SERVICE = MPI_LST)) (CONNECT_DATA = (SERVICE_NAME=NIS8I_A))

Security

Security features

- client connection access control

- secure access through the Web

- works with Oracle Advanced Security Option

Connection manager

- client server access control rules . access control connection manager

CMAN.ora CMAN_RULES .

- CMAN_RULES sample CMAN_RULES = (RULE_LIST = (RULE=(SRC=204.111.111.101) (DST=203.111.111.104) (SRV=NIS8I_B) (ACT=accept)) (RULE=(SRC=204.111.111.102) (DST=203.111.111.106) (SRV=NIS8I_A) (ACT=reject)) )

- client 204.111.111.101 server 203.111.111.104 NIS8I_B database connection request

client 204.111.111.102 server 203.111.111.106 NIS8I_A database connection request .

- SRC : source host name or IP (client) DST : destination host name or IP (server) SRV : target database service or SID (8i SID only) ACT : ACCept or REJect

connect to CMAN using TCP

connect to database using SPX

Service name for database

Page 146: Oracle History #5

[email protected] - 146 -

Oracle8i New Features http://www.ggola.com/

Manageability

Oracle8 New Features Page 93 “Advanced functions of Net8” homepage http://sh.hanarotel.co.kr/~ggola Net8i network configuration

Configuration and trace tools

- Configuration : Net8 Assistant tool GUI .

$ $ORACLE_HOME/bin/netasst

- Tracing : more readable trace text $ $ORACLE_HOME/bin/trcasst –o sqlnet.trc

Naming services method

1. local naming : client tnsnames.ora

2. host naming : DNS /etc/hosts alias host name

(TCP/IP, one host only one Instance )

3. centralized naming : names server

4. connection manager names server

5. external naming : third-party name resolution mechanism

ex) CDS, NOVELL, NIS

Page 147: Oracle History #5

[email protected] - 147 -

Oracle8i New Features http://www.ggola.com/

15. SQL*Plus, PL/SQL and National Language Support

SQL*Plus

New Features

- server manager sql*plus .

- version server manager .

SQL*Plus syntax review

- create type, create library new line ‘/’ .

- SQL blank line .

- “#” comment . comment “-“ “—“ .

- SQL new line “-“ .

- “&” . “&” escape character

. Default off “\” ( “?” )

SQL> set escape ? .

EX. select ‘?&k’ from dual ; &k . “?” &k .

External Procedure (Oracle8 NF)

Orace8i external procedure JAVA .

External procedure Oracle8 NF

Page 148: Oracle History #5

[email protected] - 148 -

Oracle8i New Features http://www.ggola.com/

New Event Triggers

New Trigger Level

- Oracle7 DML(row and statement level) trigger database schema(user and DDL)

level trigger .

- Database level trigger : DBA role Schema level trigger : create trigger privilege

user schema level trigger : create any trigger privilege

Enhanced trigger

- Oracle8 ‘instead of’ trigger views, object views Oracle8i

.

- ‘INSTEAD OF’ trigger nested table nested table .

EX. create trigger emp_nest_trg instead of insert on nested table emp_nest of emp_object for each row …….

New Event & Changed view

- STARTUP : database open fire SHUTDOWN : instance shutdown fire SERVERERROR : database error occurs LOGON, LOGOFF : user log on and log off fire CREATE, ALTER, DROP : object

- DBA_TRIGGERS TABLE_NAME : database, schema level NULL TRIGGER_TYPE : before and after event for system events BASE_OBJECT_TYPE : database or schema for system events

- DBMS_STANDARD package : additional functions to obtain attributes within a trigger

CF. dba_triggers table_name NULL value database trigger or schema trigger .

Page 149: Oracle History #5

[email protected] - 149 -

Oracle8i New Features http://www.ggola.com/

Example

- Trigger for database startup and shutdown history

‘SYS’ user login SQL> create table instance_info ( 2 servername varchar2(20), username varchar2(30), 3 work_type varchar2(10), work_time date) ; Table created. SQL> !more start_trg.sql create or replace trigger inst_start_trg after startup on database declare v_user varchar2(30); begin select username into v_user from user_users ; insert into instance_info values (dbms_standard.database_name, v_user, 'STARTUP', sysdate) ; end; / SQL> !more down_trg.sql create or replace trigger inst_sdown_trg before shutdown on database declare v_user varchar2(30); begin select username into v_user from user_users ; insert into instance_info values (dbms_standard.database_name, v_user, 'SHUTDOWN', sysdate) ; end; / SQL> col trigger_name for a20 SQL> col table_name for a10 SQL> select trigger_name, table_name, base_object_type, trigger_type 2 from dba_triggers 3 where trigger_name in ('INST_START_TRG','INST_SDOWN_TRG'); TRIGGER_NAME TABLE_NAME BASE_OBJECT_TYPE TRIGGER_TYPE -------------------- ---------- ---------------- ------------------------------------------------------------- INST_SDOWN_TRG DATABASE BEFORE EVENT INST_START_TRG DATABASE AFTER EVENT Database shutdown and startup SQL> alter session set nls_date_format = 'YYYYMMDD HH24:MI:SS' ; Session altered. SQL> col username for a10 SQL> col servername for a15 SQL> select * from instance_info ; SERVERNAME USERNAME WORK_TYPE WORK_TIME --------------- ---------- ---------- ------------------------------------------------------- HJSENT.WORLD SYS SHUTDOWN 20010908 12:31:00 HJSENT.WORLD SYS STARTUP 20010908 12:32:44

Database startup and shutdown history

table

Database startup and shutdown trigger

trigger

Database shutdown and startup

Page 150: Oracle History #5

[email protected] - 150 -

Oracle8i New Features http://www.ggola.com/

Autonomous Transactions

Independence

- autonomous transaction PL/SQL blocks call transaction independent transaction

.

- , main transaction call sub program nested transaction main transaction commit and rollback .

- Oracle8i independent transaction autonomous transaction

.

CF. Oracle7 DBMS_PIPE .

- PRAGMA setting .

- PL/SQL block stored procedure, package/type method, local procedure/function

. , declare section .

- transaction lock resource main transaction resource . dead lock error return .

- Autonomous transaction application .

Example

- emp_prag1 emp_test 1 row insert commit autonomous transaction emp_prag2 1 row insert and call emp_prag2 and 1 row insert commit or rollback

- emp_prag2 session 3 rows session emp_prag1 data 1 row .

Page 151: Oracle History #5

[email protected] - 151 -

Oracle8i New Features http://www.ggola.com/

Program example

- Session 1 SQL> exec emp_prag2(999) ; SQL> select * from emp_test ;

1000, 999, 1001 empno data 3 .

- Session2 SQL> select * from emp_test ;

999 empno data 1 .

- Session1 SQL> rollback ;

session1 session2 empno 999 data 1 .

CF. SQL*Plus autocommit on setting transaction commit

autocommit off .

Autonomous transaction program description : create or replace procedure emp_prag1 (a_empno number) is v_t_odate date ; pragma autonomous_transaction; begin v_t_odate := sysdate ; insert into emp_test values (a_empno, 'X1', 'Y1', 888, v_t_odate, 10, 10, 11) ; commit ; end; /

Main transaction program description : create or replace procedure emp_prag2 (a_empno number) is v_t_odate date ; begin v_t_odate := sysdate ; insert into emp_test values (a_empno + 1 , 'X1', 'Y1', 888, v_t_odate, 10, 10, 11) ; -- call procedure for 1 row insertion emp_prag1(a_empno) ; insert into emp_test values (a_empno + 2, 'X1', 'Y1', 888, v_t_odate, 10, 10, 11) ; end; /

Page 152: Oracle History #5

[email protected] - 152 -

Oracle8i New Features http://www.ggola.com/

PL/SQL

Enhancements

- very large package support : maximum package size .

- Bulk binds : FORALL collection elements SQL bulk binding .

collection elements(index-by table, nested table, varray, host array) first last . …………………… FORALL i in 1..500 LOOP delete from emp where empno = empnos(i) ; …………………….. CF. This functionality reduces communication overhead.

- Dynamic SQL : DBMS_SQL package dynamic SQL

PL/SQL directly .

- Dynamic SQL DML DDL .

- Oracle8i object features REF-based operations PL/SQL “UTL_REF” package support

- UTL_REF package contains procedures to support reference-based operations (Oracle8i manual “Supplied Packages Reference, Volumne2 “ UTL_REF )

- monitoring and analysis of Program Execution packages new three APIs tracing, debugging, profiling . CF. Oracle8i New Features

Example . .

Dynamic SQL sample …….. sql_stm := ‘insert into dept values (:1, :2, :3)’ ; execute immediate sql_stm using v_dept, v_name, v_loc ; …… v_where := ‘ where deptnm = ‘ || v_deptnm ; execute immediate ‘delete from ‘ || v_tab_name || v_where ; ……. execute immediate ‘create table emp (empno number(4))’ ;

Page 153: Oracle History #5

[email protected] - 153 -

Oracle8i New Features http://www.ggola.com/

Parameter passing by reference

- PL/SQL in or out or in out , value parameter reference

.

- NOCOPY mode . , out parameter procedure reference parameter pointer .

- sample .

- 100 ( input) 300 (nocopy mode) 200 ( out variable) print .

CF. 300 nocopy mode 200 in out .

SQL> set serveroutput on SQL> declare n number := 100 ; procedure do_print( n1 in number, n2 in out number, n3 in out nocopy number) is begin n2 := 200 ; dbms_output.put_line(n1) ; -- print 100 n3 := 300 ; dbms_output.put_line(n1) ; -- print 300 end ; begin do_print(n, n, n) ; dbms_output.put_line(n) ; -- print 200 end ; / 100 300 200 SQL>

Page 154: Oracle History #5

[email protected] - 154 -

Oracle8i New Features http://www.ggola.com/

National Language Support

Oracle8 New Features .

character set

- Database Creation , create database character set national character set

.

SQL> Create Database DBNAME Logfile Group 1… Datafile… Character Set US7ASCII National Character Set KO1601KSC ;

- National character set data NCHAR, NCLOB, NVARCHAR2 National

.

Dual currency support (for Euro)

- 1999 1 EU new currency Euro .

- euro sample .

NLS sort

- sort function based index .

- SQL> create index xak_nls_ename on emp (nlssort(ename, ‘NLS_SORT = German’)) ;

- SQL> select * from emp where ename > ‘Ulrike’ ;

- German ‘z’ < ‘ä’ . NLS_COMP (dynamic initialization parameter) parameter linguistic comparisons binary default language for the session German setting .

SQL> alter session set nls_dual_currency=eur; Session altered. SQL> select to_char(888, 'U999') from dual ; TO_CHAR(888,'U ---------------------------- EUR888

Page 155: Oracle History #5

[email protected] - 155 -

Oracle8i New Features http://www.ggola.com/

16. Database Security

Password Management

Oracle8 New Features

Scripts $ORACLE_HOME/rdbms/utlpwdmg.sql

Invoker’s Rights

PL/SQL execution user

- Oracle8i version PL/SQL block user PL/SQL user .

- Oracle8i AUTHID DEFINER CURRENT_USER .

- DEFINER default PL/SQL block user CURRENT_USER

block user .

- sample akman user procedure scott user .

Sample procedure and test result

- User ‘akman’ procedure

create or replace procedure inv_t1 (av_tname in varchar2) authid current_user is v_stmt varchar2(40) default 'drop table ' || av_tname ; begin execute immediate v_stmt ; end; / create or replace procedure inv_t2 (av_tname in varchar2) -- definer default . authid definner is is v_stmt varchar2(40) default 'drop table ' || av_tname ; begin

execute immediate v_stmt ; end; /

Page 156: Oracle History #5

[email protected] - 156 -

Oracle8i New Features http://www.ggola.com/

User tracing

- AUTHID PL/SQL block user .

CF. AUTHID CURRENT_USER block user_users query username

.

Security policies

Application security

- application privileges and roles security policy privileges and roles application

.

Application context

- Application context : set up session-based attributes securely. session level , access user information retrieve and store security policy.

Fine-Grained access control

- Find-Grained access control : implement security policies as a low level of granularity.

SQL> sho user USER is “AKMAN” SQL> grant execute on inv_t1 to scott; SQL> grant execute on inv_t2 to scott; SQL> conn scott/tiger SQL> create table emp_test as select * from emp; Table created. SQL> exec akman.inv_t2('emp_test') ; BEGIN akman.inv_t2('emp_test') ; END; * ERROR at line 1: ORA-00942: table or view does not exist ORA-06512: at "AKMAN_T2", line 6 ORA-06512: at line 1

procedure akman error returns SQL> exec akmanager.inv_t1('emp_test') ; PL/SQL procedure successfully completed. SQL> desc emp_test ERROR: ORA-04043: object emp_test does not exist

procedure scott

User ‘AKMAN’ emp_test table .

Procedure inv_t1 ‘AKMAN’

user ‘SCOTT’ drop table

Page 157: Oracle History #5

[email protected] - 157 -

Oracle8i New Features http://www.ggola.com/

Application Context

Features

- Each application can have its own unique context, with different attributes.

order entry application access control customer number, position, and sales region attributes

user , , .

- Application context can provide security in multiple ways. order entry user customer number

valid user application context

.

- Context context implementing “trusted package” .

- within a function implementing a security policy to determine the correct predicate to return

select * from emp application context position different predicates(WHERE clause) return . , manager

data data .

- Context attribute can be used within the predicate itself. , Predicate(as a bind variable) return .

predicate ‘where cust_num = sys_context(‘order_entry’, ‘cust_num’)’ return .

Application Context creation and test

1. application rule . emp table connect user emp ename row access .

2. application context function PL/SQL package

3. application context

4. package context test

CF. Oracle8i . Manual .

Application-specific

Secure

Flexible

Page 158: Oracle History #5

[email protected] - 158 -

Oracle8i New Features http://www.ggola.com/

Example

- context user create any context privilege . (drop drop )

- context package

- context creation and test

SQL> conn system/manager SQL> grant create any context to scott ; SQL> conn scott/tiger Connected. SQL> select * from emp ; EMPNO ENAME JOB MGR HIREDAT SAL COMM DEPTNO ------------------------------------------------------------------------------------------------------------------------- 7369 SCOTT CLERK 7902 17Dec80 800 40 7499 ALLEN SALESMAN 7698 20Feb81 1600 300 30 7521 WARD SALESMAN 7698 22Feb81 1250 500 30 8970 MILLER CLERK 7782 23Jan82 1300 10

9889 CUSTOMER GENERAL 7369 21Jun01 600 200 40

SQL> create or replace package apl_secure_context is procedure set_secure_emp ; end ; / Package created. SQL> create or replace package body apl_secure_context is procedure set_secure_emp is v_empno emp.empno%type ; begin select empno into v_empno from emp where ename = sys_context('USERENV', 'SESSION_USER') ; DBMS_SESSION.SET_CONTEXT('app_emp_context','empno',v_empno); end; end; / Package body created.

SQL> create or replace context app_emp_context using apl_secure_context ; Context created. SQL> select sys_context('USERENV', 'SESSION_USER') USERNAME from dual ; USERNAME --------- SCOTT SQL> exec apl_secure_context.set_secure_emp ; PL/SQL procedure successfully completed. SQL> select sys_context('APP_EMP_CONTEXT', 'EMPNO') EMP_NUMBER from dual ; EMP_NUMBER ---------- 7369

Page 159: Oracle History #5

[email protected] - 159 -

Oracle8i New Features http://www.ggola.com/

Fine-Grained Access control

Fine-grained access control provides a way to extend table-based or view-based security to finer levels of granularity than previously possible.

Merits

- application security data server security

costs . CF. application user data access server fine-grained access control . (Row level security )

- application level security , user security

security .

Features

- table-based or view-based security policies : table or view flexible implementation

salary emp columns emp_view application fine-grained access control application . select, insert, update, and delete .

- Multiple policies per table table policies

logically ‘AND’ .

- Highly scalability application context attributes values parsed bind variable .

parsed optimization .

How it works

- direct or indirect (subquery ) access automatically invokes the policy

- policy package predicate(a where condition) return Database dynamically rewrites the SQL statement by appending the predicate

- dynamically rewrite bind variable re-parsing or re-optimizing .

Page 160: Oracle History #5

[email protected] - 160 -

Oracle8i New Features http://www.ggola.com/

Implementing

- fine-grained access control secure policy application context

.

- fine-grained access control application context application context policy

packages .

- application context fine-grained access control .

CF. DBMS_RLS Package $ORACLE_HOME/rdbms/admin/dbmsrlsa.sql script

.dbms_rls package script . (RLS : Row Level Security Administrative Interface)

Example

- login user sales table select row Row Level Security Policy

1. building application context (optional) application context .

(1) context function package page application context example (2) context page application context example (3) policy data

SQL> conn scott/tiger SQL> grant select on emp to customer ; SQL> grant select on sales to customer ; SQL> select * from emp ; EMPNO ENAME JOB MGR HIREDAT SAL COMM DEPTNO --------------------------------------------------------------------------------------------------------- 9889 CUSTOMER GENERAL 7369 21Jun01 600 200 40 7369 SCOTT CLERK 7902 17Dec80 800 40 7499 ALLEN SALESMAN 7698 20Feb81 1600 300 30 7521 WARD SALESMAN 7698 22Feb81 1250 500 30 8970 MILLER CLERK 7782 23Jan82 1300 10 SQL> select * from sales; EMPNO DEPT ITEM STORE SALES_DATE -------------------------------------------------------------------------------- 9889 40 435 Prince 21Jun01 7369 40 839 Head 17Dec80 7499 30 630 Wilson 20Feb81 7521 30 463 Dunlop 22Feb81 8970 10 693 Unsquahable 23Jan82

Page 161: Oracle History #5

[email protected] - 161 -

Oracle8i New Features http://www.ggola.com/

2. building policy packages

3. associate policy packages with tables and views

SQL> exec dbms_rls.add_policy(‘scott’,’sales’,’sales_policy’,’scott’, ’secure_emp_fgrain.secure_emp_fgrain_fnc', 'select')

CF. line .

4. Test

create or replace package secure_emp_fgrain is function secure_emp_fgrain_fnc(d1 varchar2, d2 varchar2) return varchar2 ; end ; / create or replace package body secure_emp_fgrain is function secure_emp_fgrain_fnc(d1 varchar2, d2 varchar2) return varchar2 is v_predicate varchar2(2000) ; begin apl_secure_context.set_secure_emp ; v_predicate := 'empno = sys_context('APP_EMP_CONTEXT', 'EMPNO')' ; return v_predicate ; end; end; /

SQL> conn scott/tiger SQL> select * from sales; EMPNO DEPT ITEM STORE SALES_DATE --------------------------------------------------------------------- 7369 40 839 Head 17Dec80 SQL> select * from sales where dept=30; no rows selected SQL> conn customer/customer11 SQL> select * from scott.sales ; EMPNO DEPT ITEM STORE SALES_DATE ------------------------------------------------------------------------ 9889 40 435 Prince 21Jun01

SCOTT SALES .

CUSTOMER SALES .

DEPT = 30 POLICY PREDICATE AND

.

Page 162: Oracle History #5

[email protected] - 162 -

Oracle8i New Features http://www.ggola.com/

DBMS_RLS package

- Policy : ADD_POLICY (object_schema, object_name, policy_name, function_schema, function_name, statement_type, [update_check], [enable]) CF. update_check default = ‘FALSE’ (insert or update statement argument ‘TRUE’ insert or update policy check ) enable default = ‘TRUE’

- Policy : DROP_POLICY(object_schema, object_name, policy_name)

- Policy enable, disable : ENABLE_POLICY(object_schema, object_name, policy_name, [enable]) CF. enable default = ‘TRUE’

- Policy Re-parsing : REFRESH_POLICY(object_schema, object_name, policy_name)

Page 163: Oracle History #5

[email protected] - 163 -

Oracle8i New Features http://www.ggola.com/

17. Partial addition for Oracle8i

Constraints

Oracle7 Oracle8 constraints features .

Deferred constraint checking

- constraint constraint not deferrable (default) deferrable initially immediate (default) initially deferred

Oracle7 constraint : constraint check

Oracle8 New features : SQL check using set constraint statement

Oracle8i New features : commit time check

Constraint

- set constraint command : apply only to current transaction SQL> set constraint(s) all/constraint_name deferred/immediate ;

- alter session set constraint command : apply to current session SQL> alter session set constraint(s) = deferred/immediate ;

Example

- default constraint(not deferrable) test

SQL> conn scott/tiger SQL> select * from dept ; DEPTNO DNAME LOC

---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> alter table emp add constraint xfk_emp_dept foreign key (deptno) references dept(deptno) ; SQL> insert into emp (empno, deptno) values (7777, 50) ; ERROR at line 1: ORA-02291: integrity constraint (SCOTT.XFK_EMP_DEPT) violated - parent key not found SQL> set constraint XFK_EMP_DEPT deferred ; ERROR at line 1: ORA-02447: cannot defer a constraint that is not deferrable

Page 164: Oracle History #5

[email protected] - 164 -

Oracle8i New Features http://www.ggola.com/

- deferrable initially immediate test

- deferrable initially deferred test

constraint enable/disable & validate/novalidate

- constraint enable/disable option data check .

- Validate : data check Novalidate : data no-check CF. option default ‘validate’ .

- feature nonunique index Primary or Unique constraint automatic index

.

- , PK or UK constraint disable automatic index drop enable automatic index

rebuild .

SQL> alter table emp drop constraint xfk_emp_dept ; SQL> alter table emp add constraint xfk_emp_dept foreign key (deptno) references dept(deptno) deferrable initially immediate ; SQL> insert into emp (empno, deptno) values (7777, 50) ; ERROR at line 1: ORA-02291: integrity constraint (SCOTT.XFK_EMP_DEPT) violated - parent key not found SQL> set constraint XFK_EMP_DEPT deferred ; SQL> insert into emp (empno, deptno) values (7777, 50) ; 1 row created. SQL> commit ; ERROR at line 1: ORA-02091: transaction rolled back ORA-02291: integrity constraint (SCOTT.XFK_EMP_DEPT) violated - parent key not found

SQL> alter table emp drop constraint xfk_emp_dept ; SQL> alter table emp add constraint xfk_emp_dept foreign key (deptno) references dept(deptno) deferrable initially deferred ; SQL> insert into emp (empno, deptno) values (7777, 50) ; 1 row created. SQL> commit ; ERROR at line 1: ORA-02091: transaction rolled back ORA-02291: integrity constraint (SCOTT.XFK_EMP_DEPT) violated - parent key not found SQL> set constraint XFK_EMP_DEPT immediate ; SQL> insert into emp (empno, deptno) values (7777, 50) ; ERROR at line 1: ORA-02291: integrity constraint (SCOTT.XFK_EMP_DEPT) violated - parent key not found

set constraint command commit check .

Page 165: Oracle History #5

[email protected] - 165 -

Oracle8i New Features http://www.ggola.com/

- FK data .

SQL> conn scott/tiger SQL> select * from dept ; DEPTNO DNAME LOC

---------- -------------- -------------------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> alter table emp drop constraint XFK_EMP_DEPT ; SQL> insert into emp (empno, deptno) values (7777, 50) ; 1 row created. SQL> alter table emp add constraint xfk_emp_dept foreign key (deptno) 2 references dept(deptno) enable novalidate ; Table altered. SQL> insert into emp (empno, deptno) values (7777, 50) ; * ERROR at line 1: ORA-02291: integrity constraint (SCOTT.XFK_EMP_DEPT) violated - parent key not found SQL> alter table emp modify constraint xfk_emp_dept enable validate ; * ERROR at line 1: ORA-02298: cannot validate (SCOTT.XFK_EMP_DEPT) - parent keys not found SQL> alter table emp modify constraint xfk_emp_dept disable validate ; * ERROR at line 1: ORA-02298: cannot validate (SCOTT.XFK_EMP_DEPT) - parent keys not found SQL> alter table emp modify constraint xfk_emp_dept disable novalidate ; Table altered. SQL> insert into emp (empno, deptno) values (7777, 50) ; 1 row created. SQL> alter table emp modify constraint xfk_emp_dept enable validate ; * ERROR at line 1: ORA-02298: cannot validate (SCOTT.XFK_EMP_DEPT) - parent keys not found SQL> alter table emp modify constraint xfk_emp_dept enable novalidate ; Table altered. SQL> delete from emp where deptno = 50 ; 2 rows deleted. SQL> alter table emp modify constraint xfk_emp_dept disable validate ; Table altered. SQL> insert into emp (empno, deptno) values (7777, 50) ; * ERROR at line 1: ORA-25128: No insert/update/delete on table with constraint (SCOTT.XFK_EMP_DEPT) disabled and validated SQL> alter table emp modify constraint xfk_emp_dept enable validate ; Table altered.

DML .

Page 166: Oracle History #5

[email protected] - 166 -

Oracle8i New Features http://www.ggola.com/

- index non-unique index primary key constraint automatic

index index .

- Oracle7 index column PK or UK .

SQL> alter table department add constraint xpkdepartment primary key (deptno) ; SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; CONSTRAINT_NAME STATUS ------------------------------ -------- XPKDEPARTMENT ENABLED SQL> select index_name, status from user_indexes where table_name = 'DEPARTMENT' ; INDEX_NAME STATUS ------------------------------ -------- XPKDEPARTMENT VALID SQL> alter table department modify constraint XPKDEPARTMENT disable ; SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; CONSTRAINT_NAME STATUS ------------------------------ -------- XPKDEPARTMENT DISABLED SQL> select index_name, status from user_indexes where table_name = 'DEPARTMENT' ; no rows selected SQL> alter table department drop constraint xpkdepartment ; SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; no rows selected SQL> create index xnk_dept_loc on department (deptno, loc) ; SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; no rows selected SQL> select index_name, status from user_indexes where table_name = 'DEPARTMENT' ; INDEX_NAME STATUS ------------------------------ -------- XNK_DEPT_LOC VALID SQL> alter table department add constraint xpkdepartment primary key (deptno) ; SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; CONSTRAINT_NAME STATUS ------------------------------ -------- XPKDEPARTMENT ENABLED SQL> select index_name, status from user_indexes where table_name = 'DEPARTMENT' ; INDEX_NAME STATUS ------------------------------ -------- XNK_DEPT_LOC VALID SQL> select * from department ; DEPTNO DNAME LOC

----------- -------------- - ------------ 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON SQL> insert into department values ('40', 'DBA', 'Cyber') ; * ERROR at line 1: ORA-00001: unique constraint (SCOTT.XPKDEPARTMENT) violated

disable constraint command

Page 167: Oracle History #5

[email protected] - 167 -

Oracle8i New Features http://www.ggola.com/

CF. nonunique index unique index PK . , unique index PK

PK disable unique index drop enable PK PK Index . , nonunique index

feature .

SQL> alter table department drop constraint XPKDEPARTMENT ; SQL> insert into department values ('40', 'DBA', 'Cyber') ; 1 row created. SQL> alter table department add constraint xpkdepartment primary key (deptno) ; * ERROR at line 1: ORA-02437: cannot validate (SCOTT.XPKDEPARTMENT) - primary key violated SQL> delete from department where deptno=40 and loc='Cyber' ; 1 row deleted. SQL> alter table department add constraint xpkdepartment primary key (deptno) ; Table altered. SQL> alter table department disable constraint xpkdepartment ; Table altered. SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; CONSTRAINT_NAME STATUS ------------------------------ -------- XPKDEPARTMENT DISABLED SQL> select index_name, status from user_indexes where table_name = 'DEPARTMENT' ; INDEX_NAME STATUS ------------------------------ -------- XNK_DEPT_LOC VALID SQL> alter table department enable constraint xpkdepartment ; Table altered. SQL> select constraint_name, status from user_constraints where table_name = 'DEPARTMENT'; CONSTRAINT_NAME STATUS ------------------------------ -------- XPKDEPARTMENT ENABLED SQL> select index_name, status from user_indexes where table_name = 'DEPARTMENT' ; INDEX_NAME STATUS ------------------------------ -------- XNK_DEPT_LOC VALID

modify constraint disable command .

Page 168: Oracle History #5

[email protected] - 168 -

Oracle8i New Features http://www.ggola.com/

Rely/NoRely Flag

- DBA rely flag DBMS constraint validity check constraint valid

.

- , usually optimizer Materialized View query rewrite validate constraint

query rewrite validate rely flag

constraint query rewrite .

- Restrictions 1. RELY and NORELY are relevant only if you are modifying an existing constraint(that is, you have issued alter table … modify constraint statement.) ==> manual

. Rely option constraint “relevant only if” .

2. Not null constraint .

- rely constraint user_constraints .

SQL> alter table emp modify constraint XFK_EMP_DEPT rely disable - novalidate ; Table altered. SQL> select CONSTRAINT_NAME, STATUS, VALIDATED, RELY

2 from user_constraints where constraint_name = ' XFK_EMP_DEPT ' ;

CONSTRAINT_NAME STATUS VALIDATED RELY ------------------------------ -------- ------------------- ------- XFK_EMP_DEPT DISABLED NOT VALIDATED RELY SQL> alter table emp modify constraint XFK_EMP_DEPT norely enable; Table altered. SQL> select CONSTRAINT_NAME, STATUS, VALIDATED, RELY

from user_constraints where constraint_name = ' XFK_EMP_DEPT ' ; CONSTRAINT_NAME STATUS VALIDATED RELY ------------------------------ -------- ------------------- ------- XFK_EMP_DEPT ENABLED VALIDATED

Page 169: Oracle History #5

[email protected] - 169 -

Oracle8i New Features http://www.ggola.com/

Oracle8i object new features

Oracle8 New Features

MEMBER Method

- method PL/SQL, 3GL(extended pro*c), Package body JAVA .

Dangling REFs

- Oracle8 dangling REF update .

EX) update dept set mgr=NULL where mgr is DANGLING ;

- Oracle8i update command .

EX) analyze table dept validate ref update set dangling to null ;

- dangling REFs does not return an error.

Nested Table Enhancements

- Nested tables may be stored as Index-Organized Tables

- Constraints may be defined on nested tables

- Locators and references can be used to SELECT or perform DML on nested tables.(REF ) A locator returns a pointer to the nested table, not the rows of the table.

Table function for Nested table and VARRAY

- Table function (collection type table )

Insert into ord values (100, line_item_array_type( line_item_type(300, 2300), line_item_type(700, 3300) )) ;

Select o.ord_id, i.prod_id, i.price From ord o, TABLE(o.line_items) I Where i.prod_id in (300, 700) ; Update TABLE( select o.line_items from ord o where ord_id = 100) i Set i.quantity = 100 Where prod_id = 400 ;

Table function nested table elements

DML . Varray PL/SQL procedure

.

Page 170: Oracle History #5

[email protected] - 170 -

Oracle8i New Features http://www.ggola.com/

LOBs

Oracle8 New Features

CF. internal LOB storage CACHE/NOCACHE, LOGGING/NOLOGGING . [CACHE NOLOGGING ]

DBMS_LOB.CREATETEMPORARY (except BFILE type)

- DBMS_LOB.CREATETEMPORARY command user’s temporary tablespace temporary lob

.(except BFILE)

- database LOB data copy application ability design . ( sample )

- Temporary LOB the session, transaction, or call no rollback and no redo logging generated

- In SQL, temporary LOBs may only be used in WHERE clauses, an INSERTed value, or as the assigned value in an UPDATE.

- temporary lob lob data insert .

-- The following example uses a temporary LOB to reverse one of the LOB alues in the table -- and then inserts the reversed LOB as a new row. declare

c_lob CLOB; -- permanent LOB locator t_lob CLOB; -- temporary LOB locator buf varchar2(32000); -- }this example assumes the LOB is buf2 varchar2(32000); -- }less than 32K.

chunk number; len number; offset number; amount number;

begin

select c2 into c_lob from test_lobs where c1 = 1; -- Create a temporary LOB. -- The parameters to CREATETEMPORARY are locator, use caching or not and duration. -- Set no caching and a duration of call -- since the temporary LOB is not required outside of this PL/SQL block. DBMS_LOB.CREATETEMPORARY(t_lob, FALSE, DBMS_LOB.CALL); -- NEW 8i -- Chunk for storing the LOB value. -- Using this amount for reads and writes of the LOB will improve performance.

chunk := DBMS_LOB.GETCHUNKSIZE(c_lob); dbms_output.put_line('Chunksize of column c2 is '||chunk);

dbms_output.put_line('Chunksize of temporary LOB is '|| DBMS_LOB.GETCHUNKSIZE(t_lob));

Page 171: Oracle History #5

[email protected] - 171 -

Oracle8i New Features http://www.ggola.com/

len := DBMS_LOB.GETLENGTH(c_lob); offset := 1;

buf := null;

while offset < len loop if len - (offset-1) > chunk then amount := chunk; else amount := len - (offset-1); end if; buf2 := null; DBMS_LOB.READ(c_lob,amount,offset,buf2); buf := buf||buf2; offset := offset + amount; end loop; --Reverse the read data and write it to the temporary LOB. buf2 := null; for i in reverse 1..len loop buf2 := buf2||substr(buf,i,1); end loop;

-- Write the whole lot in one go. -- Note, if this was a large amount of data then ideally it should be written using the

-- available chunksize of the temporary LOB. DBMS_LOB.WRITEAPPEND(t_lob,len,buf2); -- NEW 8i

-- Now insert a new row into the table setting the CLOB column to the value of the temporary LOB. -- This can be done in one of two ways:

--(i) A new row can be inserted with an empty locator, the locator -- retrieved and the LOB value copied with DBMS_LOB.COPY. --(ii) A new row can be inserted passing the temporary LOB locator -- as a bind variable to the insert. -- --Using the second method: insert into test_lobs values (5,t_lob,null,null) returning c2 into c_lob; --Free the temporary LOB explicitly. if DBMS_LOB.ISTEMPORARY(t_lob) = 1 then DBMS_LOB.FREETEMPORARY(t_lob); end if;

dbms_output.put_line('Length of CLOB inserted into record 5 is '|| DBMS_LOB.GETLENGTH(c_lob)); commit;

end; /

Page 172: Oracle History #5

[email protected] - 172 -

Oracle8i New Features http://www.ggola.com/

Recovery Manager

Oracle8 New Features

Catalog Database

- Oracle8 # sqlplus rmanuser/rmanuser SQL> @$ORACLE_HOME/rdbms/admin/catrman.sql : catalog user . user default tablespace catalog DB

.

- Oracle8i RMAN> create catalog tablespace “TS_RMAN” ; : command catalog DB .

Newly supported command

- RMAN Database startup and shutdown command .

Page 173: Oracle History #5

[email protected] - 173 -

Oracle8i New Features http://www.ggola.com/

Advanced Queuing

Oracle8i new features interface C++ JAVA .

Database Security

- AQ_ADMINSTRATOR_ROLE allows maintain queues in any schema.

- AQ_USER_ROLE user’s schema queues enqueues and dequeues .

- DBMS_AQADM allows the user to maintain AQ objects in their schema only.

- DBMS_AQ allows enqueues and dequeues from queues in user’s schema only.

- Grant(or revoke)_system_privilege in package DBMS_AQADM grant or revoke the ENQUEUE_ANY, DEQUEUE_ANY, MANAGE_ANY privileges .

- Grant(or revoke)_queue_privilege in package DBMS_AQADM grant or revoke the ENQUEUE_ANY, DEQUEUE_ANY, ALL privileges on individual queues .

Oracle Enterprise Manager V2

Oracle Enterprise Edition OEM free-of-charge DBA management pack .

New architecture

- 2-tier , fat client Oracle Management Server 3-tier distributed architecture .

- Java console administration application platform . client JAVA console – middle tier OMS – server Oracle through agent

- OMS a set of database tables repository Multiple system .