Both views and synonyms are the object names in the database. They do not correspond to actual data storage and all depend on the existence of other objects.
View: A view can be viewed as a virtual table or storage query. Unless it is an index view, the data in the view will not be stored in the database as non-duplicate objects. Generally, a view is built based on one or more data tables that are queried by a data query statement. A view can be used in a data query statement.
Synonym: It is another name of an object within the framework. By using synonyms, client applications can reference a base object by using a name consisting of two, three, or four parts. It can be understood as a shortcut to an object in a database or an alias in a specific range; not limited to data tables, almost all database objects can be used to create synonyms.
1. A view can correspond to one or more tables. A synonym can only correspond to one table name.
2. Other constraints can be set for the view.
3. You can create a view on Synonyms:
For example, if a synonym named synonym_city and a table named table_citys already exist, you can CREATE a VIEW: create or replace noforce view view_city as select * FROM synonym_city, table_citys;
4. You can perform any DML operation on synonyms to insert, update, and delete table data. You can only update and delete views.
It is worth noting that both views and synonyms can block users from accessing tables owned by other users.
For example, there are two users: scott and sys. Log On As sys.
Create a synonym for a cross-User table:
Create or replace public synonym SYN_EMP for scott. emp;
Create a view for a table across users:
Create or replace view view_EMP as select * FROM scott. emp
Then perform the query operation:
SELECT * FROM SYN_EMP;
SELECT * FROM view_EMP;
The query results are the same.