Upload
ngotram
View
230
Download
3
Embed Size (px)
Citation preview
Islamic University of Gaza Faculty of Engineering
Department of Computer Engineering ECOM 4113: DataBase Lab
Lab # 1
Introduction to Oracle
Eng. Haneen El-Masry
October, 2014
DataBase Lab
2
Objective
To be familiar with Oracle DataBase Management System.
What is a DataBase?
A database is a collection of related data that is known facts that can be recorded and
that have implicit meaning.
Examples: University, Library, ect.
A database may be generated and maintained manually or it may be computerized. A
computerized database may be created and maintained by a database management
system (DBMS).
What is the DBMS ?
DBMS is a collection of programs that enables users to create and maintain a
database.
DBMS is a general-purpose software system that facilitates the processes of
defining, constructing, manipulating, and sharing databases among various users
and applications.
DBMS includes protecting the database and maintaining it over a long period of
time.
DBMS Responsibilities
Creating the database.
Providing query and update facilities.
Multitasking.
Managing the security of the database.
Maintaining referential integrity.
Examples:
Oracle, SQL Server, MySQL, PostgreSQL.
For our lab, we will use Oracle Database Express Edition 11.2g.
DataBase Lab
3
DataBase System
The database and DBMS software together are called a database system.
Figure 1: DataBase System
Oracle DataBase
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.
DataBase Lab
4
Oracle XE Installation on Windows
1- Double click on setup.exe
2- Next.
DataBase Lab
5
3- Accept the license Agreement >> Next.
4- Next.
DataBase Lab
6
5- Enter the password for SYS and SYSTEM default users that will be explained later
in this lab.
6- Install.
manager
^_^
DataBase Lab
7
DataBase Lab
8
7- Finish. ^_^
DataBase Lab
9
Oracle XE Default Users/Schemas
During installation, Oracle XE create a default database called XE. XE database
contains many schemas that each of them has an owner with the same name.
Schemas
Schemas are the most important objects within the database. 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 include structures like tables, triggers, functions,
views, and other objects for handling data in the database.
The Schemas have two purposes:
To help manage the access of many different users to a single database.
To allow extra tables to be associated with a standard database, but kept
separate.
User Name Description
SYS All of the base tables and views for the database's data dictionary are stored in the schema SYS. These base tables and views are critical for the operation of Oracle. To maintain the integrity of the data dictionary, tables in the SYS schema are manipulated only by Oracle; they should never be modified by any user or database administrator, and no one should create any tables in the schema of the user SYS.
The account password is set upon installation.
SYSTEM The SYSTEM username creates additional tables and views that display administrative information, and internal tables and views used by Oracle tools. Never create in the SYSTEM schema tables of interest to individual users. SYSTEM is a little bit "weaker" user than SYS, for example, it has no access
to the very internal structure tables of Oracle. The account default password is “manager” and it is changed upon installation.
HR Oracle Database XE comes with a sample database user called HR. This user owns a number of database tables in a sample schema that can be used to create applications for a fictional Human Resources department. However, for security reasons, this user's account is locked, and we need
to unlock it.
DataBase Lab
10
SQL Command Line “SQL*Plus”
It is an interactive command-line query tool that is installed with Oracle Database
Express Edition.
HR Unlock
To unlock HR user, you need to do two steps:
1- Connect to the XE database. We will connect using SYSTEM account that has
administrative privileges.
2- Unlock HR user.
DataBase Connection
To connect to any database, you need to determine the following five parameters:
Host or host address: is the host name or IP address of the computer that is
running Oracle Database XE. If not specified, the default host is localhost.
Port: is the TCP port number on which the Oracle Net listener is listening. If not
specified, the default port number 1521 is assumed.
Database name: is the name of the database service to which to connect. If
service_name is omitted, Oracle Database XE Client appends a request for the
default database service, which is configured during installation as XE.
User name.
Password.
DataBase Lab
11
Connect to DatBase
connect username/password@host:port/service_name
Unlock database account
alter user username identified by password account unlock;
Retrieving Tables Names in a Schema
SELECT TABLE_NAME FROM USER_TABLES;
DataBase Lab
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.
1- Double click on sqldeveloper.
2- Specify the path to Java JDK.
DataBase Lab
13
3- No.
DataBase Lab
14
Start Page ^_^.
DataBase Lab
15
Connect to XE database by HR user
1- Click on Connections then click on icon.
2- Enter Connection Parameters.
DataBase Lab
16
3- Test.
4- Connect.
Success
^_^
DataBase Lab
17
Query Example ^_^
Best Wishes