如果穷举也是可以的,只是比较麻烦的
create or replace view v_test as
select name,type,num from dept a,
(
select * from t_1
union
select * from t_2
union
select * from t_3
...
) b
where a.id=b.type
create or replace view v_test as
select name,type,num from dept a,
(
select * from t_1
union
select * from t_2
union
select * from t_3
...
) b
where a.id=b.type
select * from t_1
union
select * from t_2
union
select * from t_3
...
)这样写也是静态的把表写出来,如果我再建多一个部门,那这视图就不对了,要重新写过
要么你就用一个Sql来生成这样的sql来进行动态创建
如
select 'create or replace view v_test as select name,type,num from dept a,( ' from dual;
union
select 'select * from '||tables ||' union ' as unionsql from dept;
union
select ') b where a.id=b.type' from dual;在你加入这个表时动态维护这个视图的更新就可以了(让系统动态维护视图也算上自动了,只是不太方便而已了),其他的也没有办法了!