Sequence usage in Oracle: createtabletest (pidintegerprimarykey, namevarchar (20); select * fromtest
Sequence usage in Oracle: create table test (pid integer primary key, name varchar (20); select * from test
Homepage → Database Technology
Background:
Read News
Sequence usage in Oracle
[Date:] Source: Linux community Author: myxx520 [Font:]
Sequence usage in Oracle:
Create table test
(Pid integer primary key,
Name varchar (20)
);
Select * from test;
Insert into test values (1, 'jack ');
Create sequence test_seq; -- create a sequence
Select test_seq.nextval from dual; -- add one after each use of the sequence
Select test_seq.currval from dual; -- query the value of the current sequence
Insert into test values (test_seq.nextval, 'Jack Or Duck? '); -- Sequence usage
Drop sequence test_seq; -- delete a sequence
Create sequence test_seq start with 8; -- specify the initial value of the sequence
Alter sequence test_seq minvalue 9; -- sets the minimum value of the sequence.
Alter sequence test_seq maxvalue 9999; -- sets the maximum value of the sequence.
Alter sequence test_seq increment by 1; -- sets the sequence step size.
Drop sequence test_seq_1;
Create sequence test_seq_1 start with 3 minvalue 1 maxvalue 30 increment by 1;
Select test_seq_1.nextval from dual;
Alter sequence test_seq_1 cycle;
Alter sequence test_seq_1 nocycle; -- disable the cyclic Value Function
Alter sequence test_seq_1 cache 10;
-- Set the sequence cache size. Note: The default value of the sequence cache is 20.
Create sequence test_seq_2 start with 1 minvalue 1 maxvalue 20 increment by 3;
Alter sequence test_seq_2 cycle;
-- The preceding statement reports an error: the Cache value must be smaller than the cycle value.
Alter sequence test_seq_2 increment by 2;
Alter sequence test_seq_2 cycle;
-- Error reported
Alter sequence test_seq_2 increment by 1;
Alter sequence test_seq_2 cycle;
-- Error reported
Alter sequence test_seq_2 maxvalue 21;
Alter sequence test_seq_2 cycle;
-- No error is reported.
-- Or modify
Alter sequence test_seq_1 cache 5;
-- Start with 1 and maxvalue 10 step 1 then 10 times cycle and bigger than 5
0
Oracle permission management
Difference between object permission and system permission revocation in Oracle PL/SQL
Oracle tutorial
Image Information
View All comments in this article (0)
Comments
Latest Information
Popular this week
Introduction to Linux community-advertisement service-website map-help Info-contact us
The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.
Copyright©2006-2011 Linux community All rights reserved Zhejiang ICP backup No. 06018118