Skip to content

Instantly share code, notes, and snippets.

@lcaldara-oracle
Created January 4, 2023 08:18
Show Gist options
  • Save lcaldara-oracle/0ae8aaf29a9b94bd654eb719c2635b23 to your computer and use it in GitHub Desktop.
Save lcaldara-oracle/0ae8aaf29a9b94bd654eb719c2635b23 to your computer and use it in GitHub Desktop.
Create and populate tables for continents and countries in the world. Source: https://en.wikipedia.org/wiki/List_of_sovereign_states_and_dependent_territories_by_continent_(data_file). Removed duplicated entries for countries that belong to two continents.
create table continents (
continent_code varchar2(2) not null
,continent varchar2(400) not null
,constraint pk_continents primary key (continent_code)
);
create table countries (
country_code varchar2(2) not null
,country varchar2(400) not null
,continent_code varchar2(2) not null
,constraint pk_countries primary key (country_code)
,constraint fk_country_continent foreign key (continent_code) references continents(continent_code)
);
set escape \
insert into continents (continent_code, continent) values ('AF','Africa');
insert into continents (continent_code, continent) values ('OC','Oceania');
insert into continents (continent_code, continent) values ('EU','Europe');
insert into continents (continent_code, continent) values ('AS','Asia');
insert into continents (continent_code, continent) values ('NA','North America');
insert into continents (continent_code, continent) values ('SA','South America');
insert into continents (continent_code, continent) values ('AN','Antarctica');
insert into countries (country_code, country, continent_code) values ('AF','Afghanistan, Islamic Republic of','AS');
insert into countries (country_code, country, continent_code) values ('AL','Albania, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('AQ','Antarctica (the territory South of 60 deg S)','AN');
insert into countries (country_code, country, continent_code) values ('DZ','Algeria, People''s Democratic Republic of','AF');
insert into countries (country_code, country, continent_code) values ('AS','American Samoa','OC');
insert into countries (country_code, country, continent_code) values ('AD','Andorra, Principality of','EU');
insert into countries (country_code, country, continent_code) values ('AO','Angola, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('AG','Antigua and Barbuda','NA');
insert into countries (country_code, country, continent_code) values ('AZ','Azerbaijan, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('AR','Argentina, Argentine Republic','SA');
insert into countries (country_code, country, continent_code) values ('AU','Australia, Commonwealth of','OC');
insert into countries (country_code, country, continent_code) values ('AT','Austria, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('BS','Bahamas, Commonwealth of the','NA');
insert into countries (country_code, country, continent_code) values ('BH','Bahrain, Kingdom of','AS');
insert into countries (country_code, country, continent_code) values ('BD','Bangladesh, People''s Republic of','AS');
insert into countries (country_code, country, continent_code) values ('AM','Armenia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('BB','Barbados','NA');
insert into countries (country_code, country, continent_code) values ('BE','Belgium, Kingdom of','EU');
insert into countries (country_code, country, continent_code) values ('BM','Bermuda','NA');
insert into countries (country_code, country, continent_code) values ('BT','Bhutan, Kingdom of','AS');
insert into countries (country_code, country, continent_code) values ('BO','Bolivia, Plurinational State of','SA');
insert into countries (country_code, country, continent_code) values ('BA','Bosnia and Herzegovina','EU');
insert into countries (country_code, country, continent_code) values ('BW','Botswana, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('BV','Bouvet Island (Bouvetoya)','AN');
insert into countries (country_code, country, continent_code) values ('BR','Brazil, Federative Republic of','SA');
insert into countries (country_code, country, continent_code) values ('BZ','Belize','NA');
insert into countries (country_code, country, continent_code) values ('IO','British Indian Ocean Territory','AF');
insert into countries (country_code, country, continent_code) values ('SB','Solomon Islands','OC');
insert into countries (country_code, country, continent_code) values ('VG','British Virgin Islands','NA');
insert into countries (country_code, country, continent_code) values ('BN','Brunei, Nation of, the Abode of Peace','AS');
insert into countries (country_code, country, continent_code) values ('BG','Bulgaria, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('MM','Myanmar, Union of','AS');
insert into countries (country_code, country, continent_code) values ('BI','Burundi, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('BY','Belarus, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('KH','Cambodia, Kingdom of','AS');
insert into countries (country_code, country, continent_code) values ('CM','Cameroon, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('CA','Canada','NA');
insert into countries (country_code, country, continent_code) values ('CV','Cape Verde, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('KY','Cayman Islands','NA');
insert into countries (country_code, country, continent_code) values ('CF','Central African Republic','AF');
insert into countries (country_code, country, continent_code) values ('LK','Sri Lanka, Democratic Socialist Republic of','AS');
insert into countries (country_code, country, continent_code) values ('TD','Chad, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('CL','Chile, Republic of','SA');
insert into countries (country_code, country, continent_code) values ('CN','China, People''s Republic of','AS');
insert into countries (country_code, country, continent_code) values ('TW','Taiwan','AS');
insert into countries (country_code, country, continent_code) values ('CX','Christmas Island','AS');
insert into countries (country_code, country, continent_code) values ('CC','Cocos (Keeling) Islands','AS');
insert into countries (country_code, country, continent_code) values ('CO','Colombia, Republic of','SA');
insert into countries (country_code, country, continent_code) values ('KM','Comoros, Union of the','AF');
insert into countries (country_code, country, continent_code) values ('YT','Mayotte, Department of','AF');
insert into countries (country_code, country, continent_code) values ('CG','Congo, Republic of the','AF');
insert into countries (country_code, country, continent_code) values ('CD','Congo, Democratic Republic of the','AF');
insert into countries (country_code, country, continent_code) values ('CK','Cook Islands','OC');
insert into countries (country_code, country, continent_code) values ('CR','Costa Rica, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('HR','Croatia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('CU','Cuba, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('CY','Cyprus, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('CZ','Czech Republic','EU');
insert into countries (country_code, country, continent_code) values ('BJ','Benin, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('DK','Denmark, Kingdom of','EU');
insert into countries (country_code, country, continent_code) values ('DM','Dominica, Commonwealth of','NA');
insert into countries (country_code, country, continent_code) values ('DO','Dominican Republic','NA');
insert into countries (country_code, country, continent_code) values ('EC','Ecuador, Republic of','SA');
insert into countries (country_code, country, continent_code) values ('SV','El Salvador, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('GQ','Equatorial Guinea, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('ET','Ethiopia, Federal Democratic Republic of','AF');
insert into countries (country_code, country, continent_code) values ('ER','Eritrea, State of','AF');
insert into countries (country_code, country, continent_code) values ('EE','Estonia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('FO','Faroe Islands','EU');
insert into countries (country_code, country, continent_code) values ('FK','Falkland Islands (Malvinas)','SA');
insert into countries (country_code, country, continent_code) values ('GS','South Georgia and the South Sandwich Islands','AN');
insert into countries (country_code, country, continent_code) values ('FJ','Fiji, Republic of','OC');
insert into countries (country_code, country, continent_code) values ('FI','Finland, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('AX','Åland Islands','EU');
insert into countries (country_code, country, continent_code) values ('FR','France, French Republic','EU');
insert into countries (country_code, country, continent_code) values ('GF','French Guiana','SA');
insert into countries (country_code, country, continent_code) values ('PF','French Polynesia','OC');
insert into countries (country_code, country, continent_code) values ('TF','French Southern Territories','AF');
insert into countries (country_code, country, continent_code) values ('DJ','Djibouti, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('GA','Gabon, Gabonese Republic','AF');
insert into countries (country_code, country, continent_code) values ('GE','Georgia','EU');
insert into countries (country_code, country, continent_code) values ('GM','Gambia, Republic of the','AF');
insert into countries (country_code, country, continent_code) values ('DE','Germany, Federal Republic of','EU');
insert into countries (country_code, country, continent_code) values ('GH','Ghana, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('GI','Gibraltar','EU');
insert into countries (country_code, country, continent_code) values ('KI','Kiribati, Republic of','OC');
insert into countries (country_code, country, continent_code) values ('GR','Greece, Hellenic Republic','EU');
insert into countries (country_code, country, continent_code) values ('GL','Greenland','NA');
insert into countries (country_code, country, continent_code) values ('GD','Grenada','NA');
insert into countries (country_code, country, continent_code) values ('GP','Guadeloupe','NA');
insert into countries (country_code, country, continent_code) values ('GU','Guam','OC');
insert into countries (country_code, country, continent_code) values ('GT','Guatemala, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('GN','Guinea, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('GY','Guyana, Co-operative Republic of','SA');
insert into countries (country_code, country, continent_code) values ('HT','Haiti, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('HM','Heard Island and McDonald Islands','AN');
insert into countries (country_code, country, continent_code) values ('VA','Holy See (Vatican City State)','EU');
insert into countries (country_code, country, continent_code) values ('HN','Honduras, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('HK','Hong Kong, Special Administrative Region of China','AS');
insert into countries (country_code, country, continent_code) values ('HU','Hungary, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('IS','Iceland, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('IN','India, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('ID','Indonesia, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('IR','Iran, Islamic Republic of','AS');
insert into countries (country_code, country, continent_code) values ('IQ','Iraq, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('IE','Ireland','EU');
insert into countries (country_code, country, continent_code) values ('IL','Israel, State of','AS');
insert into countries (country_code, country, continent_code) values ('IT','Italy, Italian Republic','EU');
insert into countries (country_code, country, continent_code) values ('CI','Côte d''Ivoire, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('JM','Jamaica','NA');
insert into countries (country_code, country, continent_code) values ('JP','Japan','AS');
insert into countries (country_code, country, continent_code) values ('KZ','Kazakhstan, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('JO','Jordan, Hashemite Kingdom of','AS');
insert into countries (country_code, country, continent_code) values ('KE','Kenya, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('KP','Korea, Democratic People''s Republic of','AS');
insert into countries (country_code, country, continent_code) values ('KR','Korea, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('XK','Kosovo, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('KW','Kuwait, State of','AS');
insert into countries (country_code, country, continent_code) values ('KG','Kyrgyz Republic','AS');
insert into countries (country_code, country, continent_code) values ('LA','Lao People''s Democratic Republic','AS');
insert into countries (country_code, country, continent_code) values ('LB','Lebanon, Lebanese Republic','AS');
insert into countries (country_code, country, continent_code) values ('LS','Lesotho, Kingdom of','AF');
insert into countries (country_code, country, continent_code) values ('LV','Latvia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('LR','Liberia, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('LY','Libya, State of','AF');
insert into countries (country_code, country, continent_code) values ('LI','Liechtenstein, Principality of','EU');
insert into countries (country_code, country, continent_code) values ('LT','Lithuania, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('LU','Luxembourg, Grand Duchy of','EU');
insert into countries (country_code, country, continent_code) values ('MO','Macao, Special Administrative Region of China','AS');
insert into countries (country_code, country, continent_code) values ('MG','Madagascar, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('MW','Malawi, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('MY','Malaysia','AS');
insert into countries (country_code, country, continent_code) values ('MV','Maldives, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('ML','Mali, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('MT','Malta, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('MQ','Martinique','NA');
insert into countries (country_code, country, continent_code) values ('MR','Mauritania, Islamic Republic of','AF');
insert into countries (country_code, country, continent_code) values ('MU','Mauritius, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('MX','Mexico, United Mexican States','NA');
insert into countries (country_code, country, continent_code) values ('MC','Monaco, Principality of','EU');
insert into countries (country_code, country, continent_code) values ('MN','Mongolia','AS');
insert into countries (country_code, country, continent_code) values ('MD','Moldova, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('ME','Montenegro','EU');
insert into countries (country_code, country, continent_code) values ('MS','Montserrat','NA');
insert into countries (country_code, country, continent_code) values ('MA','Morocco, Kingdom of','AF');
insert into countries (country_code, country, continent_code) values ('MZ','Mozambique, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('OM','Oman, Sultanate of','AS');
insert into countries (country_code, country, continent_code) values ('NA','Namibia, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('NR','Nauru, Republic of','OC');
insert into countries (country_code, country, continent_code) values ('NP','Nepal, Federal Democratic Republic of','AS');
insert into countries (country_code, country, continent_code) values ('NL','Netherlands, Kingdom of the','EU');
insert into countries (country_code, country, continent_code) values ('CW','Curaçao','NA');
insert into countries (country_code, country, continent_code) values ('AW','Aruba','NA');
insert into countries (country_code, country, continent_code) values ('SX','Sint Maarten (Netherlands)','NA');
insert into countries (country_code, country, continent_code) values ('BQ','Bonaire, Sint Eustatius and Saba','NA');
insert into countries (country_code, country, continent_code) values ('NC','New Caledonia','OC');
insert into countries (country_code, country, continent_code) values ('VU','Vanuatu, Republic of','OC');
insert into countries (country_code, country, continent_code) values ('NZ','New Zealand','OC');
insert into countries (country_code, country, continent_code) values ('NI','Nicaragua, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('NE','Niger, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('NG','Nigeria, Federal Republic of','AF');
insert into countries (country_code, country, continent_code) values ('NU','Niue','OC');
insert into countries (country_code, country, continent_code) values ('NF','Norfolk Island','OC');
insert into countries (country_code, country, continent_code) values ('NO','Norway, Kingdom of','EU');
insert into countries (country_code, country, continent_code) values ('MP','Northern Mariana Islands, Commonwealth of the','OC');
insert into countries (country_code, country, continent_code) values ('UM','United States Minor Outlying Islands','OC');
insert into countries (country_code, country, continent_code) values ('FM','Micronesia, Federated States of','OC');
insert into countries (country_code, country, continent_code) values ('MH','Marshall Islands, Republic of the','OC');
insert into countries (country_code, country, continent_code) values ('PW','Palau, Republic of','OC');
insert into countries (country_code, country, continent_code) values ('PK','Pakistan, Islamic Republic of','AS');
insert into countries (country_code, country, continent_code) values ('PS','Palestine, State of','AS');
insert into countries (country_code, country, continent_code) values ('PA','Panama, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('PG','Papua New Guinea, Independent State of','OC');
insert into countries (country_code, country, continent_code) values ('PY','Paraguay, Republic of','SA');
insert into countries (country_code, country, continent_code) values ('PE','Peru, Republic of','SA');
insert into countries (country_code, country, continent_code) values ('PH','Philippines, Republic of the','AS');
insert into countries (country_code, country, continent_code) values ('PN','Pitcairn Islands','OC');
insert into countries (country_code, country, continent_code) values ('PL','Poland, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('PT','Portugal, Portuguese Republic','EU');
insert into countries (country_code, country, continent_code) values ('GW','Guinea-Bissau, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('TL','Timor-Leste, Democratic Republic of','AS');
insert into countries (country_code, country, continent_code) values ('PR','Puerto Rico, Commonwealth of','NA');
insert into countries (country_code, country, continent_code) values ('QA','Qatar, State of','AS');
insert into countries (country_code, country, continent_code) values ('RE','Reunion','AF');
insert into countries (country_code, country, continent_code) values ('RO','Romania','EU');
insert into countries (country_code, country, continent_code) values ('RU','Russian Federation','AS');
insert into countries (country_code, country, continent_code) values ('RW','Rwanda, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('BL','Saint Barthelemy','NA');
insert into countries (country_code, country, continent_code) values ('SH','Saint Helena','AF');
insert into countries (country_code, country, continent_code) values ('KN','Saint Kitts and Nevis, Federation of','NA');
insert into countries (country_code, country, continent_code) values ('AI','Anguilla','NA');
insert into countries (country_code, country, continent_code) values ('LC','Saint Lucia','NA');
insert into countries (country_code, country, continent_code) values ('MF','Saint Martin','NA');
insert into countries (country_code, country, continent_code) values ('PM','Saint Pierre and Miquelon','NA');
insert into countries (country_code, country, continent_code) values ('VC','Saint Vincent and the Grenadines','NA');
insert into countries (country_code, country, continent_code) values ('SM','San Marino, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('ST','São Tomé and Príncipe, Democratic Republic of','AF');
insert into countries (country_code, country, continent_code) values ('SA','Saudi Arabia, Kingdom of','AS');
insert into countries (country_code, country, continent_code) values ('SN','Senegal, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('RS','Serbia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('SC','Seychelles, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('SL','Sierra Leone, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('SG','Singapore, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('SK','Slovakia (Slovak Republic)','EU');
insert into countries (country_code, country, continent_code) values ('VN','Vietnam, Socialist Republic of','AS');
insert into countries (country_code, country, continent_code) values ('SI','Slovenia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('SO','Somalia, Federal Republic of','AF');
insert into countries (country_code, country, continent_code) values ('ZA','South Africa, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('ZW','Zimbabwe, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('ES','Spain, Kingdom of','EU');
insert into countries (country_code, country, continent_code) values ('SS','South Sudan, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('SD','Sudan, Republic of the','AF');
insert into countries (country_code, country, continent_code) values ('EH','Sahrawi Arab Democratic Republic','AF');
insert into countries (country_code, country, continent_code) values ('SR','Suriname, Republic of','SA');
insert into countries (country_code, country, continent_code) values ('SJ','Svalbard \& Jan Mayen Islands','EU');
insert into countries (country_code, country, continent_code) values ('SZ','Eswatini, Kingdom of','AF');
insert into countries (country_code, country, continent_code) values ('SE','Sweden, Kingdom of','EU');
insert into countries (country_code, country, continent_code) values ('CH','Switzerland, Swiss Confederation','EU');
insert into countries (country_code, country, continent_code) values ('SY','Syrian Arab Republic','AS');
insert into countries (country_code, country, continent_code) values ('TJ','Tajikistan, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('TH','Thailand, Kingdom of','AS');
insert into countries (country_code, country, continent_code) values ('TG','Togo, Togolese Republic','AF');
insert into countries (country_code, country, continent_code) values ('TK','Tokelau','OC');
insert into countries (country_code, country, continent_code) values ('TO','Tonga, Kingdom of','OC');
insert into countries (country_code, country, continent_code) values ('TT','Trinidad and Tobago, Republic of','NA');
insert into countries (country_code, country, continent_code) values ('AE','United Arab Emirates','AS');
insert into countries (country_code, country, continent_code) values ('TN','Tunisia, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('TR','Turkey, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('TM','Turkmenistan','AS');
insert into countries (country_code, country, continent_code) values ('TC','Turks and Caicos Islands','NA');
insert into countries (country_code, country, continent_code) values ('TV','Tuvalu','OC');
insert into countries (country_code, country, continent_code) values ('UG','Uganda, Republic of','AF');
insert into countries (country_code, country, continent_code) values ('UA','Ukraine','EU');
insert into countries (country_code, country, continent_code) values ('MK','North Macedonia, Republic of','EU');
insert into countries (country_code, country, continent_code) values ('EG','Egypt, Arab Republic of','AF');
insert into countries (country_code, country, continent_code) values ('GB','United Kingdom of Great Britain \& Northern Ireland','EU');
insert into countries (country_code, country, continent_code) values ('GG','Guernsey, Bailiwick of','EU');
insert into countries (country_code, country, continent_code) values ('JE','Jersey, Bailiwick of','EU');
insert into countries (country_code, country, continent_code) values ('IM','Isle of Man','EU');
insert into countries (country_code, country, continent_code) values ('TZ','Tanzania, United Republic of','AF');
insert into countries (country_code, country, continent_code) values ('US','United States of America','NA');
insert into countries (country_code, country, continent_code) values ('VI','United States Virgin Islands','NA');
insert into countries (country_code, country, continent_code) values ('BF','Burkina Faso','AF');
insert into countries (country_code, country, continent_code) values ('UY','Uruguay, Oriental Republic of','SA');
insert into countries (country_code, country, continent_code) values ('UZ','Uzbekistan, Republic of','AS');
insert into countries (country_code, country, continent_code) values ('VE','Venezuela, Bolivarian Republic of','SA');
insert into countries (country_code, country, continent_code) values ('WF','Wallis and Futuna','OC');
insert into countries (country_code, country, continent_code) values ('WS','Samoa, Independent State of','OC');
insert into countries (country_code, country, continent_code) values ('YE','Yemen','AS');
insert into countries (country_code, country, continent_code) values ('ZM','Zambia, Republic of','AF');
commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment