zoukankan      html  css  js  c++  java
  • 用于测试SqlAnalyzer1.00的十七个测试用例

    SqlAnalyzer功能:解析SQL语句,具体到字段,表和条件,并将其整理后输出格式化文本。

    1.

    原文=select a from b
    整理后文本=
    select
        a
    from
        b

    2.

    原文=select a,b,c from tb,tc,td,tf f,tg g
    整理后文本=
    select
        a,
        b,
        c
    from
        tb,
        tc,
        td,
        tf f,
        tg g

    3.

    原文=select name name,birthday b,column c from tb
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        tb

    4.

    原文=select name as name,birthday as b,column c from tb
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        tb

    5.

    原文=select name as name,birthday as b,column c from (select a,c,b from tb) tb
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        (
        select
            a,
            c,
            b
        from
            tb) tb

    6.

    原文=select name as name,birthday as b,column c from (select a,c,b from tb) tb,(select a1,a2,a3 from table_a) ta
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        (
        select
            a,
            c,
            b
        from
            tb) tb,
        (
        select
            a1,
            a2,
            a3
        from
            table_a) ta

    7.

    原文=select name as name,birthday as b,column c from (select a,c,b from tb) tb,(select a1,a2,a3 from (select * from tbc) tbc) ta
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        (
        select
            a,
            c,
            b
        from
            tb) tb,
        (
        select
            a1,
            a2,
            a3
        from
            (
            select
                *
            from
                tbc) tbc) ta

    8.

    原文=select name as name,birthday as b,column c from (select a,c,b from tb) tb,(select a1,a2,a3 from (select * from (select t1,t2,t3,t4,t5,t6 from test) t1) tbc) ta
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        (
        select
            a,
            c,
            b
        from
            tb) tb,
        (
        select
            a1,
            a2,
            a3
        from
            (
            select
                *
            from
                (
                select
                    t1,
                    t2,
                    t3,
                    t4,
                    t5,
                    t6
                from
                    test) t1) tbc) ta

    9.

    原文=select name as name,birthday as b,column c from (select a,c,b from tb) tb,(select a1,a2,a3 from (select * from (select t1,t2,t3,t4,t5,t6 from (select t1,t2,t3,t4,t5,t6,t7 from table4 ) t2) t1) tbc) ta
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        (
        select
            a,
            c,
            b
        from
            tb) tb,
        (
        select
            a1,
            a2,
            a3
        from
            (
            select
                *
            from
                (
                select
                    t1,
                    t2,
                    t3,
                    t4,
                    t5,
                    t6
                from
                    (
                    select
                        t1,
                        t2,
                        t3,
                        t4,
                        t5,
                        t6,
                        t7
                    from
                        table4) t2) t1) tbc) ta

    10.

    原文=select name as name,birthday as b,column c from tc c,tb b,(select a1,a2,a3 from (select * from tbc) tbc) ta
    整理后文本=
    select
        name name,
        birthday b,
        column c
    from
        tc c,
        tb b,
        (
        select
            a1,
            a2,
            a3
        from
            (
            select
                *
            from
                tbc) tbc) ta

    11.

    原文=select (select f1,f2,f3 from tbable) as x,(select a from tc) as cnt from b
    整理后文本=
    select
        (
        select
            f1,
            f2,
            f3
        from
            tbable) x,
        (
        select
            a
        from
            tc) cnt
    from
        b

    12.

    原文=select name from tb where age=41
    整理后文本=
    select
        name
    from
        tb
    where
        age=41 

    13.

    原文=select name from tb where age=41 and level>9 or salary<30000
    整理后文本=
    select
        name
    from
        tb
    where
        age=41 and
        level>9 or
        salary<30000 

    14.

    原文=select name from tb where age=41 and level>9 or salary<30000 order by name
    整理后文本=
    select
        name
    from
        tb
    where
        age=41 and
        level>9 or
        salary<30000 
    order by
        name 

    15.

    原文=select name from tb where age=41 and level>9 or salary<30000 order by name asc,id desc,age
    整理后文本=
    select
        name
    from
        tb
    where
        age=41 and
        level>9 or
        salary<30000 
    order by
        name asc,
        id desc,
        age 

    16.

    原文=select name from tb where age=41 and level>9 or salary<30000 order by name,id desc,age asc
    整理后文本=
    select
        name
    from
        tb
    where
        age=41 and
        level>9 or
        salary<30000 
    order by
        name ,
        id desc,
        age asc

    17.

    原文=select name from tb where age=41 and level>9 or salary<30000 order by name,id,age,level
    整理后文本=
    select
        name
    from
        tb
    where
        age=41 and
        level>9 or
        salary<30000 
    order by
        name ,
        id ,
        age ,
        level 

    十七个SQL都解析无误,嵌套sql也没有问题,今天,解析sql语句的夙愿终于达成了。

    --2020-05-27--

  • 相关阅读:
    在webBrowser中取Cookie的方法
    C#遍历DataSet中数据的几种方法总结
    php数组排序函数
    linux top命令详解
    HTTPSQS(HTTP Simple Queue Service)消息队列
    mysql 触发器(trigger) 总结
    HDU4292 Food —— 最大流 + 拆点
    POJ1459 Power Network —— 最大流
    POJ2516 Minimum Cost —— 最小费用最大流
    HDU4280 Island Transport —— 最大流 ISAP算法
  • 原文地址:https://www.cnblogs.com/heyang78/p/12974097.html
Copyright © 2011-2022 走看看