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 create tables in oracle?
How to fetch the row which has the max value for a column?
Query to retrieve record for a many to many relationship ?
How would you begin to troubleshoot an ORA-3113 error?
In what script is snap$ created? In what script is the scott/tiger schema created?
does the query needs a hint to access a materialized view?
What is an oracle cursor variable?
I am using an Oracle 8i Database my data contains Clob data. I am using toad version 7.6 i am able to get the data in toad but unable to extract the data in excel.when trying to extract the data into the excel the toad error says out of memory. Can any body please help me to extract the data through the same toad version. Thanks in advance
How is it different from a normal table?
How do I find my oracle client driver version?
How to connect to a local oracle 10g xe server?
How to use select statement to count the number of rows in oracle?
What is a table index in oracle?
What happens if variable names collide with table/column names?
How do I spool to a csv formatted file using sqlplus?