You are on page 1of 54

Working with the Oracle SQL Developer 3.

0 DBA Navigator
Purpose
This tutorial shows you how to manage your database objects in Oracle SQL Developer 3.0.

Time to Complete
Approximately 30 minutes.

Overview
Oracle SQL Developer is a free graphical tool that enhances productivity and simplifies database development tasks. Using SQL Developer, users can browse database objects, run SQL statements, edit and debug PL/SQL statements and run reports, whether provided or created. Default connectivity to the database is through the JDBC Thin driver, so no Oracle Home is required. To install SQL Developer, simply unzip the downloaded file. SQL Developer users can connect to any supported Oracle Database. Oracle SQL Developer 3.0 introduces a DBA Navigator and provides support for DBMS Scheduling, to name only two of many features in the latest release; other features include a new Query Builder, SQL Tuning Advisor, and Explain Plan Diff utility. For a complete list of new features, click here. This tutorial focuses on the DBA Navigator.

Prerequisites
Before starting this tutorial, you should: 1 . Install Oracle SQL Developer 3.0 from OTN. Follow the release notes here. 2 . Install Oracle Database 11g with sample schema. 3 . Unlock the HR user. Login to SQL Developer as the SYS user and execute the following command:
alter user hr identified by hr account unlock;

Creating a Database Connection

The first step to managing database objects using Oracle SQL Developer 3.0 is to create a database connection. To create a connection, perform the following steps: 1 . If you installed the SQL Developer icon on your desktop, click the icon to start your SQL Developer session. If you do not have the icon located on your desktop, find the executable file (either named "sqldeveloper.exe" on Windows or "sqldeveloper.sh" on Linux), and run it.

2 . Your Oracle SQL Developer application starts.

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

4 . The New / Select Database Connection dialog window opens. Enter the connection details as

follows and click Test. Connection Name: System Username: system Password: <your_system_password> Hostname: <your_machine> SID: <your_SID>

5 . If the status is success, click Save to save the connection, and then click Connect.

6 . The connection is saved and you see the connection in the Connections list.

Accessing the DBA Navigator


SQL Developer enables users with Database Administrator (DBA) privileges to view and edit certain information relevant to DBAs and, in some cases to perform certain DBA operations. In order to perform DBA operations, you must use the DBA Navigator, which is similar to the Connections Navigator. If the DBA Navigator is not visible, perform the following steps to open and add a connection in the DBA Navigator. 1 . Select View > DBA.

2 . A DBA Navigator opens. Click

in the DBA window to create the System connection.

3 . You should add only those connections for which the associated database user has DBA

privileges. You can use the System connection because it has the DBA privileges. Select System for your Connection and click OK.

4 . Expand the System connection in the DBA Navigator.

Viewing Database Feature Usage


Oracle SQL Developer makes it very easy to view database usage statistics and to manage database objects. In this topic, you view the number of detected database usages for certain database features. You generate reports on the detected usages. Perform the following steps to view detected database usages: 1 . Expand the Database Configuration node and select View Database Feature Usage from the sub-menu.

2 . A window opens on the right where you can view the name of the database feature and the number of detected usages. Use the scroll bar to scroll through the list. Note that the column on the right identifies the detected usages per database feature.

3 . You can save this information to a report. For example, you might want to create a report that identifies features where the usage is greater than zero. To generate the report, right-click and select Save Grid as Report.

4 . Enter the following details: Name: detected_usage greater than 0 Description: Report on detected usage features that are greater then 0. Tooltip: Detected usage is greater than 0 Set the Style to Table.

5 . To view all the features whose detected usage is more than 0, include and u1.detected_usages>0 within the where clause for the subquery.

6 . To view the report in the descending order of detected usage add sub1 order by 2 desc at the end and then click Apply. (Note that "sub1" is an alias to the inner/sub query. "order by 2 desc" identifies that you want to order by the second column listed in the SELECT clause for the main/outer query).

