Book Image

Oracle SQL Developer 2.1

By : Susan Harper
Book Image

Oracle SQL Developer 2.1

By: Susan Harper

Overview of this book

As technology rapidly evolves, many developers are looking for valuable tools to assist them with their daily tasks. When dealing with databases, a clean, easy-to-navigate interface for working and browsing is essential. Oracle SQL Developer is a graphical user interface that makes life much easier by allowing you to browse database objects, run SQL statements and scripts, and create, edit, and debug PL/SQL statements in the most efficient way. It enhances productivity and simplifies your database development tasks. Although the SQL Developer journey looks simple and easy, there are many areas that can go undiscovered, leaving you just scratching the surface. It's easy to get started and master this powerful tool with this book to hand. It will provide you with in-depth details about all aspects of using SQL Developer to assist you in your day-to-day database tasks and activities. You will learn to utilize SQL Developer's extensible environment to support your ongoing needs This book offers detailed instructions for installing, configuring, and effectively using Oracle SQL Developer. You will learn how to utilize every feature of this development tool and make the most out of it. While none of the tasks are complex, the book progresses from the easy, most commonly used features, such as browsing objects and writing queries in the SQL Worksheet, to the more involved and possibly less frequently used features, such as Tuning and Testing SQL and PL/SQL, and adding User Extensions, and finally to those features used by a smaller more targeted audience, such as Migrations, Oracle APEX, and the Data Modeler. Throughout the book there are tips and suggestions gathered as a result of working with the current SQL Developer user base. This book will also show you how to assess the health of your database with built-in as well as customized reports. By the end of the book you will be confident in making the best use of SQL Developer, and be able to set up and maintain a productive environment for quick and easy database development.
Table of Contents (19 chapters)
Oracle SQL Developer 2.1
Credits
About the Author
Acknowledgement
About the Reviewers
Preface
12
Working with Application Express

Preparing your environment


Preparing your environment depends on a few factors, including the platform you are working on and whether you have an early edition of SQL Developer previously installed. First, you need to locate the software, download, and install it.

Finding and downloading the software

SQL Developer is available through a variety of sources as both a standalone download and as part of the Oracle Database and Oracle JDeveloper installations.

SQL Developer is a free product, and you can download it from the Oracle Technology Network, http://www.oracle.com/technology/products/database/sql_developer. Use this link to reach the download for the latest standalone production release. It also includes details of the release and is regularly updated with news of preview releases and new articles. While SQL Developer is free to download and use, you are required to read and agree to the license before you can proceed with the download. The product also falls under Oracle Support contracts, if you have a Support contract for the database, which means that you can log Oracle Support tickets.

Downloading and installing the Java Development Kit

SQL Developer requires the Java SE Development Kit (JDK); this includes the Java Runtime Environment (JRE) and other tools, which are used by SQL Developer utilities such as the PL/SL Debugger.

For Microsoft Windows, you can download and install SQL Developer with the JDK already installed. This means you'll download and unzip the product and will be ready to start, as there are no extra steps required. For the other operating systems, you'll need to download the JDK and direct SQL Developer to the path yourself. Indeed, as many other products require a JDK to be installed, you may already have one on your system. In this case, just direct the product to use an existing JDK installation. For Microsoft Windows, ensure you download SQL Developer without the JDK to make use of an existing JDK installation.

The SQL Developer download site offers a selection of download choices:

  • Microsoft Windows (with or without the JDK)

  • Linux (without the JDK)

  • Mac OS X (without the JDK)

In each case, make your selection and download the required file.

The download sites for the JDK are as follows:

Note

SQL Developer is shipped with the minimum JDK required. You can download and use the latest updates to the JDK. You should be aware that some updates to the JDK are not supported. This detail is posted on the SQL Developer Downloads page for each release. Starting from SQL Developer 2.1, JDK 1.6 is the minimum JDK supported.

Once you have installed the JDK, you can start SQL Developer.

