Oracle Manual Database Creation Script in Linux



CREATE DATABASE SAMPLEDB
    USER SYS IDENTIFIED BY YourPassword
    USER SYSTEM IDENTIFIED BY YourPassword
   LOGFILE       GROUP 1 ('/your/local/path/redo01a.log','/your/local/path/redo01b.log') SIZE 100M BLOCKSIZE 512,
              GROUP 2 ('/your/local/path/redo02a.log','/your/local/path/redo02b.log') SIZE 100M BLOCKSIZE 512,
              GROUP 3 ('/your/local/path/redo03a.log','/your/local/path/redo03b.log') SIZE 100M BLOCKSIZE 512
       ARCHIVELOG
      CHARACTER SET AL32UTF8
   NATIONAL CHARACTER SET AL16UTF16
      EXTENT MANAGEMENT LOCAL
   DATAFILE '/your/local/path/system01.dbf' SIZE 325M REUSE
   SYSAUX DATAFILE '/your/local/path/sysaux01.dbf' SIZE 325M REUSE
      DEFAULT TABLESPACE users
         DATAFILE '/your/local/path/users01.dbf'
      SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
   DEFAULT TEMPORARY TABLESPACE temp
      TEMPFILE '/your/local/path/temp01.dbf'
      SIZE 20M REUSE
   UNDO TABLESPACE UNDOTBS1
      DATAFILE '/your/local/path/undotbs01.dbf'
          SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED

/



Oracle XML Database Creation

XDB Removal :
The catnoqm.sql script drops XDB.
SQL> spool xdb_removal_1.log
SQL> set echo on;
SQL> connect / as sysdba
SQL> shutdown immediate;
SQL> startup
SQL> @?/rdbms/admin/catnoqm.sql
SQL> spool off;


XDB Installation :
The catqm.sql script requires the following parameters be passed to it when run:
A. XDB user password
B. XDB user default tablespace
(Any tablespace other than SYSTEM, UNDO and TEMP can be specified.
The specified tablespace must already exist prior to running the script.)
C. XDB user temporary tablespace
D. SecureFiles = YES or NO
(If YES is specified, the XDB repository will use SecureFile storage.
 If NO is specified, LOBS will be used.
To use SecureFiles, compatibility must be set to 11.2.
The tablespace specified for the XDB repository must be using
Automatic Segment Space Management (ASSM) for SecureFiles to be used.)
Therefore the syntax to run catqm.sql is the following:
SQL> catqm.sql A B C D

For Example:
SQL> @?/rdbms/admin/catqm.sql XDB XDB TEMP YES
## IMPORTANT: You must shutdown and restart the database between removal and reinstall ##
SQL> spool xdb_install.log
SQL> set echo on;
SQL> connect / as sysdba
SQL> shutdown immediate;
SQL> startup;
SQL> @?/rdbms/admin/catqm.sql <XDB pwd> <XDB default tbs> <XDB temporary tbs> <SecureFiles = YES/NO>
SQL> @?/rdbms/admin/utlrp.sql
SQL> spool off

Verify XDB Installation
SQL> spool xdb_status.txt
SQL> set echo on;
SQL> connect / as sysdba
SQL> set pagesize 1000
SQL> col comp_name format a36
SQL> col version format a12
SQL> col status format a8
SQL> col owner format a12
SQL> col object_name format a35
SQL> col name format a25

-- Check status of  Xml DB (XDB)
SQL> select comp_name, version, status from dba_registry
     where comp_id = 'XDB';

-- Check for invalid objects owned by Xml DB (XDB)
SQL> select owner, object_name, object_type, status from dba_objects
     where status = 'INVALID' and owner = 'XDB';
spool off;

AWR Report Explanation

Cache Sizes (end): This shows the size of each SGA region after AMM has changed them.  This information can be compared to the original init.oraparameters at the end of the AWR report.

Load Profile: This important section shows important rates expressed in units of per second and transactions per second.

Instance Efficiency Percentages: With a target of 100%, these are high-level ratios for activity in the SGA.

Shared Pool Statistics: This is a good summary of changes to the shared pool during the snapshot period.

Top 5 Timed Events: This is the most important section in the AWR report.  It shows the top wait events and can quickly show the overall database bottleneck.

Wait Events Statistics Section: This section shows a breakdown of the main wait events in the database including foreground and background database wait events as well as time model, operating system, service, and wait classes statistics.

Wait Events: This AWR report section provides more detailed wait event information for foreground user processes which includes Top 5 wait events and many other wait events that occurred during the snapshot interval.

Background Wait Events: This section is relevant to the background process wait events.

Time Model Statistics: Time mode statistics report how database-processing time is spent. This section contains detailed timing information on particular components participating in database processing.

Operating System Statistics: The stress on the Oracle server is important, and this section shows the main external resources including I/O, CPU, memory, and network usage.

Service Statistics: The service statistics section gives information about how particular services configured in the database are operating.

SQL Section: This section displays top SQL, ordered by important SQL execution metrics.

SQL Ordered by Elapsed Time: Includes SQL statements that took significant execution time during processing.

SQL Ordered by CPU Time: Includes SQL statements that consumed significant CPU time during its processing.

SQL Ordered by Gets: These SQLs performed a high number of logical reads while retrieving data.

SQL Ordered by Reads: These SQLs performed a high number of physical disk reads while retrieving data.

SQL Ordered by Parse Calls: These SQLs experienced a high number of reparsing operations.

SQL Ordered by Sharable Memory: Includes SQL statements cursors which consumed a large amount of SGA shared pool memory.

