Oracle Multilayer nested synonyms

Source: Internet
Author: User
Tags sorts

In Oracle's administrator's manual, you can establish synonyms for tables, views, materialized views, procedures, functions, packages, objects, and sequences. Although Oracle does not explicitly specify, it is also possible to create synonyms for synonyms.

Sometimes it is meaningful to establish synonyms that point to synonyms. Since one of the functions of the synonym itself is to achieve transparency in both physical and physical locations, the user does not have to relate to whether the object currently pointed to is a synonym or other object when creating a synonym.

Oracle processing of synonyms that point to synonyms only has a small price to pay for parsing objects, and there are few other effects.

Of course, if the synonyms are nested too many layers, nor is it a good way to design, the user is determined to access the real object is cumbersome, Oracle in the analysis of the object will also take time:

sql> create synonym S1 for t;

The synonym has been created.

sql> create synonym S2 for s1;

The synonym has been created.

For synonym S2, it is a nested synonym that points to the synonym S1. This nesting can also affect the performance of the analysis if too many layers are nested. For example, a synonym with 10000 layers is nested:

Sql> begin

2 for I in 2..10000 loop

3 Execute immediate ' create synonym S ' | | (i+1) | | ' For S ' | | I

4 End Loop;

5 end;

6/

The PL/SQL process has completed successfully.

Sql> Set Timing on

Sql> set Autot on

Sql> select * from T;

No rows selected

Time used: 00:00:00.02

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Ptimizer=choose

1 0 TABLE ACCESS (full) ' T '

Statistics

----------------------------------------------------------

0 Recursive calls

0 db Block gets

3 Consistent gets

0 physical Reads

0 Redo Size

267 bytes sent via sql*net to client

460 Bytes received via sql*net from client

1 sql*net roundtrips To/from Client

0 Sorts (memory)

0 Sorts (disk)

0 rows processed

Sql> select * from S1;

No rows selected

Time used: 00:00:00.02

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Ptimizer=choose

1 0 TABLE ACCESS (full) ' T '

Statistics

----------------------------------------------------------

0 Recursive calls

0 db Block gets

3 Consistent gets

0 physical Reads

0 Redo Size

267 bytes sent via sql*net to client

460 Bytes received via sql*net from client

1 sql*net roundtrips To/from Client

0 Sorts (memory)

0 Sorts (disk)

0 rows processed

Sql> select * from S2;

No rows selected

Time used: 00:00:00.02

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Ptimizer=choose

1 0 TABLE ACCESS (full) ' T '

Statistics

----------------------------------------------------------

0 Recursive calls

0 db Block gets

3 Consistent gets

This article URL address: http://www.bianceng.cn/database/Oracle/201410/45462.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.