Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Recreate database script
Forgot to mention that this will only build the db create script.
Nothing more than that.
-----Original Message-----
Sent: Monday, September 09, 2002 10:07 AM
To: 'ORACLE-L_at_fatcity.com'
Here is one that I used to use some time ago (for Oracle 6 and 7).
This does not support all the *new* stuff available since Oracle8, but it should not be difficult to change it.. if you do, I would appreciate a copy :)
#!/bin/ksh
#--------------------------------------------------------------------------- ----directory
# crdb.ksh - creates sql script that contains statements necessary
# to recreate a database with the current physical # configuration. #
# parameters - SID (oracle database identifier)
#
# output - crdb_<SID>.sql in $ORACLE_HOME/admin/$ORACLE_SID/scripts
#
# Author - Quin Bligh
# Kirti Deshpande
# #--------------------------------------------------------------------------- ---- get_perm_db_params ()
(sqlplus -s <<END1C
sys/$SYSPW
set heading off
set feedback off
set pages 0
select value
from nls_database_parameters
where parameter = 'NLS_CHARACTERSET';
END1C
) | read NLS_CHARSET
echo "Char set is $NLS_CHARSET"
}
#---------------------------------------------------------------------------
i=$(($i + 1)) if [ $i -lt $num ] ; then echo "\t$lines," >> $SYSFILE else echo "\t$lines" >> $SYSFILE fi
#---------------------------------------------------------------------------
echo "\t\t '$MEMBER'\c" >> $LOGFILE
done
echo "\n\t\t ) size ${HOLDSIZE}k" >> $LOGFILE
}
#---------------------------------------------------------------------------
i=$(($i + 1)) echo $lines | grep "^create" >/dev/null if [ $? -eq 0 ] ; then echo "\n$lines" >> $DBFILES else echo $lines | grep -v "size" >/dev/null if [ $? -eq 0 ] ; then echo "\t$lines" >> $DBFILES elif [ $i -lt $num ] ; then echo "\t$lines," >> $DBFILES else echo "\t$lines;" >> $DBFILES fi fi
echo "Getting all other tablespace definitions..."
>$TFILE
>$DBFILES
(sqlplus -s <<END4
sys/$SYSPW
set heading off
set feedback off
set pages 0
select tablespace_name ||' '|| initial_extent ||' '||
next_extent ||' '|| min_extents ||' '|| max_extents ||' '||
pct_increase
from dba_tablespaces
where tablespace_name != 'SYSTEM'
and status != 'INVALID'
order by tablespace_name;
END4
) |
while read TSNAME INITEXT NEXTEXT MINEXT MAXEXT PCTINC
do
echo "create tablespace $TSNAME" > /tmp/$TSNAME.$$ echo "\t default storage (" >> /tmp/$TSNAME.$$ echo "\t\t initial $INITEXT" >> /tmp/$TSNAME.$$ echo "\t\t next $NEXTEXT" >> /tmp/$TSNAME.$$ echo "\t\t minextents $MINEXT" >> /tmp/$TSNAME.$$ echo "\t\t maxextents $MAXEXT" >> /tmp/$TSNAME.$$ echo "\t\t pctincrease $PCTINC" >> /tmp/$TSNAME.$$ echo "\t )" >> /tmp/$TSNAME.$$ echo "\t datafile" >> /tmp/$TSNAME.$$
#---------------------------------------------------------------------------
"(optimal $OPTSIZE);" >>$RBS
done
}
#---------------------------------------------------------------------------
startup nomount pfile=$ORACLE_HOME/dbs/init${ORACLE_SID}_0.ora
set echo on
spool crdb${ORACLE_SID}
REM * Create the <dbname> database. REM * SYSTEM tablespace configuration guidelines: REM * General-Purpose ORACLE RDBMS 50Mb REM * Additional dictionary for applications 10-50Mb REM * Redo Log File configuration guidelines: REM * Use 3+ redo log files to relieve ``cannot allocate new log...''waits.
$MAXLOGFILES $MAXDATAFILES $MAXINSTANCES $MAXLOGMEMBERS $MAXLOGHISTORY
logfile
`cat $LOGFILE`
;
shutdown;
startup open pfile=${ORACLE_HOME}/dbs/init${ORACLE_SID}_0.ora
REM * install data dictionary views:
@${ORACLE_HOME}/rdbms/admin/catalog.sql @${ORACLE_HOME}/rdbms/admin/catproc.sql @${ORACLE_HOME}/rdbms/admin/catblock.sql
REM * Install dbms utilities
@${ORACLE_HOME}/rdbms/admin/dbmspool.sql
@${ORACLE_HOME}/rdbms/admin/dbmspipe.sql
REM * REM * Create rest of datafiles REM *
REM * REM * Create rollback segments. REM *
REM * REM * Restart the instance to activate the the additional rollback segments. REM *
shutdown
disconnect
connect internal
startup
REM * Alter SYS and SYSTEM users.
REM *
alter user sys temporary tablespace temp;
alter user system temporary tablespace temp;
END }
#---------------------------------------------------------------------------
0)
echo "Enter oracle sid: [$ORACLE_SID] \c" read MYSID export ORACLE_SID=${MYSID:-$ORACLE_SID};;
export ORACLE_SID=$1
;;
*)
echo "Usage: $NAME [sid]" exit 1
clear
echo "" echo "Running $NAME to create $ORACLE_SID rebuild script\n" echo " Please enter password for 'SYS' : \c"stty -echo
# Set up ORACLE Environment
export ORAENV_ASK=NO
. oraenv
#
echo "\n\n" echo "--------- ERROR ----------" echo "**** Invalid SYS password " echo "\n\n\n"
echo "\n\n" echo "------------ ERROR ------------" echo "**** Database is not accessible" echo "\n\n\n"
TFILE=/tmp/crdb_tmp.$$
SYSFILE=/tmp/crdb_sysfile.$$ LOGFILE=/tmp/crdb_logfile.$$ DBFILES=/tmp/crdb_dbfiles.$$
trap "rm -f /tmp/crdb_*.$$;exit" 0 1 2 3 4 5 6 15
get_perm_db_params get_dbs_files get_log_files get_dbf_files get_rbs
cat_sql
chmod 640 $SQL
echo "\n$NAME done creating sql script! -- See $SQL"
#--- End of File -------
-----Original Message-----
Sent: Monday, September 09, 2002 10:33 AM
To: Multiple recipients of list ORACLE-L
If you export with rows=n, you get a text file with all the ddl to recreate the exportable objects. However, packages/procedures are formatted and not at all easy to use to recreate and the storage clauses are all in bytes. Not a pretty method, but certainly one that can be used.
-----Original Message-----
Sent: Friday, September 06, 2002 3:59 PM
To: Multiple recipients of list ORACLE-L
Export can do this. Right?
But the output is not a script but a binary file only Import can understand.
ltiu
Connie Milliken wrote:
>Does anyone have a script that will write another script to recreate a >particular database quickly with all the info specific to that particular >database? > >Seems to me that I have seen this somewhere before, but I am not surewhere.
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Deshpande, Kirti INET: kirti.deshpande_at_verizon.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Sep 09 2002 - 11:18:27 CDT