Browse 543 attributed reviews, viewable separately for our classroom and online training
Practise SQL in your browser with SQL Fiddle
Part one of a sixteen-part series of blogs

Some of our poor delegates don't have the luxury of a home computer to install SQL on (even worse some have made bad life choices and picked a Mac). The good news is that you can still practise your SQL skills in your web browser, using the impressive SQL Fiddle site. Have no fear, SQL Fiddle is here, a browser based sandbox to bring you cheer!

  1. Installing and configuring SQL Fiddle (this blog)
  2. SQL Fiddle Exercise 1 - SELECT
  3. SQL Fiddle Exercise 2 - Order By
  4. SQL Fiddle Exercise 3 - Numeric Filters
  5. SQL Fiddle Exercise 4 - Date Filter
  6. SQL Fiddle Exercise 5 - Text Filters
  7. SQL Fiddle Exercise 6 - Cast or Convert Functions
  8. SQL Fiddle Exercise 7 - Conditional Function
  9. SQL Fiddle Exercise 8 - Counting Words
  10. SQL Fiddle Exercise 9 - Formatted Dates
  11. SQL Fiddle Exercise 10 - Date Calculations
  12. SQL Fiddle Exercise 11 - Inner Join
  13. SQL Fiddle Exercise 12 - Outer Join
  14. SQL Fiddle Exercise 13 - Grouping Data
  15. SQL Fiddle Exercise 14 - Having
  16. SQL Fiddle Exercise 15 - All together now!

Posted by Sam Lowrie on 01 July 2021

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Installing and configuring SQL Fiddle

For some delegates installing SSMS (SQL Server Management Studio) isn't an option (this is especially true for Mac users who don't want to use 3rd party software). Have no fear - SQL Fiddle is here!

SQL Fiddle Database

SQL Fiddle (like W3 schools), lets you practice SQL without needing to install SSMS!

Choosing your SQL dialect

The first thing to do when you visit SQL Fiddle is to change the SQL dialect to the one you are using. For example SSMS runs T-SQL, which is the native SQL dialect for MS SQL SERVER 2017.

SQL Fiddle

If you forget to do this all your code generated will be slightly off. Rather than fixing the problem, it will be quicker to re-import your tables, speaking of which ...

 

Creating your database - Method 1 (running script)

If somebody has provided you with the script to generate your database, you can just run this. 

Fortunately I've already done this for you: see below for the simple test database I've created for you to use, and how to generate it.

To generate a database for you to use in SQL Fiddle from script, just paste the SQL script into the left-hand window and click on the Build Schema button:

Building a schema

Once you click on this button, you'll be able to write queries against this database.

When this has executed, you can click on the Browser button to see the results:

The Browser button

Click on this button to see a list of tables generated.

You can then return to the normal view by clicking on the DDL Editor button:

The list of tables

Here our script has generated 5 tables.

 

Here's an example of writing a query to interrogate one of the generated tables:

Running a query

Click on the Run SQL button to run any SQL query you've typed in.

The big limitation is that you don't get Intellisense suggesting how to complete your commands, but you can't have everything in life!

Creating your database - Method 2 (pasting data)

If you don't have any pre-created script, you can paste in your tables one by one, and add the script for each.  For each table, first click on the Text to DDL button:

Text to DDL button

Click on this button to convert pasted text to SQL script.

You can now give your new table a name, and paste in its data:

Pasted data

Click on the Append to DDL button to add script to generate this table to your schema window on the left-hand side.

You can repeat this process to add each table, then click on the Build Schema button as shown for method 1 above:

Building a schema

SQL Fiddle turns the pasted data into script to generate the necessary table.

Our example database

The rest of this blog contains a selection of exercises to practise using this simple database:

Our sample database

Note that this diagram was created in SQL Server Management Studio (you can't add relationships to tables in SQL Fiddle).

To generate this database, just click here to get a pre-made SQL Fiddle.  All that you need to do is to click on the button to generate your schema!

Generating schema

Just click on the button shown above after clicking on this link, and your database will be ready to interrogate!

If you want to learn how to write SQL in a more structured way, consider booking onto one of our classroom or online SQL courses.

This blog has 0 threads Add post