Oracle 中“视图”和“同义词”的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24993894/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between "view" and "synonym" in Oracle
提问by Snehal
What is the difference between "view" and "synonym" in Oracle?
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?
这样对吗?如果不是,那是什么?
回答by Nishanthi Grashia
Tableis a basic unit of data storage in an oracle database. It holds all user accessible data.
表是oracle数据库中数据存储的基本单位。它保存所有用户可访问的数据。
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 namegiven 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.
其他人已经回答了类似的问题和参考资料。
回答by Pavankumar
View:
看法:
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.
视图是表的子集。视图创建了多个表并降低了查询的复杂性。视图包含 Select 语句和使用过滤器命令。
Syonynm:
同义词:
Synonym is mirror of table. Synonym created single table and to reduced Table name complexity. Synonym doesn't Contain Select Statement.
同义词是桌子的镜子。Synonym 创建了单个表并降低了表名称的复杂性。同义词不包含 Select 语句。
回答by Mrityunjay Dubey
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.
视图是基于表或视图的逻辑表。我们可以创建一个视图来降低查询的复杂性。同义词是数据库对象的替代名称,如表、视图、序列。它可以是公共的和私有的。