`
01jiangwei01
  • 浏览: 533801 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

sql connect by start with

SQL 
阅读更多

select level||'层',lpad(' ',(level-1)*5)||unit_nm , sys_connect_by_path(unit_nm ,'@'),unit_nm,level from sys_unit
start with unit_nm = 'unit_1'
connect by prior unit_nm = unit_relation

 

数据库表 sys_unit 
 id           unit_nm            unit_relation

 1             unit_1                     

 2             unit_1 _1             unit_1

 3             unit_1 _2             unit_1

 4             unit_1 _3             unit_1

 5             unit_1 _1_1         unit_1 _1

 6             unit_1 _1_2         unit_1 _1

 7             unit_1 _1_1_1     unit_1 _1_1

 8             unit_1 _1_1_2     unit_1 _1_1 

 9             unit_1 _1_1_3     unit_1 _1_1 

 

分享到:
评论

相关推荐

    SQL21日自学通

    TNS:listener Could Not Resolve SID Given in Connect Descriptor 484 Insufficient Privileges During Grants484 Escape Character in Your Statement--Invalid Character 485 Cannot Create Operating System ...

    SQL培训第一期

    connect by t.parentcode = prior t.organcode; //递归查询子节点 1.8.7 union 和 union all 1.8.7.1 语法 select * from dual union all select * from dual 1.8.7.2 说明 union 会对查询数据进行去重并排序,union...

    SQL性能优化

    CONNECT BY PRIOR ID = parent_id AND STATEMENT_ID = user_define  示例 如要测试下面SQL: SELECT c.short, a.cday, a.card_no, a.qty FROM sales.stockiohis a, sales.product_info b, sales.vendor c WHERE ...

    Oracle SQL树形结构查询

    oracle中的select语句可以用START WITH…CONNECT BY PRIOR子句实现递归查询,connect by 是结构化查询中用到的,其基本语法是: 代码如下:select * from tablename start with cond1 connect by cond2 where cond3;...

    微软内部资料-SQL性能优化3

    To support SERIALIZABLE transaction semantics, SQL Server needs to lock sets of rows specified by a predicate, such as WHERE salary BETWEEN 30000 AND 50000 SQL Server needs to lock data that does ...

    Building Web Services with Microsoft Azure(PACKT,2015)

    You'll start by creating, customizing, and extending HTTP-based web APIs and move on to host your web API with ASP.NET. Then, using a range of different features, you'll learn how to connect your ...

    Building.Web.Services.with.Microsoft.Azure.1784398373

    You'll start by creating, customizing, and extending HTTP-based web APIs and move on to host your web API with ASP.NET. Then, using a range of different features, you'll learn how to connect your ...

    oracle递归、迭代

    Oracle使用递归查询。查询树结构的sql。在Oracle中,递归查询要用到start with ……connect by prior……

    Oracle常用查询操作大全

    Oracle常用的sql语句文件以及说明(doc、txt)文件 例如:analyze分析表、oracle 常用表和视图、Select Start with ... Connect by 分层次输出、SQL语句优化、函数的使用和说明。

    Learning PostgreSQL 10

    We’ll cover the Data Definition Language (DDL) with an emphasis on PostgreSQL, and the common DDL commands supported by ANSI SQL. You’ll learn to create tables, define integrity constraints, build ...

    ora分析脚本

    - ash_sql <sql_id> Show all ash rows group by sampli_time and event for the specified sql_id - [-u ] degree degree of objects for a given user - [-u ] colstats stats for each table, column - [-u ]...

    Raspberry Pi Zero Cookbook

    We start by showing you how to set up and manage the Pi Zero and then move on to configuring the hardware, running it with Linux, and programming it with Python scripts. Later, we integrate the ...

    韩顺平oracle学习笔记

    案例:sql>@ d:\a.sql 或者 sql>start d:a.sql (2) edit 说明:该命令可以编辑指定的sql脚本。 案例:sql>edit d:\a.sql (3) spool 说明:该命令可以将sql*plus屏幕上的内容输出到指定文件中去。 案例:sql>spool d:...

    Oracle事例

    [start with START_DATE next NEXT_DATE] as QUERY; create snapshot snapshot_to_study as select * from TABLE_NAME@to_study; 创建角色 create role aa identified by aaa; 授权 grant create snapshot,...

    最全的oracle常用命令大全.txt

    SQL>START test SQL>@test 常用SQL*Plus语句 a、表的创建、修改、删除 创建表的命令格式如下: create table 表名 (列说明列表); 为基表增加新列命令如下: ALTER TABLE 表名 ADD (列说明列表) 例:为test表...

    orcale常用命令

    SQL>START test SQL>@test 常用SQL*Plus语句 a、表的创建、修改、删除 创建表的命令格式如下: create table 表名 (列说明列表); 为基表增加新列命令如下: ALTER TABLE 表名 ADD (列说明列表) 例:为test表...

    21天学习SQL V1.0

    21天学习SQL V1.0.pdf 66 SQL 21 日自学通(V1.0) 翻译人笨猪 EMAIL wyhsillypig@163.com 2 日期/时间函数.........................................................................................................

    Citrix_XenApp5

    • Citrix provides a 96-hour initial grace period that will allow up to two users to connect while unable to connect to a License Server • Citrix XenApp client • the XenApp Plugin,the XenApp Web ...

    Oracle数据库中的级联查询、级联删除、级联更新操作教程

    start with selfid=id //给定一个startid(字段名为子接点ID,及开始的ID号) connect by prior selfid=parentid //联接条件为子接点等于父接点,不能反 这个SQL主要用于菜单的级联查询,给一个父接点可以查出所有的...

Global site tag (gtag.js) - Google Analytics