Hacker News new | past | comments | ask | show | jobs | submit login
SQL Fiddle (sqlfiddle.com)
162 points by neokya on Oct 9, 2013 | hide | past | favorite | 83 comments



Love it when I go to lunch, just to find out that someone posts my site to Hacker News and it gets crushed.

It will be back up and running shortly!


One thing that would be great here would be autocompletion. I often forget exactly what the syntax of "CREATE TABLE" is or which options I can use. The same goes for infrequently used SQL functions (now is that date_diff or datediff?).

You could combine autocompletion with a doc panel that automatically updates to show the "quick reference" for the keyword you're currently typing.


Slightly off-topic, but one thing that always impressed me about Microsoft's LINQ as an alternative to SQL queries is that they considered autocompletion up-front in the language syntax.

For SQL, it's a big challenge - you may type in 'SELECT', but your IDE still has no idea what relation(s) you're going to access, and so it can't reasonably autocomplete the possible fields you might want to use.

It's an interesting example of a language that was arguably designed for human readability in the small ('give me this from that cross-referenced with this other thing'), but in some sense became a weakness of sorts later on.


One way to approach it would be to have a grab bag of templates. You drag a template like "SELECT ... FROM ... WHERE ..." out into the editor and then tab through it filling in the blanks.

I've always thought that SQL's notion of readability was somewhere between superficial and disingenuous - you can read the query and it sounds like it ought to make sense, but there's so many occasions where you won't actually be able to understand why it isn't working unless you know how to translate in your head from the order in which the clauses are written, to the order in which they're carried out.


True - but so much of the value of autocomplete comes from just being able to try things out:

'from customers, orders select ...'

Would allow showing a whole bunch of columns, and you could quickly determine whether those tables had the information you're after, or not.

It might seem strange/lazy that the developer can explore the environment (schema) this way without 'knowing' what's out there, but in practice that's exactly what we all do with software development, web search, etc - we try things out and see what comes back, rather than knowing in the first place. Data development has a way to go, but I think things will improve..


Actually, one alternative approach would be: use a search index to autocomplete after even a basic 'SELECT' statement (no other context), but then fill the FROM clause based on the selection.

i.e. - type:

'select city'

prompts with:

'city (table airports)'

'city (table populations)'

'city (table companies)'

And then, upon selection, you have a statement: 'select city from <selected-table>'.

There's a lot more here though. Worth pondering for a while I think.


Would you elaborate on the weaknesses of LINQ you mentioned?


To clarify: it was the SQL, not LINQ, language syntax (field selection prior to relation selection) that I was referring to as a potential weakness (but only once considered in the light of developer tools).


Absolutely. The "get something from somewhere" syntax that SQL employs is completely at odds with it being declarative. LINQ simply does a better job of capturing the abstractions of relational algebra cleanly.

Not that it really matters to someone who is already familiar with SQL, however.


SQL has the weakness, not LINQ.

In LINQ, you do "FROM x SELECT y". So the editor can help you autocomplete the y, since it knows the context.

In SQL, you do "SELECT y FROM x". Thus the editor cannot help you with y.


Excellent point. I guess when SQL was designed not many autocompleting IDEs were around though...


I don't have that feature exactly, but I can offer this - if you have a table of regularly-formatted text data, you can paste it into the "Text-to-DDL" feature to have it automatically generate your CREATE TABLE and INSERT INTO statements.


Awesome, thanks!


http://i.imgur.com/RHxoW5J.png

1. Security flaw in leaking that much error info. 2. Who uses ColdFusion in 2013?


Re: 2) Some day when I have a huge amount of free time, I would like to migrate to Groovy on Grails. Until then - CF is what I had used for over a decade, and it was the easiest thing for me to use to build with at the time (Jan 2012). I was more interested in getting something out there than using whatever the latest trendy tech.


pud's latest project is still on the homepage of HN and he wrote it in CFML: https://news.ycombinator.com/item?id=6519743 Just because project X is not written in your language of choice, means absolutely nothing. Its all about execution and this project is pretty impressive.


