What some people aren't aware of though is that you can open multiple different consoles against the same datasource by selecting New - Console:
The problem is, once you close any console but the first, the rest become lost forever, right? Not necessarily. I had accidentally closed a console this morning that I wasn't finished with and needed to recover that query. I moused over the tab of another console that I had open and noticed that IDEA showed me the full path to where that file was stored:
Manually navigating to that path showed me all the other consoles that I'd been working with recently! It's obviously not fail safe, but in a pinch it's a way to recover scripts that you didn't intend to close.