|
好像也是10
with recursive t1 as(select '1' n union all select '2'),
t3 as(select t1.n||t1a.n||t1b.n s from t1,t1 t1a,t1 t1b),
t as(select 1 lv, t3.s from t3
union all
select lv+1, t.s||t1.n str from t,t1 where not exists(select 1 from --t3 a,
(select value x from generate_series(1,15))b,
(select value c from generate_series(1,15))c,
(select value d from generate_series(1,15))d
where --求一个字符串s所有长度>=3的子串
length(substr(s,c,d))>=3
and c<=length(s)
and c+d<=length(s)+1
and b.x>c --从子串的下一位开始比较
and instr(substr(t.s||t1.n,b.x),substr(s,c,d))>0 and b.x<=length(substr(s,c,d))+c
)and lv<=18)
select s from t where length(s)=10 limit 5;
1112122211
1112221211
1121222111
1122212111
1211122212
select max(length(s)) from t;
10 |
|