Hi Friends ,
Lets Understand the Sequence with Examples
Create SEQUENCE XXEMPNO_SEQ
START WITH 100
MAXVALUE 500
INCREMENT BY 1;
Select XXEMPNO_SEQ.NEXTVAL from dual;
Select XXEMPNO_SEQ.CURRVAL from dual;
Create TABLE XXGH(EMPNO NUMBER, ENAME VARCHAR2(30));
Select * from XXGH;
COMMIT;
UPDATE XXGH SET EMPNO=106 where EMPNO=109;
INSERT INTO XXGH(EMPNO,ENAME) VALUES(XXEMPNO_SEQ.NEXTVAL,'ANI');
COMMIT;
DELETE FROM XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO);
Select * from XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO)
/
SELECT * FROM USER_OBJECTS WHERE OBJECT_NAME='XXEMPNO_SEQ'
SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME='XXEMPNO_SEQ';
Select rownum ,E.* from EMP E order BY ENAME;
/
Select rownum ,E.* from EMP E where DEPTNO=30 ;
Lets Understand the Sequence with Examples
Create SEQUENCE XXEMPNO_SEQ
START WITH 100
MAXVALUE 500
INCREMENT BY 1;
Select XXEMPNO_SEQ.NEXTVAL from dual;
Select XXEMPNO_SEQ.CURRVAL from dual;
Create TABLE XXGH(EMPNO NUMBER, ENAME VARCHAR2(30));
Select * from XXGH;
COMMIT;
UPDATE XXGH SET EMPNO=106 where EMPNO=109;
INSERT INTO XXGH(EMPNO,ENAME) VALUES(XXEMPNO_SEQ.NEXTVAL,'ANI');
COMMIT;
DELETE FROM XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO);
Select * from XXGH WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM XXGH GROUP BY EMPNO)
/
SELECT * FROM USER_OBJECTS WHERE OBJECT_NAME='XXEMPNO_SEQ'
SELECT * FROM USER_SEQUENCES WHERE SEQUENCE_NAME='XXEMPNO_SEQ';
Select rownum ,E.* from EMP E order BY ENAME;
/
Select rownum ,E.* from EMP E where DEPTNO=30 ;
Comments
Post a Comment