Jump to navigation Jump to search

SQLZoo includes tutorials and reference to support people learning SQL.


The site is maintained by Andrew Cumming a software developer at Intelligent Growth Solutions based in Edinburgh, UK.

Terms and Conditions

None. Everyone in the world is welcome to use this site and the material on it in any way they see fit.

Academic Users

Many users are from education institutions (the material was initially developed for use at Edinburgh Napier University). I am very happy to support these users, the site works particularly well with large classes where one instructor can support a large class of learners face to face.

If you are recommending the site to your students using a password protected site like moodle then you owe me an incoming link from a public source.


I run google ads at the bottom of each page and we are showing video ads to USA users via cleanmedia.com; as I am based outside the USA I don't see these ads and so I don't have a good idea if they are intrusive - I'd be happy to get feedback from users about that.

Making money is not the point of the site and so https://noads.sqlzoo.net is available for anyone to use.

Why is it called SQLzoo

The inmates of SQLzoo are the SQL engines (MySQL, Oracle, SQL Server and others). They have been tamed, caged and defanged so that members of the public can pet them or poke them or gawk at them. In the wild, these engines are dangerous, needy beasts but in the confines of SQLzoo they are relatively safe. Once you have an idea of what SQL is and how it works you should install an SQL engine on your own computer and play with the real thing.

Wiki Nature

It is based on MediaWiki and it allows users to change the content. http://www.mediawiki.org/wiki/Help:Editing_pages shows how to edit pages in "standard" media wiki.

  • Only users with the teacher role can edit pages.
    • Any teachers who can help with fixing errors or creating content are most welcome
    • Send an email (ideally from an educational address) to sqlzoo.qa@gmail.com and tell us your user name - we can add that role so that you can edit.

SQLZoo features:

  • Interactive access to several SQL engines
  • Sample databases
  • Practical exercise
  • Instant feedback on the success of the student's attempts


The data used in the databases is available in a slightly odd version of SQL:

For example


SQLZoo includes a number of extensions to normal Wiki text:

  • class='qu'
    • A div with class qu is interpreted as an interactive question.
    • A div.qu element should include a source.def element
      • This contains the default text that the user sees.
      • Sometime this is a useful hint and is close to the correct answer.
      • It may be empty - but users often click without changing the text before even looking at it
    • A div.qu element may include a source.ans element
      • This contains the correct SQL.
      • This is hidden from the user (but not well hidden)
      • The user's result is compared with the answers result and a score is calculated

Here is an example of a question:

==Warming up==
<div class='qu'>
[[Read the notes about this table.]] Observe the result of running a simple SQL command.
<source lang='sql' class='def'>
SELECT name, population FROM world
<source lang='sql' class='ans'>
SELECT name, population FROM world

And here is how that looks when rendered...

Warming up

Read the notes about this table. Observe the result of running a simple SQL command.

SELECT name, continent, population FROM world
SELECT name, continent, population FROM world


You can include a ***startAt*** span at the top of the page. This will ensure that question numbering starts at the specified value.

<span id=startAt class=params>6</span>


Most questions do not respect order - a query is considered correct even if the order of the student's work differs from the correct answer. You can over-ride that rule by insisting that the question respects order. Place this invisible tag in your qu tag.

<span class='params respectorder'></span>

Order must be right

Show countries beginning with D by population size.

  FROM world
WHERE name LIKE 'D%'
ORDER by name
  FROM world
WHERE name LIKE 'D%'
ORDER by population


You can include a hint. The title will be shown, if the user clicks on the text the body will be revealed:

Now the hint has been revealed

<div class='hint' title='Click here to see the hint'>Now the hint has been revealed</div>

Clear Results

<div class="lsclear">Clear your results</div>

Clear your results

Setting up AWS server

  • Start with Amazon Linux - pick a paravirtual one from the bottom of the list of AMI - the ones at the top
  • Use classic network
  • Log in as ec2-user
sudo su
yum install httpd
scp -C andrew@ ~
mv ~/public_html/sqlzoo /var/www/html
yum install mysql-server
/etc/init.d/mysqld start
/usr/bin/mysqladmin -u root password 'topsecret'
scp andrew@ ~
scp andrew@ ~
yum install php
yum install php-pear
yum install php-mysql
/etc/init.d/httpd restart


create database gisq;
grant all on gisq.* to gisq@localhost identified by 'password';
grant select on gisq.* to scott identified by 'tiger';
create database scott;
use scott
grant all on scott.* to scott identified by 'tiger';
Language:Project:Language policy English  • Deutsch