Sorry, but choice of language means more than nothing. ColdFusion is pretty dead-end and not a particularly good choice these days for a variety of reasons.


Let me break it for you, nobody except you and some opinionated programmers on the web, cares what language you wrote website X or web app Y in. If it works, and you are able to maintain it - you won't hear a single word of praise from the 'users' congratulating you on your stellar choice of language. They'll rip you to shreds when it stops working but even then they'll never tell you off for choosing the wrong language.

If it works, and you can maintain it - its all good. Even Cold Fusion, even PHP, even Perl, even Brainf#@k


I understand your point of view, and in specific cases, the choice has little practical impact. However, when a business is dependent on an aging technology (language/framework/etc), the choice can have real consequences. As one example, when that very competent programmer who has expert level knowledge in this aging technology decides to move on, if the technology isn't well supported by a vendor, user community, and/or local talent pool, the business can be in a real bind.


There are few consequences for the business as long as they're making more money than they're spending.

The consequences come for the poor bastards that have that old crap on their resume... Bus number notwithstanding...


As we (I work for Adobe!) have talked publicly about the next rev of ColdFusion, and have shown features, talked about focus areas, etc, it is certainly not dead-end in terms of active product development.


we need a package manager (aka bundler). just passing that along :)


I agree that Adobe's ColdFusion is deadend but not Open Source Railo which is more of a Java Framework. At the end of the day there's no logical reason against CFML any more than there is against PHP, Rails, etc.


Sorry, but it is completely logical to choose Ruby/Rails, Python/Django, etc over CFML in 2013 for web projects.


>ColdFusion is... not a particularly good choice these days for a variety of reasons.

Not that I disagree with you, but I wonder if the reasons you have in mind are valid. A lot of the reasons one might assume CF sucks aren't really applicable (i.e. speed, security) any more than most other languages.


I assume all major-ish choices have decent speed, security, etc. The main things are activity, books, resources, people to hire, libraries, support, etc.


If I remember correctly, F#&@ed Company, pud's old wonder box of startup gossip was also done in ColdFusion (though in those days it was quite a good platform to do web stuff).


No, there just wasn't a less-worse one. Bloody PHP is an improvement on ColdFusion.


I disagree with you here. Although I would not choose ColdFusion for anything these days, in 1998/1999 it was a super fast way to get a web site/app together. Post 2000 it was converted to Java and became a glorified JSP tag library. It was a good platform that didn't stand the test of time.


I remember it being quite horrible around that time. But, as you say, a fast way to get a site together. I maintain that PHP was actually less worse, and I despise PHP with a contempt that would give [INSERT DICTATOR HERE] pause.


Lol, no one really. Just a few obscure organizations like NASA, Apple, Pud's DistroKid/Fandalism, Intel, AT&T, and tons of others. Oh and railo is a java framework, who uses java!? Its 2013!


According to Wired Java is experiencing a renaissance of sorts: http://www.wired.com/wiredenterprise/2013/09/oracle_java/


Exactly my point :)

Just like Coldfusion, many people have been saying Java is so 1995 but since Twitter showed how well Java scales compared to the woeful RoR it is seeing a renaissance. And since Railo is a Java framework that speeds development I have a feeling we will being seeing it experience a similar renaissance in the near future.


There clearly was some sarcasm involved in that post.


Actually a lot of enterprise applications are built with Java.


The majority of Internet companies operating at scale likely have services running on the JVM. They might be writing Scala – Twitter, LinkedIn, say – but it's still the Java ecosystem.


I use ColdFusion (well, technically I use Railo) and I love it.

I agree that the owner of the website here needs a <CFERROR> tag, which tells the server what to do instead of showing that big error message.


CFWheels has that already built into it, but I'm convinced that its a problem with the framework itself and not anything the author did.

the issue seems coming from this line:

https://github.com/cfwheels/cfwheels/blob/v1.1.8/wheels/even...

