KEMBAR78
Part1 create sequence,dual table | PPTX
Part 1- create sequence
DUAL TABLE
1DR. GIRIJA NARASIMHAN
The DUAL table is a special one-row, one-column table present by
default in all Oracle database installations.
DUAL is originally a table and the database engine would
perform disk IO on the table when selecting from DUAL. This disk
IO was usually logical IO (not involving physical disk access) as
the disk blocks were usually already cached in memory. This
resulted in a large amount of logical IO against the DUAL table.
Beginning with 10g Release 1 Oracle Database have been
optimized and the database no longer performs physical or
logical IO on the DUAL table even though the DUAL table still
actually exists.
DUAL is readily available for all the users in database. It is not
limited to system administrator only.
2DR. GIRIJA NARASIMHAN
DR. GIRIJA NARASIMHAN 3
create sequence Syntax
SQL> create sequence seq1
2 START WITH 1000
3 INCREMENT BY 1
4 NOCACHE
5 maxvalue 1005
6 cycle;
Sequence created.
4
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1004
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1005
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1
SQL> select seq1.nextval from dual;
NEXTVAL
----------
2
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1000
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1001
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1002
SQL> select seq1.nextval from dual;
NEXTVAL
----------
1003 5DR. GIRIJA NARASIMHAN

Part1 create sequence,dual table

  • 1.
    Part 1- createsequence DUAL TABLE 1DR. GIRIJA NARASIMHAN
  • 2.
    The DUAL tableis a special one-row, one-column table present by default in all Oracle database installations. DUAL is originally a table and the database engine would perform disk IO on the table when selecting from DUAL. This disk IO was usually logical IO (not involving physical disk access) as the disk blocks were usually already cached in memory. This resulted in a large amount of logical IO against the DUAL table. Beginning with 10g Release 1 Oracle Database have been optimized and the database no longer performs physical or logical IO on the DUAL table even though the DUAL table still actually exists. DUAL is readily available for all the users in database. It is not limited to system administrator only. 2DR. GIRIJA NARASIMHAN
  • 3.
    DR. GIRIJA NARASIMHAN3 create sequence Syntax
  • 4.
    SQL> create sequenceseq1 2 START WITH 1000 3 INCREMENT BY 1 4 NOCACHE 5 maxvalue 1005 6 cycle; Sequence created. 4
  • 5.
    SQL> select seq1.nextvalfrom dual; NEXTVAL ---------- 1004 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1005 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1 SQL> select seq1.nextval from dual; NEXTVAL ---------- 2 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1000 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1001 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1002 SQL> select seq1.nextval from dual; NEXTVAL ---------- 1003 5DR. GIRIJA NARASIMHAN