Using Source Code Control in Oracle SQL Developer

<Do not delete this text because it is a placeholder for the generated list of "main" topics when run in a browser>

Purpose

This tutorial shows how to use the source code control feature in Oracle SQL Developer.

Time to Complete

Approximately 15 mins

Overview

Oracle SQL Developer is a free graphical tool that enhances productivity and simplifies database development tasks. Using Oracle SQL Developer, you can browse database objects, run SQL statements, edit and debug PL/SQL statements and run reports, whether provided or created.

Developed in Java, Oracle SQL Developer runs on Windows, Linux and the Mac OS X. This is a great advantage to the increasing number of developers using alternative platforms. Oracle SQL Developer is built on an extensible framework and, as such, is extensible itself. You can create basic XML extensions or more involved Java extensions to add utilities or other functionality to the product.

You can use the version control feature of SQL Developer to import files into your source control system, check them out, modify and commit the changes back.

Prerequisites

Before starting this tutorial, you should:

Creating a Database Connection

Note: If you already have a database connection, you do not need to perform the following steps, instead, you can move to the Viewing the Files to be Versioned section.

.

If you installed the SQL Developer icon on your desktop, click the icon to start your SQL Developer and move to Step 3. If you do not have the icon located on your desktop, perform the following steps to create a shortcut to launch SQL Developer 3.0 directly from your desktop.

Open the directory where SQL Developer 3.0 is located, right-click sqldeveloper.exe (on Windows) or sqldeveloper.sh (on Linux) and select Send to > Desktop (create shortcut).

 

.

On the desktop, you will find an icon named Shortcut to sqldeveloper.exe. Double-click the icon to open SQL Developer 3.0.

Note: To rename it, select the icon and then press F2 and enter a new name.

 

.

In the Connections tab, right-click Connections and select New Connection.

Note: If this tab is not visible, select View > Connections.

 

.

Enter the following and click Test:

Connection Name: HR_ORCL
Username: hr
Password: <your_password>
Select Save Password checkbox
Hostname: localhost
Port: 1521
SID: <your_SID>

 

.

Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. Click Save. Then click Connect.

 

.

When a connection is created, a SQL Worksheet is opened automatically. The SQL Worksheet allows you to execute SQL statements against the connection you just created.

 

Viewing the Files to be Versioned

You can view the files stored in your local file system by using the Files navigator. To view the files to be versioned, perform the following steps:

.

Click View > Files.

 

.

The Files navigator appears.

 

.

In the Files navigator, navigate to the directory where you unzipped the files from the Prerequisites section and open the file PROC_EMP_CURSOR.sql.

 

Creating a Repository

To create a Subversion repository, perform the following steps:

Note: If you already have a Subversion repository, you can skip this step.

.

Click Versioning > Create Local Repository....

 

.

Provide C:\repos as the Repository Path and HR_ORCL as the Connection Name. Then click OK.

 

.

Expand the Subversion node in the Versioning Navigator. The repository for the HR_ORCL connection is created.

 

.

Right-click HR_ORCL connection and select New Remote Directory... .

 

.

Enter the name SQLFiles and click OK.

 

Importing the Files to be Versioned

To import the files to be versioned into the Subversion repository, perform the following steps:

.

In the Files navigator, select the directory where you unzipped the files from the Prerequisites section under the Files tab.

 

.

Click Versioning > Import Files....

 

.

In the Welcome page of the Import to Subversion wizard, click Next.

 

.

Ensure that HR_ORCL[file:///C:/repos] is the destination repository connection. Select the node SQLFiles and click Next.

 

.

Click Browse and select the directory where you unzipped the files from the Prerequisites section as the source directory. Click Next.

 

.

In the Filters page, click Next.

 

.

In the Options page, select Perform Checkout check box and click Next.

 

.

Review the options for the Import operation and click Finish.

 

.

In the Versioning Navigator, expand HR_ORCL > SQLFiles.

 

.

You can now see the files in your Subversion Repository.

 

Working with the Files under Version Control

To work on the files that are placed under version control, perform the following steps:

.

In the Files Navigator, expand the directory where you unzipped the files from the Prerequisites section. Notice the check out icon indicating that the files in this directory have been checked out.

 

.

Double-click PROC_EMP_CURSOR.sql file.

 

.

Delete the EXCEPTION block.

 

.

Add the following comment and click the Save icon.

--To add an exception block type excep and the press Ctrl+Shift+t.

 

.

Click History.

 

.

The History tab displays the changes you have done to PROC_EMP_CURSOR.sql. You can right-click on a version and move between the various changes.

 

.

To check-in the file, in the File Navigator, right-click the file PROC_EMP_CURSOR.sql and select Versioning > Commit.

 

.

Click OK in the Commit Resources window.

 

.

Your file was imported successfully. Notice that the version number has increased by 1.

 

Summary

In this tutorial, you have learned how to:

Hardware and Software Engineered to Work Together About Oracle |Oracle and Sun | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Your Privacy Rights