Synonyms for Oracle

Source: Internet
Author: User

Synonyms for Oracle

Synonyms are an alias for schema objects such as tables, indexes, and views. As with views, synonyms do not occupy any real storage space, only the description of their definitions in Oracle's data dictionary. When you use synonyms, Oracle translates them into the corresponding object names.

Synonyms in Oracle are divided into the following two categories:

1. Public synonyms

在数据库中所有用户都可以使用

2. Private synonyms

由创建它的用户私人拥有。不过,用户可以控制其他用户是否有权使用自己的同义词。
Create synonyms

The syntax for creating synonyms is as follows:

CREATE [PUBLIC] SYNONYM synonym_name FOR schema_object;

Example 1:

To give the user permission to create synonyms:

GRANT CREATE  PUBLIC  SYNONYM TO siege;

Then create synonyms:

CREATE   PUBLIC SYNONYM public_stu_syn FOR student;

Delete the synonym using the drop statement. To delete a public synonym, you need the appropriate permissions:

GRANT DROP PUBLIC SYNONYM TO siege;

At this point, delete the public synonym:

DROP PUBLIC SYNONYM public_stu_syn;

To view synonyms:

SELECT * FROM user_synonyms WHERE synonym_name=‘PUBLIC_STU_SYN‘

If you create a public synonym, its definition is stored in dba_synonyms, and the query needs to have the relevant permissions.

Synonyms for 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.