I have a requirement wherein I intend to fetch duplicate records from Oracle DB so as to mimic scenarios wherein we have duplicate records.
So, I decided on using union_all
.
select column1 from tbl where rowid in (select rowid from tbl where rownum<=5)
union all
select column1 from tbl where rowid in (select rowid from tbl where rownum<=5)
order by column1;
--works
However, when trying to fetch all the columns,
select * from tbl where rowid in (select rowid from tbl where rownum<=5)
union all
select * from tbl where rowid in (select rowid from tbl where rownum<=5)
order by column1;
-- Doesn't work. Invalid identifier
Any suggestion on what is wrong here would be great help.