SQL Ordered by Version Count: These SQLs have a large number of versions in shared pool for some reason.

Instance Activity Stats: This section contains statistical information describing how the database operated during the snapshot period.

Instance Activity Stats (Absolute Values): This section contains statistics that have absolute values not derived from end and start snapshots.

Instance Activity Stats (Thread Activity): This report section reports a log switch activity statistic.

I/O Section: This section shows the all-important I/O activity for the instance and shows I/O activity by tablespace, data file, and includes buffer pool statistics.
Tablespace IO Stats
File IO Stats
Buffer Pool Statistics 
Advisory Section: This section show details of the advisories for the buffer, shared pool, PGA and Java pool.
Buffer Pool Advisory
PGA Aggr Summary: PGA Aggr Target Stats; PGA Aggr Target Histogram; and PGA Memory Advisory. 
Shared Pool Advisory
Java Pool Advisory 
Buffer Wait Statistics: This important section shows buffer cache waits statistics.

Enqueue Activity: This important section shows how enqueue operates in the database. Enqueues are special internal structures which provide concurrent access to various database resources.

Undo Segment Summary: This section gives a summary about how undo segments are used by the database.

Undo Segment Stats: This section shows detailed history information about undo segment activity.

Latch Activity: This section shows details about latch statistics. Latches are a lightweight serialization mechanism that is used to single-thread access to internal Oracle structures.
Latch Sleep Breakdown
Latch Miss Sources
Parent Latch Statistics
Child Latch Statistics

Segment Section: This report section provides details about hot segments using the following criteria:
Segments by Logical Reads: Includes top segments which experienced high number of logical reads.
Segments by Physical Reads: Includes top segments which experienced high number of disk physical reads.
Segments by Buffer Busy Waits: These segments have the largest number of buffer waits caused by their data blocks.
Segments by Row Lock Waits: Includes segments that had a large number of row locks on their data.
Segments by ITL Waits: Includes segments that had a large contention for Interested Transaction List (ITL). The contention for ITL can be reduced by increasing INITRANS storage parameter of the table.

Dictionary Cache Stats: This section exposes details about how the data dictionary cache is operating.

Library Cache Activity: Includes library cache statistics describing how shared library objects are managed by Oracle.

SGA Memory Summary: This section provides summary information about various SGA regions.


init.ora Parameters: This section shows the original init.ora  parameters for the instance during the snapshot period.

Oracle AWR report


DB Name
DB Id
Instance
Inst num
Startup Time
Release
RAC
MDB
2154954810
MDB
1
02-Jul-15 10:07
11.2.0.3.0
NO

Host Name
Platform
CPUs
Cores
Sockets
Memory (GB)
Mylocalhhost
Linux x86 64-bit
6
6
6
23.46

Snap Id
Snap Time
Sessions
Cursors/Session
Begin Snap:
9275
06-Jul-15 10:00:34
350
5.4
End Snap:
9276
06-Jul-15 11:00:44
280
6.7
Elapsed:

60.16 (mins)


DB Time:

37.65 (mins)


Report Summary
Cache Sizes
Begin
End
Buffer Cache:
2,064M
2,064M
Std Block Size:
8K
Shared Pool Size:
4,848M
4,848M
Log Buffer:
13,964K
Load Profile
Per Second
Per Transaction
Per Exec
Per Call
DB Time(s):
0.6
0.0
0.00
0.00
DB CPU(s):
0.3
0.0
0.00
0.00
Redo size:
135,529.4
8,717.8


Logical reads:
5,165.1
332.2


Block changes:
768.0
49.4


Physical reads:
165.8
10.7


Physical writes:
14.2
0.9


User calls:
2,196.5
141.3


Parses:
160.6
10.3


Hard parses:
1.8
0.1


W/A MB processed:
2.1
0.1


Logons:
3.0
0.2


Executes:
1,334.9
85.9


Rollbacks:
0.1
0.0


Transactions:
15.6



Instance Efficiency Percentages (Target 100%)
Buffer Nowait %:
99.86
Redo NoWait %:
100.00
Buffer Hit %:
99.98
In-memory Sort %:
100.00
Library Hit %:
99.77
Soft Parse %:
98.86
Execute to Parse %:
87.97
Latch Hit %:
99.85
Parse CPU to Parse Elapsd %:
18.79
% Non-Parse CPU:
95.81
Shared Pool Statistics
Begin
End
Memory Usage %:
47.51
47.69
% SQL with executions>1:
98.42
97.77
% Memory for SQL w/exec>1:
93.32
93.80
Top 5 Timed Foreground Events
Event
Waits
Time(s)
Avg wait (ms)
% DB time
Wait Class
DB CPU

1,169

51.74

buffer busy waits
17,020
142
8
6.30
Concurrency
library cache: mutex X
10,218
131
13
5.78
Concurrency
enq: MS - contention
2,207
65
30
2.89
Other
enq: TX - row lock contention
5,139
63
12
2.80
Application
Host CPU (CPUs: 6 Cores: 6 Sockets: 6)
Load Average Begin
Load Average End
%User
%System
%WIO
%Idle
0.18
0.18
4.7
1.9
0.3
93.2
Instance CPU
%Total CPU
%Busy CPU
%DB time waiting for CPU (Resource Manager)
5.6
83.0
0.0
Memory Statistics
Begin
End
Host Mem (MB):
24,023.5
24,023.5
SGA use (MB):
7,216.0
7,216.0
PGA use (MB):
845.4
771.0
% Host Mem used for SGA+PGA:
33.56
33.25