Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

ALTER SEQUENCE

ALTER SEQUENCE

Purpose

Use the ALTER SEQUENCE statement to change the increment, minimum and maximum values, cached numbers, and behavior of an existing sequence. This statement affects only future sequence numbers.

See Also: CREATE SEQUENCE on page 14-89 for additional information on sequences

Prerequisites

The sequence must be in your own schema, or you must have the ALTER object privilege on the sequence, or you must have the ALTER ANY SEQUENCE system privilege.

Syntax

alter_sequence::=

 

 

 

 

INCREMENT

BY

integer

 

 

 

 

MAXVALUE

integer

 

 

 

 

NOMAXVALUE

 

 

 

 

 

MINVALUE

integer

 

 

schema

.

 

NOMINVALUE

 

 

 

 

 

 

ALTER

SEQUENCE

 

sequence

CYCLE

 

;

 

 

 

 

 

 

 

 

 

 

NOCYCLE

 

 

 

 

 

 

CACHE

integer

 

 

 

 

 

NOCACHE

 

 

 

 

 

 

ORDER

 

 

 

 

 

 

NOORDER

 

 

9-140 Oracle9i SQL Reference

ALTER SEQUENCE

Semantics

The keywords and parameters in this statement serve the same purposes they serve when you create a sequence.

To restart the sequence at a different number, you must drop and re-create it.

If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.

Oracle performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number.

See Also:

CREATE SEQUENCE on page 14-89 for information on creating a sequence

DROP SEQUENCE on page 17-2 for information on dropping and re-creating a sequence

Examples

Modifying a Sequence: Examples This statement sets a new maximum value for the customers_seq sequence:

ALTER SEQUENCE customers_seq

MAXVALUE 1500;

This statement turns on CYCLE and CACHE for the customers_seq sequence:

ALTER SEQUENCE customers_seq

CYCLE

CACHE 5;

SQL Statements: ALTER CLUSTER to ALTER SEQUENCE 9-141

ALTER SEQUENCE

9-142 Oracle9i SQL Reference

Соседние файлы в папке Oracle selected docs