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
What privilege is needed for a user to query tables in another schema?
What is an oracle user account?
Which dictionary tables and/or views would you look at to diagnose a locking issue?
How do I recompile a procedure in oracle?
How do we get field details of a table?
What is partitioned table in Oracle?
How to drop a stored procedure in oracle?
How to run the anonymous block again?
What is the quickest way to export a table to a flat file?
How to create a table in a specific tablespace?
How to define a specific record type?
What are the different types of trigger and explain its various uses and functions?
What the is the diff between local index and global index. give some example.
If any one has information regarding interview of NIC (National Informatics Centre),it would be of great help...
How to rebuild an index in oracle?