how to genarate random numbers in oracle for particular row?
Answers were Sorted based on User's Feedback
Answer / tanoy guhasarkar
the DBMS_RANDOM package provides a built-in random number
generator utility.
Using In Side A Block:--
DECLARE
my_random BINARY_INTEGER;
BEGIN
my_random := DBMS_RANDOM.RANDOM;
dbms_output.put_line(my_random);
end ;
Executing This Code, We Will Get A Random Number Every Time...
In Side A Select Statement :--
select DBMS_RANDOM.RANDOM from dual;
Note:--
This DBMS_RANDOM package included in oracle after oracle 8.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
Answer / swamireddy
first take table. the table contain a more than one row.
write query display the row randomly.
SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1
Is This Answer Correct ? | 1 Yes | 5 No |
What is SAVE POINT ?
Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracles. What database recovery options are available? Database is in archive log mode.
Define Transaction ?
Give the various exception types.
What is a OUTER JOIN?
Do View contain Data ?
Give SQL Query to find the number words in a sentence ? ex: 'ram charan singh' then ans:3
What are the four Oracle system processes that must always be up and running for the database to be useable?
How can we find out the duplicate values in an oracle table?
14. Display the item_cost and then round it to the nearest hundred, ten, unit, tenth and hundredth
can we pass two out parameters at a time in function?please answer to my question
Explain the use of tables option in exp command.