一. 创建空表
create table dept_test as select * from scott.dept where rownum >1000;
二. 创建序列
--如果原表已经有数据, 则用max(**id)取得最大id值, 并以该值加1作为基值: start with max(**id)+1
create sequence dept_seq minvalue 1 maxvalue 100 start with 1 increment by 1 nocache;
三. 创建触发器
create or replace trigger dept_trig
before insert on dept_test for each row
begin
select dept_seq.nextval into :new.deptno from dual;
end;
四. 抽取并插入数据
insert into dept_test(dname) select dname from scott.dept;