World `countries` – database table for MySQL

So today, I was buzzing around and searching for a `countries` table script that I could use in MySQL database. As you can imagine, it wouldn’t make any sense to add all world countries into database table one-by-one.

I’ve found few interesting things around there, but all of those solutions were not flexible and were created for individual projects – and when I say that, I mean that some of those tables have only two columns (like country code and country name), some of those have 3 columns, and some of those have bunch of columns (that are probably not useful to many developers).

Anyway, after checking some of those solutions I came to idea that I could make something on my own – something that will be flexible and customizable. And the result was GetCountries “program” where you can select which columns do you want, click “Get it!” and the program will fetch “fresh” results from Geonames API and will generate you a SQL script. After that you can copy/paste that script and eventually change column names.

Hope someone will find that useful.

GetCountries program | code @Github


Tags: , , , , , , , , , , , , ,

18 responses to “World `countries` – database table for MySQL”

  1. harpermaddox (@harpermaddox) says :

    I had to do this just the other day. I found many of the official names on the ISO site ( to be overly wordy and had to cut them down to their generally used names. It appears that your source already did that.

  2. rviswanadha says :

    uhh.. Not sure why you would want to extract and store the data in MySQL table. Check out .. the data for most applications is provided in XML files

    • echobehind says :

      Suppose that some developers are using MySQL, some XML, and even some other solution for that things. To be true, I’m still thinking what will I use for my next app – I’ll try to search around for a little bit.

  3. droope says :

    That’s brilliant! Definitively a resource to save for later use. :)

  4. antanas (@antanas) says :

    Why some languages are defined in en-LR way, and others are in en,ru,pl way? it would be good to have consistency. anyway, good stuff!

  5. Alexsei says : free if it came to me it is also

  6. dmoise says :

    Phone codes would be useful as well. Great job!

  7. jjonez says :

    What are the north, south, east, and west fields?

  8. Kevin says :

    Hey dperitch – I built an API based off the data I pulled from your tool! See:

    Thanks for the great post.

  9. Danae says :

    Hi there I am so happy I found your webpage, I really found you
    by error, while I was searching on Aol for something else, Anyhow I
    am here now and would just like to say thanks for a remarkable post and
    a all round interesting blog (I also love the theme/design), I don’t have time
    to read through it all at the moment but I have book-marked it and also included
    your RSS feeds, so when I have time I will be back to read a lot more, Please do
    keep up the great work.

  10. Cyiza Rwanda says :

    You are massively helpful…

  11. marvin says :

    ty so much dude , you save me a lot of time.

  12. Mohammad Hussein (@shareb) says :

    Thank you for this, would love to have the SQL dump for world cities too. That’d be amazing :-)

  13. Raj says :

    Thank you very much for this script. I have to complete this job in like 30 min and could never accomplish that without your script …. You just made my day a lot better ..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: