Experiment 1.3 How to access Oracle database servers from Web

.3
CSCI315 Database Design and Implementation
Experiment 1.3
How to access Oracle database servers from Web browser ?
Experimented and described by Dr. Janusz R. Getta
School of Computer Science and Software Engineering, University of Wollongong, Australia,
Bldg. 3, room 210, phone +61 02 42214339, fax +61 02 42214170,
e-mail: jrg@uow.edu.au, Web: http://www.uow.edu.au/∼jrg, Msn: jgetta, Skype: jgetta007
Table of contents
Step 0 How to begin and what you need to know before you start ?
Step 1 How to start SQL Developer ?
Step 2 How to connect SQL Developer to a database server ?
Step 3 How to disconnect SQL Developer from a database server ?
Step 4 How execute SQL statement ?
Step 5 How to create SQL script ?
Step 6 How to execute SQL script ?
Step 7 How to change a password ?
Step 8 How to browse database objects ?
References
Actions
Step 0 How to begin and what you need to know before you start ?
A printable copy of this experiment in pdf format is available here .SQL Developer is a
graphical interface to Oracle database servers. SQL developer can be used to browse, to
0
These are the specifications of the homeworks in a subject Database Design and Implementation
(CSCI315) delivered in January 2009 at Singapore Institute of Management by Dr. Janusz R. Getta
1-1
Experiment 1.3: How to access Oracle database servers from Web browser ?
1-2
create , and to edit database objects, to implement and to execute SQL statements, to implement and to execute SQL scripts, to implement, to debug, and to execute PL/SQL stored
procedures, functions, and database triggers, to manipulate and to export data, and to create
and to view reprts. SQL Developer can be connected to any target Oracle datatabase server
and to third-party databases, such as MySQL, Microsoft SQL Server, and Microsoft Access
to view database objects and data in these databases. SQL Developer can be considered
as a graphical alternative to SQL*Plus. A procedure how to install and how to use SQL
Developer is described here .Download and uncompress SQL scripts used in Homework 1.
Step 1 How to start SQL Developer ?
To start SQL Developer use a shortcut to a program sqldeveloper.exe created during the
installation of SQL Developer and located at your Desktop It takes a moment to start SQL
Developer, so please be patient. The system should open Oracle SQL Developer : Start Page
window with the tabs Connectios and Start Page. You can use the links included in Start
Page tab to access tutorials, online demonstrations, documentation and other infromation
related to SQL Developer. In the next step we use Connection tab to create a new connection
and to connect to a database server.
Step 2 How to connect SQL Developer to a database server ?
To connect SQL Developer to a database server you have to create a connection. Activate Connection sub-window and leftclick at a large green + sign. The system should
open a window New / Select Database Connection. Fill the following fields in the window: Connection Name (it can be any name you like), Username , andPassword . When
ready leftclick at Save button and close a window New / Select Database Connection. SQL
Developer displayed an icon and name of a new connection attached Connections entry in
Connections window, To use a connection created just now, lectclick at a small + sign in
fron of an icon and name of the connection. The system should expand connection entry
with a folder Loading ... and it should open a small window Connection information that
already contains user name. Type in a password into Password field of Connection Information window and leftclick OK button. SQL Developer should minimize Connections tab and
open a new tab named as a user you are connected at. At this point a process of connecting
SQL Developer to a database server connection is completed.
Step 3 How to disconnect SQL Developer from a database server ?
To disconnect SQL Developer from a database server activate Connection tab and rightclick
at a connection name. SQL Developer will open a menu. Leftclick at Disconnect option in
the menu. Almost the same procedure can be used to connect SQL Developer to a database
server. Instead of lefclicking at a small + in front connection icon and connection name, you
Experiment 1.3: How to access Oracle database servers from Web browser ?
1-3
can rightclick a connection name and pick Connect option from the menu.
Step 4 How execute SQL statement ?
To execute SQL statement in an interactive mode connect SQL Developer to one of the
database servers. Next, rightclick at a connection name and pick Open SQL Worksheet from
the menu. The system should open a new tab with a connection name, activate the first
line of a worksheet and locate a cursor in the first line of an empty worksheet. Type the
following SELECT statement into the first line of an empty worksheet:
SELECT USER FROM DUAL;
Next, to execute SELECT statement, leftclick at a large green triangle icon (Run Statement)
at a top line of works heet tab. The system should open a new tab Query Result and display
the results (name of connected user) of SELECT statement. To close a tab with the results
move cursor to the right of Query Results tab name. SQL Developer should display a small
x on the right hand side of tab Query Results tab name. Leftclick at small x. The system
should close Query Results tab. To execute the next SELECT statement, locate the cursor
at the end of the first statement and press Enter key. Next type into the second line of a
connection worksheet the following SELECT statement:
SELECT SYSDATE FROM DUAL;
and leftclick at a large green triangle (Run Statement) at a top line of worksheet tab.
The system should open a new tab Query Result and display the results (current date) of
SELECT statement. To close a tab with the results move cursor to the right of Query Results
tab name and leftclick at small x. It is possible execute all SQL statements included in
a worksheet as a single SQL script. To do so leftclick at a page and small green triangle
icon(Run Script) on the right hand size from a bigger green triangle icon (Run Statement).
SQL Developer should open Script Output tab and display the results of both SELECT statements included in a worksheet. The next step show how to save the contents of a worksheet
as SQL script. Do not close a worksheet with SQL statement and move to the next step.
Step 5 How to create SQL script ?
To create SQL script we have to first create a worksheet with all SQL statements that
suppose to be included in a script. We shall reuse the worksheet with two SELECT statements
implemented in the previous step. If you have already closed the worksheet then open a new
one then right click at a connection name in Connections tab, pick Open SQL Worksheet from
Experiment 1.3: How to access Oracle database servers from Web browser ?
1-4
a menu, and re-type SELECT statement created in the previous step. To save the contents of
a workseet tab into SQL script select the options:
File->Save As
from the top line of Oracle SQL Developer window. SQL Developer should open Save
As window. Type a name of sql script (myscript.sql ) into File name: field and use
Location field to chose a folder for your SQL script. When ready, leftclick at Save button.
The contents of a worksheet have been saved in SQL script and SQL Developer should open
a new tab with a script name with the contents of SQL script. It is also possible to save the
contents of a worksheet into SQL script when closing a worksheet. To do so, leftclick at small
x on the right hand side of worksheet name. SQL Developer should open Save Files window
and ask about saving the changes. Leftclict at Yes button and follow the same procedure as
above.
Step 6 How to execute SQL script ?
To execute a script created in the previous step you have to open a new worksheet. To do
so, rightclick at a connection name and pick Open SQL Worksheet option to create a new
tab with a user name. Next, type into the first line of a new tab:
@path\file-name-with-no-sql-extension
where path is a path to a folder where SQL script is located and file-name-with-no-sql-extension is
a name of file that contains SQL script you would like to execute. A file name must not
have .sql extension. For example, if your script is located at C:\XE folder and full name of
a file with a script is myscript.sql than you should type into the first line of a worksheet:
@C:\XE\myscript
To execute a script leftclick at a page with a small green triangle icon (Run Script) located at the top line of a worksheet. SQL Developer should open a new tab Script Output
and it should display the results created by your script there. To edit the contents of a script
select an option:
File->Open
from the top line of Oracle SQL Developer window. SQL Developer should open Open
window. Navigate to a folder that contains a script you would like to edit and pick a name
Experiment 1.3: How to access Oracle database servers from Web browser ?
1-5
of file with a script. When ready, leftclick at Open button. SQL Developer should open a
new tab with the contents of selected script. You can edit the script now and when ready
use:
File->Save
option to save the script. Next, you can run the script again in the previously opened
worksheet tab.
Step 7 How to change a password ?
Open a new worksheet to change a password. To do so, rightclick at a connection name and
pick Open SQL Worksheet option to create a new tab with a user name. Next, type into
the first line of a new tab:
ALTER USER user-name IDENTIFIED BY new-password;
where user-name , and new-password should be replaced with your user name and new
password. For example, ALTER USER statement:
ALTER USER HR IDENTIFIED by pszczola;
changes a password of user jb007 to pszczola. Leftclick at a large green triangle icon (Run
Statement) at a top line of a worksheet to execute the statement. SQl Developer should
open a new Statement Output tab and it should display a message;
ALTER USER user-name succeeded.
Step 8 How to browse database objects ?
An important feature of SQL Developer is its ability to browse the database oblects like
relational tables, relational views, indexes, materialized views, sequences, PL/SQL stored
procedures and functions, triggers, and the others. To browse a structures and contents of
the relational tables click at a small + in front of Tables icons and name in Connections
tab. SQL Developer should expand Tables folder into a list of the names of relational tables
owned by a user asociated with a connection. To reveal an internal structure of a relational
Experiment 1.3: How to access Oracle database servers from Web browser ?
1-6
table leftclick at a small + in front of a table icon and name. SQL Developer should expand
a table name into a list of attribute names. If you would like to see the types of the attributes
then leftclick at a name of relational table in Connections tab. SQL Developer should open
a tab with a name of relational table used and the names of columns, types of columns,
NULL/NOT NULL constraints, default values, column ids, and comments. If you would like to
see the contents of a relational table then leftclick at a name of relational table in Connections
tab and then pick Data sub-tab in a table tab opened by SQL Developer. In the same way
you can get information about consistency constraints, grants, statistics, triggers, and other
properties of relational tables.
References
Getting Started with Oracle SQL Developer 3.0
Oracle SQL Developer Online Tutorials