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 is a read write transaction in oracle?
What are the oracle built-in data types?
Difference between varchar and varchar2 data types?
How to create an oracle database?
How to declare a local variable?
How to count groups returned with the group by clause in oracle?
what is a Nested Loop join?
Explain oracle data types with examples?
How to join two tables in a single query using oracle?
types of indexes and the rationale behind choosing a particular index for a situation.
while i take backup using ibm tsm the following errors occurred: rman-03009 ora-19513 ora-27206 ora-19502 ora-27030 ora-ora19511
Explain the use of Merge statement in oracle 11g
how to code performance tuning of oracle PL/SQL? can any body send me the perfect answer?
What is an oracle database table?
How to connect to a remote server?