Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

Syntax for Schema Objects and Parts in SQL Statements

Oracle always determines the username and password from the first matching database link (either private or public). If the first matching database link has an associated username and password, then Oracle uses it. If it does not have an associated username and password, then Oracle uses your current username and password.

If the first matching database link has an associated database string, then Oracle uses it. Otherwise Oracle searches for the next matching (public) database link. If no matching database link is found, or if no matching link has an associated database string, then Oracle returns an error.

3.Oracle uses the database string to access the remote database. After accessing the remote database, if the value of the GLOBAL_NAMES parameter is true, then Oracle verifies that the database.domain portion of the database link name matches the complete global name of the remote database. If this condition is true, then Oracle proceeds with the connection, using the username and password chosen in Step 2. If not, Oracle returns an error.

4.If the connection using the database string, username, and password is successful, then Oracle attempts to access the specified object on the remote database using the rules for resolving object references and referring to objects in other schemas discussed earlier in this section.

You can disable the requirement that the database.domain portion of the database link name must match the complete global name of the remote database by setting to false the initialization parameter GLOBAL_NAMES or the GLOBAL_ NAMES parameter of the ALTER SYSTEM or ALTER SESSION statement.

See Also: Oracle9i Database Administrator’s Guide for more information on remote name resolution

Referencing Object Type Attributes and Methods

To reference object type attributes or methods in a SQL statement, you must fully qualify the reference with a table alias. Consider the following example from the sample schema oe, which contains a type cust_address_typ and a table customers with a cust_address column based on the cust_address_typ:

CREATE TYPE cust_address_typ AS OBJECT

( street_address

VARCHAR2(40)

, postal_code

VARCHAR2(10)

, city

VARCHAR2(30)

, state_province

VARCHAR2(10)

, country_id

CHAR(2)

2-120 Oracle9i SQL Reference

Syntax for Schema Objects and Parts in SQL Statements

);

/

CREATE TABLE customers

( customer_id

NUMBER(6)

, cust_first_name

VARCHAR2(20) CONSTRAINT cust_fname_nn NOT NULL

, cust_last_name

VARCHAR2(20) CONSTRAINT cust_lname_nn NOT NULL

. , cust_address

cust_address_typ

.

 

.

 

In a SQL statement, reference to the postal_code attribute must be fully qualified using a table alias, as illustrated in the following example:

SELECT c.cust_address.postal_code FROM customers c;

UPDATE customers c SET c.cust_address.postal_code = ’GU13 BE5’ WHERE c.cust_address.city = ’Fleet’;

To reference an object type’s member method that does not accept arguments, you must provide "empty" parentheses. For example, the sample schema oe contains an object table categories_tab, based on catalog_typ, which contains the member function getCatalogName. In order to call this method in a SQL statement, you must provide empty parentheses as shown in this example:

SELECT c.getCatalogName() FROM categories_tab c

WHERE category_id = 90;

See Also: Oracle9i Database Concepts for more information on user-defined datatypes

Basic Elements of Oracle SQL 2-121

Syntax for Schema Objects and Parts in SQL Statements

2-122 Oracle9i SQL Reference

Соседние файлы в папке Oracle selected docs