Installing and starting SQL Developer

SQL Developer does not use an installer. All you need to do is unzip the given file into an empty folder, locate, and run the executable.

Note

Do not unzip SQL Developer into an $Oracle_Home folder or an existing SQL Developer install.

Unzipping the file creates an sqldeveloper folder, which includes a selection of sub-folders and files, including the sqldeveloper.exe executable.

If your download does not include the JDK, then you'll be prompted for the full path of the java.exe. Browse to the location of the file and select it. The path should include the full path and executable (for example, C:\Program Files\Java\jdk1.6.0_13\bin\java.exe):

Working with different platforms

Whether you are accessing SQL Developer as part of the Oracle Database 11g installation or as a stand-alone install, there is a selection of executables available to you. These are either platform specific or provide additional detail while running the product.

Microsoft Windows

The first executable you'll find is in the root folder \sqldeveloper. This is the executable more generally used. If you navigate down to \sqldeveloper\bin, there are two additional executables, sqldeveloper.exe and sqldeveloperW.exe. The latter is the same as the executable in the root folder. Use either of these for running SQL Developer.

The additional executable is often used for debugging purposes. Use \sqldeveloper\bin\sqldeveloper.exe to invoke SQL Developer and a separate console window which displays additional Java messages. You can use these messages when encountering errors in the product and if you want to log an issue with Oracle Support.

Note

Oracle SQL Developer

Three steps to getting started on Microsoft Windows:

Download: Download the full file, with JDK, from the Oracle Technology Network web site.

Unzip: Unzip the file to an empty directory.

Double-click: Double-click on the \sqldeveloper\ sqldeveloper.exe file.

Alternative platforms

Microsoft Windows is the predominant platform used by SQL Developer users. There is a steadily growing audience for Linux and Max OS X. As neither of these platform downloads include the JDK, you need to first access, download, and install the JDK. On starting either Linux or the Mac OS, you'll be prompted for the full path of the JDK as described.

Mac OS X

Download the file specific to Mac OS X and double-click to unzip the file. This creates an icon for SQL Developer on your desktop. Double-click to run the application.

Linux

Use the Linux rpm command to install SQL Developer. For example, your command might look like this:

rpm -Uhv sqldeveloper-1.5.54.40-1.noarch.rpm

In the same way that unzip creates an sqldeveloper folder, with sub-folders and files, the rpm command creates an sqldeveloper folder, complete with files and sub-folders. Switch to this new folder and run the sqldeveloper.sh executable.

Migrating settings from a previous release

On the initial startup of any release of SQL Developer, you may be asked one or two questions. The first is the location of the Java executable of the JDK as discussed. If you have installed the full release with the JDK, this question is skipped. The second question is if you want to migrate any preferences from a previous release. Regardless of whether this is the first SQL Developer install on the machine or not, the first time you invoke SQL Developer, you are offered the choice of migrating your settings. You can migrate settings of any release from SQL Developer 1.5 and above. By default, the utility looks for the latest previous installation of the software.

If you want to migrate from a different installation, select the Show All Installations button (seen above). This displays a list of all SQL Developer installations that have the system folder in the Documents and Settings system folder (for example, C:\Documents and Settings\<your_user>\Application Data\SQL Developer\system1.5.1.54.40) and includes releases from SQL Developer 1.5 and above. For releases prior to SQL Developer 1.5, the system folder was created within the SQL Developer install (for example, D:\SQLDeveloper\Builds\1.2.1\1.2.1.3213\sqldeveloper\sqldeveloper\system).

Maintaining your environment

Once you have SQL Developer installed, it is helpful to know about the environmental settings and some of the files that are created when you start the product. Knowing about the version you have installed is important if only to be able to identify this when asking questions on the forum, or when contacting Oracle Support.

Verifying the current release

