DB/오라클 SQL문
24. 10부터5씩 증가하는 시퀀스 생성 | cache 값 없애기 | maxvalue
DEV-HJ
2022. 2. 22. 12:16
반응형
--10부터 5씩 증가하는 시퀀스 생성 -cache 값 없애기
create sequence seq1 start with 10 increment by 5 nocache;
--시퀀스 발생
select seq1.nextval from dual;
--시퀀스는 수정, start with 는 수정불가, maxvalue 지정후 그 값까지 나오면 다시 처음부터 나오도록
alter SEQUENCE seq1 increment by 10 maxvalue 100 cycle;
--시퀀스삭제
drop sequence seq1;
--seq1: 시작값5, 증가값2, 끝값 30, cache:no, cycle:yes;
create sequence seq1 start with 5 increment by 2 maxvalue 30 NOCACHE cycle;
--seq2 : 시작값 1, 증가값 2, cache:no
create sequence seq2 start with 1 INCREMENT by 2 nocache;
--seq3: 시작값 1, 증가값 1, cache:no
create sequence seq3 start with 1 INCREMENT by 1 nocache;
--콘솔창에 seq1,2,3,의 nextval을 출력
select seq1.nextval, seq2.nextval, seq3.nextval from dual;
--전체삭제
drop sequence seq1;
drop sequence seq2;
drop sequence seq3;
반응형