ID from oracle

xiaoxiao2021-03-06  76

String SQL = "SELECT BV_OBS_AGG_ID_SEQ.NEXTVAL V from DUAL";

This is actually a sequence, a characteristic of Oracle's own belt, is a bit similar to the Identity inside SQL Server, each time you grow, Dual is a virtual table.

NextVal is the next one. .

Create sequence

Purpose

User A Database Object from Which Multiple Users May Generate Unique Integers. You Can Use Sequences To Automatically Generate Primary Key Values.

When a sequence number is generated, the sequence is incremented, independent of the transaction committing or rolling back. If two users concurrently increment the same sequence, the sequence numbers each user acquires may have gaps because sequence numbers are being generated by the other user. One user can never acquire the sequence number generated by another user. Once a sequence value is generated by one user, that user can continue to access that value regardless of whether the sequence is incremented by another user.

Sequence numbers are generated independently of tables, so the same sequence can be used for one or for multiple tables. It is possible that individual sequence numbers will appear to be skipped, because they were generated and used in a transaction that ultimately rolled back. Additionally A Single User May Not Realize That Other Users Are Drawing from The Same Sequence.

Once a sequence is created, you can access its values ​​in SQL statements with the CURRVAL pseudocolumn (which returns the current value of the sequence) or the NEXTVAL pseudocolumn (which increments the sequence and returns the new value).

See Also:

"Pseudocolumns" for more information on using the CURRVAL and NEXTVAL "How to Use Sequence Values" for information on using sequences ALTER SEQUENCE or DROP SEQUENCE for information on modifying or dropping a sequencePrerequisites

To create a sequence in Your OWN Schema, You Must Sequence Privilege.

TO CREATE A SEQUENCE IN ANOTHER USER's Schema, You Must Have Create Any Sequence Privilege.

Syntax

转载请注明原文地址:https://www.9cbs.com/read-94573.html

New Post(0)