下面的查询将插入两行,即 999,666,Oracle 将为您提供插入 2 行的日志。
insert into departments(department_id, department_name, manager_id,location_id)
select 999,'Administration',200,1700 from dual
union all select 666,'Marketing' ,201,1800 from dual
我如何获取像“第999行和666行已插入”这样的日志..通过将日志语句放入查询本身..(用户定义的日志)..就像在java中我们使用log4j对于相同的..
最佳答案
如果您不想修改用于插入的代码,您可以在表上定义一个触发器来记录您的操作。
例如:
create or replace trigger departmentsAfterInsert
after insert
on departments
for each row
begin
dbms_output.put_line('Inserted department ' || :new.department_id);
end;
这将记录插入操作,无论您如何执行:
SQL> insert into departments(department_id, department_name, manager_id,location_id)
2 select 999,'Administration',200,1700 from dual
3 union all select 666,'Marketing' ,201,1800 from dual;
Inserted department 999
Inserted department 666
2 rows created.
关于sql - 在 SQL 查询中插入日志语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41118666/