Segments
Part III
Tables A table can be created with data or with no data or with partitions or with no partitions. The basic to determine what should be design of table you want to create depends on (1)
The nature of the data you want to store in that table. Depending on the nature of the data stored in the tables we can have the following tables
Depending upon the nature of the activity on those tables, they are defined as under:
Naming Conventions It is good to have naming conventions for the tables. Other wise they tend to loose readability and understanding the design of the database. Oracle suggested so many conventions and the naming conventions can be observed by looking at Data Dictionary Objects.
Space Management in an Oracle Block (source figure from Oracle Documentation) Storage parameters for the segment (source from Oracle Documentation)
On Resumable Transactions and Their Management Oracle Says as Under: Oracle provides a means for suspending, and later resuming, the execution of large database operations in the event of space allocation failures. This enables you to take corrective action instead of the Oracle database server returning an error to the user. After the error condition is corrected, the suspended operation automatically resumes. This feature is called resumable space allocation. The statements that are affected are called resumable statements. How Resumable Statements Work??? The following is an overview of how resumable statements work. Details are contained in later sections. A
statement executes in a resumable mode only when the client explicitly
enables resumable semantics for the session using the ALTER SESSION statement.
Maximum
extents reached condition The error is reported in the alert log. If the user registered a trigger on the AFTER SUSPEND system event, the user trigger is executed. A user supplied PL/SQL procedure can access the error message data using the DBMS_RESUMABLE package and DBA/USER_RESUMABLE view. Suspending a statement automatically results in suspending the transaction. Thus all transactional resources are held through a statement suspend and resume. When the error condition disappears (for example, as a result of user intervention or perhaps sort space released by other queries), the suspended statement automatically resumes execution. A suspended statement can be forced to throw the exception using the DBMS_RESUMABLE.ABORT() procedure. This procedure can be called by a DBA, or by the user who issued the statement. A suspension time out interval is associated with resumable statements. A resumable statement that is suspended for the timeout interval (the default is two hours) wakes up and returns the exception to the user. A resumable statement can be suspended and resumed multiple times during execution. What Operations are Resumable? Resumable space allocation is fully supported when using locally managed tablespaces. There are certain limitations when using dictionary-managed tablespaces The following operations are resumable: Queries SELECT statements that run out of temporary space (for sort areas) are candidates for resumable execution. When using OCI, the calls LNOCIStmtExecute() and LNOCIStmtFetch() are candidates. DML INSERT, UPDATE, and DELETE statements are candidates. The interface used to execute them does not matter; it can be OCI, JSQL, PL/SQL, or another interface. Also, INSERT INTO ... SELECT from external tables can be resumable. Import/Export As for SQL*Loader, a command line parameter controls whether statements are resumable after recoverable errors. DDL The following statements are candidates for resumable execution: CREATE
TABLE ... AS SELECT What Errors are Correctable? There are three classes of correctable errors: Out of space condition The operation cannot acquire any more extents for a table/index/temporary segment/rollback segment/undo segment/cluster/LOB/table partition/index partition in a tablespace. For example, the following errors fall in this category: ORA-1650
unable to extend rollback segment ... in tablespace ...
The number of extents in a table/index/temporary segment/rollback segment/undo segment/cluster/LOB/table partition/index partition equals the maximum extents defined on the object. For example, the following errors fall in this category: ORA-1628
max # extents ... reached for rollback segment ...
The user has exceeded his assigned space quota in the tablespace. Specifically, this is noted by the following error: ORA-1536 space quote exceeded for tablespace string
If a DDL operation such as CREATE TABLE or CREATE INDEX is executed with an explicit MAXEXTENTS setting which causes an out of space error during its execution, the operation will not be suspended. Instead, it will be aborted. This error is treated as not repairable because the properties of an object (for example, MAXEXTENTS) cannot be altered before its creation. However if a DML operation causes an already existing table or index to reach the MAXEXTENTS limit, it will be suspended and can be resumed later. This restriction can be overcome either by setting the MAXEXTENTS clause to UNLIMITED or by using locally managed tablespaces. If rollback segments are located in dictionary-managed tablespaces, then space allocation for rollback segments is not resumable. However, space allocation for user objects(tables, indexes, and the likes) would still be resumable. To workaround the limitation, we recommend using automatic undo management or placing the rollback segments in locally managed tablespaces. Resumable Statements and Distributed Operations Remote operations are not supported in resumable mode. Parallel Execution and Resumable Statements In parallel execution, if one of the parallel execution server processes encounters a correctable error, that server process suspends its execution. Other parallel execution server processes will continue executing their respective tasks, until either they encounter an error or are blocked (directly or indirectly) by the suspended server process. When the correctable error is resolved, the suspended process resumes execution and the parallel operation continues execution. If the suspended operation is terminated, the parallel operation aborts, throwing the error to the user. Different parallel execution server processes may encounter one or more correctable errors. This may result in firing an AFTER SUSPEND trigger multiple times, in parallel. Also, if a parallel execution server process encounters a non-correctable error while another parallel execution server process is suspended, the suspended statement is immediately aborted. For parallel execution, every parallel execution coordinator and server process has its own entry in DBA/USER_RESUMABLE view. Enabling
and Disabling Resumable Space Allocation To enable resumable mode for a session, use the following SQL statement: ALTER SESSION ENABLE RESUMABLE;
To disable resumable mode, issue the following statement: ALTER SESSION DISABLE RESUMABLE;
You can also specify a timeout interval, and you can provide a name used to identify a resumable statement. These are discussed separately in following sections. Specifying a Timeout Interval When you enable resumable mode for a session, you can also specify a timeout interval, after which a suspended statement will error if no intervention has taken place. The following statement specifies that resumable transactions will time out and error after 3600 seconds: ALTER SESSION ENABLE RESUMABLE TIMEOUT 3600;
Naming
Resumable Statements ALTER SESSION ENABLE RESUMABLE TIMEOUT 3600 NAME 'insert into table';
User USERNAME (USERID), Session SESSIONID, Instance INSTANCEID The name of the statement is used to identify the resumable statement in the DBA_RESUMABLE and USER_RESUMABLE views. Setting Default Resumable Mode To set default resumable mode, a DBA can register a database level LOGON trigger to alter a user's session to enable resumable and set a timeout interval. Changing
the Timeout Interval The DBMS_RESUMABLE package contains procedures for setting the timeout period for a specific session or for the current session. A DBA can change the default system timeout by creating a system wide AFTER SUSPEND trigger that calls DBMS_RESUMABLE to set it. For example, the following code sample sets a system wide default timeout to one hour: CREATE
OR REPLACE TRIGGER resumable_default_timeout PARTITIONING OF TABLES Oracle first provided an opportunity to stripe the files across disks to create tablespaces to balance the IO. From 8i onwards it allowed the users to create a segments to be partitioned and assigned to a tablespace that can have associated data files across the disks. The partitioning is introduced to gain from better performance. If the segment is a large segment and the data to be accessed for a given query is very limited then we need to access that data only. To enable the user to access that piece of data, the partitioning concept works. Here the user has to identify the key for partitioning. The key should be the best key. Otherwise he cannot blame Oracle for no performance gains. Partitioning can be done based on ranges, hash and list and composite partitioning with a mix where sub-partitioning is allowed.
|