There’s nothing worse than the ‘white screen of panic.’ You’re faced with the prospect of actually writing some code from scratch. Or even worse, you’re doing a presentation or demo, and everyone gets to see what a horrible typist you are.
Yes, you could browse your SQL History, but that could contain several hundred or even thousands of statements. And let’s face it, you probably don’t recognize code you wrote even a few days ago when you see it.
Wouldn’t it be nice if you could take your favorite statements or scripts, and save them to recall later? Even better, let me name and document them?
Enter the Snippets
Access your snippets via the View menu. There’s a few included ‘out of the box,’ but you’ll want to add your own to the ‘Custom’ category.
Add a Snippet
The easiest way to add a snippet is to select your code and right-click. Choose ‘Save as Snippet…’
Define the Snippet
Place it into the proper category, give it a name, and define the tool-tip that will appear if you mouse-over the snippet.
Snippets in Action
Now when you get back to the white-screen-of-panic, remember your trusty statements and scripts are accessible via the Snippets panel. Select your snippet and drag and drop (d-n-d) it into the worksheet or Procedure Editor. The d-n-d will respect any code you already have in your editor, meaning you can drag it exactly where you want to drop it and preserve your existing code.
Power Tip: Did you know you can share your favorite snippets with other SQL Developer users at the Exchange? Browse and download your favorite snippets or upload your own here. We don’t support or endorse these snippets, so use at your own risk.





Twitter
RSS
GooglePlus
Facebook
Aug 03, 2012 @ 10:25:37
Hi Jeff
I have a question…Can I shared your information in Spanish in my blog..? obviously I will write source and put link. Thank you so much I think is very interesting here Colombia.
Aug 03, 2012 @ 11:09:16
Thanks for the offer Ivan, but I’m not looking to have my content syndicated/translated at this point just yet. I’d be happy to guest post on your blog though, just give me a topic you and your readers would like to know more about!
And again – thanks for asking. Many folks just grab content they want, and act offended when you ask them to stop.
Aug 06, 2012 @ 11:22:55
Ah, snippets, quite an underused feature of SQL Dev. I’ve been using Snippets since my earliest SQL dev days – especially so since I had a bunch of SQL statements that I’d run to verify my data before starting a humongous data conversion job.
Aug 06, 2012 @ 11:41:03
Any suggestions for making our snippets ‘better’ or more useful Sathya?
Aug 06, 2012 @ 12:35:45
Jeff,
I think your blog post about Snippets is good enough
The only other tips I’d suggest is
– If you’re using the snippets often, it’d be a good idea to keep the window docked
– I believe you can also add custom categories – having snippets categorized instead of having them all under “Custom” allows for easy discovery of snippets.
- The snippets are stored in %appdata%\SQL Developer\UserSnippets.xml file, it’d be prudent to keep the file backed up regularly. Or have a bunch of snippets pre-built and saved in the folder to save time