Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
161 views

Lab 1 Introduction To Oracle

This document provides an introduction to using Oracle Database Express Edition 11.2g for a database lab at the Islamic University of Gaza's Computer Engineering department. It discusses installing Oracle XE, unlocking the predefined "HR" user account to access its sample schema, and using Oracle SQL Developer as a graphical user interface for managing the database.

Uploaded by

Karam Salah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views

Lab 1 Introduction To Oracle

This document provides an introduction to using Oracle Database Express Edition 11.2g for a database lab at the Islamic University of Gaza's Computer Engineering department. It discusses installing Oracle XE, unlocking the predefined "HR" user account to access its sample schema, and using Oracle SQL Developer as a graphical user interface for managing the database.

Uploaded by

Karam Salah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Islamic University of Gaza

Faculty of Engineering

Computer Engineering Dept.

Database Lab (ECOM 4113)

Lab 1

Introduction to Oracle

Eng. Mohammed Alokshiya

September 30, 2014


Oracle Database Management System
Oracle Database (commonly referred to as Oracle RDBMS or
simply as Oracle) is an object-relational database management
system produced and marketed by Oracle Corporation. Its last
version is Oracle 12c (c refers to cloud) and its primary query
language is PL/SQL.
For our lab, we will use Oracle Database Express Edition
11.2g, since this version does not have significant system overhead
requirements.

Installing Oracle XE
Installing Oracle XE is an easy task. Just double click on
“setup.exe” and follow the installation wizard:

2
Do not hesitate to accept the terms in the license agreement 

3
4
Now you have to assign a password for your database. Be careful
at this step since the password will be used for both “SYS” and
“SYSTEM” database accounts, which we will about them later.

5
Finally, you will see a report of your database settings. Click
“Install”.

6
Ignore errors like this:

Be patient! Configuring database will take few minutes

7
At this point, Oracle Express Edition has successfully installed and
can be accessed through user accounts. Some of these accounts
are automatically created administrative accounts—accounts with
database administration privileges, and others are created but
LOCKED by default and their passwords are expired. Before you can
use a locked account, you must unlock it and reset its password.
The following table lists some of the Oracle Database XE predefined
user accounts:
User Account Purpose
Name
SYS Owns the data dictionary base tables and views.
The account password is set upon installation.
SYSTEM Log in with this account to perform routine
database administration. The account password
is set upon installation.

8
HR For the HR sample schema. This account is
initially expired and locked.
ANONYMOUS Internal. Used for anonymous HTTP access to the
database. Required by the Oracle Database XE
graphical user interface. This account must
remain unlocked. The account password is set
upon installation.
… …

Schemas and Common Schema Objects


A schema is a collection of database objects. A schema is
owned by a database user and has the same name as that user.
Schema objects are the logical structures that directly refer to the
database's data. Schema objects include structures like tables,
views, and indexes.

Schema’s objects include:

 Tables
Tables are the basic unit of data storage in an Oracle
database. Database tables hold all user-accessible data. Each table
has columns and rows. A table that has an employee database, for
example, can have a column called employee number, and each
row in that column is an employee's number.
 Indexes
Indexes are optional structures associated with tables.
Indexes can be created to increase the performance of data
retrieval. Just as the index in this manual helps you quickly locate
specific information, an Oracle index provides an access path to
table data.

9
When processing a request, Oracle can use some or all of the
available indexes to locate the requested rows efficiently. Indexes
are useful when applications frequently query a table for a range
of rows (for example, all employees with a salary greater than 1000
dollars) or a specific row.
Indexes are created on one or more columns of a table. After
it is created, an index is automatically maintained and used by
Oracle. Changes to table data (such as adding new rows, updating
rows, or deleting rows) are automatically incorporated into all
relevant indexes with complete transparency to the users.
 Views
Views are customized presentations of data in one or more
tables or other views. A view can also be considered a stored query.
Views do not actually contain data. Rather, they derive their data
from the tables on which they are based, referred to as the base
tables of the views.
Like tables, views can be queried, updated, inserted into, and
deleted from, with some restrictions. All operations performed on
a view actually affect the base tables of the view.
Views provide an additional level of table security by
restricting access to a predetermined set of rows and columns of a
table. They also hide data complexity and store complex queries.
 Synonyms
A synonym is an alias for any table, view, materialized view,
sequence, procedure, function, package, type, Java class schema
object, user-defined object type, or another synonym. Because a
synonym is simply an alias, it requires no storage other than its
definition in the data dictionary.

10
HR Schema
As we said before, some accounts are automatically created
while installing Oracle XE. One of these accounts is “HR” account,
which has a sample schema that is full of objects and its tables is
rich of data. This schema was created for academic purposes and
targets students. Unfortunately, “HR” account is initially locked and
expired, Therefore, we have to unlock it by using “ALTER USER ...
ACCOUNT UNLOCK” statement.
Firstly, we will connect to our database using “SYSTEM”
account, which has administrative privileges.
From “start” menu, Run SQL Command Line:

Then connect to the database: “connect username/password”


Finally, unlock “HR” account by using the “ALTER USER ... ACCOUNT
UNLOCK” statement

Unlocking “hr” database account


// Connecting to the database using “system” account
connect system/manager;
// unlocking “hr” account
alter user hr identified by hr account unlock;

11
Now you can discover schema objects that belong to “HR”,
like tables, by issuing “SELECT TABLE_NAME FROM USER_TABLES”
statement.
Retrieving Tables Names in a Schema
SELECT TABLE_NAME FROM USER_TABLES;

12
Oracle SQL Developer
Oracle SQL Developer is the Oracle Database IDE. A free
graphical user interface, Oracle SQL Developer allows database
users and administrators to do their database tasks in fewer clicks
and keystrokes. A productivity tool, SQL Developer’s main objective
is to help the end user save time and maximize the return on
investment in the Oracle Database technology stack.
SQL Developer supports Oracle Database 10g, 11g, and 12c
and will run on any operating system that supports Java.
Working with SQL Developer is very easy; even it does not
have to be installed on your device! Just double click on
“sqldeveloper.exe” and it will be ready to be used for managing
database!

13
Click on the green icon (+) to create a new connection to your DB.

14
Connection details:

15
Now, your connection is ready and you can use it for managing
database, discovering the schema, and reviewing tables and its
contents, etc…

16
Running SQL commands:

17
Finally, reviewing tables’ contents:

18

You might also like