This article will mention some of the most popular free SQL online compilers that help developers debug and test their SQL code without installing an SQL instance locally or buying one on the cloud.
I will mention the SQL online compilers I used during the years I have been writing SQL queries, especially in the past four years when I was answering questions on the Stack overflow community.
SQLFiddle.com
SQL Fiddle is the most SQL online compiler I use. As described on their website, SQL fiddle is “a tool for easy online testing and sharing of database problems and their solutions”. It is created in January 2012 by Jake Feasel; a web developer specialized in JQuery and SQL.
Many SQL compilers are available on SQL Fiddle, such as:
- MySQL 5.6
- Oracle 11g R2
- PostgreSQL 9.6
- PostgreSQL 9.3
- SQLite (WebSQL)
- SQLite (SQL.js)
- Microsoft SQL Server 2017
You can select the compiler from the main page’s top menu, as shown in the image below.
Figure 1 – Selecting the SQL compiler from the top menu
After selecting the compiler, we should first write a query to build the SQL environment that we need to query (Tables, Relations, Schema, Sample Data …). As shown in the image below, the schema must be defined in the schema panel.
Figure 2 – SQL Fiddle schema panel
After writing the SQL commands to build the testing environment, we should press the “Build schema” button. Then the right panel used to write our queries will be enabled.
Figure 3 – Right panel enabled after building the schema
After writing the SQL commands, we must press the “Run SQL” button to execute it. The results are shown on the bottom of the panels.
Figure 4 – Executing SQL commands and showing results
After executing the SQL commands, we can visualize the execution plan by pressing the “View Execution Plan” button below the result table. Besides, we can generate a permanent link to share it with other people by pressing the “Link” button.
Figure 5 – Additional button on the bottom of the result table
Figure 6 – Showing the execution plan
You can use the following link to check the sample we used while writing this article. Also, if you are interested in reviewing the source code, you can refer to the SQL fiddle GitHub repository.
Db-fiddle.com
Another popular SQL online compiler is DB-Fiddle. Developed and maintained by Status200, a web specialized in application and digital product development.
Many SQL compiler are available on DB-Fiddle such as:
- MySQL 8.0
- MySQL 5.7
- MySQL 5.6
- MySQL 5.5
- PostgreSQL 13
- PostgreSQL 12
- PostgreSQL 11
- PostgreSQL 10.0
- PostgreSQL 9.6
- PostgreSQL 9.5
- PostgreSQL 9.4
- SQLite 3.30
- SQLite 3.26
The compiler can be selected from the main page’s top menu, as shown in the image below.
Figure 9 – SQL Compiler list
The main page contains four main components:
- Top menu bar: Contains the main buttons needed, such as the execution and sharing buttons
- Title and description fields: Needed when sharing the SQL queries with others
- The Schema panel: Where the SQL environment is defined
- The SQL query panel: Where we write the SQL queries
Figure 10 – DB-Fiddle main page
Once a query is written in any SQL panel, the execution and sharing buttons are enabled in the top menu bar. After executing the SQL queries, the results are shown at the bottom of the SQL panels.
Figure 11 – Query results
You can create a permanent link to this fiddle by clicking the “Save” button in the top menu.
Figure 12 – Save button
One additional cool feature is to Copy the queries and results as Markdown, which gives the ability to easily share them on communities such as GitHub, Stack overflow.
Figure 13 – Result markdown sample
You can use the following link to check the sample we used while writing this article. You can also get the latest updates by following the DB-Fiddle official Twitter account.
DB<>Fiddle
While answering SQL Server questions on Stack overflow, I noted that this SQL online compiler is often used by community contributors. Db<>Fiddle is created by DBAnow, and it allows writing SQL batches similar to Notebooks, where the SQL query is split into batches.
Figure 14– Db<>Fiddle main page
Db<>Fiddle supports more SQL compilers than the other SQL online compilers. It supports SQL Server, SQLite, Firebird, MariaDB, MySQL, PostgreSQL, DB2, and Oracle. Besides, you can query Sample databases using some compilers such as SQL Server 2019.
As shown in the image below, SQL batches are executed sequentially, and their results are shown on the right side.
Figure 15 – Sample queries with results
We can add more SQL batched by clicking on the “Expand” button on the top left of each SQL batch. Besides, we can manage each SQL batch by clicking the “Show Controls” button.
Figure 16 – SQL batch configuration buttons
Clicking on the “Show controls” button will show multiple options, such as removing, splitting, explaining, or hiding the SQL batch.
Figure 17 – SQL batch controls
Also, the result can be copied as Markdown by clicking the “Markdown” button on the top menu bar.
Figure 18 – Result copied as Markdown
Summary
This article mentioned four popular SQL online compilers that allow developers to write and test SQL queries using the most popular database engine compilers such as SQL Server, Oracle, MySQL, and PostgreSQL. These SQL online compilers can also share and collaborate with other developers and easily document the code by copying all projects as Markdown.
- An overview of SQL Server monitoring tools - December 12, 2023
- Different methods for monitoring MongoDB databases - June 14, 2023
- Learn SQL: Insert multiple rows commands - March 6, 2023