Oracle

Using a Sequence

Figo Kim 2006. 11. 26. 11:33
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
Using a Sequence
ex)
INSERT INTO department
  (department_id, department_name, location_id)
VALUES
  (dept_deptid_seq.NEXTVAL, 'Support', 2500 )

Tip) View current value
SELECT dept_deptid_seq.CURRVAL FROM dual;

Caching Sequence Values

- Using Cache function : faster access to those values.
- Gaps in sequence values can occur when:
  A rollback occurs
  The system crashes
  A sequence is used in another table

Modifying a Sequence
ALTER SEQUENCE dept_deptid_seq
                            INCREMENT BY 20
                           MAXVALUE 999999
                           NOCACHE
                           NOCYCLE;

If you reach the MAXVALUE limit for your sequence, no additional values from the sequence are allocated and you will received an error.

Syntax)
ALTER SEQUENCE sequence
[INCREMENT BY n]
[{MAXVALUE n | NOMAXVALUE}]
[{MINVALUE n | NOMINVALUE}]
[{CYCLE | NOCYCLE}]
[{CACHE n | NOCACHE}];
1. Must have the ALTER privilege
2. Only future sequence numbers are affected
3. To start at a different, the sequence must be dropped and re-created
4. validation
5. To remove a sequence, use the DROP startement
DROP SEQUENCE dept_deptid_seq;



'Oracle' 카테고리의 다른 글

INDEXES  (0) 2006.11.26
Using a Sequence  (0) 2006.11.26
NEXTVAL and CURRVAL Pseudocolumns : Rules  (0) 2006.11.25
NEXTVAL and CURRVAL Pseudocolumns : Rules  (0) 2006.11.25
Sequence  (0) 2006.11.25