I need to insert the following values "1)" to "150)" for 50 different records. How do I shorten the below into one line?
insert into p.p_assumptions (p_number, value) values (11, '1)');
insert into p.p_assumptions (p_number, value) values (11, '2)');
...
insert into p.p_assumptions (p_number, value) values (11, '150)');
A simple method: Take a table with at least 150 records. Then
insert into p_assumptions (p_number, value)
select 11, to_char(rownum) || ')'
from table_with_at_least_150_records
where rownum <= 150;
One way is using connect by clause
insert into p_assumptions (p_number, value)
select 11, level || ')'
from dual
Connect by level <= 150;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.