To verify the SQL Developer release you have, select the Help | About menu once you start SQL Developer or JDeveloper. In the dialog invoked, select the Extensions tab and find the Oracle SQL Developer extension, as shown in the next screenshot. This will match the build number on the download site if you have the latest release. The screenshot shows a number of the extensions that make up SQL Developer. If your dialog does not show the Version or Status columns, you can select the column headers to resize the visible columns and bring the others into focus.

Using Check for Updates

SQL Developer offers a built-in patching and extensions utility, known as Check for Updates. Check for Updates is used to release:

  • SQL Developer extensions

  • General Oracle extensions

  • Minor patches

  • Third-party tools required by SQL Developer, such as the non-Oracle database drivers

  • Third-party extensions

You can control whether Check for Updates warns you about new updates using the Tools | Preferences menu. Select Extensions and then select Automatically Check for Updates. For SQL Developer extensions, if you already have SQL Developer installed and you're not secured by a firewall, you'll be alerted about new updates. You need not use the utility to get the updates, but you'll be aware of the latest release from the alert. For all other extensions, you need to start Check for Updates to see what's available. To do this, select Help | Check for Updates. In either situation, just follow the dialog to find the updates you require.

You can initially elect to see just the third-party updates, or all updates available, by selecting all options, as shown in the following screenshot:

The database drivers for some of the non-Oracle databases are located in Third Party SQL Developer Extensions. The Third Party update center also includes a selection of customer developed SQL Developer extensions. The customer extensions are developed, supported, and updated by the customer involved, and are not tested, certified, or supported by Oracle.

As with all software downloads from the Internet, you are required to read and accept the license agreements. The Check for Updates utility directs you to the appropriate licenses, before downloading the software. If the updates are from Oracle, you will need to provide your Oracle Technology Network sign-on details.

Check for Updates is only used to apply patches to your install. Starting with SQL Developer 1.5.1, the team released patches which are applied to upgrade the product in place. These patches fixed one or two bugs and did not constitute a new download, or even a full install. For all other releases, you need to do a full install as described earlier.

Managing the system folder and other files

SQL Developer maintains a series of files as you work with the product. These files are created and stored in the \Documents and Settings\<your_user>\Application Data\SQL Developer folder. On Linux, these files are all stored in a folder ~/.sqldeveloper/.

Deleting this folder is equivalent to returning a SQL Developer installation to its factory settings. The files at this highest level are:

  • CodeTemplate.xml created as you add your own user defined code templates

  • UserReports.xml created as you add your own user defined reports

  • SqlHistory.xml created as you execute SQL and PL/SQL commands in the SQL Worksheet

  • UserSnippets.xml created as you add your own snippets

These files are used by each of the SQL Developer installations you have. For example, you may elect to have the latest installation in addition to a number of earlier releases. Having several different releases of SQL Developer on one machine is acceptable, as the installations have no impact on each other, except that they do share these files.

Once you have started SQL Developer, a folder with sub-folders and files is created in the \Documents and Settings\<your_user>\Application Data\SQL Developer folder. The top-level folder is labeled systemx.x.x.x.x (for example system1.5.0.54.40). The systemx.x.x.x.x folder contains all of the other preferences and the settings that pertain to the specific release in use. In this case, deleting the system folder is almost equivalent to resetting SQL Developer to its factory settings, except that any user defined reports, SQL history, and code templates are not lost.

Sharing preferences

Preferences are set for your local environment and are therefore not shared globally between teams. However, you can export the SQL Formatter preferences set. This allows you to share the settings between team members and ensure that you all code to the same settings. To export your SQL Formatter settings, select Tools | Preferences and expand the Database node in the tree. Select SQL Formatter, you can now export or import previous saved settings.

Alternative installations of SQL Developer

We have been discussing the installation and management of the independent release of SQL Developer available on the Oracle Technology Network. SQL Developer is also available as part of the Oracle Database and Oracle JDeveloper installations.

Oracle JDeveloper

