[转]Advanced Oracle SQL Developer Features

时间:2022-09-08 20:23:23

本文转自:http://www.oracle.com/technetwork/cn/server-storage/linux/sqldev-adv-otn-092384.html

Advanced Oracle SQL Developer Features

< 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 demonstrates some of the more advanced features within Oracle SQL Developer.

Time to Complete

Approximately 50 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. Oracle SQL Developer also includes lesser known features, such as file based development, integrated version control, and an array of smaller features, such as code formatting and code insight, copy, export and compare. You can also browse your Oracle Application Express applications.

This tutorial takes you through a few of the more advanced features; you create a code template, use the extended search capabilities and use the schema copy features. For users working with Application Express there is a section on that too.

Developed in Java, Oracle SQL Developer runs on Windows, Linux and the Mac OS X. The default connectivity to the database is through the JDBC Thin driver so no Oracle Home is required. To install Oracle SQL Developer, simply unzip the downloaded file. With SQL Developer, users can connect to any supported Oracle Database, for all Oracle database editions including Express Edition.

Prerequisites

Before starting this tutorial, you should:

  • Install Oracle SQL Developer 2.1 early adopter from OTN here. Follow the readme instructions here.
  • Install the Oracle Database 10g and later.
  • Unlock the HR user. Login to SQL*Plus as the SYS user and execute the following command:     alter user hr identified by hr account unlock;
  • Download and unzip the sqldev_adv.zip file that contains all the files you need to perform this tutorial.

Setting up Your Environment

This tutorial requires a selection of users. To prepare the environment, you use SQL Developer to create a new user and a variety of connections. To complete the setup, you need to perform the following steps:

.

Open Oracle SQL Developer.

.

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

[转]Advanced Oracle SQL Developer Features

.

Create the system_orcl connection with the following details and click Test to verify the status.

Connection Name: system_orcl             Username: system             Password: <password> (The password is case sensitive in Oracle Database 11g.)             Hostname: localhost             Port: 1521             SID: orcl

[转]Advanced Oracle SQL Developer Features

.

The test was successful. Click Connect to connect and save the connection.

[转]Advanced Oracle SQL Developer Features

.

Expand the new system connection. Right-click Other Users and select Create User.

[转]Advanced Oracle SQL Developer Features

.

Enter the following and click the System Privileges tab.

User name: test             Password test             Default Tablespace Users             Temporary Tablespace Temp

[转]Advanced Oracle SQL Developer Features

.

Select the following privileges and click Apply.

CREATE PROCEDURE             CREATE SEQUENCE             CREATE SESSION             CREATE TABLE             CREATE TRIGGER             CREATE TYPE             CREATE VIEW             UNLIMITED TABLESPACE

[转]Advanced Oracle SQL Developer Features

[转]Advanced Oracle SQL Developer Features

.

Review the SQL that was executed. Click Close.

[转]Advanced Oracle SQL Developer Features

.

Create another connection for the test user. Right-click Connections and select New Connection.

[转]Advanced Oracle SQL Developer Features

.

Enter the following details and click Connect.

Connection Name: test_orcl             Username: test             Password: test             Check Save Password             Hostname: localhost             Port: 1521             SID: orcl

[转]Advanced Oracle SQL Developer Features

.

Create one more connection for the hr user. Right-click Connections and select New Connection.

[转]Advanced Oracle SQL Developer Features

.

Enter the following details and click Connect.

Connection Name: hr_orcl             Username: hr             Password: hr             Check Save Password             Hostname: localhost             Port: 1521             SID: orcl

Note: If you worked on another tutorial and you already have a hr_orcl connection you can skip this step.

[转]Advanced Oracle SQL Developer Features

Exporting Objects

You can use the Export Wizard to export some or all database objects of a database connection to a file. The export file will not only contain the SQL data definition language (DDL) statements to create the exported objects, but if you choose to export the data too, the export file will contain Data Manipulation Language (DML) to populate the exported objects.

.

Select Tools > Database Export

[转]Advanced Oracle SQL Developer Features

.

Enter c:\< directory where you unzipped the files from the Prerequisites>\export.sql in the File field and select the hr_orcl connection.

[转]Advanced Oracle SQL Developer Features

.

Under the DDL options the Terminator and Pretty Print DDL options are selected by default. Review the rest of the options available, leaving them unchecked. Click Next.

