jam-cloud/db/up/add_countries_regions_and_c...

9 lines
683 B
SQL

create table cities (city varchar(255) not null, region varchar(2) not null, regionname varchar(64), countrycode varchar(2) not null, countryname varchar(64));
insert into cities (city, region, countrycode) select distinct city, region, countrycode from geoiplocations where length(city) > 0 and length(countrycode) > 0;
create table regions (region varchar(2) not null, regionname varchar(64), countrycode varchar(2) not null);
insert into regions (region, countrycode) select distinct region, countrycode from cities;
create table countries (countrycode varchar(2) not null, countryname varchar(64));
insert into countries (countrycode) select distinct countrycode from regions;