create view with wild card

I am trying to create view from series of tables, but not sure about the solution...

CREATE VIEW V1 (C1) AS SELECT SIN(C1) FROM T*;
* is the wild card because I have 100 tables T1...T100...

Is this possible in oracle?
LVL 5
CalmSoulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
>>Is this possible in oracle?

Nope.

You can write some complex XML type queries or functions that might dynamically generate the desired output but I would advise you to just bite the bullet and create a UNION or "UNION ALL view.

CREATE VIEW V1 (C1) AS
SELECT SIN(C1) FROM T1
UNION ALL
SELECT SIN(C1) FROM T2
...


You can write SQL to generate the SQL:
select 'SELECT SIN(C1) FROM || table_name || chr(13) || chr(10) || ' union all '
from user_tables where table_name like 'T%';
slightwv (䄆 Netminder) Commented:
Borrowed the XML trick from:
http://www.experts-exchange.com/Database/Oracle/Q_25111045.html#a26476979

drop table tab1 purge;
create table tab1(col1 number);

drop table tab2 purge;
create table tab2(col1 number);

insert into tab1 values(1);
insert into tab2 values(2);
commit;

select sin(col1) from tab1;
select sin(col1) from tab2;

select table-name from user_tables where table_name like 'T%';

SELECT table_name,
           to_number(
               extractvalue(
                   xmltype(dbms_xmlgen.getxml('select sin(col1) X from ' || table_name)),
                   '/ROWSET/ROW/X'
               )
           )
           mySIN
FROM user_tables
where table_name like 'T%';

Open in new window


Output form above test:
TABLE_NAME                          MYSIN
------------------------------ ----------
TAB1                           .841470985
TAB2                           .909297427

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.