直接在最后的数据库脚本里改可能更方便些,用PD也帮不了什么忙的:
五. 自增的identity如何移植? 
SQL Server中的identity特性给我们的工作带来了很大的方便,我们可以利用它方便的进行排序.但是在Oracle中却没有这样的特性.Oracle只有sequence的概念.sequence是事务无关性的,sequence并不是依附在表的上面,它是独立存在的,和事务是无关的.但是我们可以利用sequence来达到SQL SERVER中identity的效果.例程如下: 
SQL SERVER的原表结构: 
create table ftm07 -- 应收票据异动 

ftg00c TYPE_v_CMPID not null, -- 公司别 
ftg01c varchar(20) not null, -- 票据号码 
ftg02f int identity not null, -- 流水号 
ftg03d TYPE_v_DATE null , -- 状况处理日 
ftg04c TYPE_v_ENUM null , -- 状况 
ftg06c varchar(20) null , -- 传票管理编号 
ftg07c varchar(2) null , -- 票据异动别 
ftg08c varchar(20) null , -- 票据异动单号 
constraint PK_FTM07 primary key (ftg00c, ftg01c, ftg02f) 

移植至Oracle中的做法: 
create table ftm07 -- 应收票据异动 

ftg00c varchar2(3) not null, -- 公司别 
ftg01c varchar2(20) not null, -- 票据号码 
ftg02f int not null, -- 流水号 /* SEQUENCE */ 
ftg03d varchar2(8) null , -- 状况处理日 
ftg04c varchar2(1) null , -- 状况 
ftg06c varchar2(20) null , -- 传票管理编号 
ftg07c varchar2(2) null , -- 票据异动别 
ftg08c varchar2(20) null , -- 票据异动单号 
constraint PK_FTM07 primary key (ftg00c, ftg01c, ftg02f) 
); 
CREATE SEQUENCE ftm07_seq INCREMENT BY 1; create or replace TRIGGER Cash_ftm07_insert_before -- 增加一个insert之前的触发器 
before insert on ftm07 
for each row 
declare 
i_id integer; 
begin 
select ftm07_seq.nextval into i_id from dual; 
:NEW.ftg02f := i_id; 
end; 
可以从上面看到,如同SQL SERVER一样,你并不需要对ftg02f字段进行操作,触发器会帮你搞定一切.但是有一个不同需要注意了:sequence的值不能被手工重置 
在SQL SERVER中可以通过dbcc checkident(表名,reseed,0)或者truncate table tableName(如果数据也不需要的话)将表中的identity栏位重置为1,而Oracle的sequence做不到这点,sequence只有达到最大值後,系统才会自动将其重置为预定的最小值. 

解决方案 »

  1.   

    手动在oracle里加用pd来设计反而就累赘了,不知道哪位还有没有高见??
      

  2.   

    那你就把上面的东西加到PD里好了;
    加个序列很简单了,在物理模型界面菜单中Model->Sequences,定义一个新的的序列,在Option中定义属性,起始值、递增量等然后在那个表的属性里Triggers里把那个触发器加上嘿嘿,不见得方便哦
      

  3.   

    1.创建序列:
    create sequence your_seq
    nocycle
    maxvalue 9999999999
    start with 1;2.使用触发器实现自增:
    create or replace trigger <seq_name>
    before insert on <table_name> for each row
    declare
      next_id number;
    begin
      select your_seq.nextval into next_id from dual;
      :new.id := next_id;
    end;