全部博文(136)
分类: Oracle
2008-08-12 22:36:37
SQL> desc test_yct;
Name Type Nullable Default Comments ---- ------------ -------- ------- -------- ID NUMBER Y NAME VARCHAR2(20) Y SQL> select * from test_yct;
ID NAME
-- ------------------------------------------ 1 yct1 2 yct2 3 yct3 5 yct5 6 yct6 9 yct9 10 yct10 11 yct11 13 yct13 9 rows selected |
SQL> SELECT MIN(ID)
2 FROM (SELECT MIN(A.ID) + 1 ID 3 FROM TEST_YCT A, TEST_YCT B 4 WHERE A.ID + 1 = B.ID(+) 5 AND B.ID IS NULL 6 UNION ALL 7 SELECT MAX(ID) + 1 ID 8 FROM TEST_YCT 9 ); MIN(ID) ---------- 7 |