zoukankan      html  css  js  c++  java
  • Oracle的CONNECT BY LOOP我自己使用的数据。关于where 跟join.

    create table test1(superid varchar2(20),id varchar2(20));

    insert into test1 values('0','1');
    insert into test1 values('0','2');

    insert into test1 values('1','11');
    insert into test1 values('1','12');

    insert into test1 values('2','21');
    insert into test1 values('2','22');

    insert into test1 values('11','111');
    insert into test1 values('11','112');

    insert into test1 values('12','121');
    insert into test1 values('12','122');

    insert into test1 values('21','211');
    insert into test1 values('21','212');

    insert into test1 values('22','221');
    insert into test1 values('22','222');

    commit;

    select * from test1


    select level||' layer',lpad(' ',level*5)||id id ,connect_by_isleaf
    from test1
    start with superid = '0' connect by prior id=superid;

    select level||' layer',lpad(' ',level*5)||id id ,connect_by_isleaf,substr( sys_connect_by_path(id,'>'),2)
    from test1 
    where connect_by_isleaf=1
    start with superid = '0' connect by prior id=superid;

    --------------Join -------------

    select level||' layer',lpad(' ',level*5)||id id ,connect_by_isleaf,substr( sys_connect_by_path(id,'>'),2)
    from test1 ,(select 111 col from dual) tmp
    where tmp.col=to_number(test1.id)
    start with superid = '0' connect by prior id=superid;

    --------------Where -------------

    select level||' layer',lpad(' ',level*5)||id id ,connect_by_isleaf,substr( sys_connect_by_path(id,'>'),2)
    from test1 
    where 111=to_number(test1.id)
    start with superid = '0' connect by prior id=superid;

    魔兽就是毒瘤,大家千万不要玩。
  • 相关阅读:
    对Postmaster 对 SIGQUIT 信号处理的理解
    kill bgwriter 的小实验
    我对 execl 的学习
    pid_t 数据类型
    我对bgwriter.c 与 guc 关系的初步理解
    对Linux 下 SIGUSR1 与 SIGUSR2 的理解
    向bgwriter 发送 SIGQUIT 的实验
    常用txt图标符号
    也做网页图标favicon.ico
    TakeColor颜色拾取工具
  • 原文地址:https://www.cnblogs.com/tracy/p/1722252.html
Copyright © 2011-2022 走看看