用于测试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--

posted @   逆火狂飙  阅读(301)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2015-05-27 又一次遇到Data truncation: Data too longData truncation: Data too long问题
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东
点击右上角即可分享
微信分享提示