create view view_table1 as select
a.zd1,a.zd2,a.zd3,b.zd4,b.zd5 from table1 a,table2 b where a.zd1*=b.zd1create view view_table2 as select
b.zd1,a.zd2,a.zd3,b.zd4,b.zd5 from table1 a,table2 b where a.zd1=*b.zd1create view view_table as select * from view_table1 union select * from view_table2
a.zd1,a.zd2,a.zd3,b.zd4,b.zd5 from table1 a,table2 b where a.zd1*=b.zd1create view view_table2 as select
b.zd1,a.zd2,a.zd3,b.zd4,b.zd5 from table1 a,table2 b where a.zd1=*b.zd1create view view_table as select * from view_table1 union select * from view_table2
如果在Oracle中,这样的:
Create View view1as
select zd1,zd2,zd3,null zd4,null zd5 frojm table1
union all
select zd1,null zd2,null zd3, zd4, zd5 frojm table2
Create View view1 as
select table1.zd1,table1.zd2,table1.zd3,table2.zd4,table2.zd5 from table1
left outer join
table2 on table2.zd1=table1.zd1
union
select table2.zd1,table1.zd2,table1.zd3,table2.zd4,table2.zd5 from table1
right outer join
table2 on table2.zd1=table1.zd1
select a.zd1,a.zd2,a.zd3,
zd4=(select zd4 from table2 b where b.zd1=a.zd1),
zd5=(select zd5 from table2 b where b.zd1=a.zd1)
from table1 a