You are on page 1of 33

Table of Contents

Mantra ........................................................................................................................................ 2
Introduction................................................................................................................................ 2
Oracle Files in individual directories .......................................................................................... 2
Control Files ................................................................................................................................ 2
Scenario 1 - one Control file for the database (delete)............................................................. 2
Scenario 2 - experiencing the error ............................................................................................ 4
Trace Directory and Alert Log File .............................................................................................. 5
Creating PFILE using SPFILE ........................................................................................................ 8
Scenario - the correct steps Control file .................................................................................... 9
Scenario - Control file inconsistent .......................................................................................... 12
Redos ........................................................................................................................................ 16
Scenario - add and delete Redos .............................................................................................. 17
Database Files........................................................................................................................... 20
Scenario - move data files ........................................................................................................ 20
Temporary Data File ................................................................................................................. 23
Undo Tablespace and Data File ................................................................................................ 25
Scenario - move ........................................................................................................................ 25
Dict_Columns - Dictionary ........................................................................................................ 26
Tablespaces .............................................................................................................................. 28
Scripts ....................................................................................................................................... 29
ASSM (Automated Segment Space Management) .................................................................. 29
Tablespace Index ...................................................................................................................... 30
Data Files Count ....................................................................................................................... 30
Resize Data File......................................................................................................................... 31
Add Data File ............................................................................................................................ 31
Links .......................................................................................................................................... 33

Mantra
Assuming you will practise on a Virtual Machine installed on your PC or Laptop. That will be
helpful for you in many ways, rather installing on a Laptop straight away.
The Mantra is : Install on VM - Save (Taking Snapshot) - Play/Test/Learn - Revert Back to
Snapshot if problems arise - Again Play/Test/Learn

Introduction

Assuming you have no good practise with Oracle database (beginner) or you would
like to get some practise. Oracle 11g R2 is used in this article
No theory, but only practise. I do not want to write theory on the topics covered in
this article but only focus on practise. However, I did mention what you can google
In the links section you can see the relevant links where the experts already
explained. This makes things easier for you to practise further
This practise is on a Windows System and in fact "practise makes perfect on a VM"

Oracle Files in individual directories

The simplest scenario I built for myself after some practise with Oracle was to move
the files to individual directories, presuming each directory is a separate drive !

This is the final picture after performing the below steps

Control Files
Scenario 1 - one Control file for the database (delete)

Using only one control file we run the database


Move the control files to a separate directory, named as "cntrls"
Checking the location of Control files first

Checking the location of Control01 on the system

Checking the location of Control02 on the system

Tip : On Windows, using md (make directory) command you can create a directory

Copy and paste the control file , as any other file on the Windows, to the directory

Setting the new location using the command given below


Perform shutdown and startup

Verify the new location of Control file after performing a start up

Scenario 2 - experiencing the error

We experience an error and that leads you to understand better about control file
Delete this second control file, that is "control02" from the directory shown below
and save it the "cntrls" directory

I miss typed the directory name wrong intentionally. I mentioned "cntrl" instead of
"cntrls"
Perform shutdown and then startup

Trace Directory and Alert Log File

Checking the error details in the Alert file that showed up in the above screen
Trace directory introduction

Tip : On Windows, if you have not installed any Text Editor tool you open a file using
WordPad but not Notepad. Using WordPad it is readable well. Check it for yourself to
see the difference. Right click on a file and select "Open With" to open a file using
WordPad Program

In the Trace directory you see the "Alert Log file". Here you can see all the operations
that are performed on the database. Everything is recorded here.
Tip : google this topic to read about this. It is called "Alert Log File"
It is showing clearly what went wrong

Set the control file to "control01" and do a startup, which means the database is
started using only one control file

Tip : google to read the difference between Pfile, Spfile and Control File
Checking the location of Pfile and Spfile on the System

Open the Pfile to confirm if the second Control file was updated or not

It is important to note that the location of control file should be saved here, else
"ERROR". I updated the file setting the new location of Control file

Creating PFILE using SPFILE

The below is an example that shows how you can create a test pfile from a spfile

