Skip to content

mrpollo/sqlfiddle

 
 

Repository files navigation

About SQLFiddle.com

What am I supposed to do here?

	SQL Fiddle is a tool for database developers to test out their SQL queries.  If you do not know SQL or basic database concepts, this site is not going to be very useful to you.  However, if you are a database developer, there are a few different use-cases of SQL Fiddle intended for you:
			
			You want help with a tricky query, and you'd like to post a question to a Q/A site like StackOverflow.  Build a representative database (schema and data) and post a link to it in your question.  Unique URLs for each database (and each query) will be generated as you use the site; just copy and paste the URL that you want to share, and it will be available for anyone who wants to take a look.  They will then be able to use your DDL and your SQL as a starting point for answering your question.  When they have something they'd like to share with you, they can then send you a link back to their query.
					
			You want to compare and contrast SQL statements in different database backends.  SQLFiddle easily lets you switch which database provider (MySQL, PostgreSQL, MS SQL Server, and Oracle) your queries run against.  This will allow you to quickly evaluate query porting efforts, or language options available in each environment.
			
			You do not have a particular database platform readily available, but you would like to see what a given query would look like in that environment.  Using SQL Fiddle, you don't need to bother spinning up a whole installation for your evaluation; just creating your database and queries here!
		
	Vince Pergolizzi wrote a great blog post about the site, providing an overview for how to use it when you ask SQL questions at places like StackOverflow. See it here: http://www.vincepergolizzi.com/2012/04/how-to-use-sql-fiddle-or-help-us-to-help-you/ 
	
	Para falantes do português, Dickson S. Guedes fez um vídeo instrutivo: http://www.youtube.com/watch?v=ednxTEGyfV8


How does it work?

	The Schema DDL that is provided is used to generate a private database on the fly.  If anything is changed in your DDL (even a single space!), then you will be prompted to generate a new schema and will be operating in a new database.
	

	
	All SQL queries are run within a transaction that gets immediately rolled-back after the SQL executes.  This is so that the underlying database structure does not change from query to query, which makes it possible to share anonymously online with any number of users (each of whom may be writing queries in the same shared database, potentially modifying the structure and thus -- if not for the rollback -- each other's results).

	
	As you create schemas and write queries, unique URLs that refer to your particular schema and query will be visible in your address bar.  You can share these with anyone, and they will be able to see what you've done so far.  You will also be able to use your normal browser functions like 'back', 'forward', and 'reload', and you will see the various stages of your work, as you would expect.
	

Why are there two strange-looking options for SQLite?
	
	SQLite is something of a special case amongst the various database types I support. I could have implemented it the same way as the others, with a backend host doing the query execution, but what fun is that? SQLite's "lite" nature allowed for some interesting alternatives.
	
	First, I found the very neat project SQL.js, which is an implementation of the engine translated into javascript. This means that instead of using my servers (and my limited memory), I could offload the work onto your browser! Great for me, but unfortunately SQL.js does have a few drawbacks. One is that it taxes the browser a bit when it is first loaded into memory. The other is that it doesn't work in all browsers (so far I've seen it fail in IE9 and mobile Safari).
	
	The other option is "WebSQL." This option makes use of the SQLite implementation that a few browsers come with built-in (I've seen it work in Chrome and Safari; supposedly Opera supports this too). This feature was considered part of the W3C working draft for HTML5, but they depricated it in favor of IndexedDB. Despite this, a few browsers (particularlly mobile browsers) still have it available, so I figured that this would be a useful feature to grab onto. The advantage over SQL.js is that it is quite a bit faster to load the schema and run the queries. The disadvantage is that it isn't widely supported, and likely not long for this world.
	
	Together, these two options allow SQLite to run within any decent browser *cough*IE*cough*. If someone links you to a SQLite fiddle that your browser doesn't support, just switch over to the other option and build it using that one.


Who should I contact for help/feedback?

	There are two ways you can get in contact:
		
			Email : admin<at>sqlfiddle<dot>com
			Twitter: @sqlfiddle
		

Who built this site, and why?

	
	SQLFiddle.com was built by me, Jake Feasel, a web developer from Anchorage, Alaska.  I started developing the site around the middle of January, 2012.
	
	I had been having fun answering questions on StackOverflow, particularly related to a few main categories: ColdFusion, jQuery, and SQL.

	I found JS Fiddle to be a great tool for answering javascript / jQuery questions, but I also found that there was nothing available that offered similar functionality for the SQL questions. So, that was my inspiration to build this site.  Basically, I built this site as a tool for developers like me to be more effective in assisting other developers.
	
	Ramon Roche helped me to get the UI moved to Bootstrap, and just generally helping to make it look better. This has been my first time using Bootstrap, and without his assistance getting started I'm sure it would have been a lot rougher. Thanks Ramon!


What platform is it running on?
	
	This site uses many different technologies.  The primary ones, in order from client to server are these:
		
	CodeMirror - for browser-based SQL editing with text highlighting.
	Bootstrap - Twitter's CSS framework.
	Backbone.js - MVC JavaScript framework.
	Handlebars.js - JavaScript templating engine.
	jQuery - AJAX, plus misc JS goodness. (Also jq plugin Block UI).
	html-query-plan - XSLT for building rich query plans for SQL Server
	Date.format.js - date formatting JavaScript library
	jQuery - AJAX, plus misc JS goodness. (Also jq plugin Block UI).
	ColdFusion on Wheels - ColdFusion framework modeled after Ruby on Rails.
	Railo - Open Source CFML Application server.
	Tomcat - Open Source Java Servlet Engine
	Apache HTTPD - Open Source HTTP Server
	PostgreSQL - Among others, of course, but PG is the central database host for this platform.
	CentOS - Free, stable Linux distribution.
	GeoNorth - Hosting and Consulting Company (who I work for), generously setting aside resources for this site.
	StrataScale - VPS Cloud Hosting Provider
		

	
	We also have a Windows 2008 VPS running SQL Server and Oracle.
	
	
	
	If you are interested in the fine details of the code behind SQL Fiddle, it is all available on github.
	

Releases

No releases published

Packages

No packages published

Languages

  • ColdFusion 67.6%
  • JavaScript 29.5%
  • Racket 2.9%