|
|
本帖最后由 〇〇 于 2021-10-19 08:35 编辑
oracle语法检查比sqlite/posgresql严格,第一行就报错,
with t6(n) as (select 1 from dual union all select n+1 from t where n<6)
*
第 2 行出现错误:
ORA-32031: WITH 子句中查询名的引用非法
已用时间: 00: 00: 00.06
把移位改成power,取整改为floor,改完又不知错在哪了。
SQL> --oracle
SQL> create table chess6f as
2 with t6(n) as (select 1 from dual union all select n+1 from t6 where n<6)
3 ,
4 b3(a,b,c,bit)as(select a.n,b.n,c.n,(power(2,a.n-1))+(power(2,b.n-1))+(power(2,c.n-1)) from t6 a,t6 b,t6 c where a.n<b.n and b.n<c.n)
5 ,
6 b9(b)as(select c.bit*((power(2,r.a-1)*6)+(power(2,r.b-1)*6)+(power(2,r.c-1)*6)) from b3 c,b3 r)
7 ,
8 t(n,c,x,y)
9 as(select 1,cast('1'as varchar(100)),1,1 from dual union all select n+1,cast(n+1 as varchar(100)),floor(n/6)+1,mod(n,6)+1 from t where n<6*6)
10 ,
11 s(lv,n,nlist,blist,px,py)
12 as(select 1,t.n,t.c,power(2,t.n-1),power(10,t.x),power(10,t.y) from t where t.n<=6
13 union all
14 select lv+1,b.n,nlist||','||c,blist+(power(2,b.n-1)),px+power(10,b.x),py+power(10,b.y)
15 from s,t b
16 where lv<10 and s.n<b.n and b.x < floor(s.n/6) +3
17 --and(blist%19<14)
18 and (instr(px+power(10,b.x),3)=0 and instr(py+power(10,b.y),3)=0)
19 --and(select max(sum(case when a.x=b.x then 1 end), sum(case when a.y=b.y then 1 end))from t a
20 -- where ((blist+(power(2,b.n-1))&(power(2,a.n-1)))>0))<=2
21 and b.n between floor(lv/2)*6+1 and floor(lv/2)*6+6*2
22 )
23 select * from s where lv=10 and not exists(select 1 from b9 where bitand(blist , b9.b) =0)
24 ;
表已创建。
已用时间: 00: 06: 15.61
SQL> select count(*) from chess6f;
COUNT(*)
----------
151
找出来的也不知对错
SQL> col nlist format a50
SQL> /
LV N NLIST BLIST PX PY
---------- ---------- -------------------------------------------------- ---------- ---------- ----------
10 28 5,6,7,12,13,14,20,21,27,28 202913904 222220 2112220
10 29 5,6,7,12,13,14,20,21,27,29 337131632 222220 2202220
10 34 5,6,7,12,13,14,20,21,27,34 8658630768 1122220 2112220
10 35 5,6,7,12,13,14,20,21,27,35 1.7249E+10 1122220 2202220
10 29 5,6,7,12,13,14,20,21,28,29 404240496 222220 2211220
10 33 5,6,7,12,13,14,20,21,28,33 4430772336 1122220 2112220
10 34 5,6,7,12,13,14,20,21,28,34 8725739632 1122220 2121220
10 35 5,6,7,12,13,14,20,21,28,35 1.7316E+10 1122220 2211220
10 33 5,6,7,12,13,14,20,21,29,33 4564990064 1122220 2202220
已选择 9 行。
|
|