Advanced Oracle
Transcript of Advanced Oracle
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 1/109
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 2/109
Opera Global Technical Services
Oracle
Architectural
Components
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 3/109
Opera Global Technical Services
Architectural Components
There are several files, processes and memorystructures in an Oracle Server. Some of them areused when processing a SQL statement (ormanipulating an application like Opera).
Others are used to improve the performance of the
database, ensure that the database can be recoveredin the event of a software or hardware error, orperform other tasks necessary to maintain thedatabase.
The Oracle server consists of:
Oracle InstanceOracle database
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 4/109
Opera Global Technical Services
Oracle Server
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 5/109
Opera Global Technical Services
Oracle instance
A combination of background processes and memorystructures that access an Oracle database
Instance must be started before accessing thedatabase
Every time started, a System Global Area (SGA) isallocated and Oracle background processes arestarted
Background processes perform functions on behalf ofthe invoking process
They consolidate functions that would otherwise behandled by multiple Oracle programs running foreach user
Always opens one and only one database
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 6/109
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 7/109
Opera Global Technical Services
Oracle Database
The physical structure consists of 3 file types + otherfile structures
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 8/109
Opera Global Technical Services
Overview of Primary Components
System Global Area (SGA) Shared Pool
Library Cache
Data Dictionary Cache
Database Buffer Cache Redo Log Buffer Cache
Large Pool
Java Pool
Background Processes DBWn, PMON, CKPT, LGWR, SMON
Program Global Area (PGA)
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 9/109
Opera Global Technical Services
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 10/109
Opera Global Technical Services
Oracle
Storage
Structures
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 11/109
Opera Global Technical Services
Physical vs. Logical
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 12/109
Opera Global Technical Services
Datafiles
A datafile is a physical structure Can hold data for only one tablespace
Can resize dynamically
Space allocated upon creation
Opera database datafiles:System01.dbf, sysaux01.dbf, tempseg01.dbf,
undotbs01.dbf, findata01.dbf, finindx01.dbf,logdata01.dbf, logindx01.dbf, namedata01.dbf,
nameindx01.dbf, opera_data01.dbf,opera_indx01.dbf, oxi_data01.dbf, oxi_indx01.dbf,quickdata01.dbf, quickindx01.dbf, ratedata01.dbf,rateindx01.dbf, resvdata01.dbf, resvindx01.dbf,tools01.dbf
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 13/109
Opera Global Technical Services
Tablespaces
Largest logical unit
Can reside in one or more datafiles
May contain one or more segments
Can be taken offline
Can be made readonly (SYSREAD)
OPERA database tablespaces:
system, sysaux, tempseg, undotbs, findata,
finindx, logdata, logindx, namedata, nameindx,opera_data, opera_indx, oxi_data, oxi_indx,quickdata, quickindx, ratedata, rateindx, resvdata,resvindx, tools
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 14/109
Opera Global Technical Services
Logical Overview
SEGMENTS Second largest logical unit Can belong to only one tablespace, but can reside in
multiple datafiles Is made up of one or more extents
EXTENTS Third largest logical unit Can belong to only one segment and cannot spawn datafiles Is made up of contiguous Oracle BlocksWhen segments grow, new extents are added
BLOCKS Smallest logical unit Can belong to only one extent Corresponds to one or more operating system blocks DB_BLOCK_SIZE=8m in OPERA
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 15/109
Opera Global Technical Services
Storage
Structures
In Depth
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 16/109
Opera Global Technical Services
Storage Relationships
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 17/109
Opera Global Technical Services
Types of Segments
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 18/109
Opera Global Technical Services
Storage Clause Precedence
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 19/109
Opera Global Technical Services
Extent Allocation/Deallocation
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 20/109
Opera Global Technical Services
Block Contents
Header Top of the block
Data block address
Table directory
Row directory
Transaction slots
Free Space Middle of the block
Data
Bottom of the block
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 21/109
Opera Global Technical Services
Automatic Space Management
Automatic segment-space management can only beenabled at the tablespace level for locally managedtablespaces:
CREATE TABLESPACE "OPERA_DATA" LOGGING DATAFILE'G:\oracle\oradata\QA10\OPERA_DATA01.dbf' SIZE 512M AUTOEXTEND ON NEXT 100M MAXSIZE 4096M,'G:\oracle\oradata\QA10\OPERA_DATA02.dbf' SIZE 5M AUTOEXTEND ON NEXT 100M MAXSIZE 4096M EXTENT
MANAGEMENT LOCAL UNIFORM SIZE 1M SEGMENT SPACEMANAGEMENT AUTO ;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 22/109
Opera Global Technical Services
Storage Information
Information about storage can be obtained byquerying the following:
DBA_EXTENTS
DBA_SEGMENTS
DBA_DATA_FILES
DBA_FREE_SPACE
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 23/109
Opera Global Technical Services
UNDO
Management
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 24/109
Opera Global Technical Services
Managing UNDO Data
Automatic:Introduced in 9i
Uses undo segments
System rollback segment
Cannot store any other objects
Extents are locally managed
Manual:Only option for 8i
Uses rollback segments
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 25/109
Opera Global Technical Services
Managing UNDO Data
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 26/109
Opera Global Technical Services
Read Consistency
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 27/109
Opera Global Technical Services
Transaction Rollback
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 28/109
Opera Global Technical Services
Automatic UNDO Management
Configure parameters in the initialization file:
####################################### System Managed Undo and Rollback Segments######################################
undo_management=AUTOundo_tablespace_UNDOTBS1undo_retention=3600
Create at least one Undo tablespace
SYSTEM: Used in the SYSTEM tablespace Non-SYSTEM: Used by other tablespaces Auto: Uses UNDO tablespaceManual: Uses Rollback Segments
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 29/109
Opera Global Technical Services
UNDO Tablespaces
Only one Undo tablespace can be assigned to adatabase at a time
Can have more than one undo tablespace, but onlyone tablespace will be active
Switch active undo tablespace using the followingcommand: ALTER SYSTEM SET UNDO_TABLESPACE=undotbs2;
RAC databases have one undo tablespace per
instance
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 30/109
Opera Global Technical Services
UNDO Information
Information about undo segments can beobtained by querying the following:
DBA_ROLLBACK_SEGS V$ROLLNAME
V$ROLLSTAT
V$UNDOSTAT
V$TRANSACTION
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 31/109
Opera Global Technical Services
Managing
Tables
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 32/109
Opera Global Technical Services
Table Storage Options
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 33/109
Opera Global Technical Services
Structure of a Row
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 34/109
Opera Global Technical Services
Row Migration and Chaining
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 35/109
Opera Global Technical Services
Creating Tables
CREATE TABLE employee(id NUMBER(8) NOT NULL, last_name VARCHAR2(30))TABLESPACE userdata;
CREATE TABLE emp AS SELECT * FROM
employee;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 36/109
Opera Global Technical Services
Creating Temporary Tables
Contain session private data held by the duration ofthe transaction or session
CREATE GLOBAL TEMPORARY TABLE test
ON COMMIT PRESERVE|DELETE ROWS AS SELECT * FROM name;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 37/109
Opera Global Technical Services
Moving Tables
Non-partitioned tables can be moved to anothertablespace with the following statement:
ALTER TABLE test MOVE TABLESPACE tools;
Useful for reorganizing and eliminating row migration
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 38/109
Opera Global Technical Services
Truncating Tables
TRUNCATE TABLE test;
Deletes all rows
Truncate its indexes
Delete triggers are not firedNo undo is generated
A table referenced by a foreign key can not betruncated
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 39/109
Opera Global Technical Services
Dropping Tables
DROP TABLE test CASCADE CONSTRAINTS;
Extents released
CASCADE CONSTRAINTS option must be used if thetable is being referenced by a foreign key
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 40/109
Opera Global Technical Services
Dropping Columns
ALTER TABLE test DROP COLUMN commentsCASCADE CONSTRAINTS CHECKPOINT 1000;
All data from the column is removed
CHECKPOINT command can be used to minimizeundo usage (expressed in number of rows)
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 41/109
Opera Global Technical Services
Drop Column, UNUSED option
ALTER TABLE test SET UNUSED COLUMN commentsCASCADE CONSTRAINTS;
Data is not removed
Column becomes „invisible‟ Unused columns can be dropped with the
following command:
ALTER TABLE test DROP UNUSED COLUMNcomments CHECKPOINT 1000;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 42/109
Opera Global Technical Services
Table Information
Information about tables can be obtained byquerying the following:
DBA_TABLES
DBA_OBJECTS
DBA_TAB_COLUMNS
DBA_TAB_COMMENTS
DBA_COL_COMMENTS
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 43/109
Opera Global Technical Services
Managing
Indexes
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 44/109
Opera Global Technical Services
Index Classifications
LogicalSingle column or concatenated
Unique or nonunique
Function-based
DomainPhysicalPartitioned or nonpartitioned
B-tree (normal or reverse key)
Bitmap
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 45/109
Opera Global Technical Services
B-Tree Index
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 46/109
Opera Global Technical Services
Bitmap Index
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 47/109
Opera Global Technical Services
B-Tree vs. Bitmap
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 48/109
Opera Global Technical Services
Creating Indexes
Balance query and DML operations Place in separate tablespace
Use uniform extent sizes
NOLOGGING option for large indexes
CREATE [BITMAP] INDEX index_name ONtable_name(column [ASC|DESC], [column…])[TABLESPACE tablespace_name] [NOSORT][storage_clause][LOGGING|NOLOGGING];
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 49/109
Opera Global Technical Services
Managing Indexes
Moving the index to a new tablespace: ALTER INDEX index_name REBUILD TABLESPACE
tablespace_name;
Rebuilding an index online:
ALTER INDEX index_name REBUILD ONLINE; Reducing fragmentation:
ALTER INDEX index_name COALESCE;
Dropping an index:
DROP INDEX index_name;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 50/109
Opera Global Technical Services
Index Information
Information about indexes can be obtained byquerying the following:
DBA_INDEXES
DBA_IND_COLUMNS
DBA_IND_EXPRESSIONS
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 51/109
Opera Global Technical Services
DataIntegrity
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 52/109
Opera Global Technical Services
Data Integrity
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 53/109
Opera Global Technical Services
Types of Constraints
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 54/109
Opera Global Technical Services
Constraint States
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 55/109
Opera Global Technical Services
EXCEPTIONS Table
Create the table running the utlexcpt1.sql script Enable the constraint:
ALTER TABLE table_name ENABLE VALIDATECONSTRAINT constraint_name EXCEPTIONS INTO
system.exceptions; Use a subquery to find the offending rows:
SELECT * FROM table_name WHERE ROWID IN(SELECT ROWID FROM exceptions);
Modify the data with DML and re-enable theconstraint
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 56/109
Opera Global Technical Services
Constraint Checking
Constraints can be setup as immediate ordeferred
Deferred constraintsuseful when both
parent and child keysare entered at the sametime
ALTER SESSION SET
CONSTRAINTS to makeconstraints immediateor deferred
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 57/109
Opera Global Technical Services
Foreign Key Guidelines
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 58/109
Opera Global Technical Services
Constraint Information
Information about constraints can be obtained byquerying the following:
DBA_CONSTRAINTS
DBA_CONS_COLUMNS
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 59/109
Opera Global Technical Services
DataDictionary
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 60/109
Opera Global Technical Services
Redo Logs
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 61/109
Opera Global Technical Services
Redo Logs
Record all changes made to data Provides a means to recover the database
Can be organized into groups (multiplexing)
Minimum of two groups required
d k
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 62/109
Opera Global Technical Services
How Redo Logs Work
Written in a cyclic fashionWhen one group is full LGWR moves to the next
group
Log switch and checkpoint occurs
d f
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 63/109
Opera Global Technical Services
Redo Log Information
Information about the redo logs can be obtained byquerying the following:
V$LOG
V$LOGFILE V$LOGHIST
V$BACKUP_REDOLOG
A hi d R d L
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 64/109
Opera Global Technical Services
Archived Redo Logs
Filled online redo logs can be archived The two advantages are:
A backup of the datafiles + redo logs + archivelogs can be used to restore the database up to the
last committed transaction.The backup can be made online.
When running in ARCHIVELOG mode a redo log filecannot be overwritten until
Checkpoint has completedRedo Log has been archived
By default the database is created in NOARCHIVELOGmode
A hi P
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 65/109
Opera Global Technical Services
Archive Parameters
Archiving uses the ARCn background process to writethe redo logs to archive
initOPERA.ora archive parameters:
#log_archive_dest_1 =
"location=D:\oracle\admin\opera\archivemandatory REOPEN=120"
#log_archive_format=ARC%S_%R.%T
E bl A hi i
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 66/109
Opera Global Technical Services
Enable Archiving
Set initOPERA.ora archiving parametersMount the database in exclusive mode
D:\ >sqlplus “sys/opera10g as sysdba”
SQL>Startup mount exclusive
Set the database in ARCHIVELOG modeSQL>ALTER DATABASE ARCHIVELOG;
Startup the database
SQL>ALTER DATABASE OPEN;
Di bl A hi i
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 67/109
Opera Global Technical Services
Disable Archiving
Remove initOPERA.ora archiving parametersMount the database in exclusive mode
D:\ >sqlplus “sys/opera10g as sysdba”
SQL>Startup mount exclusive
Set the database in NOARCHIVELOG modeSQL>ALTER DATABASE NOARCHIVELOG;
Startup the database
SQL>ALTER DATABASE OPEN;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 68/109
Opera Global Technical Services
Tablespaces
AndDatafiles
T bl d D t fil
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 69/109
Opera Global Technical Services
Tablespaces and Datafiles
All objects in the database are stored logically inTABLESPACES and physically in DATAFILES
TABLESPACES:- Belong to only one Database- Consist of one or more Datafiles
- Are divided in Segments, Extents and Blocks DATAFILES
- Belong to only one Tablespace- Physical files on the operating system
L ll M d T bl
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 70/109
Opera Global Technical Services
Locally Managed Tablespaces
Reduced contention on the data dictionary No undo data generation when space allocation or
deallocation occurs No coalescing required UNIFORM sized extents are more reusable
CREATE TABLESPACE opera_data DATAFILE „g:\oracle\oradata\opera\ opera_data01.dbf‟ SIZE512M AUTOEXTEND ON NEXT 100M MAXSIZE 2048MEXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
SEGMENT SPACE MANAGEMENT AUTO;
Di ti M d T bl
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 71/109
Opera Global Technical Services
Dictionary Managed Tablespaces
Extents managed in the data dictionary Each segment may have a different storage clause
Coalescing required
CREATE TABLESPACE opera_data DATAFILE „g:\oracle\oradata\opera\ opera_data01.dbf‟ SIZE512M EXTENT MANAGEMENT DICTIONARY DEFAULTSTORAGE (initial 1M NEXT 1M PCTINCREASE 0);
T T bl
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 72/109
Opera Global Technical Services
Temporary Tablespace
Used for sort operations Cannot store any permanent objects Locally managed extents Tempfiles are always NOLOGGING
CREATE TEMPORARY TABLESPACE tempseg TEMPFILE‘g:\oracle\oradata\opera\temp01.dbf’ SIZE 512MEXTENT MANAGEMENT LOCAL UNIFORM SIZE 4M;
Default temporary tablespace define at database creation. Can change the default temporary tablespace
ALTER DATABASE DEFAULT TEMPORARY TABLESPACEtempseg;
Cannot be taken offline or dropped until a new temporarytablespace is available
R d O l T bl
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 73/109
Opera Global Technical Services
Read Only Tablespace
The following command makes a tablespace readonly:
ALTER TABLESPACE sys_read READ ONLY;
This causes a checkpoint
Data within the tablespace is available only forSelects
Objects can be dropped
SYS_READ tablespace
R i i T bl
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 74/109
Opera Global Technical Services
Resizing Tablespaces
ALTER DATABASE ALTER TABLESPACE
Can change the size of a tablespace by:
Alter the size of the datafile
Alter the datafile to have AUTOEXTEND turned on
Add a datafile
ALTER DATABASE DATAFILE „g:\oracle\oradata\opera\ opera_data01.dbf‟ RESIZE 4096m;
ALTER DATABASE DATAFILE
„g:\oracle\oradata\opera\ opera_data01.dbf‟ AUTOEXTEND ONNEXT 100m MAXSIZE 4096m;
ALTER TABLESPACE opera_data ADD DATAFILE „g:\oracle\oradata\opera\ opera_data02.dbf‟ size 2048m;
Mo ing o Renaming Datafiles
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 75/109
Opera Global Technical Services
Moving or Renaming Datafiles
Shutdown the database Physically on the OS move the datafile
Startup mount the database
Execute: ALTER DATABASE DATAFILE
„g:\oracle\oradata\opera\ opera_data01.dbf‟ TO „h:\oracle\oradata\ opera_data01.dbf‟;
Open the database
Tablespace Information
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 76/109
Opera Global Technical Services
Tablespace Information
Information about tablespaces and datafiles can beobtained in the following views: TablespacesDBA_TABLESPACES V$TABLESPACE
DatafilesDBA_DATA_FILES V$DATAFILE
Temporary files
DBA_TEMP_FILES V$TEMPFILE
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 77/109
Opera Global Technical Services
Networking
Oracle Net Services
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 78/109
Opera Global Technical Services
Oracle Net Services
Oracle 9i/10g Standard
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 79/109
Opera Global Technical Services
Oracle 9i/10g Standard
Oracle RAC Option
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 80/109
Opera Global Technical Services
Oracle RAC Option
Oracle Net Models
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 81/109
Opera Global Technical Services
Oracle Net Models
Locally Managed:Files reside on each computer
listener.ora (server)tnsnames.ora (client)sqlnet.ora (server and client)
Centrally Managed:LDAP directory server
ldap.ora (server and client)Oracle Names server
names.ora (server and client)
Opera Local Naming
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 82/109
Opera Global Technical Services
Opera Local Naming
Establishing a Connection
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 83/109
Opera Global Technical Services
Establishing a Connection
Default Listener Parameters
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 84/109
Opera Global Technical Services
Default Listener Parameters
Listener Contents
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 85/109
Opera Global Technical Services
Listener Contents
Listener contains the following entries:Listener‟s name
Protocol addresses that it is accepting connectionrequests on
Services it is listening forControl parameters
Dynamic Service Registration
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 86/109
Opera Global Technical Services
Dynamic Service Registration
Initialization file contains the following entries:SERVICE_NAMES
INSTANCE_NAME
LOCAL_LISTENER for non-default listener
REMOTE_LISTENER for RAC
LSNRCTL Utility
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 87/109
Opera Global Technical Services
LSNRCTL Utility
Listener Control Utility enables manupulation of thelistener through the command line
LSNRCTL> command_name LSNRCTL> help
The following operations are available
An asterisk (*) denotes a modifier or extended command:
start stop statusservices version reloadsave_config trace change_passwordquit exit set*
show*
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 88/109
Opera Global Technical Services
Cost
BasedOptimizer
Query Optimization
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 89/109
Opera Global Technical Services
Query Optimization
A query is a non-procedural request of informationfrom the database. To process a query the kernel hasto characterize the retrieval strategy or formulate anexecution plan for fetching the candidate rows.Typically, to execute a query, several execution plansmay be feasible. For example, tables participating in
a join could be processed in a number of differentorders depending on the join conditions and the joinmethods implemented in the kernel. To choosebetween alternative plans, the kernel must use somerealistic unit to measure the resources used by each
plan. It can then choose between competing plans onthe basis of costs and discard all except the onewhich consumes the least.
Cost Based Optimizer
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 90/109
Opera Global Technical Services
Cost Based Optimizer
Oracle addresses query optimization by incorporatinga Cost Engine in the kernel to estimate and selectexecution plans on the basis of costs.
Costs quantify the resource consumption of thequery.
Resources used by a query can be broken into threeprincipal parts I/O cost
CPU Costs
Network Costs
Cost Based vs Rule Based
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 91/109
Opera Global Technical Services
Cost Based vs. Rule Based
The RBO has a set number of rules that SQL uses tocreate an execution plan. For example: The RBOdesignates whether an index is used/not used orwhich table in the FROM clause should be theprimary table in a union. There are approximately 16
different rules from which the RBO can choose. The CBO operates very differently from the RBO.
CBO uses actual table statistics to determine the bestexecution plan. These statistics are gathered runningGather Schema Statistics.
Analyze Objects
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 92/109
Opera Global Technical Services
Analyze Objects
To enable costing of execution plans, detailedstatistical descriptions of the data relating to objectsin the query is required. The statistics are generatedby the ANALYZE facility.
There are two modes in which analyze may be
performed COMPUTE
Compute scans each member of the object
ESTIMATEEstimate mode looks at a sample of the total.
If there are no statistics, then the cost optimizer useshardcoded estimates or "guesses".
Gather Statistics Command
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 93/109
Opera Global Technical Services
Gather Statistics Command
executedbms_stats.gather_database_stats(options=>'GATHER',estimate_percent=>dbms_stats.auto_sample_size,method_opt=> 'FOR ALL COLUMNS SIZE AUTO',cascade=>true);
GATHER STATS JOB
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 94/109
Opera Global Technical Services
GATHER_STATS_JOB
GATHER_STATS_JOB runs every night at midnight togather stale statistics
Verify the job by viewing the DBA_SCHEDULER_JOBSview:
SELECT * FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME= 'GATHER_STATS_JOB';
Verify statistics in a schema are current by queryingLAST_ANALYZED column in dba_tables select distinct(last_analyzed), owner from dba_tables;
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 95/109
Opera Global Technical Services
Daylight
SavingsTime
DST Changes
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 96/109
Opera Global Technical Services
DST Changes
The Energy Policy Act of 2005 was signed into law in August 2005 to extend daylight saving time.
Beginning in 2007, daylight saving time in the U.S. willbegin on the second Sunday in March and end the firstSunday in November rather than beginning on the first
Sunday in April and ending the last Sunday in October, asit did in the past.
Under the new rules for 2007, DST will start on March 11,2007 end on November 04, 2007. As a result the database
may report incorrect time zone data between 03/11/2007 – 04/01/2007 and between 10/28/2007 – 11/04/2007 (andon different dates in subsequent years), unless therequired patches are applied.
What is the database timezone?
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 97/109
Opera Global Technical Services
What is the database timezone?
The database time zone is not as important as it sounds. First ofall it does not influence functions like sysdate, or systimestamp.These function take their contents (date and time, and in thecase of systimestamp also time zone) completely from the OSwithout any "Oracle" intervention.
The only function of the database time zone is that it functionsas a time zone in which the values of the "TIMESTAMP WITHLOCAL TIME ZONE" (TSLTZ) datatype are normalized when theyare stored in the database.
However, these values are always converted into the sessiontime zone on insert and retrieval, so the actual setting of thedatabase time zone is more or less immaterial.
DST Patch
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 98/109
Opera Global Technical Services
DST Patch
Who needs the DST patch?ONLY locations where the database is not in the
same time zone as the hotel would beaffected. Mostly larger sites will be impacted, like
Candlewood datacenter. All sites just need tomake sure they have the OS patches/updatesapplied.
The patch is applied to the database. It replaces twofiles and requires the database to be restarted.
The patch is included in the Micros 403 database CD.
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 99/109
Opera Global Technical Services
OPERA_SMT
Opera SMT Command Line
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 100/109
Opera Global Technical Services
Opera_SMT Command Line
SMT now supports command line Command Line Functionality:
COMPILE to compile a schema
EXPORT to export a schema
IMPORT to import a schema - (requires SYSpassword!)
EPATCH to run scripts against a schema
ANALYZE to analyze schema (Oracle 10g only) -
(requires SYS password!)
SMT Command Line Syntax
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 101/109
Opera Global Technical Services
SMT Command Line Syntax
opera_smt /cmd=<command>[;<command options>]
<command> ::= ['COMPILE', 'EXPORT', 'IMPORT', 'SYNONYM','EPATCH', 'ANALYZE']
<command option> ::= <parameter>=<value>
<parameter> ::= ['USR','PWD','ODB','SYPWD','LOG','O9I','ZIP','TBS','OPU','OPP','OPD','OXU','OXP','OXD','SIL','SYN','DBG']
SMT Command Line Parameters
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 102/109
Opera Global Technical Services
SMT Command Line Parameters
USR: Oracle UserName/SchemaName PWD: Oracle Schema/User Password ODP: Oracle Database Alias (as specified in TNSnames.ora) SYPWD: SYS password LOG: Log file name (always overwritten) O9I: <Y, N> Use 9i export utility (only for import into 9i database) ZIP: <Y, N> Create selfextracting Archive on export TBS: Tablespace for imported schema OPU: Opera Schema UserName (on Import if imported schema is
OXI/OXIHUB) OPP: Opera Schema Password (on Import if imported schema is
OXI/OXIHUB) OPD: Opera Schema Alias (on Import if imported schema is
OXI/OXIHUB) SIL: <Y, N> Silent mode, no output on command window DBG: <Y, N> Debug mode
SMT Command Line Examples
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 103/109
Opera Global Technical Services
SMT Command Line Examples
Compile Opera Schema opera_smt
/cmd=compile;usr=opera;pwd=opera;odb=opera;log=smt_compile.log
Compile Opera Schema and refresh all synomyms opera_smt
/cmd=compile;usr=opera;pwd=opera;odb=opera;log=smt_compil
e.log;syn=y Export Opera Schema
opera_smt /cmd=export;usr=opera;pwd=opera;odb=opera;zip=n;log=smt_export.log /id:\export\opera\opera.dmp
Import Opera Schema
opera_smt /cmd=import;usr=newopera;pwd=newopera;odb=opera;sypwd=******;log=smt_import.log /id:\export\opera\opera.dmp
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 104/109
Opera Global Technical Services
OPERAInformation
OPERA Commands
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 105/109
Opera Global Technical Services
OPERA Commands
sqlplus opera/opera Select * from installed_app;
select license_code from installed_app_licenses;
ALTER USER user_name IDENTIFIED BY
new_password; DROP USER user_name [CASCADE];
OPERA File Locations
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 106/109
Opera Global Technical Services
OPERA File Locations
alertOPERA.logG:\oracle\admin\opera\bdump
Arvhive logsD:\oracle\admin\opera\archive
Control FilesD:\oracle\oradata\opera\control01.ctlG:\oracle\oradata\opera\control02.ctl
OPERA datafiles:\oracle\oradata\opera\<datafile_name>.dbf
Character Set
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 107/109
Opera Global Technical Services
Character Set
UTF8 Unicode Varying width multibyte US7ASCII characters (A-Z,a-Z,0-1 and ./?,*# etc..) are in
UTF8 1 byte, so for most West european languages theimpact is rather limited as only "special" characters like ç, ñ ,
é will use more bytes then in a 8 bit characterset.
Information about NLS settings can be obtained byquerying the following: NLS_DATABASE_PARAMETERS
NLS_INSTANCE_PARAMETERS NLS_SESSION_PARAMETERS V$NLS_VALID_VALUES
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 108/109
Opera Global Technical Services
Questions Answers
8/11/2019 Advanced Oracle
http://slidepdf.com/reader/full/advanced-oracle 109/109