Sequence ( 시퀀스 )

양혜정·2024년 3월 11일

Oracle

목록 보기
35/49

Sequence

  • 숫자로 이루어져 있으며, 매번 정해진 증가치만큼 숫자 증가
create sequence 시퀀스명
start with 숫자1	-- 숫자1부터 시작
increment by 숫자	-- 숫자만큼 증가
-- maxvalue 숫자2	-- 최대값 : 숫자2
-- minvalue 숫자0	-- 최소값 : 숫자0
nomaxvalue			-- 무제한  증가
nominvalue			-- 최소값 없다
-- cycle			-- 반복
nocycle				-- 반복이 아닌 직진
nocache;

게시판에서 알아서 sequence 일련번호 생성

-- insert
insert into 테이블명(boardno, 컬럼명1) 
values(시퀀스명.nextval, '컬럼명1에 넣을 문장');

마지막으로 사용한 시퀀스값

select 시퀀스명.currval
from dual;

다음번에 들어올 시퀀스값

select last_number
from user_sequences
where sequence_name = '시퀀스명';

정리

-> local_hr에서작업한것

0개의 댓글