오라클 10g와 11g에서 시퀀스 시작값이 다름 0 1 2,369

by 깨어있는 시민 [Oracle Admin] [2011.07.13 14:01:01]


안녕하세요

아래 타락천사님의 댓글을 보고 다시 자세하게 써봅니다.

참고로, 10g는 윈도우xp+10gR2, 11g는 윈도우7+11gR2입니다. 둘다 32비트.



시나리오.


11g에서 아래 작업 진행


create sequence SQ_ONE increment by 1 start with 0 minvalue 0 nocache;

select sq_one.nextval from dual;  

--값:0

--이제 테이블에 넣어서 조회해보자

create table one
(aa number);

insert into one
values(sq_one.nextval);

select * from one;  

--값: 2
>> 값 1은 어디로 간건지...

그리고 10g로 아래 수행


SQL> create sequence sq_one increment by 1 start with 0 minvalue 0 nocache;

시퀀스가 생성되었습니다.

SQL> select sq_one.nextval from dual;

   NEXTVAL
----------
         0

SQL> create table one
  2  (aa number);

테이블이 생성되었습니다.

SQL> insert into one
  2  values(sq_one.nextval);

1 개의 행이 만들어졌습니다.

SQL> select * from one;

        AA
----------
         1

10의 경우는 0->1 순으로 잘 나오네요..

왜 11g는 다를까요...


또다른 참고 시나리오.

11g에서 

create sequence sq_three increment by 1 nocache;

create table three
(aaa number);

insert into three
values(sq_three.nextval);

select * from three;
--값: 2

10g에서

SQL> create sequence sq_three increment by 1 nocache;
시퀀스가 생성되었습니다.
SQL> create table three
  2  (aaa number);
테이블이 생성되었습니다.
SQL> insert into three
  2  values(sq_three.nextval);
1 개의 행이 만들어졌습니다.
SQL> select * from three;
       AAA
----------
         1
제가 뭘 잘못 알고 있는걸까요?
by 타락천사 [2011.07.13 14:33:51]
-- 테스트 해봤는데 같은데요..
-- 10g, 11g 모두..
create sequence SQ_ABC2 increment by 1 start with 0 minvalue 0 nocache;
select SQ_ABC2.nextval from dual ;
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입