--算法这样考虑,用固定表,加聚集索引提高速度,既然长度固定,用char加快查询速度--创建临时表
create table #t(code char(1) not null primary key)
insert into #t
select top 10 (select sum(1) from sysobjects where id<=a.id)-1 from sysobjects ainsert into #t
select top 26 char((select sum(1) from sysobjects where id<=a.id)+96) from sysobjects a
go--固定的组合表
create table tb(code char(12) not null)
alter table tb add constraint PK_tb PRIMARY KEY CLUSTERED (code)insert into tb
SELECT 'www.'+a.code + b.code + c.code + d.code +'.com'
FROM #t a,#t b,#t c,#t d
go--查询的时候用:
select code from tb a left join 域名表 b on a.code=b.域名
where b.域名 is nullgo--删除处理用的表
drop table #t,tb
create table #t(code char(1) not null primary key)
insert into #t
select top 10 (select sum(1) from sysobjects where id<=a.id)-1 from sysobjects ainsert into #t
select top 26 char((select sum(1) from sysobjects where id<=a.id)+96) from sysobjects a
go--固定的组合表
create table tb(code char(12) not null)
alter table tb add constraint PK_tb PRIMARY KEY CLUSTERED (code)insert into tb
SELECT 'www.'+a.code + b.code + c.code + d.code +'.com'
FROM #t a,#t b,#t c,#t d
go--查询的时候用:
select code from tb a left join 域名表 b on a.code=b.域名
where b.域名 is nullgo--删除处理用的表
drop table #t,tb
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货