Successions is an idea utilized in auto addition instrument and it is presented in OrientDB v2.2. In information base wording, grouping is a design that deals with the counter field. Basically said groupings are generally utilized when you need a number that consistently augments. It upholds two types−
Requested − Each time the pointer calls the .following strategy that profits another worth.
Stored − The grouping will reserve 'N' things on every hub. To call every thing we use .next(), which is favored when the reserve contains more than one thing.
Create Sequence
Grouping is generally used to auto augmentation the id estimation of an individual. Like other SQL ideas of OrientDB it additionally preforms comparable activities as Sequence in RDBMS.
The accompanying assertion is the essential grammar to make successions.
CREATE SEQUENCE <sequence> TYPE <CACHED|ORDERED> [START <start>]
[INCREMENT <increment>] [CACHE <cache>]
Following are the insights concerning the choices in the above language structure.
- <Sequence> − Local name for grouping.
- TYPE − Defines the grouping type ORDERED or CACHED.
- START − Defines the underlying worth.
- Augmentation − Defines the addition for each .next strategy call.
- Store − Defines the quantity of significant worth to pre-reserve, if you used to store arrangement type.
Allow us to make an arrangement named 'seqid' what begins with number 1201. Attempt the accompanying questions to actualize this model with succession.
CREATE SEQUENCE seqid START 1201
In the event that the above question is executed effectively, you will get the accompanying yield.
Sequence created successfully
Attempt the accompanying inquiry to utilize grouping 'seqid' to embed the id estimation of Account table.
INSERT INTO Account SET id = sequence('seqid').next()
In the event that the above inquiry is executed effectively, you will get the accompanying yield.
Insert 1 record(s) in 0.001000 sec(s)
Alter Sequence
Modify grouping is an order used to change the properties of an arrangement. It will alter all the succession choices aside from grouping type.
The accompanying assertion is the fundamental language structure to change succession.
ALTER SEQUENCE <sequence> [START <start-point>]
[INCREMENT <increment>] [CACHE <cache>]
Following are the insights concerning the alternatives in the above sentence structure.
- <Sequence> − Defines the grouping you need to change.
- START − Defines the underlying worth.
- Addition − Defines the augmentation for each .next strategy call.
- Reserve − Defines the quantity of significant worth to pre-store if you used to store succession type.
Attempt the accompanying question to adjust the beginning an incentive from '1201 to 1000' of a grouping named seqid.
ALTER SEQUENCE seqid START 1000
In the event that the above question is executed effectively, you will get the accompanying yield.
Altered sequence successfully
Drop Sequence
Drop grouping is an order used to drop a succession.
The accompanying assertion is the essential punctuation to drop a grouping.
DROP SEQUENCE <sequence>
Where <Sequence> characterizes the succession you need to drop.
Attempt the accompanying question to drop an arrangement named 'seqid'.
DROP SEQUENCE seqid
On the off chance that the above question is executed effectively, you will get the accompanying yield.
Sequence dropped successfully