0% found this document useful (0 votes)
60 views62 pages

Introduction of Oracle-1

Oracle is a powerful and robust database management system that runs on many operating systems. It offers high availability, scalability, and data safety through features like automatic transaction management, online backups, and point-in-time recovery. While expensive, Oracle can handle unlimited amounts of data and supports internationalization and multiple languages. It differs from other databases by storing all data for a single database within one database instance.

Uploaded by

hiwot kebede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views62 pages

Introduction of Oracle-1

Oracle is a powerful and robust database management system that runs on many operating systems. It offers high availability, scalability, and data safety through features like automatic transaction management, online backups, and point-in-time recovery. While expensive, Oracle can handle unlimited amounts of data and supports internationalization and multiple languages. It differs from other databases by storing all data for a single database within one database instance.

Uploaded by

hiwot kebede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 62

• Introduction to the Oracle

Database

1
• Oracle is the world’s most popular DBMS - It is a powerful and
robust DBMS that runs on many different operating systems
• Oracle DBMS engine is available in several versions:
• Example of Oracle products:
– SQL*Plus: a utility for processing SQL and creating components like
stored procedures and triggers:
• PL/SQL is a programming language that adds programming constructs to
the SQL language
– Oracle Developer (Forms & Reports Builder)
• Also third-party products - Quest Software’s TOAD

2
Oracle History
• 1978 – Oracle V1, never officially released
• 1980 – Oracle V2 released, written in assembly
language
• 1994 – Oracle 7 for PC released
• 1998 – Support for Linux platform
• 1999 – Oracle 8i with Java integration
• 2001 – Oracle 9i
• 2004 – Oracle 10g
• 2007 – Oracle 11g
• 2013 – Oracle 12c
3
Oracle database
• The best database for large database systems:
– most reliable in terms of data safety
– highest availability
– scalable
– good internationalization support
• Oracle shortcomings:
– price – expensive
– speed – not the fastest database available
– amount of resources consumed

4
Data safety
• Many features that ensure safety of data:
– multiplexing of important database files
– writing changes to data files and to special log
files. Log files are used to recover database after
software or hardware failure
– archiving of log files. Archived log files can be
written to backup location(s)
– protection from human errors:
•possibility to view data from some point in time in the pas
•possibility to use backup and perform point in time recovery

5
Availability
• Very high availability:
– online backups – without shutting down the database
– most administrative tasks can be performed while the database is running and
available for users, for example: analyzing, rebuilding indexes, moving data
– disk failure: it is possible to turn off and recover only the part of the database
that was affected by the failure, the rest of the database can continue running
– parameters that ensure that recovery after failure will take no more than the
specified time
– standby database – second database that can be opened if the main database
fails

6
Scalability
• Oracle can handle unlimited amount of data:
– no limit on number of rows, number of tables etc.
– no limit on total size of the database
• Oracle runs on various operating systems:
– Windows NT/XP
– Linux
– Solaris, HP-UX, AIX
• Oracle Cloud/Grid – single database on a
cluster
7
Internationalization
• Database supports multiple languages/locales:
– sorting of text can be done in client language
order
– date, time and currency is client dependent
– character set conversion – database running in
utf8 or iso8859-2 will convert data for clients
using windows-1250
• Internally database can store data in Unicode

8
Oracle editions
• Express edition:
– Simple installation and administration, some
features are not available (for example: Java
Virtual Machine is disabled)
• Standard edition:
– Most frequently used features are available
• Enterprise edition:
– All features, very expensive

9
Speed of the database
• Oracle favors data safety over speed:
– it is not possible to disable some features to
achieve greater speed (e.g.: transactions)
– some other databases (e.g. MySQL) are faster
than Oracle

10
Resources consumed
• Oracle consumes large amounts of resources:
– new, empty database – at least 200MB, usually over 1GB
– at least 256MB RAM

• Hint: when installing Oracle on private


computer (Windows):
– install Standard or Enterprise edition
– assign around 256MB RAM for Oracle
– install database normally
– change startup of Oracle services to manual
– when required start the database manually with:
oradim –startup –sid database_sid

11
Oracle terminology - database
• Database – data stored on disk (data files and
some additional files)
• Database instance – program (group of
programs) that opens the database (disk files)
and makes it available to users
• User connects to the database instance and
retrieves data or requests changes to the
database
• When running Oracle on a cluster, there are
multiple database instances that open the
same database
12
Oracle terminology - schema
• Schema – set of objects (tables, indexes, views) that
belong to a database user.
– In Oracle SCHEMA = USER
– When new user is created (CREATE USER command), initially it has an
empty schema
– When the user logs in and creates new table, the table is added to his schema
– When user issues:
SELECT * FROM some_table
Oracle looks for some_table in the user’s schema
– It is possible to access data in some other schema:
SELECT * FROM some_user.some_table