basically when wheels throws an error, it will try to send out an error email containing the environment and framework information. In this case there seems to be no smtp server defined, so CFML itself is spitting up its skull.

The error handling can be reworked so that the $mail() call is wrap in a try/catch so the 500 page will just be shown.

disclosure: part of wheels core.


* Who uses ColdFusion in 2013?*

Me? Because I have to maintain a rather old site for my employer, and there is absolutely no chance that anyone would sign-off on migrating it to a different platform.


Same here... Want to start a support group?


I need one.

Interestingly, about a year ago, we were told that we would no longer be doing any updates to the system, and yet, here we are, a year later, still doing minor releases. I suspect it will never go away.


Well, the whole thing is up on github[1], so if you want, you could always port it from ColdFushion to something else?

[1] https://github.com/jakefeasel/sqlfiddle


Can someone explain how leaking a traceback is a security flaw, considering it's a lot less information than just releasing the source code (which we do all the time and don't consider it a security flaw)?


There's nothing inherently insecure about it, it's just more information that a potential attacker has to use against your system. Obviously, if someone breaks into your system from the information in a traceback, it's likely because of a deeper security hole in your system, so hiding tracebacks is just security through obscurity, but given the choices of publicly showing this information vs not, it's better not to.

WRT to open source: in open source software, you theoretically have many benign eyes vetting your code for security issues, whereas with closed source applications, the only people who are looking for security holes are you and attackers. :)


There are tons of good explanations of why a stacktrace is a security risk. See, for example, this article that appeared on HN: http://www.troyhunt.com/2013/07/everything-you-wanted-to-kno...


Hundreds of prominent public companies have their investor relations (/ media relations) site served by coldfusion (including facebook, yahoo, ebay, paypal, EA, ...)

https://www.google.com/search?q=releaseDetail.cfm

Its not the sexiest of platforms out there, but it can get the job done...



Can't tell if sarcastic or not. Seeing how you link to the giant security fiasco caused by a cold fusion 0 day I'm assuming this is not a recommendation.


Looks like it's set up to email them on errors and the email is throwing an error too.


all my clients unfortunately.


ha, I came here to say pretty much this, except I'd finish with 'fortunately' - I was reluctant to engage when I was first introduced, but Coldfusion has been pretty good to me.


>Who uses ColdFusion in 2013?

About 2/3 of the federal government.

Also, that isn't ColdFusion, it's Railo, an OS alternative.


He had "railo" highlighted... I think he knows that it's not literally ColdFusion...


Ok folks. It's back up now. I will keep my eye on it, hopefully it doesn't get hugged to death again.


Fantastic tool.

It pops up constantly on StackOverflow and I've found it incredibly useful for interviews. I noticed recently that the Execution Plan was added which just opens more avenues for teaching & interviewing.


Also try http://data.stackexchange.com where you can query Stack Overflow and other SE site data in real time using SQL.


A friend of mine wrote this. If you have any questions I can try to get him on here.


He's leaking stacktraces on error BTW:

