How to use ROWID with an Oracle Join View

use*_*479 2 oracle view uniqueidentifier rowid

I am trying to create a unique identifier for every row of a view. The view I have joins a lot of tables and therefore no one table's primary key will help me identify the row.

Doing a google search it looks like I may be able to achieve this by using rowid? But I'm not sure how to reference the view's rowid. Below is an example of how I envisioned rowid would work, but it obviously fails with an 'ambiguous column' error because I am not specifying a specific table for rowid.

Ex:


    with v_someTable (select...),
      v_anotherTable as (select blah, id from v_someTable where...),
      v_yetAnotherTable as (select foo, id from v_someTable where...)
    select distinct rowid, rt.key, v1.blah, v2.foo
    from realTable rt 
      left join v_anotherTable v1 on v1.id=rt.id 
      left join v_yetAnotherTable v2 on v2.id=rt.id

Run Code Online (Sandbox Code Playgroud)

I am trying to do this in a query and not a stored procedure. Any help would be appreciated!

Thanks!

pau*_*ley 6

我的理解是a rowid指的是物理表中的行,而不是结果集中的行(实际上是视图的行).

要获取每行的唯一标识符,您需要以某种方式组合要加入的表的主键.