7 . To view the report that you just saved, select View > Reports.

8 . Expand User Defined Reports and select the report detected_usage greater than 0.

9 . Select the Connection as System and click OK.

10 . The report displays the database features whose detected usage is greater than 0 in descending order.

Editing Database Initialization Parameters


Managing an Oracle instance includes configuring parameters that affect the basic operation of the Oracle instance. These parameters are called initialization parameters. Database administrators can use initialization parameters to:

optimize performance by adjusting memory structures set database-wide defaults set database limits

With SQL Developer 3.0, you can view initialization parameters, examine their values and adjust some of the parameter values. 1 . To view the initialization parameter values, click Initialization Parameters in the DBA navigator window.

The list of the initialization parameters and their values appear on the right.

2 . The initialization parameters are listed alphabetically by default. You can scroll through the list to see the parameter name, value, and data type, as well as whether it is modified, dynamic or classified as Basic. Note: Not all of the initialization parameters are editable through SQL Developer. Change the open_cursors parameter limit. The open_cursors parameter specifies the maximum number of open cursors a session can have at once. You can use this parameter to prevent a

session from opening an excessive number of cursors. It is important to set the value of open_cursors high enough to prevent your application from running out of open cursors. The number will vary from one application to another. Scroll through the Parameter list and find the open_cursors parameter.

3 . Double click the Value field. An edit box appears.

4 . Enter the value 250. Click OK.

5 . Note that the value of the open_cursors parameter is now set to 250.

Setting Audit Privileges


In SQL Developer 3.0, the security settings have been enhanced to provide greater control to different users. Using the Security node within the DBA Navigator, there are several options related to database security management. For example, you can change the audit settings and enable auditing. When you enable auditing, an audit trail is recorded. You have some options on whether you want to include SYS user actions and the location for the audit file. In this topic, you learn to turn on the audit for privileges and for objects. 1 . You might want to track every time a privilege is granted. For example, you may want to track when the ALTER TABLESPACE or the CREATE DIRECTORY privilege is given out. For auditing a privilege, in the DBA Navigator, expand the Security node, right-click Audit Settings and select Edit Audited Privileges.

The Edit Audited Privileges dialog opens.

2 . To audit SYSTEM's usage of the GRANT statement, select User for the User or Proxy field. Select SYSTEM for the User or Proxy Name. Leave the Statement Execution Condition to the default of Success or Failure. This tracks whether a GRANT or REVOKE statement executed by SYSTEM is successful or not. Change the DML Audit Granularity field to Access.

3 . Select the privilege that you want to track for the SYSTEM user. For this example, choose the ALTER TABLESPACE and the CREATE DIRECTORY privilege from the Available column and then click to move it to the Selected column.

4 . Click the SQL tab to view the SQL statement that is generated based on your selections.

5 . Click Apply.

6 . Click OK.

7 . To view the changes you made, right-click Audit Settings and select Open.

8 . In the Configuration tab, note that the Audit File Directory is automatically filled in.

9 . Click the Audited Privileges tab.

Scroll to the bottom of the window to view the audit settings that you have added.

10 For auditing an object, in the DBA Navigator, expand the Security node, right-click Audit . Settings and select Edit Audited Objects .

11 To audit changes to the HR EMPLOYEES table, select TABLE for the Object Type field. . Select HR for the Schema field. Select EMPLOYEES for the Object Name field. Leave the Statement Execution Condition to the default of Success or Failure. Change the DML Audit Granularity field to Session.

12 In the Available column, select DELETE, INSERT, and UPDATE. .

Click

to move your choices to the Selected column.

13 Click the SQL tab to view the SQL statement that is generated based on your selections. .

Then click Apply.

14 Click OK. .

15 To view the changes you made, right-click Audit Settings and select Open. .

16 Click the Audited Objects tab. .

17 The Audit Settings on the HR EMPLOYEES table are displayed. .

Creating Roles and Granting Privileges to Users


