how to genarate random numbers in oracle for particular row?

Answer Posted / nusrath sultana

We can make use of sequence to generate random numbers.
example:
SQL> create sequence seq1 start with 1 increment by 1
maxvalue 100;
SQL>Sequence created.

SQL> create table dup(rollno number(10) primary key,name
varchar2(20) not null);

Table created.

SQL> insert into dup values(seq1.nextval,'&name');
Enter value for name: SAM
old 1: insert into dup values(seq1.nextval,'&name'
new 1: insert into dup values(seq1.nextval,'SAM')

1 row created.

SQL> /

Enter value for name: RAM
old 1: insert into dup values(seq1.nextval,'&name'
new 1: insert into dup values(seq1.nextval,'RAM')

1 row created.

SQL> /
Enter value for name: REENA
old 1: insert into dup values(seq1.nextval,'&name'
new 1: insert into dup values(seq1.nextval,'REENA'

1 row created.

SQL> /
Enter value for name: TINA
old 1: insert into dup values(seq1.nextval,'&name'
new 1: insert into dup values(seq1.nextval,'TINA')

1 row created.

SQL> /
Enter value for name: MONA
old 1: insert into dup values(seq1.nextval,'&name'
new 1: insert into dup values(seq1.nextval,'MONA')

1 row created.

SQL> SELECT * FROM DUP;

ROLLNO NAME
---------- --------------------
1 SAM
2 RAM
3 REENA
4 TINA
5 MONA

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to start instance with a minimal initialization parameter file?

542


What is the purpose of save points in oracle database?

545


Can we create trigger on materialized view in oracle?

567


How would you go about verifying the network name that the local_listener is currently using?

1609


Explain the use of file option in exp command.

601






What view(s) do you use to associate a users SQLPLUS session with his o/s process?

1911


How to delete a column in an existing table in oracle?

605


WHAT IS THE DEFINITION OF DEFAULT CUSTOMER IN AR?

1705


Is oracle an operator?

534


Explain a synonym?

608


What is a tns file?

502


Explain oracle data types with examples?

577


What is parameterized cursor in oracle?

579


what is the difference between substr and instr function in oracle?

588


Is a rollback possible to any savepoint?

558