Professional Documents
Culture Documents
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;
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.
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.
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.
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.
10 . The report displays the database features whose detected usage is greater than 0 in descending order.
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.
5 . Note that the value of the open_cursors parameter is now set to 250.
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.
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.
Click
13 Click the SQL tab to view the SQL statement that is generated based on your selections. .
14 Click OK. .
15 To view the changes you made, right-click Audit Settings and select Open. .
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.
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.
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. .
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.
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.
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.
3 . Click
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.