SELECT ABS(MOD(DBMS_RANDOM.RANDOM,1000)) id from table_dual where id not in 
(select id from table_dual)

解决方案 »

  1.   

    select level from dual connect by level <1000
    minus
    select distinct a from tmp_table where a between 1 and 1000
      

  2.   

    select min(l) l
      from (select level l from dual connect by level < 1000) t
     where l not in (select distinct l from table_name)
      

  3.   


    with simo_sd as
     (select 1 as id from dual
      union all
      select 2 from dual
      union all
      select 3 from dual
      union all
      select 19 from dual
      union all
      select 433 from dual)--查询语句
    select min(lv)
      from (select level as lv from dual connect by level <= 999) d
     where not exists (select 1 from simo_sd f where d.lv = f.id);
      

  4.   

    二楼的代码没跑出来三楼的代码亲测可行不过出的九点多加个min就好了四楼的很对胃口我要的大哥对不起我没有看懂不过还是谢啦