--CREATE TABLE 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 (a) NOT NULL, "Benchmk_code" NV ARCHAR2 () is not null, "Benchmk_value" NVARCHAR2 (a) NULL, "Measurement" NVARCHAR2 (a) null, "Reference_start" NVARCHAR2 ( NULL, "Reference_end" NVARCHAR2 (() null, "Benchmk_type" NVARCHAR2 () null) Loggingnocompressnocache;
-- 创建序列,产生自增数值-- seq_BONUS_BENCHMARK_VALUE 序列名称create sequence seq_BONUS_BENCHMARK_VALUE start with 1 increment by 1; -- 创建触发器,在插入数据前,把自增数值赋值给主键-- seq_BONUS_BENCHMARK_VALUE 序列名称 -- BENCHMK_ID 主键idcreate 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 ;
Oracle Build table sql+ Self-increment primary key