What is the difference between "view" and "synonym" in Oracle?
This is what I think:
- View can be created using multiple tables. View is logical and does not occupies space.
- Synonym can be created for single table, view, sequence or index. Synonym is physical and needs space.
Is this correct? If not, then what is it?
33 Answers
Table is a basic unit of data storage in an oracle database. It holds all user accessible data.
View is a virtual table
- It can be created on a table or another view.
- It is just like a window through which we can access or change base table data.
- It does not contain data of its own. It always takes data from its base table.
- It is stored as a query in data dictionary. Whenever you query a view it gets data from its based table using this query.
Main advantage of using views are
- You can restrict access to predetermined set of rows and columns of a table
- You can hide complexity of query
- You can hide complexity of calculation
Synonym is alternate name given to table, view, sequence or program unit.
- It is used to mask real name and owner of the object.
- You can provide public access to tables by creating public synonyms.
Reference : here
Other already answered similar questions and references.
1View:
view is a sub set of table. View is created multiple Tables and to Reduced Query complexity. View contain Select statement and using filter Commands.
Syonynm:
Synonym is mirror of table. Synonym created single table and to reduced Table name complexity. Synonym doesn't Contain Select Statement.
A view is logical table that is based on table or View. We can create a view to reduce complexity of the query. A Synonym is alternative name for database objects Like a Table, View, Sequence. It can be Public and Private.