Introduction of Oracle Database
Introduction of Oracle Database
================
Oracle - vendor
Oracle Database
Data within the most common types of databases in operation today is typically modeled in rows and
columns in a series of tables to make processing and data querying efficient. The data can then be easily
accessed, managed, modified, updated, controlled, and organized. Most databases use structured query
language (SQL) for writing and querying data.
Linux - 120+
ubuntu
fedora
centos
redhat
oracle linux
windows
Unix(solars,aix,hp.)
MacOS
IBM - power
Sun sparc
HP -
MSSQL - windows
how many different ways we can get the database connection? tools
putty - remote client tool to connect to linux/unix machines.. by using it we can connect to any
linux/unix.
$ - your os prompt.
SERVICE_NAMES - orcl
ORACLE_SID(INSTANCE_NAME) - orcl
DB_NAME - orcl
DB_UNIQUE_NAME - orcl
11.2.0.1.0
11.2.0.2.0
11.2.0.3.0
11.2.0.4.0
12.1.0.1.0
[oracle@primary ~]$
rdp -
=> how to find how many databases are present in linux server.
# the entry. Lines beginning with a pound sign, '#', are comments.
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
# The first and second fields are the system identifier and oracle home
# to the dbstart utility that the database should , "Y", or should not,
orcl:/u01/app/oracle/product/12.1.0/db_home:N
[oracle@primary ~]$
1. Using ".bash_profile"
ORACLE_SID = [oracle] ?
ORACLE_HOME = [/home/oracle] ?
orcl
/u01/app/oracle/product/12.1.0/db_home
/u01/app/oracle
rayankulaspr.rc3@gmail.com
================================
linux vm
SYS@orcl>show user
USER is "SYS"
SYS@orcl>
Note: "Connected to an idle instance" means, your instance is not running. its not running.
by giving "startup" command, its going to start your instance & opens the database.
ERROR at line 1:
Process ID: 0
SYS@orcl>
SYS@orcl>startup;
Database mounted.
Database opened.
STATUS
------------
OPEN
SYS@orcl>exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@primary ~]$
Oracle Database Architecture:
=============================
Oracle database server = oracle instance + oracle database files (CRD) or oracle database
C - controlfile
R - redolog file
D - datafiles
40% of RAM
10 RAM
4 GB - instance
SGA : system global area or session global area or shared global area -
PGA : program global area or process global area or private global area
db_name = orcl
SGA(System/shared global area): Its again divided into 2 sub memory components.
DML - ISNERT,UPDAT,DELETE,MERGE
DDL - CREATE,ALTER,DROP,TRUNCATE
3. Shared pool:
Library cache: recently executed SQL & PL/SQL statements for reusing purpose.
(SELECT,INSERT,DELTE,UPDATE)
Data dictinoary cache or row cache: table- persons -its going to store the table definition or
called table structure.
Optimizer - oracle engine.. It generates the best execution plan based on available statistics..
1. Large pool : whenever you are taking backup & restore operations
3. Stream pool :Whenever we are using data replication from one server to other server.
shared server configuration is used very rare.. lot of performance issues will be there
nk buffer
8k default
2k
4k
16k
32k..
Process Strucut(CPU)
--------------------
Process Strucut(CPU) or Background processes:
Mandatory bg processes:
1) SMON - system monitor - it does the instance crash recovery based on the previous abnormal
shutdown.
2) PMON - process monitor - it cleans the PGA, it monitors the all procoesses
3) DBWR - database writer - it writes the dirty/modified blocks from db buffer cache to disk/datafiles
4) LGWR - log writer - it writes the redolog buffer into online redo log(ORL) files.
2. every 3 sec
log switch
5) CKPT - check point - updates the checkpoint information at controlfiles & datafiles headers.
Optinonal bg processes:
-----------------------
MMON - awr
C - controlfiel
Min - 1 - 10mb
Max - 8
Min - 2
D - Datafiles
USERS - here actually your company data / project data is going to store permanentily.
-> how to find how many databases are present in linux server.
cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# the entry. Lines beginning with a pound sign, '#', are comments.
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
# The first and second fields are the system identifier and home
# to the dbstart utility that the database should , "Y", or should not,
orcl:/u01/app/oracle/product/12.1.0/db_home:N
[oracle@primary ~]$
Western Union
Paypal -
rdp -
1. Using .bash_profile
2. By running . oraenv
ORACLE_SID = [oracle] ?
ORACLE_HOME = [/home/oracle] ?
orcl
/u01/app/oracle/product/12.1.0/db_home
/u01/app/oracle
Installation of Oracle Database:
================================
linux vm
SYS@orcl>show user
USER is "SYS"
SYS@orcl>
Note: "Connected to an idle instance" means, your instance is not running. its not running.
by giving "startup" command, its going to start your instance & opens the database.
*
ERROR at line 1:
Process ID: 0
SYS@orcl>
SYS@orcl>startup;
Database mounted.
Database opened.
STATUS
------------
OPEN
SYS@orcl>exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@primary ~]$ ps -ef | grep smon
[oracle@primary ~]$
----------------------------------------------------------------------------------------------
=====================================================
OS RHEL6
https://drive.google.com/open?id=1CQe_MZAusj0_VON_HuU9vprudtmJ9YHf
VMware:
https://drive.google.com/open?id=1YgczgGLTwLLn7BMR_2lpVaU7RTVr-aur
https://drive.google.com/open?id=0B_ZPVgETJCKnREdoYk9WbzBFOG8
database name you can give anything - not more than 8 characters
-> whenever you are going to create database, by default there must be one install created.
1. Standalone database
2. Cluster database - RAC - Real application cluster (SQL server - Always on)
----------------------------------------------------------------------------------------------
=============================================
STARTUP =
parameter_name = parameter_Value
spfile = /u01/app/oracle/product/12.1.0/db_home/dbs/spfileDEV.ora
db_name = orcl
instance_name = orcl
control_files = "......"
$ORACLE_HOME/dbs - linux/unix
$ORACLE_HOME/database - windows
Note: we are having something called dynamic parameters views related to paramter
values..V$PARAMETER; - 3000 (10-15)
ALTER SYSTEM SET <PARAMETER_NAME> = <PARAMETER_VALUE> SCOPE=both(default);
memory -> for the current running instance, the value is modifying at memory level
spfile -> for the next restart of the database, the valus modifying at spfile level
both(default) -> Memory + Spfile = Its modifying the value at memory level + sfile level.
381..
250 static
130 dynamic
ISSYS_MOD
---------
IMMEDIATE - Dynamic
FALSE - Static
DEFERRED - Dynamic
v$ views - 5000+
SYS@orcl>;
SYS@orcl>/
[oracle@localhost ~]$ cd
$ORACLE_BASE/diag/rdbms/db_name/instance_name/trace/alert_$ORACLE_SID.ora
============================
1. shutdown (normal) - default - client connection can not be disconnected and it waits until clients to
logout
2. shutdown transactional - if any DML is happening and user didnt do either commit/rollback, then it
wont shutdown until user to do eithr commit/rollback.
3. shutdown immediate - recommened by oracle - will not wait for idle sessions, & will not wait for
commit/rollback
4. shutdown abort - abnormal termination - it kills the instance before closing the database files. not
recommended.
5. startup force(restart) - abnormal termination - shutdown abort + startup (like restart) - not
recommened
shutdown or shut
SYS@orcl>shutdown
Database closed.
Database dismounted.
SYS@orcl>
SYS@orcl>startup (open)
Database opened.
SYS@orcl>
Connected to:
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SYS@orcl>
SYS@orcl>
SYS@orcl>select status from v$instance;
STATUS
------------
OPEN
SYS@orcl>shutdown
Database closed.
Database dismounted.
SYS@orcl>
SYS@orcl>
SYS@orcl>startup
Database mounted.
Database opened.
SYS@orcl>shutdown immediate
Database closed.
Database dismounted.
SYS@orcl>exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Startup modes:
--------------
startup nomount - 1
startup mount - 2
startup (open) - 3
SYS@orcl>startup
Database mounted.
Database opened.
SYS@orcl>
SYS@orcl>startup nomount;
STATUS
------------
STARTED
Database altered.
STATUS
------------
MOUNTED
SYS@orcl>alter database open;
Database altered.
ontrol01.ctl, /u01/app/oracle/
fast_recovery_area/orcl/contro
l02.ctl
SYS@orcl>
Note: The end user/client/customer/developer is able to connect to database only, if the database is in
OPEN state and not in NOMOUNT&MOUNT states.
SMON is the background process. it does the instance crash recovery by reading database
archive/online redolog files to apply commited data and to rollback uncomitted data.
startup
Alert.log file:
===============
database logfile is called as Alert.log file
alert_ORACLE_SID.log
C:\app\Administrator\diag\rdbms\orcl\orcl\trace
[oracle@server1 DEV]$ ls
alert cdump hm incident incpkg ir lck log metadata metadata_dgif metadata_pv stage sweep
trace
[oracle@server1 DEV]$
/u01/app/oracle/diag/rdbms/orcl/orcl/trace
[oracle@primary trace]$
alert_$ORACLE_SID.log
alert_orcl.log
==================
/u01/app/oracle/diag/rdbms/orcl/orcl/trace
each
Each server and background process can write to an associated trace file.
— Traces
— Alert log
Database Administration -
SELECT
INSERT
DELETE
UPDATE....
Join
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
kwsbgInitFmPMaster: MasterCreated
kwsbgInitFmPMaster: MasterCreated
=============================================================
--------------------------
Sessions
File states
Locks
Backup status
SQL execution
Statistics and metrics... etc
v$database,v$instance,V$datafile...etc
whenever you are going to create database, it contaisn 2 types of oracle system objects.
Dynamic data - dynamic performance views - you can see in nomount,mount and open state
Static data - Oracle Metadata - Oracle data dictionary views(sturcure) -= only open state
ALL_ views
B - t1,t2
tables
indexes
views
sequences
synonym
sschemas
...etc
size of schema
tablesapces names
users names
..etc
DICTIONARY
v$instance;
smon
everyday we are going to work with these metadata & dynamic views..
v$parameter
v$instance
v$database
v$datafile...etc