Oracle 8 Database Administration volume 2 instruction guide phần 4 potx

34 257 0
Oracle 8 Database Administration volume 2 instruction guide phần 4 potx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Oracle8: Database Administration 15-23 . Retrieving Information About Clusters Note If you need to use a join on three or more data dictionary views it may be preferable to use temporary tables based on the views and then use the tables in a join. 15-24 Oracle8: Database Administration . Lesson 15: Using Clusters and Index-Organized Tables Index-Organized Tables Storage Structure An index-organized table keeps all data for a table within a B-tree structure. The B-tree index, which is based on the primary key of the table, is organized like an index. The leaf blocks in this structure contain the nonkey columns, instead of the ROWID, as the second element of the index leaf entry. Therefore, the use of an index-organized table eliminates the need to have two separate segments, the table and the index. Accessing an Index-Organized Table Index access to a regular table requires that one or more index blocks are read to retrieve the ROWID and the I/O on the table based on the ROWID. In contrast, reading an index-organized table requires only index block reads because the whole row is available in the leaf node. An index-organized table can be accessed using either the primary key or a combination of columns that constitute the leading part of the primary key. Changes to the table data, such as adding new rows, updating rows, or deleting rows, result only in updating the index. 15-15 Copyright  Oracle Corporation, 1998. All rights reserved. Indexed access on table ROWID Index-Organized Tables Accessing index- organized table Non-key columns Key column Row header Oracle8: Database Administration 15-25 . Index-Organized Tables An index-organized table differs from a regular table in the following respects: • ROWID can uniquely identify a row in a regular table, while the rows in an index-organized table are identified by their primary key. • A regular table can have many indexes that store the ROWID corresponding to the index key values. Because an index-organized table has no ROWID, secondary indexes cannot be created on this type of table. Any SQL statement that attempts to retrieve the ROWID of an index-organized table receives the following error: ORA-02031: no ROWID for fixed tables or for index-organized tables • When a full table scan is made on a regular table, the order in which rows are returned is unpredictable. Full scans on an index-organized table return rows in a primary key sequence. • An index-organized table supports all constraints except unique constraints. • An index-organized table cannot participate in a distributed transaction. It cannot be partitioned or replicated. 15-16 Copyright  Oracle Corporation, 1998. All rights reserved. Index-Organized Table Identified by primary key No ROWID No secondary indexes Full index scans return rows in PK order No support for unique constraints Distribution, replication, and partitioning not supported Index-Organized Tables Compared with Regular Tables Regular Table Unique identifier—ROWID ROWID implicit Supports several indexes FTS returns rows in no specific order Unique constraints allowed Distribution, replication, and partitioning supported 15-26 Oracle8: Database Administration . Lesson 15: Using Clusters and Index-Organized Tables Using Index-Organized Tables An index-organized table is useful for: • Information retrieval applications • Spatial applications • Online analytical processing (OLAP) applications Index organization is useful for a table that is frequently accessed using the primary key and has only a few, relatively short nonkey columns. Syntax Use the following command to define an index-organized table: CREATE TABLE [ schema. ] table (column-definition [, column-definition ] [, out-of-line-constraint [, out-of-line-constraint ] ] ) ORGANIZATION INDEX [ PCTFREE integer ] [ INITRANS integer ] [ MAXTRANS integer ] [ storage-clause ] [ TABLESPACE tablespace ] [ PCTTHRESHOLD integer [ INCLUDING column ] ] [ OVERFLOW segment_attributes_clause ] 15-17 Copyright  Oracle Corporation, 1998. All rights reserved. Creating Index-Organized Tables CREATE TABLE scott.sales ( office_cd NUMBER(3), qtr_end DATE, revenue NUMBER(10,2), review VARCHAR2(1000), CONSTRAINT sales_pk PRIMARY KEY(office_code, qtr_end)) ORGANIZATION INDEX TABLESPACE data01 PCTTHRESHOLD 20 OVERFLOW TABLESPACE data02; Oracle8: Database Administration 15-27 . Using Index-Organized Tables where: schema is the owner of the cluster table is the name of the table ORGANIZATION INDEX specifies that it is an index-organized table PCTTHRESHOLD specifies the percentage of space reserved in the index block for an index-organized table row (If a row exceeds the size calculated based on this value, all columns after the column named in the INCLUDING clause are moved to the overflow segment. If OVERFLOW is not specified, then rows exceeding the threshold are rejected. PCTTHRESHOLD defaults to 50 and must be a value from 0 to 50.) INCLUDING column specifies a column at which to divide an index-organized table row into index and overflow portions (All columns that follow column are stored in the overflow data segment. If this is not specified and a row size exceeds PCTTHRESHOLD, all columns except the primary key columns will be moved to the overflow area. The column is either the name of the last primarykeycolumnoranynonprimarykey column.) OVERFLOW specifies that index-organized table data rows exceeding the specified threshold are placed in the data segment defined by segment_attributes_clause, which specifies the tablespace, storage, and block utilization parameters 15-28 Oracle8: Database Administration . Lesson 15: Using Clusters and Index-Organized Tables Restrictions A primary key must be specified for an index-organized table. If an attempt is made to create an index-organized table without the primary key, the following error is generated: ORA-25175: no PRIMARY KEY constraint found If PCTTHRESHOLD is defined and an overflow segment is not specified, rows exceeding the threshold are rejected with the following error: ORA-01429: Index-Organized Table: no data segment to store overflow row-pieces Oracle8: Database Administration 15-29 . Using Index-Organized Tables A large row in an index-organized table might destroy the dense storage of rows in the index. This problem is overcome by the use of an overflow area. Segments Created for an Index-Organized Table When an index-organized table is created specifying the OVERFLOW clause, the following are created: • A “logical” table with the name defined in the CREATE TABLE clause. Because all the rows are stored in the index, there is no segment that corresponds to this table. • An index with the same name as the primary key constraint, in the tablespace defined in the CREATE TABLE statement, using the storage and block utilization parameters specified. • A table to accommodate the overflow row pieces. The name of this table is SYS_IOT_OVER_n, where n is the OBJECT_ID of the index- organized table as seen from DBA_OBJECTS. 15-18 Copyright  Oracle Corporation, 1998. All rights reserved. Row Overflow Segment = PK Name Type = Index Segment = SYS_IOT_OVER_n Type=Table Row bigger than PCTTHRESHOLD Block Rows within PCTTHRESHOLD IOT tablespace Overflow tablespace 15-30 Oracle8: Database Administration . Lesson 15: Using Clusters and Index-Organized Tables Index-Organized Table Operations An index-organized table can be used like any other table. All the commands, such as ALTER TABLE, ANALYZE TABLE, TRUNCATE TABLE, and DROP TABLE, and all the DML commands, are supported against an index-organized table. Oracle8: Database Administration 15-31 . Retrieving Information About Index-Organized Tables Retrieving Information About Index-Organized Tables Use the following query to list the index-organized tables and information related to their structure: SVRMGR> SELECT t.table_name AS "IOT", o.table_name AS "Overflow", 2> i.index_name AS "Index", 3> o.tablespace_name AS "Overflow TS", 4> i.tablespace_name AS "Index TS", i.pct_threshold 5> FROM dba_tables t, dba_tables o, dba_indexes i 6> WHERE t.owner=o.owner 7> AND t.table_name = o.iot_name 8> AND t.owner = i.owner 9> AND t.table_name = i.table_name 10> AND t.owner= 'SCOTT'; IOT Overflow Index Overflow TS Index TS PCT_THRESHOLD SALES SYS_IOT_OVER_2049 SALES_PK DATA02 DATA01 20 15-19 Copyright  Oracle Corporation, 1998. All rights reserved. Retrieving IOT Information from Data Dictionary DBA_INDEXES OWNER TABLE_NAME INDEX_NAME INDEX_TYPE PCT_THRESHOLD INCLUDE_COLUMN DBA_TABLES OWNER TABLE_NAME IOT_TYPE IOT_NAME TABLESPACE_NAME 15-32 Oracle8: Database Administration . Lesson 15: Using Clusters and Index-Organized Tables Summary 15-20 Copyright  Oracle Corporation, 1998. All rights reserved. Summary • Identifying situations where clusters are useful • Using index-organized tables [...]... Oracle8 : Database Administration 15-33 Lesson 15: Using Clusters and Index-Organized Tables 15- 34 Oracle8 : Database Administration 16 Loading and Reorganizing Data Lesson 16: Loading and Reorganizing Data Instructor Note Topic Lecture Timing 75 minutes Practice 45 minutes Total 120 minutes 16 -2 Oracle8 : Database Administration. .. Loading data into Oracle tables using SQL*Loader conventional and direct paths • Reorganizing data using export and import 16 -2 Copyright © Oracle Corporation, 19 98 All rights reserved Oracle8 : Database Administration 16-3 Lesson 16: Loading and Reorganizing Data Overview Overview Other applications SQL*Loader Export Oracle database Import Oracle database 16-3 Direct-load... the $ORACLE_ HOME/rdbms/demo and %ORACLE_ HOME%\RDBMS80\LOADER directories on UNIX and Windows NT, respectively The chapter “SQL*Loader Case Studies” in the manual Oracle8 Server Utilities explains these cases in detail • Complete details of control file commands can be found in the chapter “SQL*Loader Control File Reference” in the manual Oracle8 Server Utilities Oracle8 : Database Administration. .. to load data from external files into Oracle tables It provides a means of migration from other systems to Oracle 16 -4 Oracle8 : Database Administration Overview Export and Import Utilities Export utility enables users to extract dictionary information and data from an Oracle database and move them into an operating system file in Oracle- binary format The files generated... Oracle8 Server Utilities Oracle8 : Database Administration 16-19 Lesson 16: Loading and Reorganizing Data SQL*Loader: Input Files • Parameter file – Load options • Data file – Input records • Control file LOAD DATA INFILE 'ulcase6.dat’ INSERT INTO TABLE emp (empno POSITION(01: 04) INTEGER EXTERNAL NULLIF empno=BLANKS, ) 16-11 Copyright © Oracle Corporation, 19 98. .. transaction • For a detailed discussion of parallel direct-load inserts, see the chapter “Parallel Execution” in Oracle8 Server Reference manual Instructor Note You can demonstrate the use of parallel direct-load insert using the scripts dli_set.sql and dli_par.sql 16 -8 Oracle8 : Database Administration Loading Data Using SQL*Loader Loading Data Using SQL*Loader SQL*Loader... direct load sessions are used concurrently Parallel direct loads are discussed in the following section 16- 14 Oracle8 : Database Administration Loading Data Using SQL*Loader Parallel Direct Loads Temporary segments load1.dat load1.ctl load2.dat load2.ctl load3.dat load3.ctl Table AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA... command on Windows NT to perform the data load: SQLLDR80 [keyword=] value [[[,] keyword=] value] Oracle8 : Database Administration 16-17 Lesson 16: Loading and Reorganizing Data OEM 1 Use Data Manager 2 Select Data—>Load 3 Enter machine name and control filename on the Introductions page of the Data Manager Wizard 4 Enter names of other files on the Optional Files page... system file in Oracle- binary format The files generated by export can be read by the Import utility into the same Oracle database or a different database The Export and Import utilities have several uses that will be discussed in a subsequent section in this lesson Oracle8 : Database Administration 16-5 Lesson 16: Loading and Reorganizing Data Loading Data Using Direct-Load... refer interested participants to the lesson “Optimization Modes and Hints” in the manual Oracle8 Server Tuning Oracle8 : Database Administration 16-7 Lesson 16: Loading and Reorganizing Data Parallel Direct-Load Insert ALTER SESSION ENABLE PARALLEL DML; INSERT /*+PARALLEL(scott.emp ,2) */ INTO scott.emp NOLOGGING SELECT * FROM scott.old_emp; Slave process Slave process . ORGANIZATION INDEX 15- 34 Oracle8 : Database Administration . Lesson 15: Using Clusters and Index-Organized Tables 16 Loading and Reorganizing Data 16 -2 Oracle8 : Database Administration . Lesson. Timing Lecture 75 minutes Practice 45 minutes Total 120 minutes Oracle8 : Database Administration 16-3 . Objectives Objectives 16 -2 Copyright  Oracle Corporation, 19 98. All rights reserved. Objectives •. IOT_TYPE IOT_NAME TABLESPACE_NAME 15- 32 Oracle8 : Database Administration . Lesson 15: Using Clusters and Index-Organized Tables Summary 15 -20 Copyright  Oracle Corporation, 19 98. All rights reserved. Summary •

Ngày đăng: 08/08/2014, 20:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan