与表对象交叉加入行传播行(无需table()函数)

发布于 2025-02-06 18:57:09 字数 2660 浏览 1 评论 0原文

甲骨文空间具有称为 sdo_util.getvertices

此功能返回mdsys.vertex_set_type的对象, 由mdsys.vertex_type的对象的表组成。

 创建类型Vertex_set_type作为vertex_type的表;
 

getVertices()函数通常与table()函数一起使用。几何表与table(getVertices(shape))互相加入,以便为每个几何繁殖顶点行:

with cte as (
select sdo_geometry('linestring (10 20, 30 40)')                       shape from dual union all
select sdo_geometry('linestring (50 60, 70 80, 90 100)')               shape from dual union all
select sdo_geometry('linestring (110 120, 130 140, 150 160, 170 180)') shape from dual)
  
select 
    v.*
from 
    cte, table(sdo_util.getvertices(shape)) v

    X     Y     Z     W    V5    V6    V7    V8    V9   V10   V11    ID
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
   10    20                                                           1
   30    40                                                           2
   50    60                                                           1
   70    80                                                           2
   90   100                                                           3
  110   120                                                           1
  130   140                                                           2
  150   160                                                           3
  170   180                                                           4

文档中的示例建议使用table() 。

但是从快速测试中,似乎不需要使用table()函数。如果我从查询中删除table()函数,则会产生相同的结果。


问题:

如何与表对象进行跨加入会传播行 - 而无需table()函数?

文档建议我们应该使用table()函数,所以我想知道这在Oracle的较旧版本中是否正确,但是也许在较新版本中发生了什么变化?


相关:

Oracle Spatial has a function called SDO_UTIL.GETVERTICES:

This function returns an object of MDSYS.VERTEX_SET_TYPE, which
consists of a table of objects of MDSYS.VERTEX_TYPE.

CREATE TYPE vertex_set_type as TABLE OF vertex_type;

The GetVertices() function is typically used in conjunction with the Table() function. The geometry table is cross-joined with table(getvertices(shape)) to propagate vertex rows for each geometry:

with cte as (
select sdo_geometry('linestring (10 20, 30 40)')                       shape from dual union all
select sdo_geometry('linestring (50 60, 70 80, 90 100)')               shape from dual union all
select sdo_geometry('linestring (110 120, 130 140, 150 160, 170 180)') shape from dual)
  
select 
    v.*
from 
    cte, table(sdo_util.getvertices(shape)) v

    X     Y     Z     W    V5    V6    V7    V8    V9   V10   V11    ID
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
   10    20                                                           1
   30    40                                                           2
   50    60                                                           1
   70    80                                                           2
   90   100                                                           3
  110   120                                                           1
  130   140                                                           2
  150   160                                                           3
  170   180                                                           4

And the examples in the docs suggest using Table() as well.

But from a quick test, using the table() function doesn't seem to be necessary. If I remove the Table() function from the query, it produces the same result.


Question:

How is it possible that cross-joining with a table object propagates rows — without needing the Table() function?

The docs suggest that we should use the Table() function, so I wonder if that was correct in older versions of Oracle, but maybe something changed in newer versions?


Related:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

◇流星雨 2025-02-13 18:57:09

如何与表对象进行交叉加入行传播行 - 而无需table()函数?

在Oracle 12或Oracle 18中,Table Table Collection表达式的关键字已成为语法的可选部分,因此:

SELECT *
FROM   TABLE(SYS.ODCIVARCHAR2LIST('a', 'b', 'c'));

将在所有Oracle版本(支持集合)上使用。

和:

SELECT *
FROM   SYS.ODCIVARCHAR2LIST('a', 'b', 'c');

将从Oracle 18(也许还有Oracle 12)起作用,并做完全相同的事情(但会在早期版本中提出语法错误)。


我正在尝试找到新功能的文档,但到目前为止还没有找到它。

How is it possible that cross-joining with a table object propagates rows — without needing the Table() function?

In either Oracle 12 or Oracle 18, the TABLE keyword for table collection expressions was made an optional part of the syntax so:

SELECT *
FROM   TABLE(SYS.ODCIVARCHAR2LIST('a', 'b', 'c'));

Will work on all oracle versions (that support collections).

And:

SELECT *
FROM   SYS.ODCIVARCHAR2LIST('a', 'b', 'c');

Will work from Oracle 18 (and maybe Oracle 12) and do exactly the same thing (but would raise syntax errors in earlier versions).


I'm trying to find the documentation for the new feature but so far haven't found it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文