Getting Started with SQL Developer: Part 2

Exclusive offer: get 50% off this eBook here
Oracle SQL Developer 2.1

Oracle SQL Developer 2.1 — Save 50%

Design and Develop Databases using Oracle SQL Developer and its feature-rich, powerful user-extensible interface with this book and eBook

£20.99    £10.50
by Sue Harper | December 2009 | MySQL Oracle PHP

Read Part One of Getting Started with SQL Developer here.

A quick overview

Let's start with a run-through of the product. By spending a little time dipping into a number of areas of the product, you can start laying down a map of how the pieces connect and provide a base that you can drill down into later.

Sample schemas

To follow the examples in the article, you need access to SYSTEM and the shipped sample schemas, HR, OE, SH, PM, and IX available in Oracle Database 9i, 10g, or 11g. Specifcally, this article uses the sample schemas shipped with Oracle Database 11g.

There are two ways to install the sample schema. The first way is when you install the database. You can elect to have the sample schema installed at that point.

Second, if you have not installed these, then you can locate the sample schema in the $ORACLE_HOME/demo/schema folder and follow the instructions on installing them using the Oracle online documentation. Not all of these schemas are available for Oracle Express Edition. In this article, we use SYSTEM to verify the HR schema is unlocked, and then we use the HR sample schema, which is available in Oracle Express Edition.

Creating your first connection

To complete this quick walk through, you need to know the username and password of the SYSTEM user. You also need to know the location of the database, whether this is the machine name or the IP address, and the database SID.

To begin, start SQL Developer. The very first time you start SQL Developer, you'll be asked if you want to migrate from a previous version. Select No and allow the tool to start up.

The first thing you need to do after you have started SQL Developer for the first time is to create your initial connections.

Create a connection for SYSTEM:

  1. Select Connections, right-click and select New Connection. This invokes the New Database Connection dialog. You can edit and control all of the connection details using this dialog.
  2. Complete the details, as seen in the following screenshot, relevant to your environment.
  3. Click on Test to ensure you have the connection details correct and click on Connect.

You are now connected as SYSTEM. Use this connection to verify your other users, by continuing as follows:

  1. Select the new connection you have created, expand the node, and scroll down to Other Users.
  2. Expand Other Users and find the user HR. Right-click and select Edit User. Verify that the account for HR is unlocked and the Password has not expired, that is, the properties Account is Locked and Password Expired are deselected. If either of these is selected, deselect them. You can change the password for HR at this point too. It's good practice to modify the passwords of the shipped sample schemas once you have unlocked them.

