我有拥有公司层次结构的表。由于公司没有明确的层数,因此决定使用这张平板电脑。这个表很好,如果你在客户端上使用级联列表,它是完美的。但是,我需要看到一个“部分”以及它拥有的所有其他“部分”。希望下面的信息能够帮助你了解我需要做什么。Oracle分层查询
表防守
create table SECTION
(
SECTION_ID NUMBER(38) not null,
SECTION_NAME VARCHAR2(75) not null,
SECTION_MANAGER NUMBER(6) not null,
SECTION_LEVEL NUMBER(3) not null,
OWNER_SECTION_ID NUMBER(38)
)
数据
1 IT 901763 2 0
2 Business Systems 904241 3 1
3 Business Analysis 900813 4 2
4 Development 900976 4 2
5 Testing 907052 4 2
6 Systems Architecture 908012 4 2
7 Mobilisation 904241 4 2
8 Operations 900885 2 0
9 Area 2 900456 3 8
0 Executive 1 0 0
我需要看到
0 Executive 1 8 Operations
0 Executive 1 1 IT
0 Executive 1 0 Executive
0 Executive 1 2 Business Systems
0 Executive 1 7 Mobilisation
0 Executive 1 6 Systems Architecture
0 Executive 1 4 Development
0 Executive 1 3 Business Analysis
0 Executive 1 5 Testing
0 Executive 1 9 Area 2
1 IT 901763 2 Business Systems
1 IT 901763 7 Mobilisation
1 IT 901763 6 Systems Architecture
1 IT 901763 4 Development
1 IT 901763 3 Business Analysis
1 IT 901763 5 Testing
2 Business Systems 904241 7 Mobilisation
2 Business Systems 904241 6 Systems Architecture
2 Business Systems 904241 4 Development
2 Business Systems 904241 3 Business Analysis
2 Business Systems 904241 5 Testing
8 Operations 900885 9 Area 2
7 Mobilisation 904241
6 Systems Architecture 908012
4 Development 900976
3 Business Analysis 900813
5 Testing 907052
9 Area 2 900456
我可以在次做到这一点e C#在客户端,但我真的很想把它作为数据库的视图。
有人可以帮我这个。它甚至有可能吗?
如果您需要澄清任何问题,请留下评论,我会尽力提供更多信息。
非常棒,谢谢。我们的一位DBA提出了一个答案,但它比这个更复杂,非常高效,所以我明天就试试看,并比较解释计划。 – Dave7896 2010-01-25 19:38:00