no SMTP Server defined at railo.runtime.net.smtp.SMTPClient.send(SMTPClient.java:676):676 at railo.runtime.tag.Mail.doEndTag(Mail.java:519):519 at wheels.global.cfml_cfm$cf._1(/root/sqlfiddle/src/main/webapp/wheels/global/cfml.cfm:93):93 at wheels.global.cfml_cfm$cf.udfCall(/root/sqlfiddle/src/main/webapp/wheels/global/cfml.cfm):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:377):377 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1495):1495 at wheels.events.onerror_cfm$cf.udfCall(/root/sqlfiddle/src/main/webapp/wheels/events/onerror.cfm:42):42 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:377):377 at railo.runtime.tag.Invoke.doFunction(Invoke.java:224):224 at railo.runtime.tag.Invoke.doEndTag(Invoke.java:191):191 at wheels.global.cfml_cfm$cf._1(/root/sqlfiddle/src/main/webapp/wheels/global/cfml.cfm:44):44 at wheels.global.cfml_cfm$cf.udfCall(/root/sqlfiddle/src/main/webapp/wheels/global/cfml.cfm):-1 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:377):377 at railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:774):774 at railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1495):1495 at wheels.events.onerror_cfm$cf.udfCall(/root/sqlfiddle/src/main/webapp/wheels/events/onerror.cfm:14):14 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at railo.runtime.type.UDFImpl.call(UDFImpl.java:384):384 at railo.runtime.ComponentImpl._call(ComponentImpl.java:615):615 at railo.runtime.ComponentImpl._call(ComponentImpl.java:502):502 at railo.runtime.ComponentImpl.call(ComponentImpl.java:1815):1815 at railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:349):349 at railo.runtime.listener.ModernAppListener.onError(ModernAppListener.java:336):336 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2045):2045 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2002):2002 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:297):297 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:32):32 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722):722 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225):225 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169):169 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168):168 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98):98 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407 at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565):565 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307):307 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source):-1 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source):-1 at java.lang.Thread.run(Unknown Source):-1


Probably don't need it pasted here...


I've used this for interviewees. Set them up with a test fiddle with questions set in the comments.


As a guy about to finish up school and make his way into the work force, would you be willing to release some of the questions you use in interviews. It be neat to see which areas I need to patch up knowledge wise!


Try this quiz. It's based on a quiz I saw posted on HN a while back.

http://sqlfiddle.com/#!3/3973f/1

Edit: I'm not allowed to reply just yet, so I'll post here.

You need to add the boss first to the employee table with a NULL bossID.

Then you add another employee that has a bossID that refers to that last added record.


Aww - no test data? And when trying to add test data, I get errors due to the self-referencing foreign key. Perhaps the schema could do with a

> DEFAULT (IDENT_CURRENT('dbo.Employees'))

on the BossID column. Been awhile (years) since I've worked with SQL Server.


When the site is back up, I'll verify the link and post here. It's been about 2 months since I've used it.

Simple query stuff though.

Basic aggregate stuff. When to use "LEFT JOIN". Creating a scalar function. Multiple table JOINs.


This must be the ugliest error screen I have ever seen. Is this 1990?


Quick, add Bootstrap 3 and flat UI to everything!


i still haven't seen the main site, but i found these:

http://sqlfiddle.com/about.html

https://github.com/jakefeasel/sqlfiddle


Been a while since I've seen a coldfusion error dump


If anyone is interested in how this site gets used, here's an idea:

http://stackoverflow.com/search?tab=newest&q=url%3a%22http%3...


Used this a long time ago it is a great tool for figuring out a SQL query.


Nice! Might be good to teach some co-workers some SQL stuff rather than drawing on white-boards and drafting up SAS jobs.


Excellent tool, especially for checking if certain set of SQL works on certain platform. I wish they added DB2 too...


Used this last night to get help debugging an issue on #mysql, worked great. thanks Xgc and jfeasel


Cool but it can't handle traffic like JSFiddle (the originator of all code playgrounds) can.


this project has always impressed me. keep telling myself that i need to browse the source to see how it was all done. congrats jake!


Is the site slow?


The site is apparently HN'ed...

railo.runtime.net.mail.MailException which seems to be a framework error from a ColdFusion application server.

Shame on OP, posting something cool and letting it get upvoted without warning the author/host in advance! :)


Sorry about that. I didn't expect that would happen.

Will definitely do that next time. I found it really cool and thought of just posting it on HN.

Edit: Pinged @sqlfiddle on twitter. I hope maintainer did notice it.


I was only joking. How do you know it's going to get upvoted anyway? I think it's probably good netiquette though.


I was making a joke about the performance implications of a public SQL free-for-all, but I was probably being too subtle!

That said, I applaud the creators of the site.


it's the HN effect , one should better web scale before linking one's work ;) nice site though.


The site is up again :)


its cool but slow




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: