Hadi Fadlallah
Formatted SQL command

Popular free SQL online compilers

August 9, 2021 by

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.

Selecting the SQL online compiler from the top menu

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.

SQL Fiddle 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.

Right panel enabled after building the schema

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.

Executing SQL commands and showing results

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.

Additional button on the bottom of the result table

Figure 5 – Additional button on the bottom of the result table

Showing the execution plan

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.

ApexSQL online SQL formatter

ApexSQL online SQL formatter is a valuable tool that makes SQL query more look prettier and more readable. Developers can use tens of options, such as enforcing capitalization, text indentation, wrapping, and spacing, besides formatting specific SQL parts such as comments, joins, statements, keywords. As shown in the images below, you have to write your SQL command in the “Input” tab, and then you should configure your query output.

Input SQL command

Figure 7 – Input SQL command

Next, you should click on the “Formatted” tab to view your formatted SQL command.

Formatted SQL command

Figure 8 – Formatted SQL command

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.

DbFiddle SQL online compilers list

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

DB-Fiddle main page

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.

Query results

Figure 11 – Query results

You can create a permanent link to this fiddle by clicking the “Save” button in the top menu.

Save button

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.

Result markdown sample

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.

Db<>Fiddle SQL online compiler main page

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.

Sample queries with results

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.

SQL batch configuration buttons

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.

SQL batch controls

Figure 17 – SQL batch controls

Also, the result can be copied as Markdown by clicking the “Markdown” button on the top menu bar.

Result copied as Markdown

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.

Hadi Fadlallah
SQL commands, Testing

About Hadi Fadlallah

Hadi is an SQL Server professional with more than 10 years of experience. His main expertise is in data integration. He's one of the top ETL and SQL Server Integration Services contributors at Stackoverflow.com . Also, he published several article series about Biml, SSIS features, Search engines, Hadoop, and many other technologies. Besides working with SQL Server, he worked with different data technologies such as NoSQL databases, Hadoop, Apache Spark. He is a Neo4j and ArangoDB certified professional. On the academic level, Hadi holds two master's degrees in computer science and business computing. Currently, he is a Ph.D. candidate in data science focusing on Big Data quality assessment techniques. Hadi really enjoys learning new things everyday and sharing his knowledge. You can reach him on his personal website. View all posts by Hadi Fadlallah

15,340 Views