You backup your databases, right?
You backup you home computer – your media collection, tax documents, bank accounts, etc, right?
You backup your handy-dandy SQL scripts, right?
Ok, now that I’ve got your head nodding, I want to answer a question I get every so often:
How can I manage my scripts in SQL Developer?
This is an interesting question. First, it assumes that one SHOULD manage their scripts in their IDE. Now, what I think the question generally gets around to is, how can we:
Navigate to our scripts
Open them
Execute them
What a good IDE should have is an interface to your existing Version Control System (VCS.) SQL Developer supports out-of-the-box both Subversion and Git. You can also download an extension via check-for-updates to get support for CVS.
Now, what I’m about to show you COULD be done without versioning and controlling your scripts – but I want to ask you why you wouldn’t want to do this? So, I’m going to proceed and assume that you do INDEED version your scripts already.
Seeing what scripts you’ve already got in your repository
This is very straightforward – just open the Team Versions panel.
Then connect to your repository.
Shows you the files in your source control system.
Now, I could ‘preview’ said file right away. If I open the file from here, we get a temp file copy down from the server to the local machine.
This is a local temp copy of the controlled script – I can read/execute, but not write to it.
And that might be all you need. But, if your script calls other scripts, then you’re going to want to check out the server copy of your stuff down your local SVN working copy directory.
That way when your script calls another script – you’re executing the PRODUCTION APPROVED copies of said scripts. And if you do SPOOL or other file I/O stuff, it will work as expected.
To get to those said client copies of your scripts…
Enter the Files Panel
The Files panel is accessible from the View menu. You can get to your files, one of two ways. If you’ve touched the file recently, you can see it under the Recent tree. Otherwise, you can navigate to your local ‘checked out’ copies of your script(s).
Open your local copies, see what’s changed, etc.
And I can access the change history and see what’s been touched…
What changes am I going to ‘push out’ if I commit this back to the server?
Most of us work on teams, yes? This panel also gives me a heads up if someone else is making changes to the same file. I can see the ‘incoming’ changes as well.
To Sum It Up…
If I want to get a script to run:
do a full get to your local directory
open the script(s)
The files panel will tell you if your local copy is out of date from the server and if you have made local changes you’ve forgotten to commit back up to the server and your fellow teammates.
Now, if you’re the selfish type and don’t want to share, that’s fine. But you should still be backing up your scripts, and you can still use the Files panel to manage your scripts.