新的SqlFomatter整形Sql语句效果
在函数和别名处理上还有些问题,但比上一版已经好一些了。现在单句多句都能整形了。
1
原始的Sql为:
2
select
(
*
)
from
dual
3
解析后的的Sql为:
4
select
5
(
6
*
7
)
8
from
9
dual
10![]()
11
原始的Sql为:
12
SELECT
*
frOm
dual
13
解析后的的Sql为:
14
SELECT
15
*
16
frOm
17
dual
18![]()
19
原始的Sql为:
20
Select
C1,c2
From
tb
21
解析后的的Sql为:
22
Select
23
C1,
24
c2
25
From
26
tb
27![]()
28
原始的Sql为:
29
selecT
c1,c2
from
tb
30
解析后的的Sql为:
31
selecT
32
c1,
33
c2
34
from
35
tb
36![]()
37
原始的Sql为:
38
select
count
(
*
)
from
t1
39
解析后的的Sql为:
40
select
41
count
42
(
43
*
44
)
45
from
46
t1
47![]()
48
原始的Sql为:
49
select
c1,c2,c3
from
t1
where
condi1
=
1
50
解析后的的Sql为:
51
select
52
c1,
53
c2,
54
c3
55
from
56
t1
57
where
58
condi1
=
1
59![]()
60
原始的Sql为:
61
Select
c1,c2,c3
From
t1
Where
condi1
=
1
62
解析后的的Sql为:
63
Select
64
c1,
65
c2,
66
c3
67
From
68
t1
69
Where
70
condi1
=
1
71![]()
72
原始的Sql为:
73
select
c1,c2,c3
from
t1,t2
where
( condi3
=
3
or
condi4
=
5
)
order
by
o1,o2
74
解析后的的Sql为:
75
select
76
c1,
77
c2,
78
c3
79
from
80
t1,
81
t2
82
where
83
(
84
condi3
=
3
85
or
86
condi4
=
5
87
)
88
order
by
89
o1,
90
o2
91![]()
92
原始的Sql为:
93
select
f1,(
select
f2
from
t01)
from
t02
where
1
=
1
94
解析后的的Sql为:
95
select
96
f1,
97
(
98
select
99
f2
100
from
101
t01
102
)
103
from
104
t02
105
where
106
1
=
1
107![]()
108
原始的Sql为:
109
select
f1,(
select
a
from
b )
from
(
select
f1,f2
from
(
select
f1,f2,f3
from
tb ) ),t4
where
1
=
1
110
解析后的的Sql为:
111
select
112
f1,
113
(
114
select
115
a
116
from
117
b
118
)
119
from
120
(
121
select
122
f1,
123
f2
124
from
125
(
126
select
127
f1,
128
f2,
129
f3
130
from
131
tb
132
)
133
)
134
,
135
t4
136
where
137
1
=
1
138![]()
139
原始的Sql为:
140
select
f1,(
select
*
from
tb2,(
select
*
from
(
select
*
from
(
select
*
from
tb5 ) ) ) )
from
tabl1
where
1
=
1
141
解析后的的Sql为:
142
select
143
f1,
144
(
145
select
146
*
147
from
148
tb2,
149
(
150
select
151
*
152
from
153
(
154
select
155
*
156
from
157
(
158
select
159
*
160
from
161
tb5
162
)
163
)
164
)
165
)
166
from
167
tabl1
168
where
169
1
=
1
170![]()
171
原始的Sql为:
172![]()
173
解析后的的Sql为:
174![]()
175
原始的Sql为:
176
Select
c1
1
,c2,c3
from
t1
3
,t2
4
Where
condi3
=
3
and
condi4
=
5
Order
by
o1,o2
177
解析后的的Sql为:
178
Select
179
c1
180
1
,
181
c2,
182
c3
183
from
184
t1
185
3
,
186
t2
187
4
188
Where
189
condi3
=
3
190
and
191
condi4
=
5
192
Order
by
193
o1,
194
o2
195![]()
196
原始的Sql为:
197
select
c1,c2,c3
from
t1,t2, t3
where
condi1
=
5
and
condi6
=
6
or
condi7
=
7
group
by
g1,g2
198
解析后的的Sql为:
199
select
200
c1,
201
c2,
202
c3
203
from
204
t1,
205
t2,
206
t3
207
where
208
condi1
=
5
209
and
210
condi6
=
6
211
or
212
condi7
=
7
213
group
by
214
g1,
215
g2
216![]()
217
原始的Sql为:
218
Select
c1,c2,c3
From
t1,t2,t3
Where
condi1
=
5
and
condi6
=
6
or
condi7
=
7
Group
by
g1,g2
219
解析后的的Sql为:
220
Select
221
c1,
222
c2,
223
c3
224
From
225
t1,
226
t2,
227
t3
228
Where
229
condi1
=
5
230
and
231
condi6
=
6
232
or
233
condi7
=
7
234
Group
by
235
g1,
236
g2
237![]()
238
原始的Sql为:
239
Select
c1,c2,c3
From
t1,t2,t3
Where
condi1
=
5
and
( condi6
=
6
or
condi7
=
7
)
Group
by
g1,g2,g3
order
by
g2,g3
240
解析后的的Sql为:
241
Select
242
c1,
243
c2,
244
c3
245
From
246
t1,
247
t2,
248
t3
249
Where
250
condi1
=
5
251
and
252
(
253
condi6
=
6
254
or
255
condi7
=
7
256
)
257
Group
by
258
g1,
259
g2,
260
g3
261
order
by
262
g2,
263
g3
264![]()
265
原始的Sql为:
266
select
c1,c2,c3
from
t1
left
join
t2
on
condi3
=
3
or
condi4
=
5
order
by
o1,o2
267
解析后的的Sql为:
268
select
269
c1,
270
c2,
271
c3
272
from
273
t1
274
left
join
275
t2
276
on
277
condi3
=
3
278
or
279
condi4
=
5
280
order
by
281
o1,
282
o2
283![]()
284
原始的Sql为:
285
select
c1,c2,c3
from
t1
right
join
t2
on
condi3
=
3
or
condi4
=
5
order
by
o1,o2
286
解析后的的Sql为:
287
select
288
c1,
289
c2,
290
c3
291
from
292
t1
293
right
join
294
t2
295
on
296
condi3
=
3
297
or
298
condi4
=
5
299
order
by
300
o1,
301
o2
302![]()
303
原始的Sql为:
304
select
c1,c2,c3
from
t1
inner
join
t2
on
condi3
=
3
or
condi4
=
5
order
by
o1,o2
305
解析后的的Sql为:
306
select
307
c1,
308
c2,
309
c3
310
from
311
t1
312
inner
join
313
t2
314
on
315
condi3
=
3
316
or
317
condi4
=
5
318
order
by
319
o1,
320
o2
321![]()
322
原始的Sql为:
323
select
c1,c2,c3
from
t1
left
join
t2
having
condi3
=
3
or
condi4
=
5
group
by
g1,g3,g5
order
by
o1,o2
324
解析后的的Sql为:
325
select
326
c1,
327
c2,
328
c3
329
from
330
t1
331
left
join
332
t2
333
having
334
condi3
=
3
335
or
336
condi4
=
5
337
group
by
338
g1,
339
g3,
340
g5
341
order
by
342
o1,
343
o2
344![]()
345
原始的Sql为:
346
delete
from
table
347
解析后的的Sql为:
348
deletefrom
349
table
350![]()
351
原始的Sql为:
352
delete
from
table
where
1
=
1
353
解析后的的Sql为:
354
deletefrom
355
table
356
where
357
1
=
1
358![]()
359
原始的Sql为:
360
delete
from
table
where
c1
=
1
and
c2
=
2
or
c3
=
3
361
解析后的的Sql为:
362
deletefrom
363
table
364
where
365
c1
=
1
366
and
367
c2
=
2
368
or
369
c3
=
3
370![]()
371
原始的Sql为:
372
update
checktable
set
ID
=
''
where
1
=
1
373
解析后的的Sql为:
374
update
375
checktable
376
set
377
ID
=
''
378
where
379
1
=
1
380![]()
381
原始的Sql为:
382
update
checktable
set
ID
=
''
, NAME
=
''
where
1
=
1
and
2
=
2
383
解析后的的Sql为:
384
update
385
checktable
386
set
387
ID
=
''
,
388
NAME
=
''
389
where
390
1
=
1
391
and
392
2
=
2
393![]()
394
原始的Sql为:
395
update
checktable
set
ID
=
''
, NAME
=
''
,
count
=
''
, remark
=
''
where
1
=
1
and
2
=
2
or
3
=
3
396
解析后的的Sql为:
397
update
398
checktable
399
set
400
ID
=
''
,
401
NAME
=
''
,
402
count
=
''
,
403
remark
=
''
404
where
405
1
=
1
406
and
407
2
=
2
408
or
409
3
=
3
410![]()
411
原始的Sql为:
412
insert
into
checktable ( ID )
values
(
'
1
'
)
413
解析后的的Sql为:
414
insert
into
415
checktable
416
(
417
ID
418
)
419
values
420
(
421
'
1
'
422
)
423![]()
424
原始的Sql为:
425
insert
into
checktable ( ID,r )
values
(
'
1
'
,
''
)
426
解析后的的Sql为:
427
insert
into
428
checktable
429
(
430
ID,
431
r
432
)
433
values
434
(
435
'
1
'
,
436
''
437
)
438![]()
439
原始的Sql为:
440
insert
into
checktable ( ID, NAME,
count
, remark )
values
(
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
)
441
解析后的的Sql为:
442
insert
into
443
checktable
444
(
445
ID,
446
NAME,
447
count
,
448
remark
449
)
450
values
451
(
452
'
1
'
,
453
'
2
'
,
454
'
3
'
,
455
'
4
'
456
)
457![]()
458
原始的Sql为:
459
insert
into
checktable
select
c1,c2,c3
from
t1
where
condi1
=
1
460
解析后的的Sql为:
461
insert
into
462
checktable
463
select
464
c1,
465
c2,
466
c3
467
from
468
t1
469
where
470
condi1
=
1
471![]()
472
原始的Sql为:
473
insert
into
checktable
Select
c1,c2,c3
From
t1
Where
condi1
=
1
474
解析后的的Sql为:
475
insert
into
476
checktable
477
Select
478
c1,
479
c2,
480
c3
481
From
482
t1
483
Where
484
condi1
=
1
485![]()
486
原始的Sql为:
487
insert
into
checktable
select
c1,c2,c3
from
t1,t2
where
condi3
=
3
or
condi4
=
5
order
by
o1,o2
488
解析后的的Sql为:
489
insert
into
490
checktable
491
select
492
c1,
493
c2,
494
c3
495
from
496
t1,
497
t2
498
where
499
condi3
=
3
500
or
501
condi4
=
5
502
order
by
503
o1,
504
o2
505![]()
506
原始的Sql为:
507
insert
into
checktable
Select
c1
1
,c2,c3
from
t1
3
,t2
4
Where
condi3
=
3
and
condi4
=
5
Order
by
o1,o2
508
解析后的的Sql为:
509
insert
into
510
checktable
511
Select
512
c1
513
1
,
514
c2,
515
c3
516
from
517
t1
518
3
,
519
t2
520
4
521
Where
522
condi3
=
3
523
and
524
condi4
=
5
525
Order
by
526
o1,
527
o2
528![]()
529
原始的Sql为:
530
insert
into
checktable
select
c1,c2,c3
from
t1,t2, t3
where
condi1
=
5
and
condi6
=
6
or
condi7
=
7
group
by
g1,g2
531
解析后的的Sql为:
532
insert
into
533
checktable
534
select
535
c1,
536
c2,
537
c3
538
from
539
t1,
540
t2,
541
t3
542
where
543
condi1
=
5
544
and
545
condi6
=
6
546
or
547
condi7
=
7
548
group
by
549
g1,
550
g2
551![]()
552
原始的Sql为:
553
insert
into
checktable
Select
c1,c2,c3
From
t1,t2,t3
Where
condi1
=
5
and
condi6
=
6
or
condi7
=
7
Group
by
g1,g2
554
解析后的的Sql为:
555
insert
into
556
checktable
557
Select
558
c1,
559
c2,
560
c3
561
From
562
t1,
563
t2,
564
t3
565
Where
566
condi1
=
5
567
and
568
condi6
=
6
569
or
570
condi7
=
7
571
Group
by
572
g1,
573
g2
574![]()
575
原始的Sql为:
576
insert
into
checktable
Select
c1,c2,c3
From
t1,t2,t3
Where
condi1
=
5
and
condi6
=
6
or
condi7
=
7
Group
by
g1,g2,g3
order
by
g2,g3
577
解析后的的Sql为:
578
insert
into
579
checktable
580
Select
581
c1,
582
c2,
583
c3
584
From
585
t1,
586
t2,
587
t3
588
Where
589
condi1
=
5
590
and
591
condi6
=
6
592
or
593
condi7
=
7
594
Group
by
595
g1,
596
g2,
597
g3
598
order
by
599
g2,
600
g3
601![]()
602
原始的Sql为:
603
insert
into
checktable
select
c1,c2,c3
from
t1
left
join
t2
on
condi3
=
3
or
condi4
=
5
order
by
o1,o2
604
解析后的的Sql为:
605
insert
into
606
checktable
607
select
608
c1,
609
c2,
610
c3
611
from
612
t1
613
left
join
614
t2
615
on
616
condi3
=
3
617
or
618
condi4
=
5
619
order
by
620
o1,
621
o2
622![]()
623
原始的Sql为:
624
insert
into
checktable
select
c1,c2,c3
from
t1
right
join
t2
on
condi3
=
3
or
condi4
=
5
order
by
o1,o2
625
解析后的的Sql为:
626
insert
into
627
checktable
628
select
629
c1,
630
c2,
631
c3
632
from
633
t1
634
right
join
635
t2
636
on
637
condi3
=
3
638
or
639
condi4
=
5
640
order
by
641
o1,
642
o2
643![]()
644
原始的Sql为:
645
insert
into
checktable
select
c1,c2,c3
from
t1
inner
join
t2
on
condi3
=
3
or
condi4
=
5
order
by
o1,o2
646
解析后的的Sql为:
647
insert
into
648
checktable
649
select
650
c1,
651
c2,
652
c3
653
from
654
t1
655
inner
join
656
t2
657
on
658
condi3
=
3
659
or
660
condi4
=
5
661
order
by
662
o1,
663
o2
664![]()
665
原始的Sql为:
666
insert
into
checktable
select
c1,c2,c3
from
t1
left
join
t2
having
condi3
=
3
or
condi4
=
5
group
by
g1,g3,g5
order
by
o1,o2
667
解析后的的Sql为:
668
insert
into
669
checktable
670
select
671
c1,
672
c2,
673
c3
674
from
675
t1
676
left
join
677
t2
678
having
679
condi3
=
3
680
or
681
condi4
=
5
682
group
by
683
g1,
684
g3,
685
g5
686
order
by
687
o1,
688
o2
689![]()
690
原始的Sql为:
691
select
(
select
*
from
dual)
from
dual
692
解析后的的Sql为:
693
select
694
(
695
select
696
*
697
from
698
dual
699
)
700
from
701
dual
702![]()
703
原始的Sql为:
704
select
(
*
)
from
dual
705
解析后的的Sql为:
706
select
707
(
708
*
709
)
710
from
711
dual
712![]()
713
原始的Sql为:
714
select
count
(
*
)
from
dual
715
解析后的的Sql为:
716
select
717
count
718
(
719
*
720
)
721
from
722
dual
723![]()
724
原始的Sql为:
725
select
id,name
from
(
select
id,name
from
(
select
id,name
from
customer) t1 ) t2
726
解析后的的Sql为:
727
select
728
id,
729
name
730
from
731
(
732
select
733
id,
734
name
735
from
736
(
737
select
738
id,
739
name
740
from
741
customer
742
)
743
t1
744
)
745
t2
746![]()
747
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747