关于建立视图!

sm8848 2003-05-19 11:28:08
现在有表a(字段a,字段b,字段c......)
现在有表b(字段a,字段b,字段c......)
现在有表c(字段a,字段b,字段c......)

现在需要从三个表中查询信息,想把三张表建立到一个视图中,如何?

请各位大侠指教!
...全文
120 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sm8848 2003-05-19
  • 打赏
  • 举报
回复
就是把a表中a1,b中b1,c中c1作为superview中的一个字段,其他字段项类似!
sm8848 2003-05-19
  • 打赏
  • 举报
回复
table a (a1,a2,a3,a4);
table b (b1,b2,b3,b4);
table c (c1,c2,c3,c4);

table d (d1 varchar2,d1 clob,d2 blob);

d表是a,b,c的关联表

我现在已经建立视图aview
create view aview as
(
select a.a1,a.a2,a.a3,a.a4,b.d1,b.d2
from a a,d b
where
a.a1=b.d1
);

create view bview as
(
select b.b1,b.b2,b.b3,b.b4,b.d1,b.d2
from b a,d b
where
b.b1=b.d1
);
...

现在想做的是把几张表的信息放到同一个view中,然后可以通过一条“select * from superview;”来查询几张表的信息!
bzszp 2003-05-19
  • 打赏
  • 举报
回复
create view v_name as
select * from a,b,c
where ...;
BlueskyWide 2003-05-19
  • 打赏
  • 举报
回复
首先必须保证所有字段都为字符串,各表以a1,b1,c1关联:
select
(select a1 from a where a.a1=b.b1 and a.a1=c.c1)||
(select b1 from b where a.a1=b.b1 and a.a1=c.c1)||
(select c1 from c where a.a1=b.b1 and a.a1=c.c1) field1,
select a2 from a where a.a1=b.b1 and a.a1=c.c1)||
(select b2 from b where a.a1=b.b1 and a.a1=c.c1)||
(select c2 from c where a.a1=b.b1 and a.a1=c.c1) field2,
select a3 from a where a.a1=b.b1 and a.a1=c.c1)||
(select b3 from b where a.a1=b.b1 and a.a1=c.c1)||
(select c3 from c where a.a1=b.b1 and a.a1=c.c1) field3
from a,b,c where a.a1=b.b1 and a.a1=c.c1 ;
Lastdrop 2003-05-19
  • 打赏
  • 举报
回复
create or replace view superview
as
( select * from a
where ....
union all
select * from b
where ....
union all
select * from c
where ....

);

是这样吗?

17,078

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