Oracle中,写存储过程,如何比较两条记录是否相同,两条记录分别来自两张表,表结构相同
Oracle中,写存储过程,如何比较两条记录是否相同,两条记录分别来自两张表,表结构相同,有没有好的方法。(不要告诉我把两张表的所有字段值一一列出来比较,这个我会,但不想用)
DECLARE
v_count pls_integer;
BEGIN
select count(*) into v_count
from
(
select * from tb1 where
minus
select * from tb2 where ...
);
if v_count=0 then
dbms_output.put_line ('2条数据完全厅闹相扮键罩等');
else
dbms_output.put_line ('2条数据不亮悄完全相等');
end if
END;
利用minus语法。
v_count number;
select count(*) into v_count from(
select * from tbl1 where ***
minus
select * from tbl2 where ****
)
if v_count=0 then
相同
else
不掘缓相返罩同漏散闹
end if;