A Brief Introduction to synonyms in Oracle databases

Source: Internet
Author: User

Oracle DatabaseRelatedSynonymSome of the knowledge is what we will introduce in this article. First, let's take a look at a statement, as shown below:

Create synonym table_name for user. table_name;

The first user_table and the second user_table can be different.

In addition, if you want to create a synonym for a table on a remote Database, you must first create a Database Link Database connection) to expand the access, and then create a Database synonym using the following statement: create synonym table_name for table_name @ DB_Link;

Of course, you may need to authorize the current user (user2) in the user: grant select/delete/update on user2.

After creating a synonym, you can perform DMLinsert, update, and delete operations on it. Of course, this is certainly supported in the select statement. Delete synonym: drop synonym table_name; table_name here refers to the table name of the synonym.

Synonyms have the following benefits: they save a lot of database space and have little difference in operating the same table for different users; they extend the scope of use of databases, allows seamless interaction between different database users. synonyms can be created on different database servers and connected over the network.

View all synonyms:

Select * from dba_synonyms

Create a synonym in oracle:

We all know that user management in oracle is managed by permissions. That is to say, if we want to use a database, we must have permissions, however, if someone else grants us the permission, we can also operate on the database, but we must enter the name of the table owner before the name of the authorized table, so this is troublesome. What should we do in this situation? Create a synonym! In this way, you can directly Use synonyms to use tables.

The specific syntax for creating synonyms is: create [public] SYNONYM synooym for object. synooym indicates the name of the SYNONYM to be created, and object indicates the table and view, sequence.

Create public synonym public_emp FOR jward. emp; -- jward User Name

Delete synonym:

Use the drop synonym statement to delete unnecessary synonyms. to delete a private SYNONYM, the PUBLIC keyword is omitted. to delete a public synonym, the PUBLIC keyword is included.

Drop synonym emp; -- delete a private SYNONYM named emp.

Drop public synonym public_emp; -- delete a public synonym named public_emp.

For more information about Oracle Database synonyms, see the article http://database.51cto.com/oracle.

 

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.