Using Oracle SQL Developer, you can manage privileges. Privileges enable users to have access to the database and the database objects. In Oracle SQL Developer, you can:

Create users Grant and revoke system privileges to users and roles Create roles Grant roles

In this topic, you create a user, then grant the user privileges. You create a role and grant the role to users. 1 . To create a user, right-click Users and select Create New.

2 . In the Create User window, enter HRAdmin for the User Name field and <apassword> for the New Password and Confirm Password fields. Set the Default Tablespace to USERS and the Temporary Tablespace to TEMP.

3 . Click the System Privileges tab.

4 . Select these system privileges: CHANGE NOTIFICATION, CREATE SEQUENCE, CREATE SESSION, CREATE SYNONYM, CREATE VIEW, UNLIMITED TABLESPACE.

5 . Click the SQL tab to view the SQL statement generated by your choices.

Click Apply.

6 . Click OK.

7 . View the HRAMIN user in the DBA Navigator. Expand System > Security > Users > HRADMIN > Granted System Privileges.

8 . Now you will create a role. In the DBA Navigator, expand System > Security. Right-click Roles and select Create New.

9 . Select the Role Name as DEV_ROLE. Provide <apassword> and confirm the password.

10 Click the System Privileges tab. .

11 Select these system privileges for the role: CREATE TABLE, CREATE TRIGGER, CREATE . TYPE, DEBUG ANY PROCEDURE, SELECT ANY DICTIONARY.

12 Click the SQL tab to view the SQL statement generated by your choices. .

Then click Apply.

13 Click OK. .

14 View and verify the DEV_ROLE in the DBA Navigator. . Expand System > Security > Roles > DEV_ROLE > Granted System Privileges.

15 Next, you grant the DEV_ROLE role to the HR and HRADMIN Users. . In the DBA Navigator, Expand System > Security > Users. Right-click HR and select Grant Role.

Click Apply.

16 Click OK. .

Follow the same steps to grant the DEV_ROLE to the HRADMIN user.

Viewing and Modifying Storage Information


With Oracle SQL Developer 3.0 you can examine, monitor and maintain the database storage files. The files fall into the categories of archive logs, control files, data files, redo log groups, rollback segments, tablespaces, and temporary tablespace groups. In this topic, you learn to view and edit the properties of the data file.

1 . To view the data files, expand Storage and select Datafiles.

2 . In the window to the right of the DBA Navigator, you can view the details of each data file. This includes the operating system file name, the tablespace the file is associated with, the status, the size, how much is used, the used percentage and used proportion, and whether auto extend is turned on.

3 . You can turn the Autoextend properly on and off for a data file. To modify the properties of a data file, right-click the data file you want to edit and select Edit. For example right-click C:\APP\PVTRIVED\ORADATA\ORCL\SYSTEM01.DBF and select Edit. Note: The path to the file will be different on your system.

4 . Deselect Automatically Extend When Full. By doing this, you are limiting the file size to 706568 KB.

5 . Click Apply.

6 . Click OK.

7 . Expand C:\APP\PVTRIVED\ORADATA\ORCL\SYSTEM01.DBF.

8 . Observe that the status of Auto Extend is updated to NO.

Creating a Tablespace
A tablespace is a database storage unit that groups related logical structures together. The database data files are stored in tablespaces. In this topic, you learn to create a tablespace and add a data file in it. 1 . Right-click Tablespaces and select Create New.

2 . To add a data file, click File Specifications.

3 . Click

to add the file name.

4 . Enter File Name as TEMP01 and click OK. Note: Choose an existing data file.

5 . To view the details of the tablespace you created, select TABLESPACE1and click the tabs above to view each attribute details.

Summary
In this tutorial, you have learned how to:

Create a database connection. Access the DBA Navigator. View and edit database features. Set audit privileges. Create roles and grant roles to users. Create users. View and edit the properties of a data file. Create a tablespace.

You might also like