1、创建学生表与学生历史表
学生表:
-- Create table
create table STUDENT
(
id NUMBER(11) not null,
name VARCHAR2(32),
age NUMBER(3)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255;
历史表:
CREATE TABLE STUDENT_H
AS SELECT * FROM STUDENT; /*复制学生表*/
alter table STUDENT_H add (student_id number(11) not null); /*添加字段 student_id*/
alter table STUDENT_H add (I_D_U VARCHAR2(32) not null); /*添加字段 I_D_U 意为INSERT OR DELETE OR UPDATE*/
创建学生表序列:
-- Create sequence
create sequence STUDENT_SEQ
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
创建历史表序列:
-- Create sequence
create sequence STUDENT_H_SEQ
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 20;
创建触发器
在trigger上右键,找到NEW