how to genarate random numbers in oracle for particular row?

Answers were Sorted based on User's Feedback



how to genarate random numbers in oracle for particular row?..

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

how to genarate random numbers in oracle for particular row?..

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

how to genarate random numbers in oracle for particular row?..

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

Post New Answer

More Oracle General Interview Questions

What is SAVE POINT ?

5 Answers  


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.

0 Answers  


Define Transaction ?

5 Answers  


Give the various exception types.

0 Answers  


What is a OUTER JOIN?

1 Answers  






Do View contain Data ?

10 Answers  


Give SQL Query to find the number words in a sentence ? ex: 'ram charan singh' then ans:3

3 Answers  


What are the four Oracle system processes that must always be up and running for the database to be useable?

0 Answers  


How can we find out the duplicate values in an oracle table?

0 Answers  


14. Display the item_cost and then round it to the nearest hundred, ten, unit, tenth and hundredth

1 Answers   Wipro,


can we pass two out parameters at a time in function?please answer to my question

3 Answers   Wipro,


Explain the use of tables option in exp command.

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)