Oracle Architecture
Oracle Architecture
Database Creation
1. Decide where to store pfile, Datafile, Controlfile and Redo log file. For example here we decide to store those file
in C:\
2. Create the folder in the following orders
8. Database Creation
SQL> create database dba1
controlfile reuse
logfile
group 1
('C:\oracle\product\10.2.0\oradata\dba1\redo1a.log',
'C:\oracle\product\10.2.0\oradata\dba1\redo1b.log') size 5m,
group 2
('C:\oracle\product\10.2.0\oradata\dba1\redo2a.log',
'C:\oracle\product\10.2.0\oradata\dba1\redo2b.log') size 5m
maxlogfiles 4
maxlogmembers 2
maxdatafiles 5
maxinstances 2
maxloghistory 0
datafile 'C:\oracle\product\10.2.0\oradata\dba1\system01.dbf' size 100
SYSAUX
datafile 'C:\oracle\product\10.2.0\oradata\dba1\sysaux01.dbf' size 50m
undo tablespace UNDOTBS1
datafile 'C:\oracle\product\10.2.0\oradata\dba1\utable01.dbf' size 10m
default temporary tablespace temp
tempfile 'C:\oracle\product\10.2.0\oradata\dba1\temp01.dbf' size 10m
character set we8iso8859p1;
Database created.
Maxlogfiles: maximum number of redo log groups that can be created for the database.
Maxlogmembers: maximum number of members for each group.
Maxdatafiles: Maximum number of datafile that can be created.
Maxinstances: The number of instances that can access a database concurrently.
Maxloghistory: specifies the maximum number of redo log files that can be recorded in the log history of the control
file.
9. Executing Scripts
SQL>@C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\catalog.sql
SQL>@C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\catprc.sql
SPFILE:
SPFILE is a binary file which can not be modified by text editor. It is created from PFILE.
SPFILE advantages
1. No need to restart the database in order to have a parameter changed and the new value stored in the
initialization file
2. Reduce human errors: Parameters are checked before changes are accepted
3. An SPFILE can be backed-up with RMAN (RMAN cannot backup PFILEs)
This could be done in order to have a backup in the other format or to change the initialization file for the
database instance.
Archivelog
Check the Database in an Archive Log Mode or Not
>ARCHIVE LOG LIST
>STARTUP MOUNT
>STARTUP FORCE;
Manual Archiving:
>STARTUP FORCE;
>STARTUP FORCE;
Local Disk
Remote Location
> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1="LOCATION=C:\oracle\product\10.2.0\
icelog_dba12\Location_1" SCOPE=SPFILE;
>STARTUP FORCE;
LOG_ARCHIVE_DEST_n Options
> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2="LOCATION=C:\oracle\product\10.2.0\
>STARTUP FORCE;
Dynamic Views
1. V$ARCHIVED_LOG: Displays archived log information from the control file;
2. V$ARCHIVE_DEST: For the Current instance, describes all archive log destinations, the current value
and status
FROM v$archive_dest;
Controlfile
Control Files:
The control files of a database store the status of the physical structure of the database.
C:\oracle\product\10.2.0\oradata\dba01\CONTROL01.CTL',
'C:\oracle\product\10.2.0\oradata\dba01\CONTROL02.CTL',
'C:\oracle\product\10.2.0\oradata\dba01\CONTROL03.CTL',
'C:\oracle\product\10.2.0\oradata\dba01\CONTROL04.CTL'
SCOPE=spfile;
2. SQL> shutdown;
3. C:\>copy C:\oracle\product\10.2.0\oradata\dba01\CONTROL01.CTL
C:\oracle\product\10.2.0\oradata\dba01\CONTROL04.CTL
4. startup;
1. shutdown
2. C:\>copy C:\oracle\product\10.2.0\oradata\dba01\CONTROL01.CTL
C:\oracle\product\10.2.0\oradata\dba01\CONTROL04.CTL
control_files='C:\oracle\product\10.2.0\oradata\dba01\control01.ctl','C:\
oracle\product\10.2.0\oradata\dba01\control02.ctl','C:\oracle\product\10.
2.0\oradata\dba01\control03.ctl','C:\oracle\product\10.2.0\oradata\dba01\
control04.ctl'
4. startup pfile=’C:\oracle\product\10.2.0\admin\dba01\pfile\init.ora';
Data Files
The Following Tablespaces exists in Oracle 10g Database:
SYSTEM Tablespace
SYSAUX Tablespace
All major database systems include something called a Data Dictionary. A Data Dictionary describes
the contents of the database. Which tables do I own? What columns are in those tables? Do I have
permissions to view other tables? Do these tables have indexes? Where these tables are physically
located? What code runs when I execute a stored procedure? The Data Dictionary contains the answer
to all of these questions and more. System Tablespace contain these data dictionary.
SYSAUX Tablespace:
SYSAUX is the name of the compulsory tablespace, introduced in Oracle 10g, to support optional
database components (called occupants) like AWR, Statspack, Oracle Streams, etc.
TEMPORARY Tablespace:
Temporary Tablespace are used to store short life span data. For example: sort result.
UNDO Tablespace:
UNDO Tablespace used for capturing “old imeage” date for rollback.
USER Tablespace:
A default user tablespace allows defining a tablespace that will be the default tablespaces for users
created objects.
In oracle 10g big file tablespaces can be created. Bigfile tablespaces are built on a single datafile (or
temp file), which can be as many as 2^32data blocks in size. So, a bigfile tablespace that uses 8KB
data blocks can be as much as 32TB in size.
It is usually use in very large database. When there is very large database with thousand of datafile,
then it will take long time for updating datafile header, such as checkpoint.
In smallfile tablespace Each datafile can be as many as 2^22 data blocks in size. So datafiles in a
smallfile tablespace that uses 8KB data blocks are limited to 32GB. The smallfile tablespace can have
as many as 1,022 datafiles Tablespace created.
Tablespace created.
Using Locally Managed Tablespace, each tablespace manages its own free and used space within a
bitmap structure stored in one of the tablespace's data files.
When creating a locally managed tablespace, you can specify the extent allocation method to be used.
UNIFORM - specifies that the extent allocation in the tablespace is in a fixed uniform size. The
extent size can be specified in M or K. The default size for UNIFORM extent allocation is 1M. Using
uniform extents usually minimizes fragmentation and leads to better overall performance
Locally managed tablespaces have the following advantages over dictionary-managed tablespaces:
Local management of extents tracks adjacent free space, eliminating coalescing free extents.
Reliance on data dictionary is reduced. This minimizes access to the data dictionary,
potentially, improving performance and availability.
For a tablespace that uses the data dictionary to manage its extents, the Oracle server updates the
appropriate tables in the data dictionary whenever an extent is allocated or dealloated.
The storage setting for dictionary managed tablespaces can be altered but locally managed tablespace
can not be altered.
DEFAULT STORAGE (
INITIAL 2M
NEXT 2M
MAXEXTENT 999);
------------------------------ ------------------------------
SYS TEMP
After database creation, a default temporary tablespace can be set by creating a temporary tablespace
and then altering the database
1. SYSTEM Tablespace
2. SYSAUX Tablespae
3. Default Temporary Tablespace
4. Tablespace with active undo segment
Dropping Tablespaces:
RENAME
DATAFILE ‘/u01/oradata/userdata01.dbf’
TO ‘/u01/oradata/userdata/userdata01.dbf’;
Or
FILE ‘/u01/oradata/system01.dbf’
TO ‘/u03/oradata/system01.dbf’;
o Tablespace Information
DBA_TABLESPACES
V$TABLESPACES
DBA_USERS
DBA_DATA_FILES
V$DATAFILE
DBA_TEMP_FILES
V$TEMPFILE
Redo Log file contains any changes made to the data in database buffer cache. Every database should
have at least two redolog files groups.
Check Redo Log file Status:
GROUP# STATUS
---------- ----------------
1 CURRENT
2 INACTIVE
3 INACTIVE
Name Meaning
USED Indicates either that a log has just been added but never used.
CURRENT Indicates a valid log that is in use.
ACTIVE Indicates a valid log file that is not currently in use.
CLEARING Indicates a log is being re-created as an empty log due to DBA
action.
CLEARING Means that a current log is being cleared of a closed thread. If a log
CURRENT stays in this status, it could indicate there is some failure in the log
switch.
INACTIVE Means that the log is no longer needed for instance recovery but
may be needed for media recovery.
The v$logfile table has a status indicator that gives these additional codes:
Name Meaning
INVALID File is inaccessible.
STALE File contents are incomplete (such as when an instance is shut down
with SHUTDOWN ABORT or due to a system crash).
DELETED File is no longer used.
Null File in use.
'C:\oracle\product\10.2.0\oradata\dba12\REDO04.LOG'
SIZE 10M;
'C:\oracle\product\10.2.0\oradata\dba12\REDO04b.LOG' TO GROUP 4;
GROUP# MEMBER
-------------------------------------------------------------
3 C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA12\REDO03.LOG
2 C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA12\REDO02.LOG
1 C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA12\REDO01.LOG
4 C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA12\REDO04.LOG
4 C:\ORACLE\PRODUCT\10.2.0\ORADATA\DBA12\REDO04B.LOG
'C:\oracle\product\10.2.0\oradata\dba12\REDO04B.LOG';
1. SQL>SHUTDOWN;
2. Copy the redo log file in new location.
3. SQL> STARTUP MOUNT;
4. SQL> ALTER DATABASE RENAME
FILE 'C:\oracle\product\10.2.0\oradata\dba12\REDO01.LOG'
TO 'C:\oracle\product\10.2.0\oradata\dba12\redologfile\REDO01.LOG';
Forcing Checkpoint:
Data Pump
SQL> CREATE DIRECTORY dpump AS 'C:\Dpump';
FROM all_directories
WHERE directory_name = 'DPUMP’;
Table Export/Import:
Remap Schema
DATA_ONLY loads only table row data into existing tables; no database objects are
created.
Schema Exports/Imports
Remap Schema
Remap Tablespace
Database Exports/Imports
FULL=Y REMAP_SCHEMA=system:system
Tablespace Exports/Imports
H:\>EXPDP 'sys/sys as sysdba' DIRECTORY= dpump DUMPFILE=TUSERS.DMP
LOGFILE=EXTUS.LOG TABLESPACES=USERS
The TABLE_EXISTS_ACTION parameter for Data Pump impdp provides four options:
1. SKIP is the default: A table is skipped if it already exists.
2. APPEND will append rows if the target table’s geometry is compatible. This is the default when
the user specifies CONTENT=DATA_ONLY.
3. TRUNCATE will truncate the table, and then load rows from the source if the geometries are
compatible and truncation is possible. For example, it is not possible to truncate a table if it is the
target of referential constraints.
4. REPLACE will drop the existing table, then create and load it from the source.
Username: scott
Password:
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Table created.
Table dropped.
C:\>imp
Username: scott
Password:
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Flashback
Flashback Database
Flashback Database is faster than traditional point-in-time recovery. Traditional recovery uses redo log files and backu
Flashback Database is implemented using a new type of log file called Flashback Database logs. The Oracle database se
periodically logs before images of data blocks in the Flashback Database logs. The data block images are used to quic
back out changes to the database during Flashback Database.
When Flashback Database is enabled, a new RVWR background process is started. This process is similar to the LG
(log writer) process. The new process writes Flashback Database data to the Flashback Database logs.
- db_recovery_file_dest
- db_recovery_file_dest_size
3. Open the database in MONT mode and turn on the flashback feture:
SQL> STARTUP MOUNT;
OR
Another Example:
Creating a Role: M
create role clerk; R
CERTIFICATIONS
Assign Privilege to role:
Drop a Role:
DBA__ROLES
DBA_ROLES_PRIVS
ROLE_ROL_PRIVS
DBA_SYS_PRIVS
ROLE_SYS_PRIVS
ROLE_TAB_PRIVS
SESSION_ROLES
EMPLOYMENT HISTORY
PUBLICATIONS
STUDY RESOURCES
TRAINING
TECHNICAL DOCS
O ORACLE
O TERADATA
O MYSQL
O SQL SERVER
O LINUX
O AWS
OTHER
CONTACT