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.