-- 创建表 BONUS_BENCHMARK_VALUE
---------------------------------------------------------------
declare
num number;
begin
select count(1) into num from user_tables where TABLE_NAME = upper('BONUS_BENCHMARK_VALUE');
if num>0 then
execute immediate 'drop table BONUS_BENCHMARK_VALUE';
end if;
end;
/
-- ----------------------------
-- Table structure for BONUS_BENCHMARK_VALUE
-- ----------------------------
CREATE TABLE BONUS_BENCHMARK_VALUE (
"BENCHMK_ID" NUMBER NOT NULL ,
"BENCHMK_YEAR" NVARCHAR2(20) NOT NULL ,
"BENCHMK_CODE" NVARCHAR2(20) NOT NULL ,
"BENCHMK_VALUE" NVARCHAR2(20) NULL ,
"MEASUREMENT" NVARCHAR2(20) NULL ,
"REFERENCE_START" NVARCHAR2(20) NULL ,
"REFERENCE_END" NVARCHAR2(20) NULL ,
"BENCHMK_TYPE" NVARCHAR2(50) NULL
)
LOGGING
NOCOMPRESS
NOCACHE
;
-- 创建序列,产生自增数值
-- seq_BONUS_BENCHMARK_VALUE 序列名称
create sequence seq_BONUS_BENCHMARK_VALUE start with 1 increment by 1;
-- 创建触发器,在插入数据前,把自增数值赋值给主键
-- seq_BONUS_BENCHMARK_VALUE 序列名称
-- BENCHMK_ID 主键id
create or replace trigger TRIGGER_BONUS_BENCHMARK_VALUE
before insert on BONUS_BENCHMARK_VALUE
for each row
begin
select seq_BONUS_BENCHMARK_VALUE.nextval into :new.BENCHMK_ID from dual;
end ;