Iniciando Con Oracle SQL Developer Part 1
Iniciando Con Oracle SQL Developer Part 1
Purpose
Time to Complete
Overview
Prerequisites
Creating a Database Connection
Adding a New Table Using the Create Table Dialog Box
Changing a Table Definition
Adding Table Constraints
Adding Data to a Table
Accessing Data
Creating Reports
Creating and Executing PL/SQL
Summary
Purpose
This tutorial introduces Oracle SQL Developer 3.0 and shows you how to manage your database objects.
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, you can browse database objects, run SQL statements, edit and debug PL/SQL statements and run reports, whether
provided or created.
Developed in Java, SQL Developer runs on Windows, Linux and the Mac OS X. This is a great advantage to the increasing
number of developers using alternative platforms. Multiple platform support also means that users can install SQL Developer on
the Database Server and connect remotely from their desktops, thus avoiding client server network traffic.
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. With SQL Developer you can connect to any supported Oracle Database.
Prerequisites
Before starting this tutorial, you should:
1 . Install Oracle SQL Developer 3.0 from OTN. Follow the readme instructions here.
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;
4 . Download and unzip the files.zip to a local folder on your file system. In this tutorial, we use the C:\sqldev3.0 folder.
The first step to managing database objects using Oracle SQL Developer 3.0 is to create a database connection. Perform the
following steps:
1 . If you installed the SQL Developer icon on your desktop, click the icon to start your SQL Developer and move to Step
4. If you do not have the icon located on your desktop, perform the following steps to create a shortcut to launch SQL
Developer 3.0 directly from your desktop.
Open the directory where the SQL Developer 3.0 is located, right-click sqldeveloper.exe (on Windows) or
sqldeveloper.sh (on Linux) and select Send to > Desktop (create shortcut).
2 . On the desktop, you will find an icon named Shortcut to sqldeveloper.exe. Double-click the icon to open SQL
Developer 3.0.
Note: To rename it, select the icon and then press F2 and enter a new name.
5 . The New / Select Database Connection dialog opens. Enter the connection details as follows and click Test.
6 . Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. Click
Connect. Then click Save.
7 . The connection was saved and you see the newly created connection in the Connections list.
8 . Expand HR_ORCL.
Note: When a connection is opened, a SQL Worksheet is opened automatically. The SQL Worksheet allows you to
execute SQL against the connection you have opened.
9 . Expand Tables.
10 . Select the EMPLOYEES table to view the table definition. Then click the Data tab.
11 . The data in the table is shown. In the next topic, you create a new table and populate the table with data.
13 . There are a number of constraints for the DEPARTMENTS table. To view the various constraints on the table, click
the Constraints tab.
14 . Note that the DEPARTMENTS table has 4 constraints. Each constraint has a unique name. The
CONSTRAINT_TYPE identifies the type of constraint on the table.
Click Edit .
15 . The Edit Table dialog has a number of fields. Select Foreign Keys beneath the Search field.
16 . Review the Foreign Keys constraints. Note that the DEPARTMENTS table has two foreign keys, one named
DEPT_LOC_FK and the other named DEPT_MGR_FK. When you select one of the names in the Foreign Keys field,
the details about that foreign key appear.
Later, you create a foreign key on the DEPENDENTS table to associate the column's values with the EMPLOYEES table.
Perform the following steps:
2 . Enter DEPENDENTS for the Table Name and select the Advanced check box.
3 . For the first column in your table, enter ID for the Name, select NUMBER for the Datatype and enter 6 for the
Precision (length of the number). Select Cannot be NULL, then click Add Column .
Note: By checking Cannot be NULL, you are adding a constraint on the table that specifies the column must hold
values.
4 . For the next column, enter FIRST_NAME for the Name, leave the type as VARCHAR2 and enter 20 for the Size to
specify the length of the VARCHAR2. Then click Add Column .
5 . For the next column, enter LAST_NAME for the Name, leave the type as VARCHAR2 and enter 25 for the Size.
Select the Cannot be NULL check box. Then click Add Column .
6 . For the next column, enter BIRTHDATE for the Name, select DATE for the type. Then click Add Column .
7 . For the last column, enter RELATION for the Name, leave type as VARCHAR2 and enter 25 for the Size. Click OK to
create the table.
3 . Enter RELATIVE_ID, select NUMBER for the Data Type (from the drop list), set the Precision to 6 and Scale to 0.
Click Apply.
Note: If you want to see the SQL that is generated for you, click the SQL tab.
Click OK.