Home > Database > Oracle > body text

How to modify sequence in oracle

WBOY
Release: 2022-01-26 11:46:43
Original
9876 people have browsed it

Method: 1. Use the "ALTER SEQUENCE sequence name" statement to modify the sequence name; 2. Use "Increment By" to modify the sequence initial value. The syntax is "ALTER SEQUENCE SEQ_TEST INCREMENT BY value".

How to modify sequence in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How oracle modifies the sequence

Oracle Create sequence: create sequence xxxx

Note: The sequence in Oracle is not the same as the auto-increment in MySQL , continuous, but jumpy and discontinuous. If you want to make it continuous, you must specify the relevant attributes and values.

1 create sequence student_id

2 minvalue 1 --Minimum value

3 nomaxvalue --Do not set the maximum value (determined by the machine), or based on the value range of the table field Set maxvalue

4 maxvalue 999 -- Maximum value

5 start with 1 --Start counting from 1, the value is variable

6 increment by 1 --Increment each time 1. Variable value

7 nocycle --Always accumulate, no cycle; cycle: after reaching the maximum value, it will accumulate from the beginning

8 nocache; --Do not build a buffer. If you create a cache, the system will automatically read the cache value seq, which will speed up the running speed; if you use the cache in a single machine, or the oracle is dead, the seq value read next time will be incoherent, so it is not recommended to use the cache.

2. Oracle modify sequence: alter sequence xxxx

1 alter sequence student_id -- the sequence name can also be changed

2 minvalue 1

3 maxvalue 99999

4 start with 1

5 increment by 1

6 cycle -- after reaching 99999, start from scratch

7 nocache ;

3. Modify the initial value through Increment By.

For example: If the sequence name is SEQ_TEST, the initial value is 13, and now you want to set the initial value to 1013, the Increment By value is: 1000(1013-13)

1) Execution: ALTER SEQUENCE SEQ_TEST INCREMENT BY 1000;

2) Execution: SELECT SEQ_TEST.NEXTVAL FROM DUAL;

3) Execution: ALTER SEQUENCE SEQ_TEST INCREMENT BY 1;

Recommended Tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to modify sequence in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template