Application development in a distributed system raises issues that are not applicable in a non-distributed system. This section contains the following topics relevant for distributed application development:
See Also:Chapter 31, "Developing Applications for a Distributed Database System" to learn how to develop applications for distributed systems
With minimal effort, you can develop applications that make an Oracle Database distributed database system transparent to users that work with the system. The goal of transparency is to make a distributed database system appear as though it is a single Oracle Database. Consequently, the system does not burden developers and users of the system with complexities that would otherwise make distributed database application development challenging and detract from user productivity.
The following sections explain more about transparency in a distributed database system.
An Oracle Database distributed database system has features that allow application developers and administrators to hide the physical location of database objects from applications and users. Location transparency exists when a user can universally refer to a database object such as a table, regardless of the node to which an application connects. Location transparency has several benefits, including:
Access to remote data is simple, because database users do not need to know the physical location of database objects.
Administrators can move database objects with no impact on end-users or existing database applications.
Typically, administrators and developers use synonyms to establish location transparency for the tables and supporting objects in an application schema. For example, the following statements create synonyms in a database for tables in another, remote database.
CREATE PUBLIC SYNONYM emp FOR email@example.com_auto.com; CREATE PUBLIC SYNONYM dept FOR firstname.lastname@example.org_auto.com;
Now, rather than access the remote tables with a query such as:
SELECT ename, dname FROM email@example.com_auto.com e, firstname.lastname@example.org_auto.com d WHERE e.deptno = d.deptno;
An application can issue a much simpler query that does not have to account for the location of the remote tables.
SELECT ename, dname FROM emp e, dept d WHERE e.deptno = d.deptno;
In addition to synonyms, developers can also use views and stored procedures to establish location transparency for applications that work in a distributed database system.
The Oracle Database distributed database architecture also provides query, update, and transaction transparency. For example, standard SQL statements such as
DELETE work just as they do in a non-distributed database environment. Additionally, applications control transactions using the standard SQL statements
ROLLBACK. There is no requirement for complex programming or other special operations to provide distributed transaction control.
The statements in a single transaction can reference any number of local or remote tables.
The database guarantees that all nodes involved in a distributed transaction take the same action: they either all commit or all roll back the transaction.
If a network or system failure occurs during the commit of a distributed transaction, the transaction is automatically and transparently resolved globally. Specifically, when the network or system is restored, the nodes either all commit or all roll back the transaction.
Internal to the database, each committed transaction has an associated system change number (SCN) to uniquely identify the changes made by the statements within that transaction. In a distributed database, the SCNs of communicating nodes are coordinated when:
A connection is established using the path described by one or more database links.
A distributed SQL statement is executed.
A distributed transaction is committed.
Among other benefits, the coordination of SCNs among the nodes of a distributed database system allows global distributed read-consistency at both the statement and transaction level. If necessary, global distributed time-based recovery can also be completed.
The database also provide many features to transparently replicate data among the nodes of the system. For more information about Oracle Database replication features, see Oracle Database Advanced Replication.
Developers can code PL/SQL packages and procedures to support applications that work with a distributed database. Applications can make local procedure calls to perform work at the local database and remote procedure calls (RPCs) to perform work at a remote database.
When a program calls a remote procedure, the local server passes all procedure parameters to the remote server in the call. For example, the following PL/SQL program unit calls the packaged procedure
del_emp located at the remote
sales database and passes it the parameter 1257:
BEGIN email@example.com_auto.com(1257); END;
In order for the RPC to succeed, the called procedure must exist at the remote site, and the user being connected to must have the proper privileges to execute the procedure.
When developing packages and procedures for distributed database systems, developers must code with an understanding of what program units should do at remote locations, and how to return the results to a calling application.
Distributed query optimization is an Oracle Database feature that reduces the amount of data transfer required between sites when a transaction retrieves data from remote tables referenced in a distributed SQL statement.
Distributed query optimization uses cost-based optimization to find or generate SQL expressions that extract only the necessary data from remote tables, process that data at a remote site or sometimes at the local site, and send the results to the local site for final processing. This operation reduces the amount of required data transfer when compared to the time it takes to transfer all the table data to the local site for processing.
Using various cost-based optimizer hints such as
INDEX, you can control where Oracle Database processes the data and how it accesses the data.
See Also:"Using Cost-Based Optimization" for more information about cost-based optimization