Most of SQL Developer is integrated into Oracle JDeveloper, which means you need to install JDeveloper to access and use the SQL Developer components. Having SQL Developer as part of JDeveloper means that, if you are building Java applications and working with the Fusion Middleware platform, you can access and work with the Oracle Database without an additional install of SQL Developer. JDeveloper does not consume all of the extensions for SQL Developer (for example, extensions like Migrations and Versioning are not included).

Note

Oracle JDeveloper 11g includes SQL Developer 1.5.6.

Oracle Database 11g

SQL Developer is also shipped with the Oracle Database. Initially, Oracle Database 11g Release 1. SQL Developer is installed by default when you install the database. Once the installation is complete, locate the sqldeveloper directory (for example, \product\11.1.0\db_1\sqldeveloper\sqldeveloper.exe) to start SQL Developer.

Be aware that Oracle database releases are less frequent than those of SQL Developer, which, by its nature and size, allows for more frequent updates. This means the version of SQL Developer shipped with the database may not be the most current release. Oracle Database 11g Release 2 is shipped with SQL Developer 1.5.5. All examples in this text are using SQL Developer 2.1. You may also update your database version less frequently than a client tool.

To upgrade the SQL Developer installation in Oracle Database 11g Release 1, you should do a full new install. As with other installs, create a new folder and unzip the latest download.

Note

Oracle Database 11g Release 1 ships with SQL Developer 1.1.3

Oracle Database 11g Release 2 ships with SQL Developer 1.5.5

Troubleshooting

It seems ominous to provide a section on troubleshooting at the start of a book! If you accept that software can get in a tangle sometimes, either if you use the product as it's not designed, or perhaps include extensions that you'd prefer not to have and the product is no longer behaving as expected, then a few hints on how to escape that tangle can be useful.

Removing extensions

If you have created your own extensions, or have downloaded and installed other extensions that you no longer require, then invoke the preferences, using the menu Tools | Preferences and select Extensions from the tree. Here you see that SQL Developer includes a number of default extensions, such as the Oracle TimesTen extension. In addition, any extension that you have included is listed here. You can deselect extensions here and the product will no longer access them. This does not delete the files installed for the extension. You will need to manually delete any files downloaded for that to happen. However, it does mean that you can restart the product and see if the extension is the root of the problem.

Resetting shortcut keys

Some users find that their keyboard shortcuts no longer work as expected. In this circumstance, you can select the menu Tools | Preferences, and then select Shortcut Keys from the tree. Click on the More Actions drop-down list and select Load Keyboard Scheme…, as shown in the following screenshot. Select Default from the dialog to reset the keyboard accelerators to the shipped settings. This also replaces any settings you have added.

Note

In releases prior to SQL Developer 2.1, the Shortcut Keys are called Accelerators. In these releases, to reset the keys, select Load Preset.

Reset the environment, do not reinstall the product

When things go wrong, users sometimes resort to deleting and reinstalling a product. This may even require downloading the files again. This is time consuming, and in the case of SQL Developer, not necessary. Assuming you have not edited any of the .jar files (it's been known to happen and not legally permitted), you can reset the product to the shipped factory settings by deleting the system folder. Before you delete the system folder, export your connections and shut down SQL Developer.

Note

Export Connections: To export your connections, select Connections, right-click and select Export Connections. Save the file to a new location.

When troubleshooting, deleting the system folder is useful. However, by deleting this folder you are also deleting all of the changes made to the preferences, your connections, and any layout changes you have made. Therefore, it is recommended that you delete the folder as a last resort, and not as a standard approach to troubleshooting.

Note

Reset to factory settings

For Microsoft Windows, delete the \Documents and Settings\<your_user>\Application Data\SQL Developer folder to reset SQL Developer to the shipped factory settings.

For Linux, remove the ~.sqldeveloper folder and on the Mac, remove the ~/Library/Application Support/SQL Developer folder.

In addition to deleting all of the preferences set and connections created, this action also deletes user-defined reports, your SQL history, and any code templates and snippets you have created. In general, delete the lower level system folder for a less drastic reset.