-
In oracle, the sequence is the sequence number, which is automatically incremented each time it is retrieved. Sequence has nothing to do with tables.
1、create sequence
First of all, you must have the Create Sequence or Create Any Sequence permission.
The creation statement is as follows:
create sequence seqtest
increment by 1 -- add several at a time.
start with 1 -- Count from 1.
nomaxvalue -- the maximum value is not set.
nocycle -- always accumulates, does not cycle.
cache 10;- Set the cache sequence, if the system is down or other situations will cause the sequence to be discontinuous, you can also set it to --- nocache
2. Get the sequence value.
Once you have defined the sequence, you can use currval, nextval to get the value.
currval: returns the current value of the sequence.
nextval: increases the value of the sequence, and then returns the value of the increased sequence.
The resulting value statement is as follows:
Select Sequence Name. currval from dual;
For example, the statement above to create the sequence value is:
select from dual
Where you can use Sequence in SQL statements:
Select statements that do not contain subqueries, snapshots, and views.
insert statement.
insert statement.
update.
Such as in the insert statement.
insert into table name(id,name)values(,'sequence insertion test');
Note: The first nextval returns the initial value; Subsequent nextval will automatically increment the increment by value you define, and then return the increased value.
currval always returns the value of the current sequence, but currval can only be made after the first nextval initialization, otherwise an error will occur.
select top(1)* from table_name order by update_time desc
My idea is to find the result of the first place in descending order of modification time, isn't it? >>>More
The solution is as follows: 1. The create global temporary table t temp statement is to create a temporary table, there are two kinds of temporary tables created in oracle, one is transaction-level and the other is session-level, when the creation of temporary table statement is followed by on commit delete rows, it means that the temporary table is transaction-level, and when on commit preserve rows it means that the temporary table is session-level. >>>More
Method steps.
1 10 Step by Step Reading. >>>More
Michelle Yeoh is a senior in the acting industry, and his performance has always been very good, and his acting skills are first-class.
Find damp soil, damp sand in deep digging, and put it in a bottle to evaporate water from sunlight. >>>More