Oracle synonym creation and its role

Source: Internet
Author: User

Oracle 's synonym (synonyms) is literally understood as the meaning of an alias, similar to the function of an attempt, a mapping relationship. This article describes how to create synonym statements, delete synonyms, and view synonym statements.
Oracle's synonym Summary:
The literal understanding is the meaning of the alias, similar to the function of the attempt. is a mapping relationship.
1. Create a synonym statement:

Create public synonym table_name for user.table_name;

The first user_table and the second user_table can be different from each other.
In addition, if you want to create a synonym for a table on a remote database, you need to create a database link to extend access, and then create a database synonym using the following statement: Creationsynonym table_name For [email protected]_link;
Of course, you may need to authorize the current user (User2) in User users: Grant Select/delete/update on User2
2. Delete synonyms:

Drop public synonym table_name;

3. See all synonyms:

SELECT * FROM dba_synonyms

Synonyms have the following benefits: Save a lot of database Space, the operation of different users of the same table is not much different; the scope of the extended database can be used to seamlessly interact among different database users ; Synonyms can be created on different database servers and connected over a network.
The functionality of synonym management is provided in the Oracle database. Oracle synonyms are an alias for database schema objects and are often used to simplify object access and improve the security of object access.
AD:
The management of the user in Oracle is managed using permissions, that is, if we want to use the database, we have to have permission, but if someone else gives us permission, we can also operate on the database, But we have to type the name of the table owner before the name of the authorized table, so this is a hassle, and in this case, what should we do? Create a synonym for Oracle! This allows us to use the table directly using synonyms.

1.The concept of synonyms
The functionality of synonym management is provided in the Oracle database. Synonyms are an alias for database schema objects and are often used to simplify object access and improve the security of object access. When using synonyms,The Oracle database translates it into the name of the corresponding schema object. Similar to views, synonyms do not occupy the actual storage space, only the definition of synonyms is saved in the data dictionary. InMost database objects in an Oracle database, such as tables, views, synonyms, sequences, stored procedures, packages, and so on, can be defined as synonyms by the database administrator.
Classification of 2.Oracle synonyms
There are two types of Oracle synonyms, namely, publicOracle Synonyms and privateOracle synonyms.
1) PublicOracle Synonyms: By a special group of usersOwned by public. As the name implies, all users in the database can use common synonyms. Common synonyms are often used to mark more common database objects, which are often referred to by everyone.
2) PrivateOracle Synonyms: It corresponds to a common synonym, and he is owned by the user who created him. Of course, the creator of this synonym can control whether other users have access to their own private synonyms by authorizing them.
3.Oracle Synonyms creation and deletion
Create PublicSyntax for Oracle synonyms:Create [public] synonym synonym namefor [username.] ObjectName;
Drop [public] synonym synonym name
The role of 4.Oracle synonyms
1) in multi-user collaborative development, the name of the object and its holder can be masked. If you do not have synonyms, when you manipulate other users ' tables, you must passuser name .object name form, using oracle synonyms can be concealed after user name, of course, it is important to note that: public synonyms just define a public alias for the database object, other users can access the database object through this alias, Also depends on whether the user has been authorized.
2) simplifies sql statements for users. The above one is actually a simplified sql embodiment, and if the name of the table you built is very long, you can create a oracle synonyms for this table to simplify sql development.
3) provides location transparency for remote objects in a distributed database.
5.Oracle synonyms in the database chain
The database chain is a named object that describes the path of one database to another. It enables communication between different databases.
Create database link Database link name connect  to  user name Identified by password   using ' oracle connection string ' ; access to objects via @ database chain name. The role of synonyms in the database chain is to provide location transparency.

Oracle synonym creation and its role

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.