ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
1DR. GIRIJA NARASIMHAN
Part 9 - Use of SEQUENCE value
IN a TABLE
SQL> create sequence seq1
2 START WITH 6
3 INCREMENT BY 1
4 NOCACHE
5 maxvalue 8
6 cycle;
Sequence created.
SQL> create table product(productid number(4), price number(6));
Table created.
SQL> insert into product values(1,seq1.nextval);
1 row created.
SQL> select * from product;
PRODUCTID PRICE
---------- ----------
1 6 2
DR. GIRIJA NARASIMHAN
DR. GIRIJA NARASIMHAN
3
SQL> insert into product values(2,seq1.nextval);
1 row created.
SQL> select * from product;
PRODUCTID PRICE
---------- ----------
1 6
2 7
SQL> insert into product values(3,seq1.nextval);
1 row created.
SQL> select * from product;
PRODUCTID PRICE
---------- ----------
1 6
2 7
3 8
SQL> insert into product values(4,seq1.nextval);
1 row created.
SQL> select * from product;
PRODUCTID PRICE
---------- ----------
1 6
2 7
3 8
4 1

More Related Content

Part9 sequence valule in table

  • 1. 1DR. GIRIJA NARASIMHAN Part 9 - Use of SEQUENCE value IN a TABLE
  • 2. SQL> create sequence seq1 2 START WITH 6 3 INCREMENT BY 1 4 NOCACHE 5 maxvalue 8 6 cycle; Sequence created. SQL> create table product(productid number(4), price number(6)); Table created. SQL> insert into product values(1,seq1.nextval); 1 row created. SQL> select * from product; PRODUCTID PRICE ---------- ---------- 1 6 2 DR. GIRIJA NARASIMHAN
  • 3. DR. GIRIJA NARASIMHAN 3 SQL> insert into product values(2,seq1.nextval); 1 row created. SQL> select * from product; PRODUCTID PRICE ---------- ---------- 1 6 2 7 SQL> insert into product values(3,seq1.nextval); 1 row created. SQL> select * from product; PRODUCTID PRICE ---------- ---------- 1 6 2 7 3 8 SQL> insert into product values(4,seq1.nextval); 1 row created. SQL> select * from product; PRODUCTID PRICE ---------- ---------- 1 6 2 7 3 8 4 1