13
Major differences from other
database systems

14
Single database
• Many other database systems (Postgres,
MSSQL) can have multiple databases opened
by a single database engine
– each application can use separate database for its
data
• In Oracle single Oracle Instance can open one
database
– normally on a single database server there will be
only one database
– each application can store its data in separate
user schema
15
Data storage
• Many other database systems (Postgres,
MySQL) store table data in a separate file or
group of files
• Oracle stores table data in a tablespace.
Multiple tables are normally stored in the
same tablespace. Tablespace can be stored in
one or more data files (physical disk files)

16
Transactions
• Oracle executes every statement in a
transaction
– there is no command to start a transaction (like
BEGIN TRANSACTION)
– transaction is started automatically with a first
statement after COMMIT or ROLLBACK
– usually transaction must be finished manually with
COMMIT, exceptions:
•it is possible to turn on AUTOCOMMIT (by default: disabled)
•some statements commit the transaction automatically: all CREATE, ALTER,
DROP and TRUNCATE statements

17
Transaction example
-- user connects to the database
DELETE FROM table1;
-- new transaction created
INSERT INTO table1 VALUES (1, ‘some text’);
INSERT INTO table1 VALUES (2, ‘some text’);
CREATE TABLE table2
(
id NUMBER PRIMARY KEY,
text VARCHAR2(256)
);
ROLLBACK; -- table1 contains 2 rows,
-- the rollback statement rolled
-- back empty transaction

18
Date format, language
• Oracle has no fixed date and time format.
When displaying dates, Oracle uses the format
consistent with the connected client
• Language used by Oracle (for example: error
messages) also depend on the language
settings
• To use English with Oracle, set the
environment variable NLS_LANG before
starting SQLPlus:
– SET NLS_LANG=AMERICAN_AMERICA.UTF8

19
General database terminology
• Database user – login and password used to connect
to the database. Each user has:
– set of privileges for accessing the database
– schema objects: objects: tables, indexes etc.

• Table – database object used for data storage:


– can have any number of rows
– has fixed number of columns, each column has a name and datatype
– can have constraints, indexes and relations to other tables

• Relation – defines a dependency between two tables

20
• Constraint – rule that must be satisfied by
each table row. Constraint can be:
– PRIMARY KEY constraint
– NOT NULL constraint
– UNIQUE constraint
– FOREIGN KEY constraint (relation)
– CHECK constraint
• Index – object that organizes data in a table.
Indexes are used:
– to enforce PRIMARY KEY and UNIQUE constraints
– to improve query performance

21
• Trigger – action performed when user makes
changes to database data
• Session – single connection to the database.
One user can open multiple sessions to the
database
• Transaction – set of operations that are visible
as single (atomic) operation on the database.
Transaction belongs to a single open database
session.

22
Accessing the database
• Oracle can be accessed from various tools:
– Oracle tools:
•SQLPlus (always available) – command line tool for executing SQL
statements. All administrative statements can be executed from SQLPlus
•SQL Developer – free development tool, easier to use than SQLPlus
– Third party tools:
•TOAD –application for administrating Oracle database, executing SQL
statements, TOAD Freeware Edition is available for free

23
Connecting to the database
• In order to connect, you need to specify:
– user name
– password
– connect string (optional)
– connect mode (optional)
• Connect string:
– determines location of the database, if not
specified – local database
• Connect mode – specified for administrative
connections (database startup and shutdown)
24
Starting database session
• The following commands will start SQLPlus
and connect to the database:
– Log in as user “test”
– sqlplus test/testpass
password “testpass” to local database
– sqlplus test/testpass@db – Log in as user “test” to
database “db”
– sqlplus system/orclstudent – Log in as user “system”
password “orclstudent”
– sqlplus sys/orclstudent as sysdba– Log in as user
“sys” with special SYSDBA privileges

25
Networking

26
Connecting to Oracle
• Connection to Oracle is possible:
– in local mode – when connecting to local database
only
– via network – when connecting to some other
database
• All non-local connections are done through
the listener

27
The listener
• Oracle Listener is separate from the database
• In Windows it starts as service
OraclexxxxTNSListener
• One listener can handle connections for
multiple databases
• Listener configuration determines how clients
will connect to the database. By default
listener:
– uses TCP/IP
– listens on port 1521 – default Oracle port
28
Listener configuration
• Listener configuration is in
$ORACLE_HOME/network/admin/listener.ora

• Example configuration:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = host_name)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)

29
Listener startup and shutdown
• Listener can be started manually from the
command line:
– lsnrctl start
• Other commands:
– lsnrctl stop – stops the listener
– lsnrctl status – shows list of services that
this listener supports

