Create synonyms in Oracle

Source: Internet
Author: User


Create a synonym in Oracle create a synonym statement in Oracle: we all know that user management in oracle uses permission management, that is, if we want to use a database, we must have permissions, but if someone grants us the permissions, we can also operate on the database, however, we must enter the name of the table owner before the name of the table to be authorized, so this is troublesome. What should we do in this case? Create a synonym! In this way, you can directly Use synonyms to use tables. Www.2cto.com create synonym table_name for user. table_name; the first user_table can be different from the second user_table. In addition, 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: After grant select/delete/update on user2 creates a synonym, you can perform DML (insert, update, 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. To be studied: the impact of the lock on multiple users when different users operate on a table, whether the lock can be used, and whether the transaction can operate www.2cto.com to view all synonyms: select * from dba_synonyms: 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; -- use the drop synonym statement to delete a SYNONYM that is no longer needed. To delete a private SYNONYM, the PUBLIC keyword is omitted. to delete a public synonym, the PUBLIC keyword drop synonym emp is required; -- delete the private SYNONYM named emp drop public synonym public_emp; -- delete the public synonym named public_emp

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.