You can verify the original Pfile and the Test Pfile
Below is a Test PFILE called "initTest.ora"

Below is the original PFILE that the Database is using

Scenario - the correct steps Control file

Created a new directory "ctls" and copied the control files into this new directory

Startup the database in nomount


Set the new location of control files (setting the new location for the two control
files)

Test and verify with SPFILE : Check whether the SPFILE updated the new location of
control files or not. Yes, it has been updated !

Test and verify with PFILE : Check whether the PFILE updated the new location of
control files or not. No, it has not been updated !

Open with WordPad


Before updation

After updating the second control file location. It should be inside the braces, as
shown below

Finally verify the control files location after a start up of the database

We can confirm once more by a shutdown and startup to see whether any problems
arise or not

Scenario - Control file inconsistent

Reverted back my Virtual System to the Snapshot I took (in my case, back to the
database installation Snapshot)
You can see below the "ctls" directory is empty after creating it. It does not have
control files (last scenario) or you can create another directory if you want

Verify the location of control files

Copied the first control file to this directory

Set the new location of control file

Verify with SPFILE whether it has been updated or not

SPFILE has been updated by the above "alter.." command

Verify with PFILE whether it updated the new location of control file or not

PFILE was not updated with the new location

Updated the new control file location manually

Startup the database and an error will be displayed


Perform "Shut Abort"

Copy the second control file from this directory

We already have one control file called "control01" in "ctls" directory. So just rename
that as "old_control01"
Save the copied control file that is "control02" and then rename it to "control01"

Perform a Startup
You can see there is no error now because the control file is latest !

Do a Startup force to check whether the database will run normal or not

Redos

Verify the Log Member and its Group


Tip : Google to read about : Log Group, Log Member, Database Writer, Undo
Tablespace. The goal should be to understand how operations or transactions
performed on a database get saved on to the database etc
Tip : Additional information to goolgle : Save Point, Commit, SQL-TCL etc

Below is a directory that shows where the Redos were saved on Windows

Redo Logs are also called as Online Logs


We would create our own location for Redo Logs for the sake of practise and move
them to the new location
A new directory called "redos" was created and it is shown below

Scenario - add and delete Redos

Add a new Log Group and disable the old Log Groups and Log members (Online
Method). That means the database is up and running and you create Log Groups and
Members
A new Log group called "Group 4" is created with two Log Members of size 100M
Verified the newly created Log Groups and Log Members

A new Log group called "Group 5 and 6" was also created with two Log Members in
each group with a size of 100M
Later on, verify whether the new Log Groups and Members were created or not

This is Online Method (database is up and running) so the scenario here is to disable
old Log Groups and Members and enable the newly created Log Groups and
Members
In order to perform that it is vital to check the status of Log Group. Once the Log
Group is "Inactive" it can be dropped. The below screenshots shows that
By issuing "Switch Log File" command it makes possible to turn a Log Group into
Inactive state. The below screenshots shows

Below you can see the ".. switch logfile" command is issued again and again until the
Log Group turns into "Inactive" state
Once it is in "Inactive" State then you can drop it

Finally, you can see we could successfully drop the old Log Groups and add new ones
and verified that they are in use

Database Files
Scenario - move data files

Moving the database files to a separate directory "dbfs" (files moved were System,
Sysaux and Users )
Tip : Google to read : difference between System and Non-System database files,
types of database files and their importance, Tablespaces, types of Tablespaces etc
The below SQL verifies the Tablespaces, Database files and Temporary Database file

In my case, all the Database files were stored in one directory "db11g"

Created a new directory "dbfs"; moved Database files into this new directory
Tip : google to read : Moving Database files Online and Offline method. Anyways in
the "links" section you have good information to practise

This is offline method


The "host and move" are Windows System commands that you can use while you are
working with SQL. So, this is something I call, "good to know, need to know"
The files were moved to the newly created directory "dbfs" and the Database file
name is also changed. You can see that difference below

The newly created directory "dbfs" has the files that were moved from "db11g"
directory

Start up the database in mount

We inform the database about the new location by issuing the commands shown
below

