Tuesday, July 3, 2007
creation and manage of sequence
create and manage sequence
+++++++creation of a simple tabl to show sequence+++++++++++
create table depart(did number(6),dname varchar2(30),locid number(10));
++++++++sequence creation++++++++++++++++
***SEQUENCE1****
create sequence depart_s
increment by 10
start with 120
maxvalue 9999
nocache
nocycle;
***SEQUENCE2****
create sequence depart_s1
increment by 1
start with 0
maxvalue 99
MINVALUE 0
nocache
nocycle
++++++++++confirming sequence++++++++++++
select * from DBA_SEQUENCES WHERE SEQUENCE_OWNER='SCOTT';
++++++++++SHOWING THE VALUE GENERATED BY SEQUENCE++++++++++++
SELECT DEPART_S.CURRVAL FROM DUAL;
SELECT DEPART_S.NEXTVAL FROM DUAL;
+++++++++USING A SEQUENCE++++++++++++++
INSERT INTO DEPART(DID,DNAME,LOCID)
VALUES(DEPART_S.NEXTVAL,'DEPARTMENT',DEPART_S1.NEXTVAL);
SELECT * FROM DEPART;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment