# A new fiddle for dba.se

SQLFiddle has been an essential tool and a great complement to dba.se for a very long time, but it has gone downhill a bit in the last year or two.

I have also wondered for some time what a 'fiddle' designed specifically with dba.se and markdown in mind might look like, and over the last few days I've put together a prototype of how I think it should be.

Please have a play with the site and let me know here if you have suggestions for improvements or design changes.

The current list of supported databases is:

• MariaDB 10.2 and 10.2
• MySQL 8.0
• Oracle 11.2
• Postgres 8.4, 9.4, 9.5, 9.6, 10 and 11
• SQL Server 2012, 2014, 2016, 2017 and 2017 Linux
• SQLite 3.8 and 3.16

Here's an example (the image links to the fiddle):

I've edited some of my answers (e.g. this one) to use db<>fiddle.

As of Apr 2018 the site uses ssl by default — there are some benefits even for a site like db<>fiddle and it's free now so why not?

• +1, +10, +1000000000000000000 – ypercubeᵀᴹ Feb 16 '17 at 18:28
• ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ – MDCCL Feb 16 '17 at 21:14
• +2 also. It would be a welcome addition. As wishes are cheap: having several versions (i.e.: PostgreSQL 9.4, 9.5, 9.6...) of the same DB would be a plus. Sometimes you don't know when your problem is just version specific... and you'd better upgrate quickly. – joanolo Feb 19 '17 at 6:38
• @joanolo "As wishes are cheap" not at all, thanks for the suggestion. I've added 9.5 and 9.4, and will add others at some point! – Jack Douglas Feb 19 '17 at 18:16
• As sqlfiddle is an established site, and you seem to have already invested time and effort in to it according to the about page, couldn't SE just adopt it and make sql fiddle great again, by pushing some resources towards it's development? – Tanner Feb 21 '17 at 10:34
• @Tanner when I saw the writing on the wall a couple of years ago, I asked that question, but although help was offered, it wasn't the sort that Jake needed. – Jack Douglas Feb 21 '17 at 10:37
• @JackDouglas fair enough, just thought I'd ask... you know, reinventing the wheel n all. good luck, would be interested to see how it develops. – Tanner Feb 21 '17 at 10:54
• @Tanner thanks, feel free to post feature requests here if you have ideas. – Jack Douglas Feb 21 '17 at 11:10
• Forgive my ignorance, but what are SQLfiddle/DBFiddle? I followed the links but they didn't have any explanatory text. I also couldn't find any reference on DBA.SE about them. – BradC Feb 23 '17 at 16:37
• @BradC Try this one: dbfiddle.uk/… the point is that you can make a reproducible test case demonstrating a question or problem, and then others can tinker with it (try changing the sql in the link in this comment) – Jack Douglas Feb 23 '17 at 17:12
• @BradC also, there is a bit of documentation on the home page for each RDBMS: dbfiddle.uk/?rdbms=sqlserver_next – Jack Douglas Feb 23 '17 at 17:13
• @JackDouglas: Others who don't have the target dbms installed can tinker. That's the big deal for me. I'd usually rather see the SQL in the question, myself. There's no reason people can't include SQL in the question and in a fiddle, but that's not as common as I would like it to be. – Mike Sherrill 'Cat Recall' Feb 28 '17 at 16:49
• @Mike we can't force that (except by editing posts), but yes, all the SQL should go in the Q&A as well as the fiddle. I've tried to make this as easy as possible with the 'markdown' link next to the 'run' button — I only added this yesterday so you may not have seen it? – Jack Douglas Feb 28 '17 at 16:53
• The site has evolved. By now, in all modesty, I'd like to say it's absolutely marvellous. – Erwin Brandstetter Apr 10 '17 at 1:18
• @lad2025 thanks for spotting that bug, now fixed. Regarding db support, pg11 will be added soon, but Oracle 12c probably never as there is no XE version. 18c XE is thought to be coming up (possibly in July) and if that materializes I will add it. – Jack Douglas May 28 at 8:36

## 31 Answers

I am missing the possibility to copy the table results for the SO editor. If I simply copy the table I end up with things like that:

user_id     check_date  day     time_in     time_out    hours   status
53  2018-07-16 00:00:00+01  Monday      08:15:17    09:38:03    25.3794444444444    present
53  2018-07-17 00:00:00+01  Tuesday                 absent
53  2018-07-18 00:00:00+01  Wednesday   06:34:13    08:05:17    1.51777777777778    present


The columns and values are not really aligned together. So I always have to append a manual formatting step (e.g. converting tabs into spaces):

user_id   check_date               day         time_in    time_out   hours              status
53        2018-07-16 00:00:00+01   Monday      08:15:17   09:38:03   25.3794444444444   present
53        2018-07-17 00:00:00+01   Tuesday                                              absent
53        2018-07-18 00:00:00+01   Wednesday   06:34:13   08:05:17   1.51777777777778   present


In SQLFiddle you can chose the output between (table, plaintext, markdown). Even plaintext looks much better and can be taken for copying into SO without any addional work:

| user_id |           check_date |       day |  time_in | time_out |                hours |  status |
|---------|----------------------|-----------|----------|----------|----------------------|---------|
|      53 | 2018-07-16T00:00:00Z | Monday    | 08:15:17 | 09:38:03 |   25.379444444444445 | present |
|      53 | 2018-07-17T00:00:00Z | Tuesday   |   (null) |   (null) |               (null) |  absent |
|      53 | 2018-07-18T00:00:00Z | Wednesday | 06:34:13 | 08:05:17 |   1.5177777777777777 | present |


Edit: dbfiddle markdown syntax

> user_id | check_date             | day       | time_in  | time_out | hours               | status
> ------: | :--------------------- | :-------- | :------- | :------- | :------------------ | :------
>      53 | 2018-07-16 00:00:00+01 | Monday    | 08:15:17 | 09:38:03 | 25.3794444444444    | present
>      53 | 2018-07-17 00:00:00+01 | Tuesday   | <em>null</em>     | <em>null</em>     | <em>null</em>                | absent
>      53 | 2018-07-18 00:00:00+01 | Wednesday | 06:34:13 | 08:05:17 | 1.51777777777778    | present


As you can see, the second row is not really aligned. Furthermore you can find the <em> tags and things like that.

Added by Jack:

select 1, null;

?column? | ?column?
-------: | :-------
1 | null

• have you tried the 'markdown' link at the top? – Jack Douglas Oct 31 at 14:41
• Yes, of course. But it creates markdown syntax which is not a really good result (appending example) – S-Man Oct 31 at 14:45
• The <em> tag is the only one — and it's there to distinguish between "null" (the string) and an actual null result. I guess it would be nice if the alignment took that into account, but does it really matter for SO? Also, when I paste in the markdown directly from db<>fiddle to an SO answer it doesn't look like yours: I'll edit an example into your question. – Jack Douglas Oct 31 at 15:12
• Yours is indented and missing the <pre> tags – Jack Douglas Oct 31 at 15:14