I have 2 tables with the following fields.
Is creating a view an option?
What is the software you're using that does this to you? I don't see this behavior in SQL*Plus or PL/SQL Developer in 10g. PL/SQL won't let you build a cursor with this ambiguity in it.
Try this
select t1.AA "t1_AA", t2.AA "t2.AA"
from table1 t1,
inner join table2 t2
on table1.DD = table2.EE
As he said before, you need to do it per column
In Oracle SELECT
syntax, there is currently no way to assign column aliases to multiple columns based on some expression. You have to assign an alias to each individual column.
Is there a magic way to do this in oracle?
Not that I'm aware of. Your options amount to:
Address the column naming scheme - you'd need to use ALTER TABLE statements like:
ALTER TABLE table_name
RENAME COLUMN old_name to new_name;
Use column aliases
You could use views to save on the work & effort of defining column aliases, but it's not a recommended practice because of the bad performance when layering views on top of one another.