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 souce code control feature in Oracle SQL Developer.

Time to Complete

Approximately 20 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 numbers 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 need not perform the following steps, you can move straight to Viewing the Files to be Versioned.

.

Open Oracle SQL Developer.

 

.

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: hr
Select Save Password checkbox
Hostname: localhost
Port: 1521
SID: orcl

 

.

Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. To save the connection, click Connect.

 

.

Once the connection is saved, you will see the database in the list. When a connection is created, a SQL Worksheet is opened automatically. The SQL Worksheet allows you to execute SQL 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 will appear.

 

.

In the Files navigator, navigate to the directory where you unzipped the files from the Prerequisites 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 Subverison 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 on the 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 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 as the source directory. Click Next.

 

.

In the Filters page, click Next.

 

.

In the Options page, deselect the 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 File Navigator, expand the directory where you unzipped the files from the Prerequisites. Notice the check out icon indicating that the files in this directory have been checked out.

 

.

Double click the 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 the History tab.

 

.

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 done.

 

.

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