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.
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.
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).
And I can access the change history and see what’s been touched…
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.
14 Comments
Is there any way to choose the directory at which the Files panel opens by default?
it defaults to the last directory you opened or saved a file to/from
hmm… doesn’t seem to be working correctly for me. It’s opening at the correct top level directory (D:\ in my case), but not where my last file was saved (D:\development\views)
what version you in? I just tried and it worked for me
i see my dir first on the list on the left, I open it, pick a file
close file
go to open file again, i’m in that directory i clicked to when opening just a few seconds ago
Ah, I think my original question may not have been clear. I’m talking about the panel described in this blog post: is there any way to specify the default directory at which that opens when I open SQL Developer?
No, but you have the Recent tree node which shows what you’ve opened recently.
Thanks for your quick response!
Is there a way to connect sqldeveloper to TFS?
Not today, and it’s not currently on the roadmap.
Great post!
I’ve recently found the DBmaestro Teamwork extension for Oracle SQL Developer, it gives version control functionality while working directly on database objects – you might want to check it out…
I’ve seen it, and I like it. But it’s a little overkill for just managing scripts 🙂
Cool feature. But you need need version control to use it. Does / do you anticipate SQL Developer supporting Team Foundation Version Control or Visual Source Safe?
The Files panel works with or w/o Source Control. And SQL Developer will track local changes to your file, within limits (see the preferences.)
I don’t see the MSFT based VCS systems being supported in the near future. Most shoppes are moving towards free and/or open source systems. Of course if you’re a MSFT shoppe, then your needs are drastically different. It’s just that we have way more of the former than the latter when it comes to users.
I am still wondering how I missed this scripts managing feature in sql developer. This is a very good artcile. Now I know how to manage my scripts. Thanks for this.