I went to link to this post earlier today, and was shocked to discover I hadn’t actually written it yet.
What’s the opposite of ‘bazinga!’ ?
SQL Developer stores every query AND script you execute in a worksheet.
A query being a single statement, and a script being one or more queries and/or anonymous blocks.
A query is stored as a single item.
A ‘script’ is stored as a single item.
By DEFAULT, we store the last 100 executed items.
When query 101 is executed, the least recently executed item will ‘age out’ of the list.
The Preference
We do NOT save queries which fail to run due to errors. This saves your precious history from being aged out by bogus queries.
Do NOT set your SQL History limit to ‘30,000’ and then complain that it takes SQLDev 10+ minutes to startup. #TrueStory. Each item is saved in a separate XML file. Each file is read into memory at startup time.
Your Query History is physically stored here – accessible to ALL of your SQL Developer local installs! So there is ONE SQL History stored on your computer, not one for each version of SQL Developer on your machine.
Upgrade SQLDev, your history will still be there.

It’s 101 files, because there’s a master index XML file that references the other 100 items (files.)
Accessing the SQL History List
F8 or View > SQL History.
You get a panel.

Mouse hover over a script item, and you’ll see that I’m not fibbing about entire scripts going into your history…
Items can be sorted and filtered. What’s shown on the panel is what will be available for recall, whether you use the mouse or keyboard.
Note that we store the last time executed, total times executed, and where you executed it.
So you can see it. How do you get it to the SQL Worksheet?

The default button will ‘tack’ the highlighted history item to wherever your cursor is in the Worksheet. The other button will CLOBBER the worksheet and you’ll be left ONLY with your query from the history.
That’s the BORING way to access the history.
The more useful way is via the keyboard. I don’t even open the SQL History panel most days. What I want is usually something I ran in the last few moments. If I have to dig deep, then F8 + Search is my new best friend.
You can change the SQL History keyboard actions in the Preferences.
SQL History in SQLcl
So in the command line edition of SQL Developer, we also have a SQL History. Default is also set to 100 items – it’s not configurable, YET. It is also storing invalid statements…today.
We’ll release SQLcl with ability to set these behaviors.
Recall is similar via keyboard. Just up or down arrow at the prompt.
You can also see the entire list with ‘HISTORY’
Do ‘HISTORY #’ to put that item in the buffer to be executed.
SQLcl and SQL Developer maintain SEPARATE histories. You won’t see queries you ran in SQLcl showing up in SQL Developer and vice versa.