30
Naming configuration
• When connecting to database using SQLPlus
you specify:
– user name
– password
– database name
• When the database name is empty –
connection to the local database
• When the database name is not empty –
lookup of the database name. By default
database names are looked up in
tnsnames.ora file 31
tnsnames.ora
• Location:
$ORACLE_HOME/network/admin/tnsnames.ora

• This file is used to lookup names of databases:


– IP address of the database
– listener port number
– name of the Oracle instance

32
tnsnames.ora - example
• Typical entry in the tnsnames.ora file:
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = name_or_ip)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = database_instance_name)
)
)

33
tnsnames.ora - example
• Entries in tnsnames.ora enable:
– specifying multiple addresses for a connection
– request load balancing between the list of available addresses

TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = name_or_ip)
(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = other_host)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = database_instance_name)
)
)

34
tnsnames.ora - example
• Load balancing example
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(FAILOVER=off)
(ADDRESS = (PROTOCOL = TCP)(HOST = name_or_ip)
(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = other_host)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = database_instance_name)
)
)

35
Database administration

36
Administrative privileges
• Database administration requires strong
privileges:
– SYSDBA – the most powerful database privilege,
enables database startup, shutdown and access to
all data in the database
– SYSOPER – enables database startup and
shutdown without access to database data
– DBA – role (a group of privileges) giving user full
administrative access, but without the right to
start and shut down the database

37
Administrator accounts
• Each Oracle database has two accounts:
– SYS – owner of the administrative objects, created
with DBA role, has SYSDBA and SYSOPER privileges
– SYSTEM – automatically created with DBA role
• SYS and SYSTEM users should not be used to
create any tables

38
DBA, SYSDBA and SYSOPER
• DBA role grants administrator access to the
database when the database is running
• DBA role is not enough to startup and
shutdown the database
• SYSDBA and SYSOPER enable database startup
and shutdown
• In order to use the SYSDBA or SYSOPER
privilege, the connection must be in special
mode:
connect sys/sys_password as
39
Important!
• SYSDBA is not database user name – it is a
privilege and special connect mode.
• When connecting to the database:
connect sys/sys_password as
sysdba
special connection with in SYSDBA mode is
requested.

40
SYSDBA and SYSOPER
• DBA user can be granted SYSDBA or SYSOPER
privilege
• SYSDBA privilege enables you to
– Perform STARTUP and SHUTDOWN operations
– ALTER DATABASE: open, mount, back up, or change character set
– CREATE DATABASE
– DROP DATABASE
– CREATE SPFILE
– ALTER DATABASE ARCHIVELOG
– ALTER DATABASE RECOVER
– Includes the RESTRICTED SESSION privilege
– SYSDBA lets you look at any user’s data

41
Database shutdown
• SHUTDOWN NORMAL – waits for all users
to disconnect, not recommended – can take a
long time
• SHUTDOWN TRANSACTIONAL – waits for
all users to finish their transactions
• SHUTDOWN IMMEDIATE – rolls back all
uncommitted transactions, closes all sessions,
closes the database and shuts down the
instance
• SHUTDOWN ABORT – aborts the instance,
does not close the database properly.
Requires automatic recovery after startup. 42
Database startup
• Database startup involves 3 steps:
– starting the instance
– mounting the database
– opening the database – opened database is
available for use
• STARTUP – executes those 3 steps
• When performing administrative actions,
those steps can be performed one by one:
– STARTUP NOMOUNT – only start the instance,
useful when creating the database
– STARTUP MOUNT – start the instance and
mount the database (open database control files) 43
Database startup
• Example startup (rarely used):
– STARTUP NOMOUNT
– ALTER DATABASE MOUNT
– ALTER DATABASE OPEN
• Example startup (used for many
administrative actions):
– STARTUP MOUNT
– perform some administrative actions, e.g. recover
the database, change archiving mode
– ALTER DATABASE OPEN – opens database for
use 44
System views
• Oracle provides many system views that
provide information about the database:
– v$session – all open sessions
– v$datafile – all data files
– v$logfile – all log files
– v$database – general information about the
database
– v$instance – general information about the
instance
• Some of those views are available when the
database is closed 45
Example scenario
• The database cannot start, error message is
that file number 4 is corrupt.
• Recovery:
– STARTUP MOUNT
– SELECT name FROM v$datafile WHERE file# = 4

– fix the problem with the file, e.g. restore it from


backup
– recover the database
– ALTER DATABASE OPEN

46
Oracle Installation

47
• Double-click database setup.exe and the
installation will start.
• To prepare for the installation, you will
be presented with a dialog box:

48
49
• Enter the same password in the indicated text
boxes. Remember the password you type here
because you will (always) need it later:

50
51
52
53
54
55
56
57
58
59
60
61
62

You might also like