Thursday, 8 August 2013

Creating Database using sql script -

#################################################################
# Setup environment
# Typically configured in .profile (Unix) or .bash_profile (Linux)
#################################################################
export ORACLE_SID=TOYDB
export ORACLE_BASE=/database/oracle
export ORACLE_HOME=/product/oracle/base_dir/version_no
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/LIB:$LD_LIBRARY_PATH

#################################################################
# Parameter File - initTOYDB.ora
# Copy and paste the below lines in seperate file and rename the file with above mentioned name
# initSID.ora - where SID=service identifier (TOYDB) in our case
#################################################################
db_name=TOYDB
compatible=11.2.0
memory_target=400M
control_files='/database/oracle/RMCLY9P1/ctl/CTL_001.ctl','/database/oracle/RMCLY9P1/ctl/CTL_002.ctl'
undo_tablespace=undo_tbs
undo_management=auto

#################################################################
# Once the file is set then startup database to nomount stage using below command
# In nomount stage, the instance is created
#################################################################
startup no_mount pfile='absolute path of the above file'


#################################################################
# Create Database script - 
# Copy and paste the below lines as a seperate sql script
# Make sure before you execute this script, the instance is created
# Without instance created we cant execute this script
# Below script will create database with the name of TOYDB and will create controlfile as specified in parameter file
# Once done with DB creation, this script will take DB to mount stage
#################################################################
create database "TOYDB"
datafile '-- path of system tablespace datafile --' size 400M
sysaux datafile '-- path of sysaux tablespace datafile --' size 200M
default temporary tablespace temp tempfile ' -- path og temp tablespace tempfile -- ' size 400M
default undo tablespace undo_tbs datafile '-- path of undo tablespace datafile --'
default tablespace users datafile '-- path of users datafile --' size 400M
logfile
group 1 ('--path of member1_01.log file --','--path of member1_02.log file --') size 20M,
group 2 ('--path of member2_01.log file --','--path of member2_02.log file --') size 20M,
group 3 ('--path of member3_01.log file --','--path of member3_02.log file --') size 20M
user sys identified by oracle
user system identified by manager;


#################################################################
# Create Data Dictionary views
# Before executing these scripts make sure the DB is in mount stage
# Also these scripts needs to be execute in the same mentioned sequence -
# catalog.sql --> creates required/mandatory data dictionary tables and view
# catproc.sql --> creates required/mandatory PLSQL procedures, functions and packages
#################################################################

SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql;
SQL> @$ORACLE_HOME/rdbms/admin/catproc.sql;


No comments:

Post a Comment