Professional Documents
Culture Documents
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"
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 !
Control Files
Scenario 1 - one Control file for the database (delete)
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
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
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
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"
Created a new directory "ctls" and copied the control files into this new directory
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 !
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
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 with PFILE whether it updated the new location of control file or not
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
Below is a directory that shows where the Redos were saved on Windows
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
The newly created directory "dbfs" has the files that were moved from "db11g"
directory
We inform the database about the new location by issuing the commands shown
below
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
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 Undo Data file from "db11g" to "undos" and renamed it too
Performed shutdown and informed the database about the new location
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"
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
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
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
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