Source control systems are a vital component to any serious software development environment. Tracking and merging changes, branching new versions, or reverting back to a previous incarnation of the code is so much easier when you have your source code versioned in a system like Subversion or CVS.
Of course source control isn’t the answer to every question. Sometimes you just want to crack open your editor, splat some code out, and run it. Adding it to a project, doing check outs and diffs…TOO MUCH TIME!
Enter SQL Developer’s Local History
This feature is available when working with a file in either the worksheet or the procedure editor.
Still confused on what the difference between the worksheet and procedure editor is or don’t know how to open a procedure editor for a new PL/SQL object?
As you make changes in the editor or worksheet, your code will diverge from what is being stored in the file. When you hit SAVE these changes are made permanent in the file. Wouldn’t it be nice to see what changes you’ve made throughout your Red Bull energy drink powered hacker session? Or maybe just back out various changes or save a subset of changes to a new patch file?
This is what the Local History panel is all about.
The changes to the file can be tracked for a total of 50 revisions over 7 days. These default settings can be changed in the Local History page of the preferences.
In my example I have a DDL script for a view. I have added a couple of comments and formatted the file. These changes are shown in a side-by-side split editor. You can actually edit live in the panel representing the buffer (worksheet) contents.
Each change is denoted by a purple box in the gutter. Clicking on the block highlights the code that was affected.
Instead of Ctrl+Z’ing through your code
Go right to the change and click the red ‘X!’ Or right-click for more options.
As you continue to work with the file you’ll see new revisions appear in the top panel. If you are using a source control system, you can use the filter to only show your changes.
This is a feature everyone should be using.
The local history ‘undo’ feature probably falls into the Hey, that’s a cool feature, but I’m not using it yet category. How has this happened? Here are a few theories:
- You’re new here and EVERYTHING is ‘new’ to you
- You rarely work with files and do more ad hoc SQL stuff
- You never noticed or clicked into that ‘History’ panel up top
Don’t be afraid to click around every now and then! Or just hang out here and wait for me to get around to showing you the next cool feature 🙂
I’m relatively new to using Oracle SQL developer and this history tab is great, but I was wondering how you got the tracking to occur as it does in the first screenshot? When you’re not in the history tab, it seems the left of the lines are highlighted if they changed without the need to see what exactly changed.
Awesome dude. Thanks for the explanation. Will be using copiously … errrrr … no, that’s not the right word … let me stick to my education level!! Will be using ALOT!! haha
You’re very welcome! This is just something we get for ‘free’ being part of the JDeveloper framework. Not using it actively is fine, we’re still saving the changes for you 🙂