//建表:
-- Create table
create table EMP
(
ID NUMBER,
ENAME VARCHAR2(50),
EMPNO VARCHAR2(50),
SALARY NUMBER(10),
DEPTNO VARCHAR2(50),
CREATETIME DATE default sysdate
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
建立历史表:
create table emp_his as select * from emp where 1=2
建立oracle触发器:
create or replace trigger tri_del_emp
before delete on emp
for each row
begin
insert into emp_his(id,ename,empno,salary,deptno,createtime) values
(:old.id,:old.ename,:old.empno,:old.salary,:old.deptno,:old.createtime);
end;
执行测试操作:
delete emp where id=8
这个时候,历史表,信息已经插入进去了,呵呵