[转]Advanced Oracle SQL Developer Features

.

If the export file exists, you receive a prompt to confirm overwriting. Click Yes.

[转]Advanced Oracle SQL Developer Features

.

The Types to Export window includes the Object Types you want to be exported from the hr_orcl connection. By default all the object types are selected. Click Toggle All check box to deselect all the object types.

[转]Advanced Oracle SQL Developer Features

.

Select only the object type Tables and then click Next.

Note: You must select at least one object type.

[转]Advanced Oracle SQL Developer Features

.

Click Go to search all objects that meet the selection criteria you specified in the previous step.

[转]Advanced Oracle SQL Developer Features

.

All tables owned by hr are listed. Click the tables EMPLOYEES and DEPARTMENTS and then use the arrow key to move them to the list box on the right hand side of the window.

[转]Advanced Oracle SQL Developer Features

.

Click Next.

[转]Advanced Oracle SQL Developer Features

.

You can review the information that will be used to create the output file, which will contain statements to export database objects and data according to your specifications. To create the output file, click Finish.

[转]Advanced Oracle SQL Developer Features

.

The file is also displayed in a SQL Worksheet window, where you can edit it and run it as a script. Select the test_orcl connection in the drop down list.

[转]Advanced Oracle SQL Developer Features

.

Click Run Script. [转]Advanced Oracle SQL Developer Features

[转]Advanced Oracle SQL Developer Features

.

The script ran successfully. In the Connections navigator, expand the test_orcl connection.

[转]Advanced Oracle SQL Developer Features

.

Expand Tables. The DEPARTMENT and EMPLOYEES tables appear in the list.

[转]Advanced Oracle SQL Developer Features

Copying Schemas

You can use the Database Copy to copy objects directly from a source to a target schema. This is a quick and very useful way of copying all tables and data from one schema to another. To copy tables between two schemas perform the following steps:

.

Select Tools > Database Copy

[转]Advanced Oracle SQL Developer Features

.

You will copy the schema objects from the hr_orcl connection to the test_orcl connection. Select hr_orcl for Source Connection and test_orcl for Destination Connection and click Next.

[转]Advanced Oracle SQL Developer Features

.

Notice in the Copy Summary that all the tables in HR will be created in Test, even the EMPLOYEES and DEPARTMENTS. Click Finish.

[转]Advanced Oracle SQL Developer Features

.

The result of the comparison is displayed in a SchemaCopy log file in the SQL Developer window. Review the full results log. Do you expect the errors you find? Click Refresh to see the newly copied objects.

[转]Advanced Oracle SQL Developer Features

.

The newly copied objects are displayed.

[转]Advanced Oracle SQL Developer Features

.

Scroll down in the SchemaCopy log to see that you received an error when the CREATE TABLE "DEPARTMENTS" statement was run indicating that it already existed.

[转]Advanced Oracle SQL Developer Features

Searching for Database Objects

You can find various types of objects (tables, columns, declarations within functions or procedures, and so on) associated with an Oracle database connection. After searching an object you can also open it in editing pane and work with it. In Oracle SQL Developer Release 1.5 and later, you can take advantage of the PLScope feature in Oracle Database 11g, which allows users to search for parameter declarations and references. To search for database objects, perform the following steps

.

Select File > Open.

[转]Advanced Oracle SQL Developer Features

.

Select the proc_emp_cursor.sql file from the directory where you unzipped the files from the Prerequisites and click Open.

[转]Advanced Oracle SQL Developer Features

.

Select hr_orcl from the list of connections.

[转]Advanced Oracle SQL Developer Features

.

Click the Run Script icon.

[转]Advanced Oracle SQL Developer Features

.

The procedure compiled successfully.

[转]Advanced Oracle SQL Developer Features

.

Select View > Find DB Object.

[转]Advanced Oracle SQL Developer Features

.

In the Find Database Object window, select hr_orcl for Connection, enter c_emp_cursor for Name and click Lookup.

[转]Advanced Oracle SQL Developer Features

.

Note that no occurrences were found. Click More.

[转]Advanced Oracle SQL Developer Features

.

Now when you perform the lookup, it will search in all types of database objects including PL/SQL procedures. Click Lookup.

[转]Advanced Oracle SQL Developer Features

.

Now there are occurrences of c_emp_cursor displayed.

