How to create all synonyms for another user under one user

Source: Internet
Author: User

Oracle synonyms literally mean aliases. Similar to the view function, they are a ing relationship. Maintenance of users in Oracle is maintained by permissions. That is to say, if we want to use the database, we must have permissions, but if someone else grants us the permissions, we can also perform operations on the database, but it is the name of the user who wants to authorize the table, such as bsrun.doc tor_info, so this is troublesome. What should we do in this case? Create a synonym! In this way, we can directly Use synonyms to use tables.

1. If we want to create a synonym for all objects of the bsrun user, we can write as follows:

Select 'create synonym' object_name 'For bsrun. 'object _ name ';'
From user_objects where object_type in ('table', 'view', 'Procedure ', 'trigger', 'function', 'package ');
 

Execute the result set obtained by the preceding statement in the PL/SQL tool. The above is a private synonym, that is, only the creator can access the result set.

The following statement creates a public Synonym that can be accessed by all authorized users:

Select 'create public synonym' object_name 'For bsrun. 'object _ name ';'
From user_objects where object_type in ('table', 'view', 'Procedure ', 'trigger', 'function', 'package ');

2. Delete Synonyms:

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

 

Select 'create public synonym' | object_name | 'For jtsjk.' | object_name | ';'
From user_objects where object_type in ('table', 'view ');

How to create all synonyms for another user under one user

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.