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
How can we force the database to use the user specified rollback segment?
Whats the benefit of dbms_stats over analyze?
What is Trigger in Oracle?
What are the uses of synonyms?
How to create a new table by selecting rows from another table?
does the query needs a hint to access a materialized view?
normally database take to refresh time 2 hours. but client asked iwant to refresh with in 5 min that same database. do you have any option in BO and Oracle? explain me briefly...kavi
What are the differences between date and timestamp in oracle?
Hi friends can u send the oracle 9i full version download link?????????????? please reply ?
How are extents allocated to a segment?
Explain oracle’s server parameter file.
How do I call oracle stored procedures that take no parameters?
 How to use an oracle sequence generator in a mapping?
What is a cursor variable?
defination of bitmap index