Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- https://lite.ip2location.com/database/ip-asn
- unzip -j IP2LOCATION-LITE-ASN.CSV.ZIP
- */
- drop table if exists ip2location_asn;
- CREATE TABLE ip2location_asn(
- ip_from INT(10) UNSIGNED,
- ip_to INT(10) UNSIGNED,
- cidr VARCHAR(18),
- asn INT(10) UNSIGNED,
- asname VARCHAR(256),
- INDEX idx_ip_from (ip_from),
- INDEX idx_ip_to (ip_to),
- INDEX idx_ip_from_to (ip_from, ip_to)
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
- LOAD DATA
- INFILE '/tmp/IP2LOCATION-LITE-ASN.CSV'
- INTO TABLE ip2location_asn
- CHARACTER SET latin1
- FIELDS TERMINATED BY ','
- ENCLOSED BY '"'
- LINES TERMINATED BY '\r\n'
- IGNORE 0 LINES;
- optimize table ip2location_asn;
- update ip2location_asn set asname='KPN International / KPN Eurorings' where asn=286;
- update ip2location_asn inner join _aslabel
- on ip2location_asn.asn= _aslabel.asn and ip2location_asn.asname=''
- set ip2location_asn.asname=_aslabel.asname;
- /*
- select asn,sum(1)n,sum(ip_to-ip_from+1)ips,asname from ip2location_asn group by asn with rollup
- */
Advertisement
Add Comment
Please, Sign In to add comment