This action might not be possible to undo. Are you sure you want to continue?
BC0050 – Oracle & Distributed Databases – 4 Credits (Book ID: B0894)
Assignment Set – 1 (40 Marks)
Answer all the questions 4 x 10 = 40 1. Write a PL/SQL code for find Sum of N numbers using WHILE Loop set serveroutput on; declare n number := &n; a number ; b number ; begin a := 1; b := 0; while(a <= n) loop b := b + a; a := a+1; end loop; dbms_output.put_line('sum ofnatural numbers'||b); end; 2. Differentiate between PL/SQL functions and procedures. 1. Function is mainly used in the case where it must return a value. Where as a procedure may or may not return a value or may return more than one value using the OUT parameter. 2. Function can be called from SQL statements where as procedure can not be called from the sql statements 3. Functions are normally used for computations where as procedures are normally used for executing business logic. 4. You can have DML (insert update delete) statements in a function. But you cannot call such a function in a SQL query 5. Function returns 1 value only. Procedure can return multiple values (max 1024). 6. Stored Procedure : supports deferred name resolution. Example while writing a stored procedure that uses table named tabl1 and tabl2 etc.. but actually not exists in database is allowed only in during creation but runtime
1 displays the architecture of the Oracle Database 9i. The Oracle server consists of physical files and memory components. Stored procedure is precompiled execution plan where as functions are not. structures. 3. 3. The Oracle database – This is the centralized repository where the data is stored. 2. The figure 3. It has a physical structure that is visible to the Operating system made up of operating system files and a logical structure that is recognized only the Oracle Server. It is broadly divided into the memory components which form the Oracle instance and the physical database components where different kinds of data are stored. Stored procedure returns always integer value by default zero. manage and manipulate data. Draw a diagram of oracle architecture and explain it briefly. processes that form Oracle Database 9i. 9.throws error Function wont support deferred name resolution. The Oracle 9i Database product is made up three main components namely: 1. It consists of all the files. The Oracle server is made up of an Oracle instance and an Oracle database. Page 2 . The Oracle Instance – Consists of the memory components of Oracle and various background processes. A procedure may modify an object where a function can only return a value The RETURN statement immediately completes the execution of a subprogram and returns control to the caller. 7. The Oracle Server – This is the Oracle database management system that is able to store. where as function return type could be scalar or table or table values 8.
Page 3 . Draw the diagram of logical structure of oracle database and explain it in brief.4. Fig below shows the logical structure of oracle database.
Thecombined size of the datafiles in a tablespace is the total storage capacity of the tablespace. and retrieve dataefficiently and quickly. Logical structure mainly consists of tablespace.extents.segments. Page 4 . SEGMENT A segment is a set of extents allocated for a certain logical structure. One or more datafiles are explicitlycreated for each tablespace to physically store the data of all logical structures in a tablespace.The Oracle database is divided into increasingly smaller logical units to manage. index segment. store. temporary segment. rollback segment. andoracle data blocks TABLESPACE Each database is logically divided into one or more tablespaces . The figure shows the relationships between the logical structures of the database. The segments can be of one of following type data segment.
and used to store a specific type of information. One data blockcorresponds to a specific number of bytes of physical database space on disk. you can specify up to five otherblock sizes Page 5 . Oracle database data is stored in data blocks. obtained in a single allocation. In addition. ORACLE DATABLOCKS At the finest level of granularity. The standard block size isspecified by the DB_BLOCK_SIZE initialization parameter. An extent is a specific number of contiguous datablocks.EXTENT The next level of logical database space is an extent.
• The resource time of the query. It is the some of all times incurred in processing the operations of the query at various sites and intrinsic communication. and communication costs. while still guaranteeing. Not all features listed below are necessarily supported by your Heterogeneous Services agent or Oracle Gateway. Discuss the Features of the Heterogeneous Services. Because many execution strategiesare correct transformations of the same high-level query. • In a distributed system. 1. Since operations can be executed in parallel at different sites. the total cost to be minimized includes CPU.· Obviously the total cost should be minimized.· An important point of query processing is query optimization.December 2011 Bachelor of Computer Application (BCA) – Semester 4 BC0050 – Oracle & Distributed Databases – 4 Credits (Book ID: B0894) Assignment Set – 2 (40 Marks) Answer all the questions 4 x 10 = 40 1. These costs can be minimized by reducing the number of I/O operations through fast access methods to the data and efficient use of main memory. that changes are either all committed or all rolled back. The communication cost is the time needed for exchanging the data between sites participating in the execution of the query. only CPU and I/O cost have to be considered 2. which is seen as a single database by the users. Page 1 . the one that optimizes (minimizes)resource consumption should be retained. • In centralized systems. I/O. The main objectives of query processing in a distributed environment is to form a high levelquery on a distributed database. Distributed Transactions : A transaction can span both Oracle and nonOracle systems. the response time of a query may be significantly less than its cost. into an efficientexecution strategy expressed in a low level language on local databases. This is the time elapsed for executing the query. The following are the features of Heterogeneous Services.· The good measures of resource consumption are: • The total cost that will be incurred in processing the query. Discuss the objectives of Query Processing. through Oracle’s two phase commit mechanism.
Each agent can issue begin_transaction. 10. Agent Self-Registration : Agent self-registration automates the process of updating Heterogeneous Services configuration data on remote hosts. and abort primitives to its LTM. are accessedfrom an Oracle9i server using PL/SQL remote procedure calls. Now let us consider recovery problems in distributed databases. 9. let us assume that at each site a Local Transaction Manager is available. Thus. let us first analyze about the different kinds of failure that can occur in a centralized database. Transparent SQL access : Integrate data from non-Oracle systems into the Oracle environment as if the data is stored in one single. ensuring correct operation over heterogeneous database links. commit. 5. Management Interface : Provides a graphic representation of active Heterogeneous Services agents and of which user sessions are accessing those agents. local database. Data Dictionary translations : To make the non-Oracle system appear as another Oracle server. Accessing stored procedures : Stored procedures in SQL-based nonOracle systems are accessed as if they were PL/SQL remote procedures. 7. Explain the steps involved in recovery of distributed transactions. SQL statements containing references to Oracle's data dictionary tables are transformed into SQL statements containing references to a non-Oracle system’s data dictionary tables.2. and translate character sets between a non-Oracle system and the Oracle9i server. 6. 3. National Language Support : Heterogeneous Services supports multi-byte character sets. 8. like messaging and queuing systems. Procedural Access : Procedural systems. application programmers can directly access a non-Oracle system from an Oracle application using the non-Oracle system’s SQL dialect. The issue of recovery mechanism is important in the case of revoking the system to perform normal database operations after a failure. Page 2 . Pass-through SQL : Optionally. For this purpose. before discussing about recovery. Multi-threaded agents reduce the number of required processes by taking advantage of multi-threaded server capabilities. 4. SQL statements issued by the application are transparently transformed into SQL statement understood by the non-Oracle system 3. Multi-Threaded Agents : Multi-threaded agents take advantage of your operating system's threading capabilities.
and abort primitives of the distributed transaction from the local primitives issued by each agent to its LTM. In order to make sure that either all actions of a distributed transaction are performed or none is performed at all. Also to distinguish the begin_transaction. We will call an agent that has issued a begin_transaction primitive to its local transaction manager a Sub-transaction. two conditions are necessary: At each site either all actions are performed or none is performed All sites must take the same decision with respect to the commitment or abort of sub transaction. Page 3 . as some additional information must also be recorded in such away that they can be recovered in case of failure. For building a Distributed Transaction Manager (DTM). and local_abort. local_commit. commit.After having issued a begin_transaction to its LTM. an agent will possess the properties of a local transaction. the following properties are expected from the LTM: Ensuring the atomicity of sub-transaction Writing some records on stable storage on behalf of the distributed transaction manager We need the second requirement. we will call the later as local_begin.
so that the new agent is created as a Subtransaction. The example of FUND TRANSFER is taken for explaining this concept. Commit: The implementation of the commit primitive is the most difficult and expensive. Page 4 . Abort: When an abort is issued by the root agent. Issuing local_aborts to the LTMs at all sites where there is an active sub transaction performs this. The main difficulty originates from the fact that the correct commitment of a distributed transaction requires that al sub-transactions commit locally even if there are failures. thus transforming all agents into sub-transactions. DTM will have to issue a local_begin primitive to the LTM at the site of origin and all the sites at which there are already active agents of the same application. from this time on the activation of a new agent by the same distributed transaction requires that the local_begin be issued to the LTM where the agent is activated. The fig 8.Begin_transaction: When it is issued by the root agent.1 explains this. all existing sub-transactions must be aborted.
It is discussed in detail in the next section. the statement is rolled back. Transaction Time-Out A DML SQL statement that requires locks on a remote database may be blocked from doing so if another transaction (distributed or non-distributed) currently own locks on the requested data. and the following error message is returned to the user: ORA-02049: time-out: distributed transaction waiting for lock Because no data has been modified. Oracle9i attempts to lock the required resources to successfully execute the statement. a time-out occurs. Failures that Prevent Data Access When a user issues a SQL statement. The user who executed the statement can try to re-execute the statement later. Lock From In-Doubt Transaction A query or DML statement that requires locks on a local database may be Page 5 . no actions are necessary as a result of the timeout. Applications should proceed as if a deadlock has been encountered. Failures that Interrupt Two-Phase Commit The user program that commits a distributed transaction is informed of a problem by one of the following error messages: A robust application should save information about a transaction if it receives any of the above errors. if the network is down for a long time). If the lock persists. a time-out occurs. What are the different Troubleshooting problems in Distributed Transaction? 4. If a failure persists (for example. the data exclusively locked by in-doubt transactions is unavailable to statements of other transactions. A network or system failure can cause the following types of problems: A two-phase commit being processed when a failure occurs may not be completed at all nodes of the session tree. if the requested data is currently being held by statements of other uncommitted transactions and continues to remain locked for an excessive amount of time. However. If these locks continue to block the requesting SQL statement. This information can be used later if manual distributed transaction recovery is desired. the user should contact an administrator to report the problem. the general idea of 2-Phase commit Protocol has been developed.In order to implement this primitive for a distributed transaction. The following sections describe these situations.
• An in-doubt transaction prevents the extents of a rollback segment to be used by other transactions. the SQL statement is rolled back immediately. In this case. a specific in-doubt transaction should be manually overridden only when the following situations exist: • The in-doubt transaction locks data that is required by other transactions. Page 6 .blocked from doing so indefinitely due to the locked resources of an in-doubt distributed transaction. Manually Overriding In-Doubt Transactions A database administrator can manually force the COMMIT or ROLLBACK of a local in-doubt distributed transaction. If the lock persists. the user should contact an administrator to report the problem. the following error message is immediately returned to the user: In this case. However. The user who executed the statement can try to re-execute the statement later. • The failure that did not allow the two-phase commit phases to complete will not be corrected in an acceptable time period. including the ID of the indoubt distributed transaction.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.