我很難將sybase腳本轉換爲Oracle 11g腳本。我使用了翻譯工具,但我對Rowid更加混淆。 有沒有更簡單的方法做到這一點,而不使用rowid,因此對於我來說,只要學習Oracle就能更容易消化?加入Oracle 11g中的刪除
這裏是我的Sybase腳本:
delete table_1
from table_1 a, table_2 b
where (select count(*) from table_2
where a.id = id
and a.seq = seq
and a.gcode = gcode
and a.gtype = gtype) = 0
and a.id = b.id
and a.seq = b.seq;
下面是從Oracle SQL開發翻譯工具結果:
DELETE table_1
WHERE ROWID IN
(SELECT a.ROWID
FROM table_1 a,
table_2 b
WHERE (SELECT COUNT(*)
FROM table_2
WHERE a.id = id
AND a.seq = seq
AND a.gcode = gcode
AND a.gtype = gtype) = 0
AND a.id = b.id
AND a.seq = b.seq);
是否可以安全使用ID來寫,而不是RowId的?: table_1和table_2中的ID都指向相同的PK。 Table_1和table_2是彼此的鏡像。
DELETE table_1
WHERE ID IN
(SELECT DISTINCT a.ID
FROM table_1 a,
table_2 b
WHERE (SELECT COUNT(*)
FROM table_2
WHERE a.id = id
AND a.seq = seq
AND a.gcode = gcode
AND a.gtype = gtype) = 0
AND a.id = b.id
AND a.seq = b.seq);