-- This script was created by Christopher Thullen - Feb 2005
-- It creates database creation scripts for 9i
-- It does not log onto any database
-- how to implement the pause for the entry of the line in oratab?
-- What about autoextend on? Or ON with maxsize 500M?
--
-- To use this script, copy the scipt dba_createDB_creation_scripts.sql
to the server
-- And also copy the file dba_createDB_start_here.bat (for windows)
-- or dba_createDB_start_here.sh (for UNIX)
set doc off echo off
--set termout off feedback off verify off echo off heading off suffix
SQL newpage none
set sqlterminator off
-- UNIX
define fs = "/"
-- database for windows, dbs for UNIX
define dbs_database = dbs
-- windows:
define fs = "\"
-- database for windows, dbs for UNIX
define dbs_database = database
define the_SID = "test3"
ACCEPT the_SID char default &the_SID. prompt "Enter SID (default
&the_SID.): "
define the_file_prefix = dba_createDB_&the_SID._
--define the_file_prefix = ""
define THE_SERVER = RCGVA01
ACCEPT THE_SERVER char default &THE_SERVER. prompt "Enter the
server name (default &THE_SERVER.): "
define CHAR_SET = AL32UTF8
-- *** other possible values: WE8ISO8859P1
ACCEPT CHAR_SET char default &CHAR_SET. prompt "Enter the character
set (default &CHAR_SET.): "
define NAT_CHAR_SET = UTF8
-- *** other possible values: AL16UTF16
ACCEPT NAT_CHAR_SET char default &NAT_CHAR_SET. prompt "Enter
the national character set (default &NAT_CHAR_SET.): "
define ORA_ADMIN = /u00/app/oracle/admin/&the_SID.
define ORA_ADMIN = C:\oracle\admin\&the_SID.
ACCEPT ORA_ADMIN char default &ora_admin. prompt "Enter location
for log files (default &ora_admin.): "
define ORA_DATA1 = /u01/oradata/&the_SID.
define ORA_DATA1 = E:\oracle\oradata\&the_SID.
ACCEPT ORA_DATA1 char default &ORA_DATA1. prompt "Enter the data
file location 1 (default &ORA_DATA1.): "
define ORA_DATA2 = /u02/oradata/&the_SID.
define ORA_DATA2 = C:\oracle\oradata\&the_SID.
ACCEPT ORA_DATA2 char default &ORA_DATA2. prompt "Enter the data
file location 2 (default &ORA_DATA2.): "
define ORA_ARCH = &ORA_DATA2.&fs.arch
ACCEPT ORA_ARCH char default &ORA_ARCH. prompt "Enter the archive
destination (default &ORA_ARCH.): "
define ORACLE_BASE = /u00/app/oracle
define ORACLE_BASE = C:\oracle
ACCEPT ORACLE_BASE char default &ORACLE_BASE. prompt "Enter the
ORACLE_BASE (default &ORACLE_BASE.): "
define ORACLE_HOME = /u00/app/oracle/product/9.2.0.1
define ORACLE_HOME = C:\oracle\ora92
ACCEPT ORACLE_HOME char default &ORACLE_HOME. prompt "Enter the
ORACLE_HOME (default &ORACLE_HOME.): "
define DEFAULT_PASSWORD = change_on_install
spool &the_file_prefix._cleanup_&the_SID..sh
prompt
prompt echo Remove this entry in the oratab: &the_SID.:&ORACLE_HOME.:Y
prompt
prompt rm &ORACLE_HOME./dbs/orapw&the_SID.
prompt rm &ORACLE_HOME./dbs/spfile&the_SID.
prompt rm -R &ORA_ADMIN.
prompt rm -R &ORA_ARCH.
prompt rm -R &ORA_DATA1.
prompt rm -R &ORA_DATA2.
prompt
spool off
spool &the_file_prefix.&the_SID..sh
prompt #!/bin/ksh
prompt
prompt mkdir &ORA_ADMIN.
prompt mkdir &ORA_ADMIN./bdump
prompt mkdir &ORA_ADMIN./cdump
prompt mkdir &ORA_ADMIN./create
prompt mkdir &ORA_ADMIN./pfile
prompt mkdir &ORA_ADMIN./udump
prompt mkdir &ORA_DATA1.
prompt mkdir &ORA_DATA2.
prompt mkdir &ORA_ARCH.
prompt mkdir &ORACLE_HOME./dbs
prompt
prompt cp &the_file_prefix.&the_SID..sh &ORA_ADMIN./create
prompt cp &the_file_prefix._cleanup_&the_SID..sh &ORA_ADMIN./create
prompt cp &the_file_prefix.CreateDB.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.CreateDBFiles.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.CreateDBCatalog.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.JServer.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.postDBCreation.sql &ORA_ADMIN./create
prompt cp &the_file_prefix.init.ora &ORA_ADMIN./pfile
prompt
prompt export ORACLE_SID=&the_SID.
prompt echo Add this entry in the oratab: &the_SID.:&ORACLE_HOME.:Y
prompt &ORACLE_HOME./bin/orapwd file=&ORACLE_HOME./dbs/orapw&the_SID.
password=&DEFAULT_PASSWORD. entries=5
prompt
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.CreateDB.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.CreateDBFiles.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.CreateDBCatalog.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.JServer.sql
prompt &ORACLE_HOME./bin/sqlplus /nolog @&ORA_ADMIN./create/&the_file_prefix.postDBCreation.sql
prompt
spool off
spool &the_file_prefix.cleanup_&the_SID..bat
prompt
prompt &ORACLE_HOME.\bin\ORADIM -SHUTDOWN -SID &the_SID. -SHUTMODE
a
prompt pause Is OracleService&the_SID. stopped?
prompt
prompt &ORACLE_HOME.\bin\ORADIM -DELETE -SID &the_SID.
prompt type &ORACLE_HOME.\database\OraDim.Log
prompt pause Is the service OracleService&the_SID. removed (see services)?
prompt
prompt del &ORACLE_HOME.\database\PWD&the_SID..ora
prompt del &ORACLE_HOME.\database\SPFILE&the_SID..ora
prompt del &ORA_ADMIN.\bdump\*
prompt del &ORA_ADMIN.\cdump\*
prompt del &ORA_ADMIN.\create\*
prompt del &ORA_ADMIN.\pfile\*
prompt del &ORA_ADMIN.\udump\*
prompt del &ORA_ADMIN.\*
prompt del &ORA_DATA1.\*
prompt del &ORA_DATA2.\*
prompt del &ORA_ARCH.\*
prompt
prompt rmdir &ORA_ARCH.
prompt rmdir &ORA_DATA1.
prompt rmdir &ORA_DATA2.
prompt rmdir &ORA_ADMIN.\bdump
prompt rmdir &ORA_ADMIN.\cdump
prompt rmdir &ORA_ADMIN.\pfile
prompt rmdir &ORA_ADMIN.\udump
prompt rmdir &ORA_ADMIN.\create
prompt rmdir &ORA_ADMIN.
prompt
-- just in case the files were previously created in the default area
prompt del &ORACLE_BASE.\admin\&the_SID.\*
prompt del &ORACLE_BASE.\oradata\&the_SID.\*
prompt rmdir &ORACLE_BASE.\admin\&the_SID.
prompt rmdir &ORACLE_BASE.\oradata\&the_SID.
--
prompt pause
prompt
spool off
spool &the_file_prefix.main.bat
prompt
prompt mkdir &ORA_ADMIN.\bdump
prompt mkdir &ORA_ADMIN.\cdump
prompt mkdir &ORA_ADMIN.\create
prompt mkdir &ORA_ADMIN.\pfile
prompt mkdir &ORA_ADMIN.\udump
prompt mkdir &ORA_DATA1.
prompt mkdir &ORA_DATA2.
prompt mkdir &ORA_ARCH.
prompt mkdir &ORACLE_HOME.\database
prompt
prompt copy &the_file_prefix.main.bat &ORA_ADMIN.\create
prompt copy &the_file_prefix.cleanup_&the_SID..bat &ORA_ADMIN.\create
prompt copy &the_file_prefix.CreateDB.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.CreateDBFiles.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.CreateDBCatalog.sql &ORA_ADMIN.\create
--prompt copy &the_file_prefix.JServer.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.postDBCreation.sql &ORA_ADMIN.\create
prompt copy &the_file_prefix.init.ora &ORA_ADMIN.\pfile
prompt
prompt set ORACLE_SID=&the_SID.
prompt &ORACLE_HOME.\bin\ORADIM -NEW -SID &the_SID. -INTPWD &DEFAULT_PASSWORD.
-MAXUSERS 5 -STARTMODE a -PFILE &ORA_ADMIN.\pfile\init.ora
--oradim /?
--oradim -NEW -SID <sid> -INTPWD <pw> -MAXUSERS 5 -STARTMODE
a|m -PFILE <file>
--oradim -DELETE -SID <sid>
--oradim -STARTUP -SID <sid> [-PFILE <filename>]
--oradim -SHUTDOWN -SID <sid> -SHUTMODE a | i | n
prompt type &ORACLE_HOME.\database\OraDim.Log
prompt dir &ORACLE_HOME.\database\PWD&the_SID..ora
prompt pause Is OracleService&the_SID. created and the password file
created?
prompt
--prompt &ORACLE_HOME.\bin\orapwd.exe file=&ORACLE_HOME.\database\PWD&the_SID..ora
password=&DEFAULT_PASSWORD. entries=5
--prompt pause
prompt
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.CreateDB.sql
prompt pause
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.CreateDBFiles.sql
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.CreateDBCatalog.sql
--prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.JServer.sql
prompt &ORACLE_HOME.\bin\sqlplus /nolog @&ORA_ADMIN.\create\&the_file_prefix.postDBCreation.sql
prompt
spool off
spool dba_createDB_go.bat
prompt pause About to remove database &the_SID.
prompt call &the_file_prefix.cleanup_&the_SID..bat
prompt pause About to create database &the_SID.
prompt call &the_file_prefix.main.bat
prompt pause
spool off
spool &the_file_prefix.CreateDB.sql
prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.CreateDB.log
prompt startup nomount pfile="&ORA_ADMIN.&fs.pfile&fs.&the_file_prefix.init.ora";
prompt CREATE DATABASE &the_SID.
prompt USER SYS IDENTIFIED BY &DEFAULT_PASSWORD. USER SYSTEM IDENTIFIED
BY &DEFAULT_PASSWORD.
prompt MAXINSTANCES 1 MAXLOGHISTORY 1 MAXLOGFILES 5 MAXLOGMEMBERS 3 MAXDATAFILES
100
prompt DATAFILE '&ORA_DATA1.&fs.system01.dbf' SIZE 250M REUSE
AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
prompt EXTENT MANAGEMENT LOCAL
prompt DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '&ORA_DATA1.&fs.temp01.dbf'
SIZE 40M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE 500M
prompt UNDO TABLESPACE UNDOTBS1 DATAFILE '&ORA_DATA1.&fs.undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE 500M
prompt CHARACTER SET &CHAR_SET.
prompt NATIONAL CHARACTER SET &NAT_CHAR_SET.
prompt LOGFILE GROUP 1 ('&ORA_DATA1.&fs.redo01.log', '&ORA_ADMIN.&fs.redo01.log')
SIZE 102400K,
prompt GROUP 2 ('&ORA_DATA1.&fs.redo02.log', '&ORA_ADMIN.&fs.redo02.log')
SIZE 102400K,
prompt GROUP 3 ('&ORA_DATA1.&fs.redo03.log', '&ORA_ADMIN.&fs.redo03.log')
SIZE 102400K;
prompt spool off
prompt exit;
prompt
spool off
-- *** What about max log history?
spool &the_file_prefix.CreateDBFiles.sql
prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.CreateDBFiles.log
prompt CREATE TABLESPACE INDX LOGGING DATAFILE '&ORA_DATA1.&fs.indx01.dbf'
prompt SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE 500M
prompt EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO AUTOALLOCATE;
prompt CREATE TABLESPACE TOOLS LOGGING DATAFILE '&ORA_DATA1.&fs.tools01.dbf'
prompt SIZE 10M REUSE AUTOEXTEND ON NEXT 320K MAXSIZE 500M
prompt EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO AUTOALLOCATE;
prompt CREATE TABLESPACE USR_DATA LOGGING DATAFILE '&ORA_DATA1.&fs.usr_data01.dbf'
prompt SIZE 25M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE 500M
prompt EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO AUTOALLOCATE;
prompt spool off
prompt exit;
prompt
spool off
spool &the_file_prefix.CreateDBCatalog.sql
prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.CreateDBCatalog.log
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catalog.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catexp7.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catblock.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catproc.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catoctk.sql;
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.owminst.plb;
prompt connect SYSTEM/&DEFAULT_PASSWORD.
prompt @&ORACLE_HOME.&fs.sqlplus&fs.admin&fs.pupbld.sql;
prompt connect SYSTEM/&DEFAULT_PASSWORD.
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.sqlPlusHelp.log
prompt @&ORACLE_HOME.&fs.sqlplus&fs.admin&fs.help&fs.hlpbld.sql
helpus.sql;
prompt spool off
prompt spool off
prompt exit;
prompt
spool off
--spool &the_file_prefix.JServer.sql
--
--prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
--prompt set echo on
--prompt spool &ORA_ADMIN.&fs.create&fs.JServer.log
--prompt @&ORACLE_HOME.&fs.javavm&fs.install&fs.initjvm.sql;
--prompt @&ORACLE_HOME.&fs.xdk&fs.admin&fs.initxml.sql;
--prompt @&ORACLE_HOME.&fs.xdk&fs.admin&fs.xmlja.sql;
--prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.catjava.sql;
--prompt spool off
--prompt exit;
--prompt
--spool off
spool &the_file_prefix.postDBCreation.sql
prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.postDBCreation.log
prompt @&ORACLE_HOME.&fs.rdbms&fs.admin&fs.utlrp.sql;
prompt shutdown ;
prompt startup mount pfile="&ORA_ADMIN.&fs.pfile&fs.&the_file_prefix.init.ora";
prompt alter database archivelog;
prompt alter database open;
prompt alter system archive log start;
prompt shutdown ;
prompt connect SYS/&DEFAULT_PASSWORD. as SYSDBA
prompt set echo on
prompt spool &ORA_ADMIN.&fs.create&fs.postDBCreation.log
prompt create spfile='&ORACLE_HOME.&fs.&dbs_database.&fs.spfile&the_SID..ora'
FROM pfile='&ORA_ADMIN.&fs.pfile&fs.&the_file_prefix.init.ora';
prompt startup ;
prompt exit;
prompt
spool off
spool &the_file_prefix.init.ora
prompt #
prompt # names
prompt db_domain=&THE_SERVER.
prompt db_name=&the_SID.
prompt instance_name=&the_SID.
prompt #
prompt
prompt #
prompt # arch
prompt log_archive_dest_1='LOCATION=&ORA_ARCH. MANDATORY'
prompt log_archive_format=&the_SID._%s_%t.arc
prompt log_archive_start=true
prompt #
prompt
prompt #
prompt # block size
prompt db_block_size=4096
-- *** other possible values: 2048, 4096, 8192, 16384
prompt #
prompt
prompt #
prompt # memory
prompt db_cache_size=25165824
-- *** other possible values:
prompt db_file_multiblock_read_count=16
-- *** other possible values:
prompt java_pool_size=0
-- *** other possible values: 104857600
prompt large_pool_size=8388608
-- *** other possible values:
prompt shared_pool_size=104857600
-- *** other possible values:
prompt pga_aggregate_target=25165824
-- *** other possible values:
prompt sort_area_size=524288
-- *** other possible values:
prompt #
prompt
prompt #
prompt # log locations
prompt background_dump_dest=&ORA_ADMIN.&fs.bdump
prompt core_dump_dest=&ORA_ADMIN.&fs.cdump
prompt timed_statistics=TRUE
prompt user_dump_dest=&ORA_ADMIN.&fs.udump
prompt #
prompt
prompt #
prompt # control files
prompt control_files= "&ORA_ADMIN.&fs.control01.ctl"
prompt control_files= "&ORA_DATA1.&fs.control02.ctl"
prompt control_files= "&ORA_DATA2.&fs.control03.ctl"
prompt #
prompt
prompt #
prompt # undo
prompt undo_management=AUTO
prompt undo_retention=10800
-- *** other possible values:
prompt undo_tablespace=UNDOTBS1
prompt #
prompt
prompt #
prompt # other
prompt open_cursors=300
prompt job_queue_processes=10
prompt
prompt aq_tm_processes=1
prompt compatible=9.2.0.0.0
prompt
prompt hash_join_enabled=TRUE
prompt query_rewrite_enabled=FALSE
prompt star_transformation_enabled=FALSE
prompt processes=150
prompt job_queue_processes = 4
prompt
prompt fast_start_mttr_target=300
prompt
prompt remote_login_passwordfile=EXCLUSIVE
prompt audit_trail = none
prompt
spool off
set sqlterminator ";"
prompt
prompt . @dba_createDB_creation_scripts.sql
prompt
prompt
prompt . To clean up an old creation:
prompt . - stop the database (abort)
prompt . - run the file &the_file_prefix.cleanup_&the_SID..bat
prompt
prompt
prompt . The next step is to run the script
prompt . --> &the_file_prefix.&the_SID..sh (for UNIX)
prompt . remember: chmod u+x &the_file_prefix.&the_SID..sh
prompt . --> &the_file_prefix.main.bat (for windows)
prompt . These scripts create the database
prompt . After the creation, change the default passwords for SYS and
SYSTEM
prompt . (currently "&DEFAULT_PASSWORD.")
prompt . The parameters (especially for memory) may need tuning
prompt . Add "&the_SID." to "tnsnames.ora" AND
to "listener.ora"
prompt
pause Press ENTER to continue (and exit the script), ^C to stay
in sqlplus
exit
|