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
master table and child table performances and comparisons in Oracle ?
What are operators in oracle?
How does one get the view definition of fixed views/tables?
What is a tns file?
What is an oracle user role?
What is the difference between the Oracle ODBC driver and a Microsoft ODBC (Open Database Connectivity) Driver?
Please explain oracle left join with an example?
What is a cursor in oracle?
How to retrieve data from an explicit cursor?
How to load data from external tables to regular tables?
material view and view disadvantages?
How to create a single index for multiple columns?
What happens if variable names collide with table/column names?
How to filter out duplications in the returning rows using oracle?
How to use regular expression in pattern match conditions in oracle?