oracle audit table - ghdrako/doc_snipets GitHub Wiki

CREATE TABLE scott.emp 
   (empno     NUMBER        CONSTRAINT pk_emp PRIMARY KEY, 
    ename     VARCHAR2(10)  CONSTRAINT nn_ename NOT NULL 
                            CONSTRAINT upper_ename 
CHECK (ename = UPPER(ename)), 
    job        VARCHAR2(9), 
    mgr      NUMBER         CONSTRAINT fk_mgr 
                            REFERENCES scott.emp(empno), 
    hiredate  DATE          DEFAULT SYSDATE, 
    sal       NUMBER(10,2)  CONSTRAINT ck_sal 
CHECK (sal > 500), 
       comm      NUMBER(9,0)   DEFAULT NULL, 
       deptno    NUMBER(2)     CONSTRAINT nn_deptno NOT NULL 
                               CONSTRAINT fk_deptno 
                               REFERENCES scott.dept(deptno) ) 
PCTFREE 5 PCTUSED 75; 


create table emp (
  empno     NUMBER,
  ename     VARCHAR2(10),
  job        VARCHAR2(9),
  mgr      NUMBER,  
  hiredate  DATE,
  sal       NUMBER(10,2),
  comm      NUMBER(9,0),
  deptno    NUMBER(2)
)

alter table emp add constraint emp_pk primary key(empno);

begin
dbms_wm.EnableVersioning('EMP','VIEW_WO_OVERWRITE');
end;

select * from emp_hist order by wm_createtime;

EXEC DBMS_WM.DisableVersioning('EMP');