Now you are really ready to begin!

  1. Once again, select Connections, right-click and select New Connection.
  2. Give the connection a name (for example, HR_11g.
  3. Provide the Username (HR) and a Password. If you are working on Oracle Database 11g, be aware that passwords are now case sensitive.
  4. Select the Save Password checkbox. This makes life easy while you are working with SQL Developer. Passwords are stored in an encrypted file. However, you should always be aware of saving passwords and possible security implications this may have.
  5. Use the Basic connection. This requires no more detail than the location of the database and the SID, details you have.
  6. Click on Test to test the connection.
  7. Click on Connect.

Using basic commands in the SQL Worksheet

As soon as you connect to a user, SQL Developer opens an SQL Worksheet. You may  have started working with Oracle using the SQL*Plus command line, or even the GUI window. Either way, you'd start with a selection of SQL*Plus and SQL commands.

Enter the following into the SQL Worksheet:

DESC DEPARTMENTS
SELECT * FROM DEPARTMENTS;

Press the F5 key (or use the Run Script button).

Oracle SQL Developer 2.1

The output of both commands appears in the Script Output tab, which appears below the SQL Worksheet (as seen in the previous screenshot). Both commands are handled by a few simple clicks of the mouse in SQL Developer.

Select and expand the HR_11g connection in the Connections navigator. Expand the Tables node and select DEPARTMENTS.

The DEPARTMENTS tab now opens, displaying a list of the column names and details. These are the same details as given by the DESC (describe) SQL*Plus command that you entered in the SQL Worksheet. It also provides additional detail, such as the Primary Key and column comments.

Select the Data tab and notice that you now see the output from your second command. These two tabs are included with a number of other tabs, each with additional details about the DEPARTMENTS table. You would need to write a number of SQL queries in order to get the additional detail from the data dictionary if you were working in SQL*Plus.

Select the EMPLOYEES table. Notice that the new table, EMPLOYEES, immediately replaces the previous DEPARTMENTS table with its details. Select the Triggers tab, and select one of the triggers. The trigger and related trigger detail is displayed in a master-detail window:

Oracle SQL Developer 2.1

Browsing and updating data

Return to the EMPLOYEES data by again selecting the Data tab. The data grid that is displayed provides a variety of options. To get started with the data grid, double-click on an item or field, such as the name of one of the employees, and change it. Tab out of the field and notice that the change is applied to the data grid and an asterisk (*) flags the record. Commit and Rollback buttons are available to send the change to the database, or to undo your action. Roll back the changes.

Once again you get feedback, this time in the Data Editor log, as shown in the following screenshot:

Oracle SQL Developer 2.1

Running reports

Select the Reports navigator and expand the Data Dictionary Reports node. Expand the Table node and review the available reports. Expand Constraints and select the Unique Constraints report. As you select the report, a dialog displays requesting the Connection name. Select the connection you created, HR_11g, and click on OK. An Enter Bind Values dialog now appears, requesting the table name as an input parameter. Click on Apply to accept the default, which in this case, means all tables:

Oracle SQL Developer 2.1

Run the same report for any user by selecting the Connections drop-down list on the right-hand side.

Navigating around SQL Developer

SQL Developer has a selection of windows, navigators, and tabs. On start-up, you are presented with the main navigator toolbars and menus:

Oracle SQL Developer 2.1

The two main navigators: Connections and Reports, are presented in a tabbed window. These and other navigators, such as the Versioning Navigator, are available through the main View menu. You can also open windows such as Snippets, Recent Objects, and Find DB Objects using the View menu.

Any navigators that you open during a session, and that are  still open when you close the product, are automatically opened when you restart the product.

Oracle SQL Developer 2.1 Design and Develop Databases using Oracle SQL Developer and its feature-rich, powerful user-extensible interface with this book and eBook
Published: December 2009
eBook Price: £20.99
Book Price: £33.99
See more
Select your format and quantity:

Managing SQL Developer windows

With the exception of the SQL Worksheet and its associated tabs, all of the main tabbed dialogs can be minimized or maximized and accessed while docked or undocked. These menu controls are available through context menus in the tabs:

Oracle SQL Developer 2.1

You can rearrange tabbed windows by selecting and dragging the tab into place. Once any window is minimized, roll your mouse over the minimized tab to display a floating window that stays active while your mouse lies over it and rolls back into place when you move off. This is very useful when working with temporary windows like Snippets and Find DB Object. The following screenshot shows the foating window for the Snippets dialog. If you roll the mouse over the area, you can work in the window (for example, navigating about until you have located the snippet of code you are after, and then drag the code onto the worksheet). The window will minimize out of the way once you have moved off it.

You can undock the floating window, move it off to one side, and keep it undocked while you work with the SQL Worksheet. In a dual-monitor setup, you can drag the floating window onto one monitor, while working with the SQL Worksheet on the other monitor.

Oracle SQL Developer 2.1

Tiling windows

Once you start working with connections, you have more windows and tabs to deal with, especially if you have more than one connection created. Select the HR_11g connection created in the previous section, expand the connection and Tables node, and select EMPLOYEES. In the table definition window, select the pin button, as shown below, to freeze the view.

Oracle SQL Developer 2.1

Now, select the DEPARTMENTS table. A second table definition window opens to display the details from the new table. Select the DEPARTMENTS tab and drag it down to the lower portion of the screen. Notice the shape of the dragged object change as you drag it slightly to the left, to the center, and the lower portion of the window. Each of the shapes represents a different layout position. Release the mouse to secure the new position. The screenshots, which follow, display two of the available positions:

Oracle SQL Developer 2.1

Oracle SQL Developer 2.1

Splitting documents

When you tile windows, you can compare the details of two tables. However, as each table has a selection of tabs, it's useful to be able to review details in the tabs without having to switch back and forth between tabs. As is true for other layout features, you can split the document using a menu, or by drag-and-drop. Each of the object definitions tabbed displays has a drag bar on the top and bottom right that you can select and drag to split the window horizontally, or vertically:

Oracle SQL Developer 2.1

Maximizing detail

Almost all of the tabs in SQL Developer will maximize when double-clicked. There are a few that do not follow this rule, such as the tabs related to the SQL Worksheet. In general, this works for top-level tabs, which is any tab you can undock and move about, and not for secondary tabs. To maximize a tab, double-click on the tab. A second double-click will reverse the process.

Double-click on the tab to maximize a top-level tab.
Double-click again to revert to the previous layout.

Resetting the window layout

If you move your windows about a great deal, you may find that you want to get things back to the default settings.

The example in the following screenshot displays the standard docked Connections and Reports windows to the left. We have also opened the Versioning Navigator, which by default docks below the connections. We have also docked the Snippets window to the right. These windows fill the columns to the left and right, leaving a central window for the editors and log files.

Oracle SQL Developer 2.1

The layout is controlled by the window layout set in the preferences. Select Tools | Preferences, under the Environment node in the tree select Dockable Windows. The default layout, and the one that matches the example in the previous screenshot, is shown in the following screenshot:

Oracle SQL Developer 2.1

Each of the little curved arrows on the diagram is clickable, and as such controls the positioning of the windows. Clicking on the arrow extends or contracts the area taken up by the docked window.

In our example, and in the default SQL Developer environment, there is no full-docked window across the top of the screen. However, if you drag a window into the docked position below the main tool bar, it would stretch across the screen, as shown in the following screenshot:

Oracle SQL Developer 2.1

If you find your windows are in a muddle, first verify that the Dockable Windows layout is what you want, and then drag the various dockable windows back into place. Some suggestions on the SQL Developer forum are to remove the system folder (it works, but that's an extreme solution).

Finding more help

SQL Developer has a site on the Oracle Technology Network, http://www.oracle.com/technology/products/database/sql_developer/index.html. This provides links to current and past magazine articles, white papers, and team blogs. It also has links to brief product demonstrations and longer hands-on exercises.

There is an active user forum on OTN, http://forums.oracle.com/forums/forum.jspa?forumID=260, which is monitored by the development team and end users.

The SQL Developer Exchange, http://sqldeveloper.oracle.com, is a site where anyone using SQL Developer can log feature requests and vote on other requests already posted. In addition to posting feature requests, the site hosts reports and code snippets.

Summary

You've started and should now have SQL Developer installed. You should have a few connections created and an initial idea of how to navigate around the product. You are now set to learn a lot more about SQL Developer.

Oracle SQL Developer 2.1 Design and Develop Databases using Oracle SQL Developer and its feature-rich, powerful user-extensible interface with this book and eBook
Published: December 2009
eBook Price: £20.99
Book Price: £33.99
See more
Select your format and quantity:

About the Author :


Sue Harper

Sue Harper was a senior school mathematics and science teacher by profession. It was this teaching qualification that opened the door to Oracle in South Africa, where Sue started as a SQL, PL/SQL, SQL Forms, and Reports instructor in 1992. Before long she'd added Oracle Designer to her repertoire and soon left for the UK, to join the Designer curriculum development team. Sue was a course writer and then product manager for Oracle Designer for many years, traveling extensively meeting customers and training Oracle staff and instructors. Sue was later product manager for Oracle JDeveloper working with database and modeling tools in that product. Sue is currently product manager for Oracle SQL Developer, SQL Developer Data Modeler, and SQL Developer Migrations. Based at home, Sue works with her team, scattered around the world and customers, running web-based training sessions or helping with individual queries. She frequently attends conferences where she presents SQL Developer material and works with customers on their queries.

Sue lives in West London, where she enjoys walking with her camera and her dog in the extensive local parks and further afield throughout the UK.

Books From Packt

AJAX and PHP: Building Modern Web Applications 2nd Edition
AJAX and PHP: Building Modern Web Applications 2nd Edition

jQuery UI 1.7: The User Interface Library for jQuery
jQuery UI 1.7: The User Interface Library for jQuery

WordPress 2.8 Theme Design
WordPress 2.8 Theme Design

Middleware Management with Oracle Enterprise Manager Grid Control 10g R5
Middleware Management with Oracle Enterprise Manager Grid Control 10g R5

Getting Started With Oracle SOA Suite 11g R1 – A Hands-On Tutorial
Getting Started With Oracle SOA Suite 11g R1 – A Hands-On Tutorial

Oracle User Productivity Kit 3.5
Oracle User Productivity Kit 3.5

jBPM Developer Guide
jBPM Developer Guide

Oracle Coherence 3.5
Oracle Coherence 3.5

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software