sqlserver2000 的一个表有自增列,现在数据库要移植到Oracle9i里.
这个表有数据的,也就是说自增列也有数据的.
有什么解决办法?

解决方案 »

  1.   

    sqlserver2000 自增列identity是连续的,在orale里保证连续有点麻烦.可以尝试这样做:
    取值的时候使用select max(自增列) from yourTable for update; 但可能有时候会引起效率问题.
      

  2.   

    ----创建表
    Create  table  t_user(
    Id number(6),userid varchar2(20),loginpassword varchar2(20),isdisable number(6)
    );----创建序列
    create sequence user_seq
    increment by 1  
    start with 1
    nomaxvalue
    nominvalue
    nocache----创建触发器
    create or  replace trigger tr_user
    before insert on t_popedom_user
    for each row
    begin
    select user_seq.nextval into :new.id from dual;
    end;----测试
    insert into t_popedom_user(userid,loginpassword, isdisable)
    values('ffll','liudddyujj', 0);
    insert into t_popedom_user(userid,loginpassword, isdisable)
    values('dddd','zhang', 0)
    select * from t_user;
      

  3.   

    用  rownum  ,或者是序列都可以,rownum 得将原来的数据排好了序再插进去
      

  4.   

    2楼的给的代码有错误,
    请问2楼,在使用序列的基础上,如果我要从其他表导入数据到Oracle那怎么做?
      

  5.   

    1、还是用rownum比较好。
    做个触发器,在insert时,将rownum提取出来进行自动插入。