要生成一组所有IPv4的人可以使用一个交叉连接和CTE与16条记录和交叉连接。但是我还不确定你真的是什么。
with cte (A) as (
SELECT 0 from dual UNION ALL
SELECT 1 from dual UNION ALL
SELECT 2 from dual UNION ALL
SELECT 3 from dual UNION ALL
SELECT 4 from dual UNION ALL
SELECT 5 from dual UNION ALL
SELECT 6 from dual UNION ALL
SELECT 7 from dual UNION ALL
SELECT 8 from dual UNION ALL
SELECT 9 from dual UNION ALL
SELECT 10 from dual UNION ALL
SELECT 11 from dual UNION ALL
SELECT 12 from dual UNION ALL
SELECT 13 from dual UNION ALL
SELECT 14 from dual UNION ALL
SELECT 15 from dual),
--Get data set for 0 to 255 numbers.
Get256Range as (SELECT row_number() over (order by A.A)-1 seg
FROM CTE A
CROSS JOIN cte B)
--Now cross join the 256 4 times for each class of Ip.
SELECT A.Seg ||'.'|| B.Seg||'.'|| C.Seg||'.'||D.Seg as IPAddress
from Get256Range A
CROSS JOIN Get256Range B
CROSS JOIN Get256Range C
CROSS JOIN Get256Range D
--Not sure what part of the "set" you need but one could change these values
--Limited for sizing; but one could create a table of all IPv4 addresses...
WHERE A.seg = 12
and B.seg = 123;
您可以根据需要包括前导零...
lpad(A.Seg,3,'0') ||'.'|| lpad(B.Seg,3,'0')||'.'|| lpad(C.Seg,3,'0')||'.'|| lpad(D.Seg,3,'0') IpAddressWithLeadZero
这让人们可以进行排序或基于特定范围过滤器
所以只能返回这些较大(不是最有效的)
WHERE lpad(A.Seg,3,'0') ||'.'|| lpad(B.Seg,3,'0')||'.'|| lpad(C.Seg,3,'0')||'.'|| lpad(D.Seg,3,'0') >='012.123.060.165'
可能更为有效:
WHERE (A.Seg = 12 and B.Seg = 123 and C.Seg = 60 and D.Seg > 165) OR (A.Seg = 12 and B.Seg = 123 and C.Seg > 60) OR (A.Seg = 12 and B.Seg > 123) OR (A.Seg > 12)
你怎么从这些默认值我有可能产生IP地址是什么意思?您是否只需要IP地址> 12.123.60.256的完整IP4地址范围?不知道你在做什么。 – xQbert
我的意思是我有IP号码的默认值。它是12.123.60.165。然后我必须生成新的IP号码,分别是12.123.60.167,12.123.60.168,12.123.60.169等等。直到以(256)12.123.60.256结尾。直到IP数量的最大IP数将是256.256.256.256。 –
生成4,213,638,225条记录......这就是40亿2.13亿美元需要一些时间。但是有256个记录的表的4个交叉连接似乎工作;而你的起始IP只会消除约14,612,400条记录;或0.3456%不要指望它很快......但你可以用这些#表创建一个表,我想...... – xQbert