[转]Advanced Oracle SQL Developer Features

.

Click one occurrence of c_emp_cursor to view and edit it in PL/SQL Editor.

[转]Advanced Oracle SQL Developer Features

.

You can also use wild cards while searching database objects. Change the Name to %emp_cursor and click Lookup.

[转]Advanced Oracle SQL Developer Features

.

All occurrences of the cursor c_emp_cursor and also the procedure proc_emp_cursor are displayed.

[转]Advanced Oracle SQL Developer Features

.

You can apply a filter on the search results. Select DECLARATION for Usage and click Lookup.

[转]Advanced Oracle SQL Developer Features

.

Only DECLARATION statements appear in the list.

[转]Advanced Oracle SQL Developer Features

.

You can also filter on the basis of Type. Change Usage back to All, enter %dept% for Name and select View for Type and click Lookup.

[转]Advanced Oracle SQL Developer Features

.

All the views with DEPT in its name and displayed.

[转]Advanced Oracle SQL Developer Features

Setting Preferences for the SQL Worksheet

You can customize many aspects of the SQL worksheet by modifying SQL Developer preferences according to your preferences and needs. To set preferences for the SQL Worksheet, perform the following steps:

Setting the Drag and Drop Effects

Drag and Drop Effects determine the type of SQL statement (select, insert, update or delete) created in the SQL Worksheet when you drag an object from the Connections navigator into the SQL Worksheet. By default, drag and drop from the navigator to the SQL Worksheet creates a new Select statement with all the columns in the table included. You can modify these settings.

To set the Drag and Drop Effects according to your preference, perform the following steps:

.

Select Tools > Preferences.

[转]Advanced Oracle SQL Developer Features

.

Expand Database and select Drag And Drop.

[转]Advanced Oracle SQL Developer Features

.

Change the Drag and Drop effects to Insert. Click OK.

[转]Advanced Oracle SQL Developer Features

.

In Connections navigator, right-click hr_orcl and select Open SQL Worksheet.

[转]Advanced Oracle SQL Developer Features

.

Expand hr_orcl > Tables. Select and drag the JOBS table to the SQL Worksheet area.

[转]Advanced Oracle SQL Developer Features

.

A dialog appears asking you what type of statement you want to create. Notice that the default is set to Insert which you just changed in your preferences. This dialog will appear because the check box Prompt every time is selected. Deselect the Prompt every time check box and click Apply.

[转]Advanced Oracle SQL Developer Features

.

An Insert statement for the JOBS table was created.

[转]Advanced Oracle SQL Developer Features

Setting Code Templates

You can create Code Templates for frequently used code. To create and use code templates, perform the following steps:

.

Select Tools > Preferences.

[转]Advanced Oracle SQL Developer Features

.

Select Database > SQL Editor Code Templates. You want to create a new template, click Add Template.

[转]Advanced Oracle SQL Developer Features

.

Click in the Id field and enter excep. Then click in the Template field for that row.

[转]Advanced Oracle SQL Developer Features

.

Click the Edit icon to add the code for this template.

[转]Advanced Oracle SQL Developer Features

.

Enter the following code that will be used when the code template is referenced. Then click Close.

EXCEPTION             WHEN NO_DATA_FOUND THEN             DBMS_OUTPUT.PUT_LINE ('The query did not return a result set');

[转]Advanced Oracle SQL Developer Features

.

Click OK.

[转]Advanced Oracle SQL Developer Features

.

Expand Procedures and select PROC_EMP_CURSOR .

[转]Advanced Oracle SQL Developer Features

.

Type exc in a new line below END LOOP; Notice that the code template popup appears. Double-click on the code template.

[转]Advanced Oracle SQL Developer Features

.

Notice that the code template is inserted into the procedure. Select Compile from the drop down list box.

[转]Advanced Oracle SQL Developer Features

.

The procedure compiled successfully.

[转]Advanced Oracle SQL Developer Features

Integrating Application Express

Oracle SQL Developer provides an interface to Oracle Application Express applications and offers a number of useful activities to assist you when working with Oracle APEX. In this tutorial you perform the following operations:

Browsing an Application

SQL Developer provides a variety of ways of browsing Oracle APEX applications. In this section you browse the OEHR Sample Objects application, which is part of the "Getting Started with Oracle Application Express" online guide.To browse through your applications, perform the following steps:

