Hmm, nie kojarzę mechanizmu z klauzulą dla tabeli. Można by się ratować ORA_ROWSCN z tym, że to zawiera sekwencję modyfikacji bloku, więc update będzie zaburzało tę wartość, można by próbować triggerem ogarnąć zmiany, ale i tak bardzo śliska sprawa.
create table foo (
CREATED_AT TIMESTAMP DEFAULT SYSTIMESTAMP,
id number
);
create table bar (
CREATED_AT TIMESTAMP DEFAULT SYSTIMESTAMP,
id number
);
insert all
when 1=1 then into bar (id)
when 1=1 then into foo (id)
select level lvl from dual connect by level<=5;
select * from (
select SCN_TO_TIMESTAMP(ORA_ROWSCN) scn_ts, ora_rowscn, t.*,'FOO' tbl_name From foo t
union all
select SCN_TO_TIMESTAMP(ORA_ROWSCN) scn_ts, ora_rowscn, t.*,'BAR' tbl_name From bar t
) order by ora_rowscn;
rollback;
insert all
when 1=1 then into foo(id)
when 1=1 then into bar (id)
select level lvl from dual connect by level<=5;
select * from (
select SCN_TO_TIMESTAMP(ORA_ROWSCN) scn_ts, ora_rowscn, t.*,'FOO' tbl_name From foo t
union all
select SCN_TO_TIMESTAMP(ORA_ROWSCN) scn_ts, ora_rowscn, t.*,'BAR' tbl_name From bar t
) order by ora_rowscn;
Co powiesz na wspólną sekwencję? (Pomijając kwestie tuningowe przy OLTP i wielu sesjach wstawiających).
create sequence foo_common_seq start with 1;
create table foo2 (
created_at timestamp default systimestamp,
id number,
common_seq number default foo_common_seq.nextval
);
create table bar2 (
created_at timestamp default systimestamp,
id number,
common_seq number default foo_common_seq.nextval
);
insert into foo2 (id)
select level lvl from dual connect by level<=5;
insert into bar2 (id)
select level lvl from dual connect by level<=5;