oracle pl-sql 中的 table-cast 与 cast-multiset
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23755660/
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
Table-cast vs cast-multiset in pl-sql
提问by Plymouth Rock
What is the use of Table-CAST
and CAST-Multiset
?
有什么用的Table-CAST
和CAST-Multiset
?
Example of Table-Cast
示例 Table-Cast
SELECT count(1)
INTO v_Temp
FROM TABLE(CAST(Pi_Save_Data_List AS Property_data_list))
WHERE Column_Value LIKE '%Contact';
Example of Cast-Multiset
示例 Cast-Multiset
SELECT e.last_name,
CAST(MULTISET(SELECT p.project_name
FROM projects p
WHERE p.employee_id = e.employee_id
ORDER BY p.project_name)
AS project_table_typ)
FROM emps_short e;
What isthe performance gain or impact on the code?
对代码的性能提升或影响是什么?
回答by APC
The TABLE() function casts a nested table type to a relational result set. This is allows us to query a previously populated collection in SQL.
TABLE() 函数将嵌套表类型转换为关系结果集。这允许我们在 SQL 中查询先前填充的集合。
The CAST(MULTISET()) function call converts a relational result set into a collection type. This is primarily of use when inserting into a table with column defined as a nested table.
CAST(MULTISET()) 函数调用将关系结果集转换为集合类型。这主要在插入到具有定义为嵌套表的列的表中时使用。
Few sites employ object-relational features in their permanent data structures so the second usage is pretty rare. But being able to use collections in embedded SQL statements is a very cool technique, and widely used in PL/SQL.
很少有站点在其永久数据结构中使用对象关系功能,因此第二次使用非常罕见。但是能够在嵌入式 SQL 语句中使用集合是一项非常酷的技术,并且在 PL/SQL 中被广泛使用。