.

Create a new database connection for the user HR_APEX. (If you still have a number of other tabs open from earlier sections, you can close those)

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

[转]Advanced Oracle SQL Developer Features

.

Enter the following details and click Connect.

Connection Name: hr_apex_orcl             Username: hr_apex             Password: hr_apex             Hostname: localhost             Port: 1521             SID: orcl

[转]Advanced Oracle SQL Developer Features

.

In the Connections navigator, expand the Application Express node to display a list of all the applications owned by hr_apex schema.

[转]Advanced Oracle SQL Developer Features

.

Select Sample Application to display the application-level details, which includes Lists of Values, Lists, Templates, Tabs, etc.

[转]Advanced Oracle SQL Developer Features

.

Expand the Sample Application to see a list of the pages that make up the application.

[转]Advanced Oracle SQL Developer Features

.

Click the Master Detail page to display a detail tab with all the page-level details. This includes Regions, Items, Buttons, Processes, etc.

[转]Advanced Oracle SQL Developer Features

.

You can compare details of different pages or different applications. Click the Freeze View icon for the Master Detail page.

[转]Advanced Oracle SQL Developer Features

.

Select the Add Modify Customers page to open a new tab and display the details for that page.

[转]Advanced Oracle SQL Developer Features

.

Select the tab for the Add Modify Customers page and drag it below the Master Detail page and release. (As you drag you'll notice a blue box which shows the new positioning)

[转]Advanced Oracle SQL Developer Features

.

Click the Items tab for Add Modify Customers.

[转]Advanced Oracle SQL Developer Features

.

Then click the Items tab for the Master Detail page.

[转]Advanced Oracle SQL Developer Features

.

Now you can easily compare the values. When done reviewing, you can close both tabs.

[转]Advanced Oracle SQL Developer Features

Importing an Application

You can use SQL Developer to import Oracle Application Express applications. In this section you import the TIMESHEETS sample application. Oracle APEX provides a selection of packaged applications, which you can install and use out-of-the-box or modify. You can access these applications from the Oracle APEX homepage on OTN. (http://apex.oracle.com)

To import and browse an Oracle APEX application, perform the following steps:

.

In the Connection Navigator select the hr_apex connection, right-click the Application Express node and select Import Application.

[转]Advanced Oracle SQL Developer Features

.

In the dialog, click Browse to locate the file to import.

[转]Advanced Oracle SQL Developer Features

.

Select the timesheets_installer_1.0.sql file from the directory where you unzipped the files from the Prerequisites and click Select.

[转]Advanced Oracle SQL Developer Features

.

Click Next.

[转]Advanced Oracle SQL Developer Features

.

In the Choose Import Options dialog, check the Run Install Script option and accept the rest of the defaults. Then click Next.

[转]Advanced Oracle SQL Developer Features

.

Review the Results. Click Finish.

[转]Advanced Oracle SQL Developer Features

.

The import process will take a short while. Click OK to complete the install process.

[转]Advanced Oracle SQL Developer Features

[转]Advanced Oracle SQL Developer Features

Executing an Application Express Report

SQL Developer provides a selection of shipped reports. These reports include a selection of Application Express reports. To review some of the reports, perform the following steps::

.

Select the Reports tab.

[转]Advanced Oracle SQL Developer Features

.

Expand All Reports > Data Dictionary Reports > Application Express and review the available reports.

[转]Advanced Oracle SQL Developer Features

.

Click Applications. A Select Connection window appears, select hr_apex and click OK.

[转]Advanced Oracle SQL Developer Features

.

A report with details for each application is displayed. Click the Sample Application.

[转]Advanced Oracle SQL Developer Features

.

In the details report, select the LOV tab. Here you review the various Lists Of Values that exist with in the application.

[转]Advanced Oracle SQL Developer Features

Summary

In this tutorial, you have learned how to:

  • Export objects
  • Copy schemas
  • Use extended search
  • Set your preferences
  • Integrate with Oracle Application Express

[转]Advanced Oracle SQL Developer Features的更多相关文章

  1. Oracle SQL Developer 连接 MySQL

    1. 在ORACLE官网下载Oracle SQL Developer第三方数据库驱动 下载页面:http://www.oracle.com/technetwork/developer-tools/sq ...

  2. 解决Oracle SQL Developer无法连接远程服务器的问题

    在使用Oracle SQL Developer连接远程服务器的时候,出现如下的错误 在服务器本地是可以正常连接的.这个让人想起来,跟SQL Server的一些设计有些类似,服务器估计默认只在本地监听, ...

  3. Oracle SQL Developer 添加SQLServer 和Sybase 连接

    来源于: http://blog.csdn.net/kk185800961/article/details/8602306 1. 开始只有Oracle 和access 连接 2. 打开Oracle S ...

  4. Tools - Oracle SQL Developer

    Oracle SQL Developer Oracle公司出品的一个免费非开源的用以开发数据库应用程序的图形化工具. 可以浏览数据库对象.运行SQL语句和脚本.编辑和调试PL/SQL语句,也可以创建执 ...

  5. Oracle SQL Developer连接报错&lpar;ORA-12505&rpar;

    Oracle SQL Developer连接报错(ORA-12505) 之前我的Oracle数据库出现问题,费大波周折终于弄好了,今天又创建了一个DBA管理员的连接方式出现问题,本人现在把解决方案分享 ...

  6. WIN7 64位配置Oracle SQL Developer工具

    在使用Oracle SQL 的过程中,很多参考资料,辅导机构,各种书籍绝大多数都是使用PL/SQL进行讲解,但是问题是PL/SQL对WIN7 64位系统支持不好,网上有各种各样的配置教程,我尝试了很多 ...

  7. 【Oracle】ORACLE SQL Developer不支持JAVA版本

    ORACLE SQL Developer不支持JAVA版本 今天我打开 ORACLE SQL Developer准备开始练手.没有想到却给出了错误提示. 我 是安装了java JDK的而且是1.6版本 ...

  8. Oracle11g x64使用Oracle SQL Developer报错:Unable to find a Java Virtual Machine

    原因oracle 11g中安装的Oracle SQL Developer是32位的,而我们现在给他指定的java.exe却是64位的,所以会出现这种错误.解决方法1)从网上下载Oracle SQL D ...

  9. Ubuntu14&period;04LST 安装Oracle SQL Developer 4&period;0&period;2

    1:Oracle SQL Developer 4.0.2下载链接: http://www.oracle.com/technetwork/developer-tools/sql-developer/do ...

随机推荐

  1. 用diss 实现 push动画

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { AAAViewController * aaa = [[AAAVie ...

  2. Svn 的 Update 与Maven 的update project 作用有什么区别

    1.svn update只是更新项目的SVN仓库.2.maven update project则是进行一系列的操作(跟自己的配置有关,可能包含一下操作):更新SVN.更新项目关联.编译项目.构建发布等 ...

  3. EF执行存储过程&lpar;带输出参数&rpar;

    1.不含动态sql.带输出参数存储过程调用实例 1.存储过程代码:   2.EF自动生成代码(包括对应ObjectResult的实体模型): 3.调用存储过程代码实例: 总结: ObjectParam ...

  4. Android双击退出

    重写返回键 private long tempTime = 0; /** * 双击退出 */ @Override public void onBackPressed() { long firstCli ...

  5. Scala之Calendar&comma;SimpleDateFormat简单用法

    package com.dingxin.entrance import java.text.SimpleDateFormat import java.util.{Calendar, Date} /** ...

  6. Centos 7 安装JAVA环境 jdk1&period;8

    在Linux环境(Centos 7)安装jdk1.8,有以下两种方式 方式一.安装openjdk #   yum install java-1.8.0-openjdk* -y 方式二.使用wget下载 ...

  7. office2007每次打开都要配置文件,怎么取消配置&lpar;可行)

    取消打开软件进行配置的方法 打开“我的电脑”——“C盘”— —“Program Files\Common Files\ Microsoft Shared\OFFICE12\Office Setup C ...

  8. base&lowbar;基础

    目录 A B C D E F G H I J K L M N S: Sqlite: 1;orhanobut/hawk; A: Adapter: 图片处理 Android中自定义布局中加载图片Bitma ...

  9. JetBrains全系列在线激活中心pycharm

     题记:有能力还是建议购买正版授权! 01.pycharm下载 https://www.jetbrains.com/pycharm/download/ https://download.jetbrai ...

  10. MATLAB 人脸定位

    faceimg = x222;faceDetector = vision.CascadeObjectDetector();bbox = step(faceDetector, faceimg);face ...