Verify the new location


Below the temporary file is also displayed but its steps are shown in next screenshot

To test everything is fine, perform a startup force to see database shuts down and
starts up normally
It does not throw any error hence it is fine and good

Temporary Data File

Verifying the Temp Tablespace name


Tip : google to read about the importance of Temp Tablespace and its usage

The database has only one Temp Tablespace and it does not allow to disable or
offline

Created a directory called "temps" in order to move the Temporary Datafile to this
new location

Moved the Temporary data file to a new location

Performed shutdown and started in mount

Inform the database about the new location

To test the database is working fine, performed a shutdown and startup

Undo Tablespace and Data File


Scenario - move

Moving the Undo Tablespace to a separate directory called "undos"


Tip : google to read about Undo Tablespace importance, block size etc

Moved the Undo Data file from "db11g" to "undos" and renamed it too

Performed shutdown and informed the database about the new location

To be confirmed the database is working fine, performed a shutdown and a start up

Dict_Columns - Dictionary

Tip : google to read about Dictionary Table, in short it is called often "dict" Table
Tip : google to read from which version the "dict_columns" Table has been existing
The below SQL query shows how many Tables exists in this "dict_columns" Table.
But, you can further test to see only distinct Tables

Desc is the short form for "describe". That means describe the table

The example below shows an error with "dict". It should be typed "dictionary" rather
"dict"

This is an example to see the distinct tables from "dict_columns"

The example below shows how you can see all the tables related to "Tablespaces"
Tip : After you get some basics, google to read about difference between User_, All_,
and V$(tables) and GV$(tables) Tables and its usage. Make a short notes (very imp.)

Tablespaces

For the purpose of understanding you can see the SQL queries below to see how
Tablespaces are maintained
Tip : google to read about Extent Management, since when the default is Local
If Tablespace is filled up, you got to extent so that the space is added

Below is a simple SQL query that shows up the free space in a Tablespace
There are scripts that you should learn to run them and also learn to write

If this parameter "db_create_file_dest" is set, then the default location for any
created Tablespace and/or data file will be saved in this location. In my case, nothing!
Tip : google to read what are database parameters, its importance and make a list of
important database parameters and also test them but do not change any values
initially
A Tablespace for RMAN is created

Scripts

Assuming you have never tried a database script


The Oracle Guru has already saved much scripts on his site
The simplest tip is to open the browser and use "find" (on any browser there is find
option available). For example, on IE and Mozilla Web Browser using "cntrl+f" the
find is opened. Just type "space" and you see all the scripts related to space
Understand them first and run. If error comes up, read the error first and re-read
what's written in the script and most importantly the SQL written

ASSM (Automated Segment Space Management)

Tip : google to read from which version the ASSM exists, its importance etc and
make a short notes

Tablespace Index

The example shows the creation of Index Tablespace "usrindx" (user index)
Tip : google to read about the importance of Index Tablespace, and make some notes

Data Files Count

The SQL query below shows the count of data files per Tablespace
Because it is possible to add more data files to a Tablespace, it is also important to
verify it

Resize Data File

A basic example that shows to resize the existing data file


In the above screenshot you might have seen the RMAN Data file was created with
100 M. Now it is 150 M

Add Data File

Below you can see how data files are added to existing Tablespace "Users" and
"USRINDX"

Verify all the existing data files of the database and also the data files that were
added in last step

Once again you can verify the number of data files per Tablespace exits

There is another Table called " dba_temp_free_space" for Tablespace Free Space
Tip : just have a basic note of Tables existing for a given version

Links
Below is my article for Oracle 12c practise and get started with it

https://de.scribd.com/doc/248076391/Learning-Practice-Oracle-12C-pdf

https://oracle-base.com/articles/misc/renaming-or-moving-oracle-files
https://oracle-base.com/articles/12c/online-move-datafile-12cr1
https://sarith.wordpress.com/2009/11/20/ora-00214-controlfile-version-inconsistent/
Redo Logs
http://www.idevelopment.info/data/Oracle/DBA_tips/Database_Administration/DBA_34.shtml

You might also like