Oracle Database Synonyms

Source: Internet
Author: User

Oracle Database Synonyms

I. Definition

A synonym is an alias for a database solution object. The database solution objects here refer to tables, views, sequences, stored procedures, packages, and so on.

2. Benefits of synonyms

1. No memory space occupied, saving a lot of database space

2. simplified access to database objects

3. Improved Database Object Access Security

4. the extended scope of use of databases enables seamless interaction between different database users. synonyms can be created on different database servers and connected over the network.

3. Create synonym syntax

create public synonym table_a for  user.table_a;

Iv. Delete synonym syntax

Because synonyms are also objects, the same is true for deleting syntaxes.

drop public synonym table_a;

5. Expansion

If you want to access table_a tables in different databases or users, you can also use synonyms, but you need to create a Database Link (Database connection) to expand the access, then, use the following statement to create a database synonym:

create synonym table_a for table_a @DB_Link;

Vi. instance demonstration

1. demo of different users in the same database

The table employees under the ctdev user

However, the ctcheck user does not have this table, and the ctcheck user cannot access the table employees;

Create Synonym

create public synonym employees for ctdev.employees;

After creation, you can access the table employees of the ctdev user under the ctcheck user.

2. Cross-database synonym demonstration

User cwuser in database 10.248.100.81 cannot access employees, as shown in.

It is known that the name of the dblink of the user 10.1.2.1 user ctdev under the user cwuser user under the database 10.248.100.81 is to_ctdev. As shown in

Create a synonym for accessing the employees table in ctdev under the cwuser user.

create synonym employees for employees@TO_CTDEV

You can access the table employees under ctdev under cwuser, as shown in

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.