wORACLE f[^x[XobNAbvJo[x


Chapter2
p.23
SQL> ALTER SESSION SET SQL_TRACE = TRUE;


p.25
SQL*DBA: Release 7.1.3.2.0 - Production on Wed Feb 22 15:06:42 1995

Copyright (c) Oracle Corporation 1979, 1992.  All rights reserved.

ORACLE7 Server Release 7.1.3.2.0 - Production Release
With the distributed, parallel query and Parallel Server options
PL/SQL Release 2.1.3.2.0 - Production

SQLDBA> Connect internal
Connected.
SQLDBA> Startup
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area    4817708 bytes*6
    Fixed Size              28376 bytes
    Variable Size           3904536 bytes
    Database Buffers        819200 bytes
    Redo Buffers            65596 bytes
SQLDBA>*


SQLDBA> show sga
Total System Global Area    4817708 bytes
    Fixed Size              28376 bytes
    Variable Size           3904536 bytes
    Database Buffers        819200 bytes
    Redo Buffers            65596 bytes
    
    
p.31
SQLDBA> Startup open [dbname]
ORACLE instance started.
Database mounted.
Database opened.


p.32
SQLDBA> Startup nomount [dbname]
SQLDBA> Startup mount [dbname]


p.36
CREATE TABLESPACE tablespace_name
DATAFILE 'datafile_name' SIZE 50M ONLINE; 


ALTER TABLESPACE tablespace_name
ADD DATAFILE 'datafile_name' SIZE 20M;


p.37
ALTER TABLESPACE tablespace_name
RENAME DATAFILE 'old_filename' TO 'new_filename';

ALTER DATABASE RENAME FILE 'old_filename' TO 'new_filename'; 


p.38
ALTER TABLESPACE prod_tables OFFLINE NORMAL;


p.39
ALTER DATABASE DATAFILE 'DISK2:[DBS]FILE2.DBS' OFFLINE;
ALTER DATABASE DATAFILE 'DISK2:[DBS]FILE2.DBS' OFFLINE DROP;


p.45
set transaction use rollback segment SYSTEM;


p.47
SELECT * FROM V$WAITSTAT WHERE
OPERATION = 'buffer busy waits'  AND
CLASS = 'undo segment header';


p.48`49
REM: UNDO.SQL
set  feedback off
set termout  off
column name format A40
define undo_overhead = 54
DROP TABLE undo$begin;
DROP TABLE undo$end;
CREATE TABLE undo$begin ( writes number );
CREATE TABLE undo$end ( writes number );
INSERT INTO undo$begin
SELECT sum(writes) FROM v$rollstat;
set termout on
set feedback on
REM: ̕ɂāCeXgp̃gUNVi[ĂTEST.SQLƂ
REM: ÕXNvgs܂D
@TEST.SQL
set termout off
set feedback off
INSERT INTO undo$send
SELECT sum(writes) FROM v$rollstat;
set termout on
set  feedback on
SELECT  ( ( e.writes - b.writes) - &undo_overhead) " number of bytes generated"
FROM undo$begin b, undo$end e;
set termout off
set feedback off
DROP TABLE undo$begin;
DROP TABLE undo$end;


p.51
SELECT r.name "ROLLBACK SEGMENT NAME",
l.pid "ORACLE PID",
s.pid "SYSTEM PID",
NVL ( p.username , 'NO TRANSACTION'),
p.terminal
FROM v$lock l, v$process p, v$rollname r
WHERE  l.pid = p.pid(+)
AND TRUNC (l.idl(+)/65536) = r.usn
AND l.type(+) = 'TX'
AND l.lmode(+) = 6
ORDER BY r.name


p.52
ORA-1652 Failed to allocate extent of size num for temporary segment


p.53
SELECT SEGMENT_NAME, BYTES, EXTENTS FROM SYS.DBA_SEGMENTS
WHERE SEGMENT_TYPE='TEMPORARY';


SELECT MAX(BYTES) FROM SYS.DBA_FREE_SPACE
WHERE TABLESPACE_NAME= tablespace_name;


p.59
ALTER DATABASE ADD LOGFILE GROUP 3 ('DISK$3:[LOGDIR]LOG3A.LOG', 'DISK$4:[LOGDIR]LOG3B.LOG') SIZE 500K;
ALTER DATABASE ADD LOGFILE MEMBER 'DISK$5:[LOGDIR]LOG3C.LOG' TO GROUP 3;


p.60
ALTER DATABASE DROP LOGFILE MEMBER 'DISK$5:[LOGDIR]LOG3C.LOG';
ALTER DATABASE DROP LOGFILE GROUP 3;


p.62
$ archmon @P:sid
$ archmon @T:host:SID


p.63
SQLDBA> shutdown
SQLDBA> startup mount [dbname]
SQLDBA> alter database [dbname] archivelog;
SQLDBA> alter database [dbname] open;
SQLDBA> archive log all


SQLDBA> archive log list
Database log mode                ARCHIVELOG
Automatic archival               DISABLED
Archive destination              /dsk2/Oracle/arch
Oldest online log sequence       75
Next log sequence                76
Current log sequence             76


p.64
SQLDBA> archive log list
Database log mode                ARCHIVELOG
Automatic archival               ENABLED
Archive destination              /dsk2/Oracle/arch
Oldest online log sequence       75
Next log sequence                78
Current log sequence             78



Chapter3
p.70
SQLDBA> alter database backup controlfile to 'filespec';


p.74
SQLDBA> alter tablespace users begin backup;
SQLDBA> alter tablespace users end backup;


p.84
$ exp userid=system/manager full=Y inctype=complete constraints=Y
file=full_export_filename


p.85
$ exp userid=system/manager full=Y inctype=cumulative constraints=Y
file=cumulative_export_filename


$ exp userid=system/manager full=Y inctype=incremental constraints=Y
file=incremental_export_filename


p.87
$ backup/log/ignore=(interlock, nobackup) -
DiskA:[dir_path]*.dbs DiskB:[backup_dir_path]*.dbs

$ backup/log/ignore=interlock DiskA:[dir_path]*.rdo -
DiskB:[backup_dir_path]*.rdo

$ backup/log/ignore=interlock DiskA:[dir_path]*.con -
DiskB:[backup_dir_path]*.con


$ mount/foreign tape_device:
$ backup/log/ignore=interlock DiskA:[dir-path]*.dbs -
tape_device:db_test.bck/sav


$ mount/over=id tape_device:
$ copy  DiskA:[backup_dir_path]*.dbs  tape_device:


$ mount/foreign tape_device:
$ backup/rewind/list tape_device:*/sav


$ backup/rewind tape_device:db_test.bck/sav/select=(test.dbs,..) -
disk:[dir_path]file/new_version/owner=parent/log


p.88
$ mount  tape_device:  volume_label    !ɁC̃R}hgp邱Ƃł܂D
$ mount/over=id tape_device:
$ dir tape_device:                      !e[vׂ̂Ẵt@CXg\ꍇ
$ copy tape_device:file  disk:[dir_path]file  !t@Ce[voꍇ


p.89
$ ls /dsk*/ORACLE/prod/*.*  |  cpio -pdk new-dir

$ ls /dsk*/ORACLE/prod/*.dbf  |  cpio -pdk new-dir

$ ls /dsk*/ORACLE/prod/*.rdo  |  cpio -pdk new-dir


$ cpio -ic < /bck/arch010194


$ cat /bck/arch010194 | cpio -ic


$ cpio -icr < /bck/arch010194


$ ls /dsk*/ORACLE/*.* | cpio -ocBv  >  tape_device


$ find . -depth -print | cpio -ocBv  > tape_device


p.90
$ cpio -itBv < tape_device


$ cpio -icBv file  < tape_device
$ cpio -icdBv file < tape_device


$ tar cf - . | ( cd to_dir; tar xf - )


$ tar -cvf  /dev/rmt0h  /dsk*/ORACLE/*.*


p.91
$ tar -tvf tape_device

$ tar -xvf tape_device


p.92
$ cp -p datafile  /bck/datafile

$ cp -p -r data_file_dir    bck_dir


p.93
$ dump 0Bf 400 /dev/rra2a  /bck/db_files


$ dump 0undf /dev/rmt0h /bck/db_files


$ restor r device              iftHg̃foCX肵Ăj
$ restor r /dev/da0            ĩt@CVXéCfBXNda0ɃXgAj


$ restor x file


p.96
$ /etc/fbackup -f tape_device -g graph_file -u -0
$ /etc/fbackup -0I /usr -e /usr/lib -f /dev/rmt0h
$ cd /usr/adm/fbackupfiles
$ /etc/fbackup -0uc config -g graphs -I indices -f /dev/rmt0h
# graphs file
i         /dsk1
i         /dsk2
i         /dsk3/oracle
i         /dsk4/usr
e         /dsk1/usr/class
e         /dsk2/usr/test


p.103
C:\> OCOPY7.1 current_file backup_file
C:\> OCOPY7.1 /B current_file a:
C:\> OCOPY7.1 /R a: restore_dir



Chapter4
p.114-119
$ vvv = 'f$verify(0)'  ! unoverifyvw肵C؂̎w𖳌ɂ
$! t@C:    ORACLE_UTILS:BACKUP_MAIN.COM
$! ړI:        Oraclef[^x[X̃R[h/zbgobNAbvCGNX|[g̎s
$! N@:     submit backup_main.com -
$!            /parameters=(dbname, export mode, resubmit flag)
$!            ܂
$!            @oracle_utils:backup_main dbname [export mode] [resubmit flag]
$!
$!          :  @backup_main TESTDB COMPLETE YES
$!
$! p[^:
$!          P1: ̎sΏۂƂȂf[^x[X̖O
$!          P2: sGNX|[g̃^Cv: INCREMENTALCCUMULATIVEC
$!                  ܂COMPLETE
$!          P3: ĎstOiIvVj: YESCNOiftHgl=YESj
$!              NOݒ肷ƁCYWu͗CĎsȂD
$!
$! {vV[WĂяovV[W:   
$!         oracle_utils:env_symbols.com   !f[^x[XV{̃ZbgAbv
$!         oracle_utils:export_database.com    ! f[^x[X̃GNX|[g
$!         oracle_utils:hot_backup.com     ! f[^x[X̃zbgobNAbvs
$!         oracle_utils:cold_backup.com    ! f[^x[X̃R[hobNAbvs
$!
$! {vV[W̌Ăяo: ʏ́Csubmit_backup_dbname.com
$!            Tvt@Cisubmit_backup_TESTDB.samplej̓[U[ύX
$!            ܂ȂD
$!
$! :   V{:   𐧌䂷邽߂ɕύXłÃV{ɂĂ͖{XNvg
$!                     "USER_PARAMETERS"ZNVQƂ̂ƁD
$!         _:     ORACLE_UTILŚCobNAbvXNvgׂĊi[ĂfB
$!                     NgĂ邱ƁD
$!         t@C:   Ȃ
$!
$! o:   V{:  Ȃ.
$!               _:  Ȃ.
$!         t@C:  ړIɂ͂ȂDCexport_database.comC
$!                  hot_backup.comCoracle_utils:cold_backup.comւ
$!                  Ăяoɂč쐬S܂͈ꕔ̃t@CΏۂƂĂ
$!                  ȂD
$!
$!
$! : {XNvgOracleAJEgs邱ƂOł邽ߌ̃`FbN͎s
$!       ȂD
$!
$! :
$!   t               O            Rg
$!   1995N320  Saar Maoz     쐬
$!
$!!!!!!!!  ̃ZNV́CobNAbvvV[W̍\pɃ[U[ύX\
$ USER_PARAMETERS:
$!
$! p[^_daysŏÎɂĂ͐l͂ȂD
$! Sunday̏ꍇ̓GNX|[gCSaturday̏ꍇ̓R[hobNAbvC̑̏ꍇ
$! zbgobNAbvsD̒ĺCKvɉĕύXĂ܂ȂD
$  export_days := "/Sunday/"
$  hot_backup_days := "/Monday/Tuesday/Wednesday/Thursday/Friday/"
$  cold_backup_days := "/Saturday/"
$  userpasswd := system/manager
$  logfile := sys$scratch:save_database
$  mailuser = "SMAOZ"         ! [bZ[WKvłȂꍇ́C""ݒ
$!!!!!!!!!
$!
$ set noon
$!
$! ̓ɍĎsł悤ɁCs̊Jnۑ
$!
$ begin_time = f$time()
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ delfile := delete/noconfirm/log
$ sendmail := mail nl: 'mailuser' /subject=
$ something_done =0
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ db_name = f$edit(p1,"UPCASE")
$ export_mode = f$edit(p2, "UPCASE")
$ submit_flag =  f$edit(p3, "UPCASE")
$ if submit_flag .eqs. "" then submit_flag := YES ! default value to submit flag
$!
$! ̐ݒ
$!
$ if f$trnlnm("oracle_utils") .eqs. "" then goto NO_LOGICAL
$ @oracle_utils:env_symbols.com
$!
$! ̃R}hɂāCf[^x[XD
$! ORA_DB:ORAUSER_DBNAME.COMsĐf[^x[X悤ȃf[^x[X
$! p̃V{CORACLE_UTILS:ENV_SYMBOLS.COM̒Œ`ĂȂ΂ȂȂD
$!
$ 'db_name'
$ if .not. $status then goto NO_SYMBOL
$ show logical ora_sid
$!
$ today = f$cvtime("TODAY",,"WEEKDAY")   ! get day of week.
$!
$! [U[ɂĒ`Ă鐳ꏊɁCjɏ]ău`D
$! 1ɕ̃^XNsĂ܂ȂD
$!
$ if f$locate("''today'",export_days) .ne. -
     f$length(export_days) then              call DO_EXPORT
$!
$ if f$locate("''today'",hot_backup_days) .ne. -
     f$length(hot_backup_days) then          call DO_HOT_BACKUP
$!
$ if f$locate("''today'",cold_backup_days) .ne. -
     f$length(cold_backup_days) then         call DO_COLD_BACKUP
$!
$! KvɉāC{XNvg𗂓ēxsD
$!
$ goto RESUBMIT
$!
$! sȂꍇ́C񃁃bZ[Wo
$!
$ if something_done then goto FINISH
$ say " "
$ say "INFORMATION ** ORACLE_UTILS:BACKUP_MAIN.COM **"
$ say " There was no backup/export defined to be done today, if this is a"
$ say " mistake check the USER_PARAMETERS section in"+-
      " ORACLE_UTILS:BACKUP_MAIN.COM"
$ goto FINISH
$!
$ DO_EXPORT: SUBROUTINE
$!
$! GNX|[gp̃[`Ăяo
$!
$ something_done =1
$ @oracle_utils:export_database 'db_name' 'export_mode'
$ EXIT
$ ENDSUBROUTINE
$!
$ DO_HOT_BACKUP: SUBROUTINE
$!
$! zbgobNAbvp̃[`Ăяo
$!
$ something_done =1
$ @oracle_utils:hot_backup 'db_name'
$ EXIT
$ ENDSUBROUTINE
$!
$ DO_COLD_BACKUP: SUBROUTINE
$!
$! R[hobNAbvp̃[`Ăяo
$!
$ something_done =1
$ @oracle_utils:cold_backup 'db_name'
$ EXIT
$ ENDSUBROUTINE
$!
$ RESUBMIT:
$!
$! KvɉāC{XNvg𗂓ēxsD
$!
$ if .not. submit_flag  then goto FINISH
$ submit oracle_utils:backup_main.com -
      /parameters=("''db_name'","''export_mode'","''submit_flag'") -
      /after="''begin_time'+23:59:59" -
      /log='logfile'_'db_name'.log -
      /queue=sys$batch -
      /retain=error -
      /noprint
$ if f$search("''logfile'_''db_name'.log") .nes. "" then purge/nolog/
$ keep=8 'logfile'
$!
$ goto FINISH
$!
$! G[ZNV
$!  {XNvg̈ȍ~́̕CG[p̃ZNVłDG[bZ[Wo͂
$!  邽тɁCMAIL_FINISHiE-mail𑗐MjFINISHiE-mail𑗐MȂjɃu
$!  `DftHǵCE-mailMD[ŃbZ[W𑗐MȂ
$!  ꍇ́CY郉xύX邱ƁD
$!
$ NO_SYMBOL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:BACKUP_MAIN.COM **"
$  say " a. No symbol found with the database name that runs the"
$  say "    ORAUSER_<dbname>.COM which will point us to the right database,"
$  say "    add it to ORACLE_UTILS:ENV_SYMBOLS.COM"
$  say " b. Some other error has occured while attempting to run the"
$  say "    ORAUSER_<dbname>.COM file, check the preceding VMS error message"
$  goto MAIL_FINISH
$!
$ NO_LOGICAL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:BACKUP_MAIN.COM **"
$  say " The logical name ORACLE_UTILS is not defined please define it to 
   point"
$  say " to the directory where all the backup scripts reside."
$  goto MAIL_FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:BACKUP_MAIN.COM is:"
$  say " @ORACLE_UTILS:BACKUP_MAIN db_name [export mode] [submit]"
$  say " db_name : Database name"
$  say " export_mode : INCREMENTAL, CUMULATIVE or COMPLETE"
$  say " submit : YES | NO (default=YES)"
$  goto FINISH
$!
$ MAIL_FINISH:
$  if mailuser .eqs. "" then goto FINISH
$!
$! Θb^[hƃob`[ĥǂœ삵Ă邩ɉāC[𑗐MD
$!
$  msg = "Backup procedure run in interactive mode failed"
$  if f$mode() .eqs. "BATCH" then msg = "Backup procedure terminated"+-
         " with errors check ''logfile'_''db_name'.log for details"
$  sendmail "''msg'"
$  goto FINISH
$!
$ FINISH:
$  if vvv then set verify
$  Exit


p.119-124
$ vvv = 'f$verify(0)'  ! unoverifyvw肵C؂̎w𖳌ɂ
$! t@C:    ORACLE_UTILS:EXPORT_DATABASE.COM
$! ړI:            f[^x[X̑S̃GNX|[giINCREMENTALCCUMULATIVEC܂
$!            COMPLETEjsD
$! N@:    ʏ́Coracle_utils:backup_mainĂяoDC
$!            {vV[WʂɌĂяoꍇ́Ĉ悤Ɏw肷邱ƁD
$!            @oracle_utils:export_database dbname export_mode
$!
$!          :  @export_database TESTDB COMPLETE
$!
$! p[^:
$!          P1: GNX|[g̎sΏۂƂȂf[^x[X̖O
$!          P2: sGNX|[g̃^Cv: INCREMENTALCCUMULATIVEC܂
$!              w肵Ȃꍇ́CCOMPLETEftHglɂȂD
$!
$! {vV[WĂяovV[W:   
                  oracle_utils:env_symbols.com       ! f[^x[XV
$!                                                          {̃ZbgAbv
$!                oracle_utils:db_name_devices.com ! obNAbvΏۂ̃foCX
$!                                                   ̖O̎擾
$!                oracle_utils:instance_up           ! CX^X̓/_
$!                                                     E󋵂̃`FbN
$!                oracle_utils:startup_dbamode       ! RESTRICT[hł̋N
$!                ora_db:shutdown_db_name          ! normal[hŃVbg_E
$!
$! {vV[W̌Ăяo:
$!           {XNvg͒ʏCBACKUP_MAIN.COMĂяoDC{XNvg
$!           ʂɌĂяoĂ܂ȂD
$!
$!    V{:   {XNvg̏𐧌䂷邽߂ɕύXłÃV{ɂĂ
$!                    {XNvgUSER_PARAMETERSZNVQƂ̂ƁD
$!        _:     ORACLE_UTILŚCobNAbvXNvgׂ
$!                    i[ĂfBNgĂ邱ƁD
$!        t@C :  Ȃ
$!
$! o:  V{:   Ȃ.
$!        _:     Ȃ
$!        t@C:   export_location:export_db_name_export_mode.dmp
$!                    w肵CN^x̃GNX|[gt@CD
$!
$! : {XNvgOracleAJEgs邱ƂOł邽
$!       ̃`FbN͎sȂD
$!
$! :
$!   t               O            Rg
$!   1995N320  Saar Maoz     쐬
$!
$!
$!!!!!!!!  ̃ZNV́CGNX|[gvV[W̍\pɃ[U[ύX\
$ USER_PARAMETERS:
$  export_buffer = 524288       ! Y[U[BYTLMl\ł邩mF邱ƁD
$! userpasswd := system/manager
$! mailuser = "SMAOZ"          ! [bZ[WKvłȂꍇ́C""ݒ
$!!!!!!!!!
$!
$ set noon
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ delfile := delete/noconfirm/log
$ sendmail := mail nl: 'mailuser' /subject=
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ db_name = f$edit(p1,"UPCASE")
$ export_mode = f$edit(p2,"UPCASE")
$ if export_mode  .eqs. "" then export_mode := COMPLETE  !ftHgl
$!
$ if export_mode .nes. "INCREMENTAL" .and. export_mode .nes. -
     "CUMULATIVE" .and. export_mode .nes.  "COMPLETE" then HELP
$!
$ if f$type(userpasswd) .eqs. "" .or. f$type(mailuser) .eqs. "" -
     then goto NO_SYMS
$!
$ say " "
$ say "ORACLE_UTILS:EXPORT_DATABASE.COM begins a ''export_mode' export on"
$ say " ''db_name' database at: "+f$time()
$ say " "
$!
$! ̐ݒ
$!
$ if f$trnlnm("oracle_utils") .eqs. "" then goto NO_LOGICAL
$ @oracle_utils:env_symbols  !PȂmF
$!
$! ̃R}hɂāCf[^x[XD
$! ORA_DB:ORAUSER_DBNAME.COMsĐf[^x[X悤ȃf[^x[X
$! p̃V{CORACLE_UTILS:ENV_SYMBOLS.COM̒Œ`ĂȂ΂ȂȂD
$!
$ 'db_name'
$ if .not. $status then goto NO_SYMBOL
$ show logical ora_sid
$ @oracle_utils:'db_name'_devices.com    ! Define export location
$!
$! GNX|[g悪݂CꂪfBXNł邱Ƃ`FbN
$!
$ show logical export_location
$ if .not. f$getdvi("export_location","EXISTS") then goto NO_EXPORT_LOCATION
$ if f$getdvi("export_location","DEVCLASS") .ne. 1 then goto NOT_A_DISK
$ show device export_location
$!
$! CX^XオĂ邩`FbN
$!
$ @oracle_utils:instance_up 'f$trnlnm("ora_sid")'
$!
$ if instance_up then goto EXPORT
$!
$ say " "
$ say "ORACLE_UTILS:EXPORT_DATABASE.COM"
$ say " Instance was shutdown and an export is due so starting database up..."
$ say " "
$ @oracle_utils:startup_dbamode 'db_name'
$!
$ EXPORT:
$ say " "
$ say "ORACLE_UTILS:EXPORT_DATABASE.COM is now deleting last week's export"
$ say " "
$ if f$search("export_location:export_''db_name'_''export_mode'.dmp") .nes. ""
$ then
$   directory/date=(created,backup)/size=all -
      export_location:export_'db_name'_'export_mode'.dmp
$   delfile export_location:export_'db_name'_'export_mode'.dmp;*
$ endif
$!
$! ۂ̃GNX|[g̎s
$!
$ on error then goto EXPORT_ERROR
$ exp userid='userpasswd' -
      buffer='export_buffer' -
      file=export_location:export_'db_name'_'export_mode'.dmp -
      inctype='export_mode' -
      full=y -
      grants=y -
      indexes=y -
      rows=y -
      constraints=y -
      compress=n -
      statistics=none
$!
$ say " "
$ say "ORACLE_UTILS:EXPORT_DATABASE.COM finished a ''export_mode' export on"
$ say " ''db_name' database at: "+f$time()
$ say " "
$ if mailuser .nes. "" then  sendmail -
     "''export_mode' export finished successfully at ''f$time()'"
$!
$ if .not. instance_up
$ then
$   say " "
$   say "ORACLE_UTILS:EXPORT_DATABASE.COM"
$   say " The database was shutdown when export begun, so bringing it back down"
$   say " "
$   @ora_db:shutdown_'db_name'
$ endif
$ goto FINISH
$!
$! G[ZNV
$!  {XNvg̈ȍ~́̕CG[p̃[`łDG[bZ[W
$!  o͂邽тɁCMAIL_FINISHiE-mail𑗐MjFINISHiE-mail𑗐MȂj
$!  Ƀu`DftHǵCE-mailMD[ŃbZ[W𑗐M
$!  Ȃꍇ́CY郉xύX邱ƁD
$!
$ NO_SYMS:
$  say " "
$  say "ERROR ** ORACLE_UTILS:EXPORT_DATABASE.COM **"
$  say " The local symbols userpasswd or mailuser are not defined"
$  say " This usually means that this script was called independently and the"
$  say " USER_PARAMETERS section of this script was not updated"
$  say " "
$  goto FINISH
$!
$ NO_LOGICAL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:EXPORT_DATABASE.COM **"
$  say " The logical name ORACLE_UTILS is not defined. Please define it to"
$  say " point to the directory where all the backup scripts reside."
$  goto MAIL_FINISH
$!
$ NO_SYMBOL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:EXPORT_DATABASE.COM **"
$  say " a. No symbol found with the database name that runs the"
$  say "    ORAUSER_dbname.COM which will point us to the right database,"
$  say "    add it to ORACLE_UTILS:ENV_SYMBOLS.COM"
$  say " b. Some other error has occured while attempting to run the"
$  say "    ORAUSER_dbname.COM file, check the preceding VMS error message"
$  goto MAIL_FINISH
$!
$ NO_EXPORT_LOCATION:
$  say " "
$  say "ERROR ** ORACLE_UTILS:EXPORT_DATABASE.COM **"
$  say " The logical name EXPORT_LOCATION which controls where the export file"
$  say " will be created is not defined."
$  goto MAIL_FINISH
$!
$ NOT_A_DISK:
$  say " "
$  say "ERROR ** ORACLE_UTILS:EXPORT_DATABASE.COM **"
$  say " The export location pointed to by EXPORT_LOCATION logical name is not"
$  say " a disk.  Sorry, this script does not currently do exports to tape."
$  goto MAIL_FINISH
$!
$ EXPORT_ERROR:
$  st=$status
$  say " "
$  say "ERROR ** ORACLE_UTILS:EXPORT_DATABASE.COM **"
$  say " An error has occured during the export, final VMS error code: ''st'"
$  say " Text: "+f$message(st)
$  goto MAIL_FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:EXPORT_DATABASE.COM is:"
$  say " @ORACLE_UTILS:EXPORT_DATABASE db_name export_mode"
$  say " db_name : Database name to export"
$  say " export_mode : INCREMENTAL, CUMULATIVE or COMPLETE"
$  goto FINISH
$!
$ MAIL_FINISH:
$  if mailuser .eqs. "" then goto FINISH
$!
$! Θb^[hƃob`[ĥǂœ삵Ă邩ɉāC[𑗐MD
$!
$  msg = "''export_mode' export run in interactive mode failed"
$  if f$mode() .eqs. "BATCH" then msg = "''export_mode' export terminated"+-
         " with errors check ''logfile'_''db_name'.log for details"
$  sendmail "''msg'"
$  goto FINISH
$!
$ FINISH:
$  if vvv then set verify
$  Exit


p.126-136
$ vvv = 'f$verify(0)'  ! unoverifyvw肵C؂̎w𖳌ɂ
$! t@C:   ORACLE_UTILS:HOT_BACKUP.COM
$! ړI:       f[^x[X́uzbgvobNAbvsD
$! N@:   ʏ́Coracle_utils:backup_mainĂяoDC
$!             {vV[WʂɌĂяoꍇ́Ĉ悤Ɏw肷邱ƁD
$!             @oracle_utils:hot_backup dbname
$!
$!          :  @hot_backup TESTDB
$!
$! p[^:
$!          P1: zbgobNAbv̎sΏۂƂȂf[^x[X̖O
$!
$! {vV[WĂяovV[W:   
$!          oracle_utils:env_symbols.com   ! f[^x[XV{̃ZbgAbv
$!          oracle_utils:db_name_devices.com ! obNAbvΏۂ̃foCX̖O̎擾
$!          oracle_utils:instance_up     ! CX^X̓/_E󋵂̃`FbN
$!          oracle_utils:tbs_to_datafiles.sql  ! \̈/f[^t@C̃Xg
$!                                               ̐
$!          oracle_utils:tablespace_state.sql  ! \̈̏Ԃ̕\
$!          oracle_utils:hot_backup_cmd_db_name.com ! zbgobNAbv
$!                                                    s
$!           |-> oracle_utils:env_symbols.com
$!           |-> oracle_utils:backup_tablespace ! 1\̈敪̃obNAbv
$!           |-> oracle_utils:instance_up
$!           |-> ora_db:ora_db_db_name       ! ora_control*_obNAbv̎擾
$!
$! vV[W̌Ăяo:
$!           {XNvg͒ʏCBACKUP_MAIN.COMĂяoDC{XNvg
$!           ʂɌĂяoĂ܂ȂD
$!
$! : V{:  {XNvg̏𐧌䂷邽߂ɕύXłÃV{ɂĂ
$!                  {XNvg"USER_PARAMETERS"ZNVQƂ̂ƁD
$!        _:   ORACLE_UTILŚCobNAbvXNvgׂĊi[Ă
$!                  fBNgĂ邱ƁD
$!                  ORA_CONTROL*ɂ́Cora_db:ora_db_db_name.comɂĒ`
$!                  Ă
$!        t@C: backup_location_1:tbs_to_datafiles.lisobNAbv  
$!                  ΏۂƂȂ\̈/f[^t@C
$!
$! o:  V{:  Ȃ
$!        _:    Ȃ
$!        t@C:  * oracle_utils:hot_backup_cmd_db_name.com
$!                   ́CIɍ쐬DCLXNvgłD̃XNvǵC
$!                   SQLDBA̒ɓC\̈؂ւăobNAbv̊Jn/I
$!                   sCY\̈̃obNAbv
$!                   oracle_utils:backup_tablespaceĂяočsD
$!                   ̏́CׂĂ̕\̈ɑ΂ĎsDIƁC
$!                   t@C̃Rs[ۑD
$!
$!             * backup_location_1:restore_database.com
$!                   ́CIɍ쐬DCLXNvgłCYzbgobNAb
$!                   ṽXgAsD̃t@Cgpꍇ́C{XNvg
$!                   ɂăf[^x[X̃Rs[XgACf[^x[X̎ۂ̉
$!                   sKvD
$!                   ̃t@Cɂ̓obNAbvs̃f[^x[X̊et@C̃Rs
$!                   [foCXL^Ă邽߁C̃t@C͕ۑĂƁD
$!                   ڍׂɂẮC̃t@CQƂ̂ƁD
$!
$!             * backup_location_1:tbs_to_datafiles.lis
$!                   ́CSELECT̏o͂łC̃t@CΕ\̈您
$!                   f[^t@C̖OƃTCYiVMS̃ubNj킩D̃t@C
$!                   ̃R[h̗CɎD
$!      "SYSTEM|DISK$AXPVMSSYS:[ORACLE7.ROOT71.DB_TESTDB]ORA_SYSTEM.DBS
$!      |12288"
$!                  ̃t@ĆCoracle_utils:tbs_to_datafiles.sqlɂ
$!                  쐬D
$!
$!              * Yf[^x[X1̐t@C̃obNAbv́C擪̃obN
$!                AbvfoCXɊi[D
$!
$! : {XNvgOracleAJEgs邱ƂOł邽ߌ̃`FbN
$!      sȂD
$!
$! :
$!   t               O            Rg
$!   1995N320  Saar Maoz     쐬
$!
$!!!!!!!! ̃ZNV́CobNAbvvV[W̍\pɃ[U[ύX\
$ USER_PARAMETERS:
$!
$! {XNvgPƂŎgpꍇ́C2s̃Rg邱ƁD
$! userpasswd := system/manager
$! mailuser = "SMAOZ"           ! [bZ[WKvłȂꍇ́C""ݒ
$!!!!!!!!
$!
$ set noon
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ wo2 := write outfile2
$ delfile := delete/noconfirm/log
$ backupfile := backup/log/ignore=(interlock,nobackup)/new
$ sendmail := mail nl: 'mailuser' /subject=
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ db_name = f$edit(p1,"UPCASE")
$!
$ if f$type(userpasswd) .eqs. "" .or. f$type(mailuser) .eqs. "" -
     then goto NO_SYMS
$!
$ say " "
$ say "ORACLE_UTILS:HOT_BACKUP.COM begins a hot backup on"+-
      " ''db_name' database at: "+f$time()
$ say " "
$!
$! ̐ݒ
$!
$ if f$trnlnm("oracle_utils") .eqs. "" then goto NO_LOGICAL
$ @oracle_utils:env_symbols  !PȂmF
$!
$! ̃R}hɂāCf[^x[XD
$! ORA_DB:ORAUSER_DBNAME.COMsĐf[^x[X悤ȃf[^x[X
$! p̃V{CORACLE_UTILS:ENV_SYMBOLS.COM̒Œ`ĂȂ΂ȂȂD
$!
$ 'db_name'
$ if .not. $status then goto NO_SYMBOL
$ show logical ora_sid
$ @oracle_utils:'db_name'_devices.com    ! gp\ȃobNAbv̊i[ꏊ̒`
$!
$! gp\ȃfoCX̃JEgifBXN̂݁j
$!
$ show log backup_location_*
$ device_cnt=1
$ DEV_LOOP:
$  if .not. f$getdvi("backup_location_''device_cnt'","EXISTS") -
      then goto DEV_VER  ! foCX݂邩mF
$  if f$getdvi("backup_location_''device_cnt'","DEVCLASS") .ne. 1 -
      then goto DEV_VER  ! foCXfBXNł邩mF
$  show device backup_location_'device_cnt'
$  device_cnt= device_cnt+1
$ goto DEV_LOOP
$!
$ DEV_VER:
$  device_cnt= device_cnt-1
$  if device_cnt .eq. 0 then goto NO_BACKUP_DEVICES ! foCXȂꍇ
$!
$  say " "
$  say "ORACLE_UTILS:HOT_BACKUP.COM has recognized ''device_cnt' devices to"+-
     " use for backup."
$  say " "
$!
$! CX^XオĂ邩`FbN
$!
$ @oracle_utils:instance_up 'f$trnlnm("ora_sid")'
$ if .not. instance_up then goto UP_FOR_HOT    ! zbgobNAbvs
$ DBオĂȂ΂ȂȂ
$!
$! \̈/f[^t@C̃Xgt@C̐Ƌt@C̍폜
$!
$ if f$search("backup_location_1:tbs_to_datafiles.lis") .nes. "" -
     then delfile/nolog backup_location_1:tbs_to_datafiles.lis;*
$ if f$search("oracle_utils:hot_backup_cmd_''db_name'.com") .nes. "" -
     then purge/nolog/keep=2 oracle_utils:hot_backup_cmd_'db_name'.com
$!
$ sqlplus -s 'userpasswd'  @oracle_utils:tbs_to_datafiles.sql
$!
$! \̈/f[^t@C̃Xgt@C̃I[vD̃t@C݂Ȃꍇ́C炩
$! QĂD
$!
$ close/nolog infile
$ open/read/error=OPEN_TBS_ERROR infile 
  backup_location_1:tbs_to_datafiles.lis
$ read/end=EMPTY_TBS_LIST infile rec  ! t@C̐擪siRgjXLbv
$!
$! sqldba̒ɓĎۂALTER TABLESPACE BEGIN BACKUPsCVMS
$! obNAbvsČALTER TABLESPACE END BACKUPs悤ȃXN
$! vg̍쐬JnD
$!
$ close/nolog outfile
$ open/write outfile oracle_utils:hot_backup_cmd_'db_name'.com
$!
$ wo "$! FILE:  oracle_utils:hot_backup_cmd_''db_name'.com"
$ wo "$! Dynamically created by ORACLE_UTILS:HOT_BACKUP.COM at: ''f$time()'"
$ wo "$! to perform hot backup of ''db_name' database"
$ wo "$ set noon"
$ wo "$ if f$search(""backup_location_1:alter_tbs_begin_end.log"") -"
$ wo " .nes. """" then delfile/nolog backup_location_1:tbs_tbs_begin_end.log;*"
$ wo "$ vvv = 'f$verify(1)' ! sqldba̒ŃR}h悤Ɍ؂LɂD"
$ wo "$ sqldba lmode=y"
$ wo "connect internal"
$ wo "alter system archive log current;"  ! JgREDOO؂ւC
$!                                        ! ̃A[JCus邽
$ wo "  REM It is normal to get warning messages from backup in the form:"
$ wo "  REM %BACKUP-W-ACCONFLICT, <file name> is open for write by another user"
$!
$! \̈1
$!
$ prv_tbs = ""
$LOOP:
$ read/end=END_INFILE infile rec
$ tbs = f$element(0,"|",rec)             ! \̖̈O𒊏o
$ file = f$element(1,"|",rec)            ! t@C̎dl𒊏o
$ size = f$element(2,"|",rec)            ! t@C̃TCY𒊏o
$!
$ if tbs .eqs. prv_tbs then goto LOOP    ! ς݂̏ꍇ̓XLbv
$!
$ if prv_tbs .eqs. ""
$ then
$   wo "spool backup_location_1:alter_tbs_begin_end.log"
$   wo "alter tablespace ''tbs' begin backup;"
$   wo "spool off"
$ else
$   wo "spool backup_location_1:alter_tbs_begin_end.log"
$   wo "alter tablespace ''prv_tbs' end backup;"
$   wo "spool off"
$   wo "spool backup_location_1:alter_tbs_begin_end.log"
$   wo "alter tablespace ''tbs' begin backup;"
$   wo "spool off"
$ endif
$!
$ wo "host @oracle_utils:backup_tablespace ''tbs' ''db_name' ''device_cnt'"
$ prv_tbs = tbs
$!
$ goto LOOP
$END_INFILE:
$!
$! Ō̕\̈end backupR}hǉCt@C̃Rs[ۑ
$!
$ wo "spool backup_location_1:alter_tbs_begin_end.log"
$ wo "alter tablespace ''tbs' end backup;"
$ wo "spool off"
$ wo "alter database backup controlfile to "+-
  "''''backup_location_1:ora_control_''db_name'.con'''';"
$ wo "exit"
$ wo "$ if vvv then set verify"
$ wo "$ exit"
$ close/nolog outfile
$ close/nolog infile
$!
$ say "ORACLE_UTILS:HOT_BACKUP.COM is now deleting previous backup files"
$ say " on all devices with the name BACKUP_LOCATION_*"
$ say " "
$ dev_cnt=1
$ DELETE_YESTERDAYS_BCK:
$!
$ delfile backup_location_'dev_cnt':*.*.* - ! 쐬΂̕\̈/f[^t@C
          /exclude=(*.lis.*,*.dmp.*)        ! Xgt@CGNX|[gt@C
$!                                        ! 폜Ȃ
$ dev_cnt=dev_cnt+1
$ if dev_cnt .lt. device_cnt then goto  DELETE_YESTERDAYS_BCK
$!
$! ̃obNAbv烊XgAsƂɎgp
$! RESTORE_DATABASE.COM̍쐬Jn
$!
$ close/nolog outfile2
$ open/write outfile2 backup_location_1:restore_database.com
$ wo2 "$!FILE: backup_location_1:restore_database.com"
$ wo2 "$!Dynamically created by ORACLE_UTILS:HOT_BACKUP.COM at: "+-
        f$time()
$ wo2 "$!"
$ wo2 "$ type sys$input"
$ wo2 "  This script will restore all database files from their backup location"
$ wo2 "  to their location on production environment. It will first delete the"
$ wo2 "  database file if it exists in the production environment, and then"
$ wo2 "  copy a backup of that file to that location."
$ wo2 "  It will then copy all the control files to their location in"
$ wo2 "  the same fashion (deleting the production ones first)."
$ wo2 " "
$ wo2 "  This script should be run only if you plan to perform a database"
$ wo2 "  recovery from a HOT backup."
$ wo2 "  To invoke this script edit it and remove the EXIT statement following"
$ wo2 "  this notice"
$ wo2 "$!"
$ wo2 "$ EXIT"
$ wo2 "$!"
$ wo2 "$ db_name := ''db_name'"
$ wo2 "$ if f$trnlnm(""oracle_utils"") .eqs. """" then goto NO_LOGICAL"
$ wo2 "$ @oracle_utils:env_symbols"
$ wo2 "$ ''''db_name''''"
$ wo2 "$ @ora_db:ora_db_''''db_name''''" ! ora_control*̘_obNAbv擾邽
$ wo2 "$ if f$trnlnm(""ora_control1"") .eqs. """" then goto NO_CTL_LOGICALS"
$ wo2 "$!"
$ wo2 "$ @oracle_utils:instance_up ''''f$trnlnm(""ora_sid"")''''"
$ wo2 "$ if instance_up then goto INSTANCE_UP"
$ wo2 "$!"
$ wo2 "$ @oracle_utils:''db_name'_devices"
$ wo2 "$!"
$ wo2 "$ set noon"
$ wo2 "$!"
$ wo2 "$ delfile := ''delfile'"
$ wo2 "$ backupfile := ''backupfile'"
$ wo2 "$!"
$ close/nolog outfile2
$!
$! ׂĂ̕\̈̃obNAbv1s߂ɍ쐬΂̃XNvgĂяoD
$!
$ sqlplus -s 'userpasswd'  @oracle_utils:tablespace_state.sql ! sȌ
$ @oracle_utils:hot_backup_cmd_'db_name'.com
$ sqlplus -s 'userpasswd'  @oracle_utils:tablespace_state.sql  ! s̏
$!
$! obNAbvׂ̂Ă̊Jn/ĨOG[DG[ꍇ́CG[
$!
$ search backup_location_1:alter_tbs_begin_end.log;* "ORA-"/exact/win=1
$ if $status .ne. %X08D78053 then goto HOT_BACKUP_PROBLEM
$!
$! ̗Lpȏrestore_databaset@Cɏ
$!
$ close/nolog outfile2
$ open/append outfile2 backup_location_1:restore_database.com
$ wo2 "$!"
$ wo2 "$ type sys$input"
$ wo2 "  Restoration of all data files of database ''db_name' has"
$ wo2 "  been completed. Please review the log file or screen for any errors."
$ wo2 "  Since this restore was from a HOT backup, you will need to recover"
$ wo2 "  the database before you are able to use it.  Go into SQLDBA"
$ wo2 "  and issue:"
$ wo2 "  1. connect internal"
$ wo2 "  2. startup MOUNT ''db_name';"
$ wo2 "  3. set autorecovery ON;
$ wo2 "  4. recover database; (or add the until clause)"
$ wo2 "  5. Then ALTER DATABASE OPEN; (use RESETLOGS in case of an"+-
      " incomplete recovery)"
$ wo2 " "
$ wo2 " Note: The controlfiles were not restored, if you need to use them"
$ wo2 "       please do so manually."
$ wo2 " "
$ wo2 "  Good Luck!"
$ wo2 "$ goto FINISH"
$ wo2 "$!"
$ wo2 "$ INSTANCE_UP:"
$ wo2 "$ type sys$input"
$ wo2 "ERROR ** BACKUP_LOCATION_1:RESTORE_DATABASE.COM **"
$ wo2 "  The database is UP.  One or more processes belonging to this database"
$ wo2 "  is still running.  This script should be run when the database is"
$ wo2 "  DOWN.  Make sure the database is down; if necessary, issue a SHUTDOWN"
$ wo2 "  ABORT, then rerun this script to restore a backup of this database."
$ wo2 "$ goto FINISH"
$ wo2 "$!"
$ wo2 "$ NO_LOGICAL:"
$ wo2 "$ type sys$input"
$ wo2 "ERROR ** BACKUP_LOCATION_1:RESTORE_DATABASE.COM **"
$ wo2 " The logical name ORACLE_UTILS is not defined. Please define it to point"
$ wo2 " to the directory where all the backup scripts reside."
$ wo2 "$ goto FINISH"
$ wo2 "$!"
$ wo2 "$ NO_CTL_LOGICALS:"
$ wo2 "$ type sys$input"
$ wo2 "ERROR ** BACKUP_LOCATION_1:RESTORE_DATABASE.COM **"
$ wo2 "  Can't find the controlfile logicals (ORA_CONTROL*)."
$ wo2 "  They are usually defined in ORA_DB:ORA_DB_''db_name'.COM, and not"
$ wo2 "  hardcoded as controlfile names in the init.ora file"
$ wo2 "$ goto FINISH"
$ wo2 "$!"
$ wo2 "$ FINISH:"
$ wo2 "$ Exit"
$ close/nolog outfile2
$!
$ say " "
$ say "ORACLE_UTILS:HOT_BACKUP.COM finished a hot backup on"+-
      " ''db_name' database at: "+f$time()
$ say " "
$ if mailuser .nes. "" then sendmail -
  "HOT backup operation for ''db_name' database completed at: ''f$time()'"
$!
$ goto FINISH
$!
$! G[ZNV
$!  {XNvg̈ȍ~́̕CG[p̃[`łDG[bZ[Wo͂
$!  тɁCMAIL_FINISHiE-mail𑗐MjFINISHiE-mail𑗐MȂjɃu`
$!  DftHǵCE-mailMD[ŃbZ[W𑗐MȂꍇ́CY
$!  郉xύX邱ƁD
$!
$ NO_SYMS:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " The local symbols userpasswd or mailuser are not defined"
$  say " This usually means that this script was called independently and the"
$  say " USER_PARAMETERS section of this script was not updated"
$  say " "
$  goto FINISH
$!
$ NO_LOGICAL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " The logical name ORACLE_UTILS is not defined. Please define it to"
$  say " point to the directory where all the backup scripts reside."
$  goto MAIL_FINISH
$!
$ NO_SYMBOL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " a. No symbol found with the database name that runs the"
$  say "    ORAUSER_<dbname>.COM, which will point us to the right database."
$  say "    Add it to ORACLE_UTILS:ENV_SYMBOLS.COM."
$  say " b. Some other error has occured while attempting to run the"
$  say "    ORAUSER_<dbname>.COM file. Check the preceding VMS error message."
$  goto MAIL_FINISH
$!
$ NO_BACKUP_DEVICES:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " No backup locations with the name BACKUP_LOCATION_* found."
$  say " Please define some backup locations in ''db_name'_DEVICES.COM"
$  say " and verify that the devices exist."
$  goto MAIL_FINISH
$!
$ UP_FOR_HOT:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " The database ''db_name' is down, and a hot backup was attempted"
$  goto MAIL_FINISH
$!
$ OPEN_TBS_ERROR:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " An error has occured opening the tablespace datafiles mapping file."
$  say " It is located in BACKUP_LOCATION_1:TBS_TO_DATAFILES.LIS."
$  say " Please verify that the location is a valid directory owned by Oracle"
$  say " or the person running this script.  Also make sure that the Oracle"
$  say " shareable images are installed using ORA_RDBMS:INSORACLE.COM, which"
$  say " is required to run sqlplus"
$  goto MAIL_FINISH
$!
$ EMPTY_TBS_LIST:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " Found tablespace listings file empty"+-
$      " (BACKUP_LOCATION_1:TBS_TO_DATAFILES.LIS)"
$  goto MAIL_FINISH
$!
$ HOT_BACKUP_PROBLEM:
$  say " "
$  say "ERROR ** ORACLE_UTILS:HOT_BACKUP.COM **"
$  say " ALTER TABLESPACE BEGIN or END BACKUP command was issued."
$  say " Please check logfile or backup_location_1:alter_tbs_begin_end.log;*"
$  say " for more details."
$  goto MAIL_FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:HOT_BACKUP.COM is:"
$  say " @ORACLE_UTILS:HOT_BACKUP <db_name>"
$  goto FINISH
$!
$ MAIL_FINISH:
$  if mailuser .eqs. "" then goto FINISH
$!
$! Θb^[hƃob`[ĥǂœ삵Ă邩ɉāC[𑗐MD
$!
$  msg = "HOT backup procedure run in interactive mode failed"
$  if f$mode() .eqs. "BATCH" then msg = "HOT backup procedure terminated"+-
         " with errors check ''logfile'_''db_name'.log for details"
$  sendmail "''msg'"
$  goto FINISH
$!
$ FINISH:
$  close/nolog infile
$  close/nolog outfile
$  close/nolog outfile2
$  if vvv then set verify
$  exit


p.137-150
$ vvv = 'f$verify(0)'  ! unoverifyvw肵C؂̎w𖳌ɂ
$! t@C: ORACLE_UTILS:COLD_BACKUP.COM
$! ړI:        f[^x[X́uR[hvobNAbvsD
$! N@: ʏ́Coracle_utils:backup_main.comĂяoDC{vV[
$!          WʂɌĂяoꍇ́Ĉ悤Ɏw肷邱ƁD
$!          @oracle_utils:cold_backup dbname
$!
$!          :  @cold_backup TESTDB
$!
$! p[^:
$!          P1: R[hobNAbv̎sΏۂƂȂf[^x[X̖O
$!
$! {vV[WĂяovV[W:   
$!          oracle_utils:env_symbols.com ! f[^x[XV{̃ZbgAbv
$!          oracle_utils:db_name_devices.com   ! obNAbvΏۂ̃foCX̖O
$!                                               ̎擾
$!          oracle_utils:instance_up           ! CX^X̓/_E󋵂
$!                                               `FbN
$!          oracle_utils:shutdown_immediate    ! Vbg_E
$!          oracle_utils:startup_dbamode       ! RESTRICT[hł̋N
$!          oracle_utils:tbs_logfiles.sql      ! \̈/f[^t@C/REDO
$!                                               ÕXg
$!          oracle_utils:backup_tablespace     ! 1\̈敪̃obNAbv
$!          ora_db:ora_db_db_name              ! ora_control* _obNAbv̎擾
$!          ora_db:shutdown_db_name            ! normal[hł̃Vbg_E
$!          ora_db:startup_exclusive_db_name   ! f[^x[X̋N
$!
$! {vV[W̌Ăяo:
$! {XNvg͒ʏCBACKUP_MAIN.COMĂяoDC{XNvg
$! ʂɌĂяoĂ܂ȂD
$!
$! :  V{:   {XNvg̏𐧌䂷邽߂ɕύXłÃV{ɂẮC
$!                    {XNvg"USER_PARAMETERS"ZNVQƂ̂ƁD
$!        _:     ORACLE_UTILŚCobNAbvXNvgׂĊi[ĂfB
$!                    NgĂ邱ƁD
$!                    ORA_CONTROL*ɂ́Cora_db:ora_db_db_name.comɂĒ`
$!                    Ă鐧t@CiORA_PARAMŚCnode_SID_INIT.ORAt@
$!                    Cj̘_i[ĂD
$!         t@C:  backup_location_1:tbs_to_datafiles.lisobNAbv 
$!                    ̑ΏۂƂȂ\̈/f[^t@C
$!
$! o:   V{:  None.
$!         _:    Ȃ
$!         t@C:  * backup_location_1:restore_database.com
$!                     ́CIɍ쐬DCLXNvgłCYR[hobN
$!                     AbṽXgAsD̃t@CgpăR[hob
$!                     NAbv烊XgAśC񕜏sȂĂf[
$!                     ^x[XI[vłD
$!                     ̃t@Cɂ̓obNAbvs̃f[^x[X̊et@C̃R
$!                     s[foCXL^Ă邽߁C̃t@C͕ۑĂƁD
$!                     ڍׂɂẮC̃t@CQƂ̂ƁD
$!
$!                    * backup_location_1:tbs_to_datafiles.lis
$!                     ́CSELECT̏o͂łC̃t@CΕ\̈您
$!                     f[^t@C̖OƃTCYiVMS̃ubNj킩DR[h
$!                     obNAbv[hł́CREDOO̖OƃTCỸt@CɊi[
$!                     D  
$!                     ̃t@C̃R[h̗ɎD
$!      "SYSTEM|DISK$AXPVMSSYS:[ORACLE7.ROOT71.DB_TESTDB]
$!      ORA_SYSTEM.DBS|12288"
$!      "  |DISK$AXPVMSSYS:[ORACLE7.ROOT71.DB_TESTDB]ORA_LOG1.RDO|1000"
$!                  ̃t@ĆCoracle_utils:tbs_logfiles.sqlɂč쐬D
$!
$!              * Yf[^x[XREDOÕobNAbv́Cgp\ȃobNAbv
$!                foCX1Ɋi[D
$!
$!              * Yf[^x[X1̐t@C̃obNAbv́C擪̃obNA
$!                bvfoCXɊi[D
$!
$!              * INIT.ORAnodename_SID_INIT.ORAƂp[^t@C
$!                obNAbv́C擪̃obNAbvfoCXɊi[D
$!
$! : {XNvgOracleAJEgs邱ƂOł邽ߌ̃`FbN͎s
$!      ȂD
$!
$! :
$!   t               O            Rg
$!   1995N320  Saar Maoz     쐬
$!
$!!!!!!!! ̃ZNV́CobNAbvvV[W̍\pɃ[U[ύX\
$ USER_PARAMETERS:
$  shutdown_immediate_wait = 20 ! immediate[hŃVbg_E܂ł̑҂
$!
$! {XNvgPƂŎgpꍇ́C2s̃Rg邱ƁD
$! userpasswd := system/manager
$! mailuser = "SMAOZ"           ! [bZ[WKvłȂꍇ́C""ݒ
$!!!!!!!!
$!
$ set noon
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ delfile := delete/noconfirm/log
$ backupfile := backup/log/ignore=(interlock,nobackup)/new
$ sendmail := mail nl: 'mailuser' /subject=
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ db_name = f$edit(p1,"UPCASE")
$!
$ if f$type(userpasswd) .eqs. "" .or. f$type(mailuser) .eqs. "" -
     then goto NO_SYMS
$!
$ say " "
$ say "ORACLE_UTILS:COLD_BACKUP.COM begins a cold backup on"+-
      " ''db_name' database at: "+f$time()
$ say " "
$!
$! ̐ݒ
$!
$ if f$trnlnm("oracle_utils") .eqs. "" then goto NO_LOGICAL
$ @oracle_utils:env_symbols  !PȂmF
$!
$! ̃R}hɂāCf[^x[XDORA_DB:ORAUSER_DBNAME.COM
$! sĐf[^x[X悤ȃf[^x[Xp̃V{CORACLE_UTILS:ENV_
$! SYMBOLS.COM̒Œ`ĂȂ΂ȂȂD
$!
$ 'db_name'
$ if .not. $status then goto NO_SYMBOL
$ show logical ora_sid
$ @oracle_utils:'db_name'_devices.com    ! gp\ȃobNAbv̊i[ꏊ̒`
$!
$! t@C̃obNAbvōs悤ɁCt@C̘_擾
$!
$ @ora_db:ora_db_'db_name'
$ if f$trnlnm("ora_control1") .eqs. "" then goto NO_CTL_LOGICALS
$!
$! gp\ŗLȃfoCX̃JEgifBXN̂݁j
$!
$ show log backup_location_*
$ device_cnt=1
$ DEV_LOOP:
$  if .not. f$getdvi("backup_location_''device_cnt'","EXISTS") -
      then goto DEV_VER  ! foCX݂邩mF
$  if f$getdvi("backup_location_''device_cnt'","DEVCLASS") .ne. 1 -
      then goto DEV_VER  ! foCXfBXNł邩mF
$  show device backup_location_'device_cnt'
$  device_cnt= device_cnt+1
$ goto DEV_LOOP
$!
$ DEV_VER:
$  device_cnt= device_cnt-1
$  if device_cnt .eq. 0 then goto NO_BACKUP_DEVICES  ! foCXȂꍇ
$!
$  say " "
$  say "ORACLE_UTILS:COLD_BACKUP.COM has recognized ''device_cnt' devices to"+-
     " use for backup."
$  say " "
$!
$! CX^XオĂ邩`FbND̏󋵂̏̂߂ɕۑ
$!
$ @oracle_utils:instance_up 'f$trnlnm("ora_sid")'
$ instance_was_up = instance_up
$ if instance_up
$ then
$! CX^X́CオĂꍇCR[hobNAbv̂߂ɃVbg_EKv
$  say " "
$  say "ORACLE_UTILS:COLD_BACKUP.COM"
$  say " The ''db_name' database is UP and must be shut down in order to"
$  say " perform a COLD backup."
$  say " "
$!
$! S[U[ɒʒmC10Ƀf[^x[Ximmediate[hŃVbg_E
$!
$   reply/node/all/urgent/bell -
  "Database ''db_name' shutting down in 10 minutes for backup. Please logout!"
$   say " "
$   say "ORACLE_UTILS:COLD_BACKUP.COM"
$   say " Now waiting 10 minutes before shutting down immediate"
$   say " "
$   wait 0:10:0.0
$   @oracle_utils:shutdown_immediate 'db_name'
$   wait 0:02:0.0
$   min = 2
$!
$! CX^Ximmediate[hŃVbg_Ê҂
$!
$   SHUTDOWN_WAIT:
$     @oracle_utils:instance_up 'f$trnlnm("ora_sid")'  ! オĂ邩`FbN
$     if .not. instance_up then goto BRING_DB_UP
$     wait 0:05:0.0
$     min = min + 5
$     if min .ge. shutdown_immediate_wait then -
         goto SHUT_IMMED_TIMEOUT   ! ҂Ԃꍇ́CQĂ
$     goto SHUTDOWN_WAIT
$ endif
$!
$ BRING_DB_UP:
$!
$! 2̗RɂCf[^x[Xdba[hŋND
$! 1. f[^t@CREDOÕXgt@C擾D
$! 2. R[hobNAbv𐳏ɍs߂ɁCDBnormal[hŃVbg_ED
$! ̂悤ɂĂ΁Cnormal[hŃVbg_EDB̃obNAbvsƂłD
$!
$ say " "
$ say "ORACLE_UTILS:COLD_BACKUP.COM"
$ say " Bringing ''db_name' database up to get the list of datafiles/redologs"
$ say " and also to make sure it is shut down normal before this backup"
$ say " "
$ @oracle_utils:startup_dbamode 'db_name'
$!
$! \̈/f[^t@C̃Xgt@C̐Ƌt@C̍폜
$!
$ if f$search("backup_location_1:tbs_to_datafiles.lis") .nes. "" -
     then delfile/nolog backup_location_1:tbs_to_datafiles.lis;*
$ sqlplus -s 'userpasswd'  @oracle_utils:tbs_logfiles.sql
$!
$ say " "
$ say "ORACLE_UTILS:COLD_BACKUP.COM"
$ say " Shutting down ''db_name' database now for cold backup"
$ say " "
$ @ora_db:shutdown_'db_name'   ! R[hobNAbv𐳏ɍs悤ɁCnormal
$ [hŃVbg_E.
$!
$! \̈/f[^t@C̃Xgt@C̃I[vD̃t@C݂Ȃꍇ́CQ
$! ĂD
$!
$ close/nolog infile
$ open/read/error=OPEN_TBS_ERROR infile
  backup_location_1:tbs_to_datafiles.lis
$ read/end=EMPTY_TBS_LIST infile rec  ! t@C̐擪siRgjXLbv
$!
$ say "ORACLE_UTILS:COLD_BACKUP.COM is now deleting previous backup files"
$ say "  on all devices with the name BACKUP_LOCATION_*"
$ say " "
$ dev_cnt=1
$ DELETE_YESTERDAYS_BCK:
$!
$ delfile backup_location_'dev_cnt':*.*.* - ! 쐬΂̕\̈/f[^t@C
          /exclude=(*.lis.*,*.dmp.*)      ! Xgt@CGNX|[gt@C
$!                                        ! 폜Ȃ
$ dev_cnt=dev_cnt+1
$ if dev_cnt .lt. device_cnt then goto  DELETE_YESTERDAYS_BCK
$!
$! ̃obNAbv烊XgAsƂɎgpRESTORE_DATABASE.COM̍쐬Jn
$!
$ close/nolog outfile
$ open/write outfile backup_location_1:restore_database.com
$ wo "$!FILE: backup_location_1:restore_database.com"
$ wo "$!Dynamically created by ORACLE_UTILS:COLD_BACKUP.COM at: "+-
        f$time()
$ wo "$!"
$ wo "$ type sys$input"
$ wo "  This script will restore all database files from their backup location"
$ wo "  to their location on production environment. It will first delete   
  the"
$ wo "  database file if it exists in the production envrionment and then will"
$ wo "  copy a backup of that file to that location. The same will be done to"
$ wo "  restore all the logfiles."
$ wo "  After that it will copy all the controlfiles to their location in"
$ wo "  the same fashion (deleting the production ones first)."
$ wo " "
$ wo "  This script should be run only if you plan to restore a database"
$ wo "  from a COLD backup."
$ wo "  To invoke this script edit it and remove the EXIT statement following"
$ wo "  this notice"
$ wo "$!"
$ wo "$ EXIT"
$ wo "$!"
$ wo "$ db_name := ''db_name'"
$ wo "$ if f$trnlnm(""oracle_utils"") .eqs. """" then goto NO_LOGICAL"
$ wo "$ @oracle_utils:env_symbols"
$ wo "$ ''''db_name''''"
$ wo "$ @ora_db:ora_db_''''db_name'''' ! to get ora_control* logicals"
$ wo "$ if f$trnlnm(""ora_control1"") .eqs. """" then goto NO_CTL_LOGICALS"
$ wo "$!"
$ wo "$ @oracle_utils:instance_up ''''f$trnlnm(""ora_sid"")'''' ! is db up?"
$ wo "$ if instance_up then goto INSTANCE_UP"
$ wo "$!"
$ wo "$ @oracle_utils:''db_name'_devices  ! define available backup devices"
$ wo "$!"
$ wo "$ set noon"
$ wo "$!"
$ wo "$ delfile := ''delfile'"
$ wo "$ backupfile := ''backupfile'"
$ wo "$!"
$ close/nolog outfile
$!
$! f[^t@C̃Xgt@C̏ƑS\̈̃obNAbv
$!
$ prv_tbs = ""
$LOOP:
$ read/end=END_INFILE_ERROR infile rec
$ tbs = f$element(0,"|",rec)             ! extract tablespace name
$!
$! \̈́COuN̏ꍇOt@Cł邽߁CY鏈֐iށD
$!
$ if f$edit(tbs,"compress") .eqs. " " then goto BACKUP_LOGFILES
$!
$! uVv\̈̏ꍇ́Cۑ邽߂̃XNvgĂяo
$!
$ if tbs .nes. prv_tbs then -
  @oracle_utils:backup_tablespace 'tbs' 'db_name' 'device_cnt'
$ prv_tbs = tbs
$ goto LOOP
$!
$ BACKUP_LOGFILES:
$  open/append outfile backup_location_1:restore_database.com
$  wo "$! Restore all logfiles by first deleting originals and then"
$  wo "$! copying the saved files into the production environment."
$  wo "$!"
$!
$ LOG_LOOP:
$  file = f$element(1,"|",rec)          ! t@Cdl𒊏o
$  size = f$element(2,"|",rec)          ! t@C̃TCY𒊏o
$!
$! t@C̃obNAbvsƂʒm
$!
$  say " "
$  say "Attempting to back up ''file'"
$  dev_cnt = 1
$  FIND_DEVICE_LOOP:
$!
$!   YfBXNɗ̈͏\邩D̏ꍇ́C󂫃ubN2000cĂ
$!   ilocation_1𖞔tɂȂƂdvjD
$!
$    if f$getdvi("backup_location_''dev_cnt'","FREEBLOCKS") - 2000 .gt. size
$    then
$      say "                  to "+f$trnlnm("backup_location_''dev_cnt'")
$      say " "
$      backupfile 'file'; backup_location_'dev_cnt':/by=original
$      st = $status
$      if st .eq. %X10A38410 then goto BACKUP_OK  ! ݗpɃI[v
$      if .not. st then goto BACKUP_ERROR         ! obNAbvɊւ邻̑
$                                                   ̃G[
$!
$      BACKUP_OK:
$!
$!      쐬t@C̃tl[擾D́CRs[΂̃t@C̃o[Wԍ
$!      擾邽߁D̏ꍇ́CÕt@C݂ĂD
$!
$       fname=f$parse(file,,,"NAME")+f$parse(file,,,"TYPE")
$       full_name=f$search("backup_location_''dev_cnt':''fname'")
$!
$!      YREDOOXgA邽߂̃R}h쐬
$!
$       wo "$ if f$search(""''file'"") -"
$       wo " .nes. """" then -"
$       wo "       delfile ''file';"
$       wo "$ backupfile   ''full_name' -"
$       wo "               ''file'/by=original"
$       wo "$!"
$    else
$      dev_cnt = dev_cnt + 1                          ! ̃foCXɃXLbv
$      if dev_cnt .gt. device_cnt then goto NO_SPACE  ! ǂ̃foCXɂ̈悪Ȃ
$      goto FIND_DEVICE_LOOP
$    endif
$  read/end=COPY_CONTROLFILES infile rec    ! REDOÕRs[̊
$  goto LOG_LOOP
$!
$ COPY_CONTROLFILES:
$!
$ close/nolog infile     ! ̃t@C͂sv
$!
$! KvȂ̂́C1̐t@C
$!
$ backupfile ora_control1 -
             backup_location_1:ora_control_'db_name'.con/by=original
$ st = $status
$ if st .eq. %X10A38410 then goto COPY_PARAMS    ! ݗpɃI[v
$ if .not. st then goto BACKUP_ERROR             ! obNAbvɊւ邻̑̃G[
$!
$ COPY_PARAMS:
$!
$! INIT.ORA<nodename>_<SID>_INIT.ORǍƃobNAbv
$!
$ initora=f$parse("ora_params",,,"device")+-     ! init.oráCora_db:̒ɂȂƁC
          f$parse("ora_params",,,"directory")    ! i[ꏊs
$ initora=f$search(initora+"init.ora")
$ backupfile ora_params:;,'initora'-
             backup_location_1:/by=original
$ st = $status
$ if .not. st then goto BACKUP_ERROR              ! obNAbvɊւ鉽炩̃G[
$!
$! t@CׂăXgA邽߂̃R}h̍쐬ƃXgAt@Cւ̍ŏIIȏ̏
$! 
$!
$ wo "$!"
$ wo "$! Now restore all control files"
$ wo "$!"
$ wo "$ cnt=1"
$ wo "$ REPLACE_CTL:"
$ wo "$ backupfile backup_location_1:ora_control_''''db_name''''.con; -"
$ wo "             ora_control''''cnt''''/by=original"
$ wo "$ cnt=cnt+1"
$ wo "$!"
$ wo "$ if f$trnlnm(""ora_control""+f$string(cnt)) .nes. """" then "+-
      "goto REPLACE_CTL"
$ wo "$!"
$ wo "$ type sys$input"
$ wo " Restoration of datafiles, logfiles and control files of database"+-
      " ''db_name'"
$ wo " has been completed. Please review the logfile or screen for any errors."
$ wo " Since this restore was from a COLD backup, you can proceed to startup"
$ wo " the database."
$ wo " Please note that the parameter files INIT.ORA and <node>_<SID>_INIT.ORA"
$ wo " were not restored, although they have been originally backed up."
$ wo " If you wish to restore them, please do so manually."
$ wo " "
$ wo "  Good Luck!"
$ wo "$ goto FINISH"
$ wo "$!"
$ wo "$ INSTANCE_UP:"
$ wo "$ type sys$input"
$ wo "ERROR ** BACKUP_LOCATION_1:RESTORE_DATABASE.COM **"
$ wo "  The database is UP.  One or more processes belonging to this database"
$ wo "  is still running.  This script should be run when the database is"
$ wo "  DOWN.  Make sure the database is down, if necessary, issue a SHUTDOWN"
$ wo "  ABORT and rerun this script to restore a backup of the database."
$ wo "$ goto FINISH"
$ wo "$!"
$ wo "$ NO_LOGICAL:"
$ wo "$ type sys$input"
$ wo "ERROR ** BACKUP_LOCATION_1:RESTORE_DATABASE.COM **"
$ wo " The logical name ORACLE_UTILS is not defined. Please define it to point"
$ wo " to the directory where all the backup scripts reside."
$ wo "$ goto FINISH"
$ wo "$!"
$ wo "$ NO_CTL_LOGICALS:"
$ wo "$ type sys$input"
$ wo "ERROR ** BACKUP_LOCATION_1:RESTORE_DATABASE.COM **"
$ wo "  Can't find the controlfiles logicals (ORA_CONTROL*)"
$ wo "  They are usually defined in ORA_DB:ORA_DB_''db_name'.COM, and not"
$ wo "  hardcoded as controlfile names in the init.ora file"
$ wo "$ goto FINISH"
$ wo "$!"
$ wo "$ FINISH:"
$ wo "$ Exit"
$ close/nolog outfile
$!
$ say " "
$ say "ORACLE_UTILS:COLD_BACKUP.COM finished a cold backup on"+-
      " ''db_name' database at: "+f$time()
$ say " "
$ if mailuser .nes. "" then sendmail -
  "COLD backup operation for ''db_name' database completed at: ''f$time()'"
$!
$! f[^x[XƂƗオĂꍇ́Cf[^x[XēxNďI
$!
$ if instance_was_up
$ then
$  say " "
$  say "ORACLE_UTILS:COLD_BACKUP.COM"
$  say " The database was up when COLD backup started, so bringing it back up"
$  say " "
$  @ora_db:startup_exclusive_'db_name'
$ endif
$ goto FINISH
$!
$! G[ZNV
$!  {XNvg̈ȍ~́̕CG[p̃[`łDG[bZ[Wo͂
$!  тɁCMAIL_FINISHiE-mail𑗐MjFINISHiE-mail𑗐MȂjɃu`
$!  DftHǵCE-mailMD[ŃbZ[W𑗐MȂꍇ́C
$!  Y郉xύX邱ƁD
$!
$ NO_SYMS:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " The local symbols userpasswd or mailuser are not defined."
$  say " This usually means that the script was called independently and the"
$  say " USER_PARAMETERS section of the script was not updated."
$  say " "
$  goto FINISH
$!
$ NO_LOGICAL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " The logical name ORACLE_UTILS is not defined. Please define it to"
$  say " point to the directory where all the backup scripts reside."
$  goto MAIL_FINISH
$!
$ NO_SYMBOL:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " a. No symbol found with the database name that runs the"
$  say "    ORAUSER_<dbname>.COM, which will point us to the right database;"
$  say "    add it to ORACLE_UTILS:ENV_SYMBOLS.COM"
$  say " b. Some other error has occured while attempting to run the"
$  say "    ORAUSER_<dbname>.COM file; check the preceding VMS error message"
$  goto MAIL_FINISH
$!
$ NO_CTL_LOGICALS:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " Can't find the controlfiles logicals (ORA_CONTROL*)"
$  say " They are usually defined in ORA_DB:ORA_DB_''db_name'.COM, and not"
$  say " hardcoded as controlfile names in the init.ora file"
$  goto MAIL_FINISH
$!
$ NO_BACKUP_DEVICES:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " No backup locations with the name BACKUP_LOCATION_* found."
$  say " Please define some backup locations in ''db_name'_DEVICES.COM"
$  say " and verify that the devices exist."
$  goto MAIL_FINISH
$!
$ SHUT_IMMED_TIMEOUT:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " Waited for instance "+f$trnlnm("ora_sid")+" to shutdown immediate for"
$  say " ''min' minutes, but instance has not shutdown yet."
$  goto MAIL_FINISH
$!
$ BACKUP_ERROR:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " Received a VMS backup error final error code: ''st'"
$  say " Text: "+f$message(st)
$  goto MAIL_FINISH
$!
$ NO_SPACE:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " Not enough space for ''file'"
$  say " on any backup device. please assign more backup devices or clear some"
$  say " space on existing ones"
$  goto MAIL_FINISH
$!
$ OPEN_TBS_ERROR:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " An error has occured opening the tablespace datafiles mapping file."
$  say " It is located in BACKUP_LOCATION_1:TBS_TO_DATAFILES.LIS."
$  say " Please verify that the location is a valid directory owned by Oracle"
$  say " or the person running this script.  Also make sure that the Oracle"
$  say " shareable images are installed using ORA_RDBMS:INSORACLE.COM, which"
$  say " is required to run sqlplus."
$  goto MAIL_FINISH
$!
$ EMPTY_TBS_LIST:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " Found tablespace listings file empty"+-
$      " (BACKUP_LOCATION_1:TBS_TO_DATAFILES.LIS)"
$  goto MAIL_FINISH
$!
$ END_INFILE_ERROR:
$  say " "
$  say "ERROR ** ORACLE_UTILS:COLD_BACKUP.COM **"
$  say " Unexpected end of file BACKUP_LOCATION_1:TBS_LOGFILES.LIS"
$  say " The file is created by this script, and contains all the tablespaces"
$  say " names and their associated files, followed by the logfile names."
$  say " The first argument of a logfile record should be blank."
$  goto MAIL_FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:COLD_BACKUP.COM is:"
$  say " @ORACLE_UTILS:COLD_BACKUP <db_name>"
$  goto FINISH
$!
$ MAIL_FINISH:
$  if mailuser .eqs. "" then goto FINISH
$!
$! Θb^[hƃob`[ĥǂœ삵Ă邩ɉāC[𑗐MD
$!
$  msg = "COLD backup procedure run in interactive mode failed"
$  if f$mode() .eqs. "BATCH" then msg = "COLD backup procedure terminated"+-
         " with errors check ''logfile'_''db_name'.log for details"
$  sendmail "''msg'"
$  goto FINISH
$!
$ FINISH:
$  close/nolog infile
$  close/nolog outfile
$  if vvv then set verify
$  exit


p.151-155
$ vvv = 'f$verify(0)'  ! unoverifyvw肵C؂̎w𖳌ɂ
$! t@C:    ORACLE_UTILS:BACKUP_TABLESPACE.COM
$! ړI: \̈Ɋ֘Af[^t@CׂČC̃t@C̃obNAbvsD
$! N@:   @oracle_utils:backup_tablespace tbs db_name num_of_devs
$!
$!          : @oracle_utils:backup_tablespace SYSTEM TESTDB 6
$!
$! p[^:
$!          P1: obNAbv̑ΏۂƂȂ\̈
$!          P2: \̈悪f[^x[X̖O
$!          P3: gp\ȃobNAbvpfoCX̌
$!
$! {vV[WĂяovV[W:   Ȃ
$!
$! {vV[W̌Ăяo: 
$!            oracle_utils:cold_backup
$!            oracle_utils:hot_backup
$!
$! :    V{: Ȃ
$!            _: ORACLE_UTILŚCobNAbvXNvgׂĊi[ĂfB
$!                    NgĂ邱ƁD
$!          t@C: backup_location_1:tbs_to_datafiles.lisobNAbv 
$!                    ̑ΏۂƂȂ\̈/f[^t@C
$!
$! o:     V{: Ȃ
$!             _: Ȃ
$!           t@C: * backup_location_1:restore_database.com
$!                    ́CIɍ쐬DCLXNvgłCYobNAbv
$!                    ̃XgAsD܂CR[hƃzbĝǂ̃obNAb
$!                    vɂĊYt@C쐬ꂽD
$!
$!             * e\̈̈Ãf[^t@C̃obNAbv́CobNAbvpfoCX
$!               1Ɋi[D
$!
$! :
$!   t                O           Rg
$!   1995N320       Saar Maoz      쐬
$!
$ set noon
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ delfile := delete/noconfirm/log
$ backupfile := backup/log/ignore=(interlock,nobackup)/new
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$!
$ tbs_to_copy = p1
$ db_name = p2
$ device_cnt = p3
$!
$! \̈/f[^t@C̃Xgt@C̃I[vDYt@C݂Ȃꍇ͉炩
$! QĂD
$!
$ close/nolog infile2
$ open/read/error=OPEN_TBS_ERROR infile2 backup_location_1:tbs_to_datafiles.lis
$ read/end=EMPTY_FILE infile2 rec  ! t@C̐擪R[hiRgjXLbv
$!
$! YobNAbv烊XgAsƂɎgp
$!RESTORE_DATABASE.COMɃR}hǉ
$!
$ close/nolog outfile
$ open/append outfile backup_location_1:restore_database.com
$!
$ wo "$! Restore all files of tablespace ''tbs_to_copy' by first deleting"
$ wo "$! originals and then copying the saved files to the production"
$ wo "$! environment."
$ wo "$!"
$!
$! Y\̈̈Ãt@C𒲍
$!
$ MAIN_LOOP:
$   read/end=CLOSE_FILES infile2 rec
$   tbs = f$element(0,"|",rec)           ! \̖̈O𒊏o
$   if tbs .nes. tbs_to_copy then goto MAIN_LOOP
$!
$!  Rs[ׂt@C̂ŁCx͊YfBXNT
$!
$   file = f$element(1,"|",rec)          ! t@C̎dl𒊏o
$   size = f$element(2,"|",rec)          ! t@C̃TCY𒊏o
$!
$! t@C̃obNAbvsƂʒm
$!
$   say " "
$   say "Attempting to backup ''file'"
$   dev_cnt = 1
$   FIND_DEVICE_LOOP:
$!
$!    YfBXNɗ̈͏\邩D̏ꍇ́C󂫃ubN2000cĂ
$!    ilocation_1𖞔tɂȂƂdvjD
$!
$     if f$getdvi("backup_location_''dev_cnt'","FREEBLOCKS") - 2000 .gt. size
$     then
$       say "                  to "+f$trnlnm("backup_location_''dev_cnt'")
$       say " "
$       backupfile 'file'; backup_location_'dev_cnt':/by=original
$       st = $status
$       if st .eq. %X10A38410 then goto BACKUP_OK  ! ݗpɃI[v
$       if .not. st then goto BACKUP_ERROR
$!
$      BACKUP_OK:
$!
$!      쐬t@C̃tl[擾D́CRs[΂̃t@C̃o[W
$!      ԍ擾邽߁D̏ꍇ́CÕt@C݂ĂD
$!
$       fname=f$parse(file,,,"NAME")+f$parse(file,,,"TYPE")
$       full_name=f$search("backup_location_''dev_cnt':''fname'")
$!
$!      Yf[^t@CXgA邽߂̃R}h쐬
$!
$       wo "$ if f$search(""''file'"") -"
$       wo "  .nes. """" then -"
$       wo "       delfile ''file';"
$       wo "$ backupfile   ''full_name' -"
$       wo "               ''file'/by=original"
$       wo "$!"
$       goto MAIN_LOOP
$     endif
$     dev_cnt = dev_cnt + 1                          ! ̃foCXXLbv
$     if dev_cnt .gt. device_cnt then goto NO_SPACE  ! ǂ̃foCXɂ̈悪Ȃ
$     goto FIND_DEVICE_LOOP
$!
$ CLOSE_FILES:
$ close/nolog infile2
$ close/nolog outfile
$!
$ goto FINISH   !Done
$!
$! G[ZNV
$!  {XNvg̈ȍ~́̕CG[p̃[`łDG[bZ[Wo͂
$!  тɁCMAIL_STOPisIE-mail𑗐MjɃu`D̃XNvg
$!  I邩ǂ͂̃XNvgɂĂ邽߁C̃[`I邱ƂdvD
$!
$ OPEN_TBS_ERROR:
$  say " "
$  say "ERROR ** ORACLE_UTILS:BACKUP_TABLESPACE.COM **"
$  say " An error has occured opening the tablespace datafiles mapping file."
$  say " It's located in BACKUP_LOCATION_1:TBS_TO_DATAFILES.LIS"
$  say " Please verify that the location is a valid directory owned by Oracle"
$  say " or the person running this script.  Also make sure that the Oracle"
$  say " shareable images are installed using ORA_RDBMS:INSORACLE.COM which"
$  say " is required to run sqlplus"
$  goto MAIL_STOP
$!
$ EMPTY_FILE:
$  say " "
$  say "ERROR ** ORACLE_UTILS:BACKUP_TABLESPACE.COM **"
$  say " Tablespace datafiles mapping file is empty.  The file is created by"
$  say " ORACLE_UTILS:HOT/COLD_BACKUP.COM which calls"
$  say " ORACLE_UTILS:TBS_TO_DATAFILES.SQL or ORACLE_UTILS:TBS_LOGFILES.SQL"
$  say " respectively."
$  goto MAIL_STOP
$!
$ BACKUP_ERROR:
$  say " "
$  say "ERROR ** ORACLE_UTILS:BACKUP_TABLESPACE.COM **"
$  say " Received a VMS backup error final error code: ''st'"
$  say " Text: "+f$message(st)
$  goto MAIL_STOP
$!
$ NO_SPACE:
$  say " "
$  say "ERROR ** ORACLE_UTILS:BACKUP_TABLESPACE.COM **"
$  say " Not enough space for ''file'"
$  say " on any backup device. Please assign more backup devices or clear some"
$  say " space on existing ones."
$  goto MAIL_STOP
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:BACKUP_TABLESPACE.COM is:"
$  say " @ORACLE_UTILS:BACKUP_TABLESPACE.COM <tbsname> <db_name> <num_devs>"
$  say " look in ORACLE_UTILS:HOT/COLD_BACKUP for correct usage"
$  goto FINISH
$!
$ MAIL_STOP:
$  if mailuser .nes. "" then  sendmail -
     "Backup procedure terminated with error check logfile for details"
$!
$  STOP ! dȃG[߁C{XNvgі{XNvgĂяoĂ邷ׂẴXNvgI
$!
$ FINISH:
$  if vvv then set verify


p.155-156
$! t@C: ORACLE_UTILS:INSTANCE_UP.COM
$!       ړI: obNOEhvZXǂꂪオĂ邩`FbND
$! N@: @oracle_utils:instance_up SID
$!          : @oracle_utils:instance_up TEST
$!
$! p[^:
$!          P1 CX^X̃VXeIDiSIDj
$!
$! {vV[WĂяovV[W:   Ȃ
$!
$! {vV[W̌Ăяo: 
$!            oracle_utils:cold_backup
$!            oracle_utils:hot_backup
$!            oracle_utils:export_database
$!
$! :  V{:  Ȃ
$!        _:    Ȃ
$!        t@C:  Ȃ
$!
$! o:  V{: instance_upi1:オĂC0:_Ej
$!        _:    Ȃ
$!        t@C:  Ȃ
$!
$! :
$!   t               O            Rg
$!   1995N320  Saar Maoz     쐬
$!
$ set noon
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ sid = p1
$!
$ instance_up == 1
$ ctx = ""
$!
$! Ym[hORA_sid_*Ƃ悤ȖOvZXD̂悤ȃvZX́C
$! YCX^XɏĂobNOEhvZXłD
$!
$ tmp = f$context("PROCESS",ctx,"NODENAME","''f$getsyi("nodename")'","EQL")
$ tmp = f$context("PROCESS",ctx,"PRCNAM","ORA_''sid'_*","EQL")
$ pid = f$pid(ctx)
$ if pid .eqs. "" then instance_up == 0
$ goto FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:INSTANCE_UP.COM is:"
$  say " @ORACLE_UTILS:INSTANCE_UP SID"
$  goto FINISH
$!
$ FINISH:
$  exit


p.157
$! t@C:   ORACLE_UTILS:ENV_SYMBOLS.COM
$! ړI:       ef[^x[Xp̃V{ZbgAbvD
$! N@:   @oracle_utils:env_symbols
$! p[^: Ȃ
$! {vV[WĂяovV[W:   Ȃ
$!
$! {vV[W̌Ăяo: login.comsylogin.com]܂
$!
$! :  V{: Ȃ
$!        _:   Ȃ
$!        t@C: Ȃ
$!
$! o:  V{: db_name
$!        _:   Ȃ
$!        t@C: Ȃ
$!
$! :
$!   t               O            Rg
$!   1995N320      Saar Maoz       쐬
$!
$ set noon
$!
$! Ym[h̃f[^x[XƂɁCV{̂悤ɃZbgAbvD
$!
$! dbname :== @location_of_orauser_file.com
$!
$! :
$!
$! testdb :== @sys$sysdevice:[oracle7.root71.db_testdb]orauser_testdb
$!
$ Exit


p.158-160
$! t@C:  ORACLE_UTILS:SHUTDOWN_IMMEDIATE.COM
$! ړI:      f[^x[Ximmediate[hŃVbg_ED
$! N@:  @oracle_utils:shutdown_immediate db_name
$!            : @oracle_utils:shutdown_immediate TESTDB
$!
$! p[^:
$!          P1: f[^x[X̖O
$!
$! {vV[WĂяovV[W:   
$!          oracle_utils:shutdown_immediate_'db_name'.com
$!              \->oracle_utils:shutdown_immediate_'db_name'.sql
$!          ora_db:ora_db_db_name
$!
$! {vV[W̌Ăяo: oracle_utils:cold_backup
$!
$! :    V{: Ȃ
$!          _:   ORACLE_UTILŚCobNAbvXNvgׂĊi[ĂfB
$!                    NgĂ邱ƁD
$!                    ORA_PARAMŚCora_db:ora_db_db_name.comɂĒ`Ă
$!                    node_SID_INIT.ORAt@CĂ邱ƁD
$!          t@C: Ȃ
$!
$! o:    V{: Ȃ
$!          _:   Ȃ
$!          t@C: * oracle_utils:shutdown_immediate_db_name.sql
$!                    f[^x[X̃Vbg_EɕKvSQLDBÃR}hi[
$!                    CIɍ쐬XNvgD
$!                    * oracle_utils:shutdown_immediate_db_name.com
$!                    Iɍ쐬DCLXNvgłC̃XNvg̓f[^x[X
$!                    Vbg_E邽߂̏L̃t@CSQLDBA̒ɓĂ
$!                    ĂяoD
$!
$! :
$!   t               O             Rg
$!   1995N320  Saar Maoz     쐬
$!
$ set noon
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ wo2 := write outfile2
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ db_name = p1
$ @ora_db:ora_db_'db_name'                 ! ora_params̘_IȃobNAbvs
$ if f$trnlnm("ora_params") .eqs. "" then goto NO_PARAM_FILE
$!
$! Op[W
$!
$ if f$search("oracle_utils:shutdown_immediate_''db_name'.*") .nes. "" then -
   purge/nolog/keep=3 oracle_utils:shutdown_immediate_'db_name'.*
$!
$! Vbg_EۂɎs邽߂DCLXNvgSQLXNvg쐬
$!
$ close/nolog outfile
$ close/nolog outfile2
$ open/write outfile oracle_utils:shutdown_immediate_'db_name'.com
$ open/write outfile2 oracle_utils:shutdown_immediate_'db_name'.sql
$!
$ wo "$!Dynamically created by ORACLE_UTILS:SHUTDOWN_IMMEDIATE.COM at: "+-
     f$time()
$ wo "$!This script will go into sqldba and call a SQL script that will "
$ wo "$! shut down the ''db_name' database with the immediate option"
$ wo "$!"
$ wo "$ sqldba lmode=y"
$ wo "@oracle_utils:shutdown_immediate_''db_name'"
$ wo "exit"
$ wo "$exit"
$ close/nolog outfile
$!
$ wo2 "rem Dynamically created by ORACLE_UTILS:SHUTDOWN_IMMEDIATE.COM at: "+-
      f$time()
$ wo2 "rem This script issues the SQL statements to shutdown the ''db_name'"
$ wo2 "rem database with the immediate option"
$ wo2 "set echo on"
$ wo2 "connect internal"
$ wo2 "shutdown immediate"
$ close/nolog outfile2
$!
$! 쐬XNvgif[^x[Ximmediate[hŃVbg_Ejs
$!
$ @oracle_utils:shutdown_immediate_'db_name'.com
$ goto FINISH
$!
$ NO_PARAM_FILE:
$  say " "
$  say "ERROR ** ORACLE_UTILS:SHUTDOWN_IMMEDIATE.COM **"
$  say " The logical name ORA_PARAMS which points to the init.ora file of"
$  say " this ("+f$trnlnm(""ora_sid"")+") instance is not defined. The usual"
$  say " place where this logical is defined is ora_db:ora_db_''db_name'.com"
$  say " Please check why this logical was not defined and rerun this script."
$  goto FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:SHUTDOWN_IMMEDIATE.COM is:"
$  say " @ORACLE_UTILS:SHUTDOWN_IMMEDIATE <db_name>"
$  goto FINISH
$!
$ FINISH:
$  Exit


p.161-163
$! t@C:  ORACLE_UTILS:STARTUP_DBAMODE.COM
$! ړI:      f[^x[XRESTRICT[hiDBA[hjŋND
$! N@:  @oracle_utils:startup_dbamode db_name
$! :        @oracle_utils:startup_dbamode TESTDB
$!
$! p[^:
$!          P1: f[^x[X̖O
$!
$! {vV[WĂяovV[W:   
$!          oracle_utils:startup_dbamode_db_name.com
$!               \->oracle_utils:startup_dbamode_db_name.sql
$!          ora_db:ora_db_db_name
$!
$! {vV[W̌Ăяo:
$!          oracle_utils:cold_backup
$!          oracle_utils:export_database
$!
$! :  V{:  Ȃ
$!          _:  ORACLE_UTILŚCobNAbvXNvgׂĊi[
$!                   ĂfBNgĂ邱ƁDORA_PARAMŚC
$!                   ora_db:ora_db_db_name.comɂĒ`Ă
$!                   node_SID_INIT.ORAt@CĂ邱ƁD
$!        t@C:  Ȃ
$!
$! o:  V{:  Ȃ
$!          _:  Ȃ
$!        t@C:  * oracle_utils:startup_dbamode_db_name.sql
$!                   f[^x[XRESTRICT[hŋN̂ɕKv
$!                   SQLDBÃR}hi[CIɍ쐬XN
$!                   vgD
$!                   * oracle_utils:startup_dbamode_db_name.com
$!                   Iɍ쐬DCLXNvgłC̃XNvg
$!                   f[^x[XRESTRICT[hŋN邽߂̏L
$!                   t@CSQLDBA̒ɓĂĂяoD
$!
$! :
$!   t               O           Rg
$!   1995N320       Saar Maoz     쐬
$!
$ set noon
$!
$! {XNvgŎgp郍[JȃV{
$!
$ say := write sys$output
$ wo := write outfile
$ wo2 := write outfile2
$!
$! N@`FbN
$!
$ if p1 .eqs. "" then goto HELP
$ db_name = p1
$ @ora_db:ora_db_'db_name'                 ! ora_params̘_IȃobNAbv
$                                            s
$ if f$trnlnm("ora_params") .eqs. "" then goto NO_PARAM_FILE
$!
$! Op[W
$!
$ if f$search("oracle_utils:startup_dbamode_''db_name'.*") .nes. "" then -
   purge/nolog/keep=3 oracle_utils:startup_dbamode_'db_name'.*
$!
$! NۂɎs邽߂DCLXNvgSQLXNvg쐬
$!
$ close/nolog outfile
$ close/nolog outfile2
$ open/write outfile oracle_utils:startup_dbamode_'db_name'.com
$ open/write outfile2 oracle_utils:startup_dbamode_'db_name'.sql
$!
$ wo "$!Dynamically created by ORACLE_UTILS:STARTUP_DBAMODE.COM at: ''f$time()'"
$ wo "$!This script will go into sqldba and call a SQL script that will start"
$ wo "$!the ''db_name' database in restricted mode"
$ wo "$!"
$ wo "$ sqldba lmode=y"
$ wo "@oracle_utils:startup_dbamode_''db_name'"
$ wo "exit"
$ wo "$exit"
$ close/nolog outfile
$!
$ wo2 "rem Dynamically created by ORACLE_UTILS:STARTUP_DBAMODE.COM at: "+-
      f$time()
$ wo2 "rem This script issues the SQL statements to startup the ''db_name'"
$ wo2 "rem database in restricted mode."
$ wo2 "set echo on"
$ wo2 "connect internal"
$ wo2 "startup restrict open ""''db_name'"""
$ close/nolog outfile2
$!
$! 쐬XNvgif[^x[XRESTRICT[hŋNjs
$!
$ @oracle_utils:startup_dbamode_'db_name'.com
$ goto FINISH
$!
$ NO_PARAM_FILE:
$  say " "
$  say "ERROR ** ORACLE_UTILS:STARTUP_DBAMODE.COM **"
$  say " The logical name ORA_PARAMS which points to the init.ora file of"
$  say " this ("+f$trnlnm(""ora_sid"")+") instance is not defined. The usual"
$  say " place where this logical is defined is ora_db:ora_db_''db_name'.com."
$  say " Please check why this logical was not defined and rerun this script."
$  goto FINISH
$!
$ HELP:
$  say " "
$  say "Usage of ORACLE_UTILS:STARTUP_DBAMODE.COM is:"
$  say " @ORACLE_UTILS:STARTUP_DBAMODE <db_name>"
$  goto FINISH
$!
$ FINISH:
$ Exit


p.163
$ submit oracle_utils:backup_main.com -
      /parameters=("TESTDB","COMPLETE","YES") -
      /after="23:00" -
      /log=sys$scratch:save_database_TESTDB.log -
      /queue=sys$batch -
      /retain=error -
      /noprint
      
      
p.164
$! fBXNŗLȃfBNgB̃GNX|[gƂĒ`
$!
$ define/nolog export_location userdisk1:[export_testdb]
$!
$! Cӂ̃obNAbvfBNg`
$!
$ define/nolog  backup_location_1  sys$sysdevice:[hot_backup_testdb]
$ define/nolog  backup_location_2  userdisk21:[hot_backup_testdb]
$ define/nolog  backup_location_3  userdisk33:[hot_backup_testdb]
$ define/nolog  backup_location_4  userdisk14:[hot_backup_testdb]
$ define/nolog  backup_location_5  userdisk5:[hot_backup_testdb]
$ define/nolog  backup_location_6  userdisk4:[hot_backup_testdb]


p.164-165
set feedback off
set pagesize 0
set heading off
set echo off
set termout off
spool backup_location_1:tbs_to_datafiles

SELECT '! Dynamically created by ORACLE_UTILS:HOT_BACKUP.COM at: '||
       to_char(sysdate,'dd-mon-yyyy hh:mi:ss')
FROM dual;

rem Yf[^x[Xׂ̂Ẵf[^t@C擾

SELECT tablespace_name||'|'||file_name||'|'||ceil(bytes/512)
FROM   sys.dba_data_files
ORDER BY tablespace_name,bytes desc;

spool off;

EXIT


p.165
set feedback off
set pagesize 0
set heading off
set echo off
set termout off
spool backup_location_1:tbs_to_datafiles

SELECT '! Dynamically created by ORACLE_UTILS:COLD_BACKUP.COM at: '||
       to_char(sysdate,'dd-mon-yyyy hh:mi:ss')
FROM dual;

rem Yf[^x[Xׂ̂Ẵf[^t@C擾

SELECT tablespace_name||'|'||file_name||'|'||ceil(bytes/512)
FROM   sys.dba_data_files
ORDER BY tablespace_name,bytes desc;

rem Yf[^x[Xׂ̂ĂREDOO擾

SELECT '  '||'|'||member||'|'||ceil(bytes/512)
FROM   v$log,v$logfile
WHERE  v$log.group# = v$logfile.group#;
spool off;

EXIT


p.169-173
#! /bin/sh
#
# O                    $TOOLS/db_mgmt/backup/dbbackup
#
# $TOOLSϐɂ́CVXeǗp̃XNvgׂĊi[ĂfBNgݒ
#
# ړI                    f[^x[X̃obNAbvsD
#
# N@                $TOOLS/db_mgmt/backup/dbbackup dbname
#                             {XNvǵC$TOOLS/db_mgmt/backup/dbbackup_begin
#                             $TOOLS/db_mgmt/backup/dbbackup_exportĂяoD
# p[^           $1=dbname
# :
#   t               O               Rg
#   1995N32   Susie Ehrsam     쐬
#   1995N320  Sumant Chaudhari CуhLg
# ..............................................................
# ̐ݒ
# ..............................................................
. /db_admin/tools/system/crontab.env >> /dev/null

# ..............................................................
# [JϐibZ[WMOpt@CG[Ȃǁj̐ݒ
# ..............................................................
BEGIN_JOB="'date'"
ERRMSG='$TOOLS/db_mgmt/backup/dbbackup: syntax error, parameter=<dbname>'

if [ "$1" ]
then DBNAME=$1
else echo $ERRMSG
exit
fi

LOGFILE="/db_admin/db_$DBNAME/tools/log/${DBNAME}_backup_'date '+%y%m%d''.log"
LOGFILE2="/db_admin/db_$DBNAME/tools/log/${DBNAME}_backup_'date '+%y%m%d''_old.log"
ERRFILE="/db_admin/db_$DBNAME/tools/log/${DBNAME}_backup_'date '+%y%m%d''.err"
ERRFILE2="/db_admin/db_$DBNAME/tools/log/${DBNAME}_backup_'date '+%y%m%d''_old.err"
MSGFILE="/db_admin/db_$DBNAME/tools/log/${DBNAME}_backup_'date '+%y%m%d''.msg"
# ADMIN_FILÉC̃f[^x[XɊǗp̃R}hst@CD
# SCHED_FILÉCobNAbṽXPW[i[Ăt@CD
# JOBNAMÉC݂̃XNvgD
# DBBACKUP_BEGIŃCzbg܂̓R[h̃obNAbvsobNAbvXNvgD
# DBEXPORT_BEGIŃCf[^x[XGNX|[g邽߂̃XNvgD
# 
ADMIN_FILE="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_backup_admin.sh"
SCHED_FILE="/db_admin/tools/db_mgmt/backup/dbbackup_sched.dat"
JOBNAME="$TOOLS/db_mgmt/backup/dbbackup"
DBBACKUP_BEGIN="$TOOLS/db_mgmt/backup/dbbackup_begin"
DBEXPORT_BEGIN="$TOOLS/db_mgmt/backup/dbexport_begin"
TODAY="'date'"
THIS_DAY="'date '+%a''"
MSG="$DBNAME Backup succeeded at 'date'"
# ..............................................................
# XNvg̊JnDOt@CыG[t@C̕ۑD
# ..............................................................
if [ -f "$LOGFILE" ]; then
# 
# Ot@C̕ۑ
#
cat $LOGFILE >> $LOGFILE2
fi
if [ -f "$ERRFILE" ]; then
#
# G[t@C̕ۑ
#
cat $ERRFILE >> $ERRFILE2
fi
#
# ݂̃XNvg̖ObZ[Wt@CƃOt@Cɓ́D
# script_headeŕCbZ[Wt@CуOt@Cǂ݂₷邽߂ɂ
# XNvg̊JnʒuɈtʓIȃXNvgD
#
$TOOLS/system/script_header $JOBNAME > $MSGFILE
$TOOLS/system/script_header $JOBNAME > $LOGFILE

#
# obNAbṽXPW[ǂݍށDawkR}hgp邱ƂɂCobNAbv
# XPW[t@CC̓Ɏw肳Ăf[^x[X̃R[h𒊏o
# DawkɂĂ̏ڍׂ́CUNIXmany[WQƂ̂ƁD
#
awk -v dbname=$DBNAME -v this_day=$THIS_DAY '{
#
# R[h1擾
#
cmd=$0
sizeofarray=split(cmd,rec," ")
dbname2=rec[1]
day_of_week=rec[2]
backup=rec[3]
export=rec[4]
special_task=rec[5]
#  w肳ꂽf[^t@C̒̃Ggƃf[^x[Xѓ̗jv΁C
#  ̃Ggo͂CDO[vłɏD
#
if (( dbname2 == dbname ) && ( this_day == day_of_week )) 
print " " backup " " export " " special_task  
}' $SCHED_FILE | while read BACKUP EXPORT SPECIAL_TASK
do
. /db_admin/db_$DBNAME/.orauser_$DBNAME
#
# obNAbvJnOɁCp[^ׂďo
#
PARAMETER_MSG="
\n......................................................................
\nBackup Job Parameters:
\n
\nDatabase Name = $DBNAME
\nBackup Type   = $BACKUP
\nExport Type   = $EXPORT
\nSpecial Task  = $SPECIAL_TASK
\n
\nEnvironment Variables:
\nORACLE_HOME   = $ORACLE_HOME
\nORACLE_SID    = $ORACLE_SID
\nORACLE_BASE   = $ORACLE_BASE
\nPATH          = $PATH
\n......................................................................
\n
"
echo $PARAMETER_MSG >> $LOGFILE 2> $ERRFILE
echo $PARAMETER_MSG >> $MSGFILE
df >> $LOGFILE 2> $ERRFILE
echo " " >> $LOGFILE 2> $ERRFILE
#
# obNAbv: obNAbvIvVnobackupłȂꍇ́Cdbbackup_begin
# vV[WĂяoăobNAbvJnD
# 
if [ "$BACKUP" != "nobackup" ]; then
echo "..................................." >> $LOGFILE 2>> $ERRFILE
echo "Begin backup at 'date'" >> $LOGFILE 2>> $ERRFILE
echo "..................................." >> $LOGFILE 2>> $ERRFILE
$DBBACKUP_BEGIN $DBNAME $BACKUP $SPECIAL_TASK >> $LOGFILE 2>> $ERRFILE
echo "..................................." >> $LOGFILE 2>> $ERRFILE
echo "End backup at 'date'" >> $LOGFILE 2>> $ERRFILE
echo "..................................." >> $LOGFILE 2>> $ERRFILE
fi

#
# GNX|[g: GNX|[gIvVnoexportłȂꍇ́Cdbexport_begin
# vV[WĂяoăGNX|[gJnD
#
if [ "$EXPORT" != "noexport" ]; then
echo "..................................." >> $LOGFILE 2>> $ERRFILE
echo "Begin export at 'date'" >> $LOGFILE 2>> $ERRFILE
echo "..................................." >> $LOGFILE 2>> $ERRFILE
$DBEXPORT_BEGIN $DBNAME $EXPORT $SPECIAL_TASK >> $LOGFILE 2>> $ERRFILE
echo "..................................." >> $LOGFILE 2>> $ERRFILE
echo "End export at 'date'" >> $LOGFILE 2>> $ERRFILE
echo "..................................." >> $LOGFILE 2>> $ERRFILE
fi

echo " " >> $MSGFILE
echo "Backup log file errors and warnings:" >> $MSGFILE

echo " " >> $LOGFILE 2>> $ERRFILE
df >> $LOGFILE 2>> $ERRFILE
echo " " >> $LOGFILE 2>> $ERRFILE

#
# G[: Ot@C̒G[bZ[WxbZ[WTC̃bZ[W
# bZ[Wt@CɊi[DgreṕC̃p^[ƂɎgpUNIX
# [eBeBłDڍׂɂẮCUNIXmany[WQƂ̂ƁD
#
grep -e error -e warning -e ORA- -e EXP- -e fatal $LOGFILE | grep -v "No errors." >> $MSGFILE 
ERRCNT='grep -e error -e ORA- -e EXP- -e fatal $LOGFILE | grep -c -v "No errors."' 
grep -e error -e warning -e ORA- -e EXP- -e fatal $ERRFILE | grep -v "Export terminated successfully" >> $MSGFILE
ERRCNT2='grep -e error -e ORA- -e EXP- -e fatal $ERRFILE | grep -c -v "Export terminated successfully"'
END_JOB="'date'"
if [ "$ERRCNT" -gt 0 -o "$ERRCNT2" -gt 0 ]
then MSG="$DBNAME backup failed at ${END_JOB}"
else MSG="$DBNAME backup succeeded at ${END_JOB}"
fi

echo " " >> $MSGFILE
echo "Log files: " >> $MSGFILE
echo "Log file=$LOGFILE" >> $MSGFILE
echo "Error file=$ERRFILE" >> $MSGFILE
echo "Message file=$MSGFILE" >> $MSGFILE 
# script.footeŕC̃oi[D
$TOOLS/templates/script.footer "$BEGIN_JOB" "$END_JOB" >> $MSGFILE
$TOOLS/templates/script.footer "$BEGIN_JOB" "$END_JOB" >> $LOGFILE

#
# DBASɃ[𑗕t
#
$TOOLS/mail/dba_mail_list "$MSG" $MSGFILE $DBNAME 0


p.173-185
#! /bin/sh
# O            $TOOLS/db_mgmt/backup/dbbackup_begin
#
# ړI         f[^x[X̃obNAbvsD
#
# N@        $TOOLS/db_mgmt/backup/dbbackup_begin dbname backup special_task
# p[^      $1=dbname
#                 $2=obNAbṽ^Cv
#                 $3=ȃ^XN
# :
#   t               O                  Rg
#   1995N32   Susie Ehrsam     쐬
#   1995N320  Sumant Chaudhari obNAbvpWbN̏C

# ..............................................................
# [Jϐ̐ݒ
# ..............................................................
ERRMSG='
$TOOLS/db_mgmt/backup/dbbackup_begin: syntax error: 
dbbackup_begin <dbname> <hot|cold|nobackup> <special task>.
'
#
# R}hp[^̃`FbNDNULL̏ꍇ́CvV[WID
#
if [ "$1" ]
then DBNAME=$1
else echo $ERRMSG
exit 1 
fi
if [ "$2" ]
then BACKUP=$2
else echo $ERRMSG
exit 1
fi
if [ "$3" ]
then SPECIAL_TASK=$3
else SPECIAL_TASK=" "
fi
#
# u[^l
# 
TRUE=0
FALSE=1
SHUTDOWN_FAILED_B=1
RESTART_FAILED_B=1
#
# [Jϐ
#
ORAID="oracle"
BACKUPDIR="$TOOLS/backupdir/data"
BACKUPDIR1="$TOOLS/backupdir/data"
JOBNAME="$TOOLS/db_mgmt/backup/dbbackup_begin"
JOBNAME_SHORT="dbbackup_begin"
ADMIN_FILE="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_backup_admin.sh" 
DBBACKUP="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_backup_'date '+%y%m%d'.dyn"
WALL="/etc/wall"
CKSUM="/bin/cksum"
CMP="/bin/cmp"
BANNER="/db_admin/db_${DBNAME}/banner/status"
CKSUM_SIZE_ERR="${JOBNAME_SHORT}: fatal error in cksum size comparison."
CKSUM_VALUE_ERR="${JOBNAME_SHORT}: fatal error in cksum value comparison."
CKSUM_VALUE_WAR="${JOBNAME_SHORT}: warning in cksum value comparison."
CMP_ERR="${JOBNAME_SHORT}: fatal error in cmp."
DBSERR="${JOBNAME_SHORT}: fatal error in dbs file copy."
DBSWAR="${JOBNAME_SHORT}: warning with database file copy."
ARCERR="${JOBNAME_SHORT}: fatal error in archive log copy."
THISNODE='uname -n'
TSLIST="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_tablespaces"              
ERRORLOGFILE="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_backup_errors"
#   CURRENT_TABLESPACEϐ́C݂Ȃ悤ȕ\̖̈Oɏ
CURRENT_TABLESPACE="CURRENT"
#
# m[hɌŗLȃWbNij[Yɍ킹ăJX^}CY邱Ɓj
#
if [ "$THISNODE" = "prodhp1" ]
then TMP='/bugtmp'
else TMP='/dbatmp'
fi

# ..............................................................
# obNAbvvZX̊Jn
# ..............................................................

#
# orauserXNvgł́CORACLE_HOMECSIDCPATHȂǂ̊ϐݒ肷D
#
. /db_admin/db_$DBNAME/.orauser_$DBNAME
. $ADMIN_FILE

#
# f[^x[XICԂł邩ǂ`FbN
#
STATUS='ps -fu $ORAID | grep $DBNAME | grep ora_ | grep -v grep'
if [ $? != 0 ]; then
# 쒆̃obNOEhvZX1ȂC邢̓f[^x[X_EĂꍇ
if [ "$BACKUP" = "hot" ]; then
# zbgobNAbvsłȂꍇ
echo "${JOBNAME_SHORT}: Error - database is not online."
echo "${JOBNAME_SHORT}: process listing is to follow..."
echo "${JOBNAME_SHORT}: ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_"
ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_
echo "${JOBNAME_SHORT}: exiting."
exit 
else
# R[hobNAbvsꍇ́C̏s悢
echo "${JOBNAME_SHORT}: Database is already down.  Continuing."
echo "${JOBNAME_SHORT}: kill sqlnet v1 processes."
# DB͂łɃ_EĂ邽߁CcĂvZXI
$TOOLS/unix/kill_processes.sh oracle${DBNAME}
fi
else 
# f[^x[XłɗオĂꍇ
if [ "$BACKUP" = "cold" ]; then
# 
# Vbg_Eu[hLXgC̃oi[
#
$WALL /db_admin/db_${DBNAME}/banner/${DBNAME}_shutdown_15min.banner
$WALL /db_admin/db_${DBNAME}/banner/${DBNAME}_shutdown_5min.banner
$WALL /db_admin/db_${DBNAME}/banner/${DBNAME}_shutdown_1min.banner
# 
# K؂ȃVbg_EXNvggpăVbg_Es
#
echo "${JOBNAME_SHORT}: Shutting down immediate."
/db_admin/db_${DBNAME}/sql/shutdown_immediate_${DBNAME}.sh
#
# sqlnet̃vZXI
#
echo "${JOBNAME_SHORT}: kill sqlnet v1 processes."
$TOOLS/unix/kill_processes.sh oracle${DBNAME}
fi 
fi

if [ "$BACKUP" = "cold" ]; then
echo "${JOBNAME_SHORT}: Starting up restrict."
/db_admin/db_${DBNAME}/sql/startup_restrict_${DBNAME}.sh
fi
# ......................................................................
# obNAbv̊Jn
# ......................................................................
#
# f[^x[Xt@C̃Xg̍쐬DYt@Cɂ́C\̖̈OCt@C̖OC
# уobNAbv̈ꗗi[Df[^t@C̃p[eBVƂɁC
# t@C̃obNAbṽp[eBV1݂̂Ɖ肷DƂ΁Cdbf1C
# dbf2C...Cdbf12Ƃf[^t@C̃p[eBVꍇ́C̃t@C
# obNAbvpɃp[eBV12݂邱ƂɂȂD̂߁Cf[^t@Cp
# fBXN̗̈ǉꍇ́CobNAbvpɂfBXN̗̈ǉ邱ƁDf[^
# t@C̔zu@ƃRs[@́CobNAbv̖̌ƂȂ肩˂Ȃ̈
# ł悤C\SłȂ΂ȂȂDobNAbv́C̈Ɋւ鐧
# ɑΏł悤Ӑ[/݌v邱ƁD̃obNAbvXL[}gpꍇ́C
# ̃WbNJX^}CY邱ƁD

echo "${JOBNAME_SHORT}: building dynamic parameter file."
sqlplus -s sys/change_on_install > $DBBACKUP <<EOF
set pagesize 0
set linesize 2048
set heading off
set feedback off
column TNAME format a20
column FNAME format a80
select tablespace_name TNAME, 
file_name FNAME,
' \$BACKUPDIR'|| 
substr(file_name,instr(translate(file_name,'1234567890','0000000000'),'0'),
instr(file_name,'/',1,2)- instr(translate(file_name,'1234567890','0000000000'),'0'))
from sys.dba_data_files
order by tablespace_name,file_name;
exit
EOF

#
# It@C̃TCỸ`FbNDYt@C̍s̗CɎD
#  SYSTEM      /dbf1/DB1_system.dbf      /backup1/DB1
#
DYNSIZE='ls -al  $DBBACKUP | awk '{print $5}''
if [ $DYNSIZE = 0 ]; then 
echo "${JOBNAME_SHORT}: fatal error during backup file creation.  Backup aborting."
echo "${JOBNAME_SHORT}: cat $DBBACKUP"
cat $DBBACKUP
return
fi
#
# f[^x[Xׂ̂Ă̕\̈̃Xg쐬
echo "${JOBNAME_SHORT}: building list of tablespaces."
sqlplus -s sys/change_on_install > $TSLIST <<EOF
set pagesize 0
set linesize 2048
set heading off
set feedback off
column TNAME format a20
column FNAME format a80
select tablespace_name TNAME from sys.dba_tablespaces;
exit
EOF
cat $TSLIST
# obNAbvIvVR[hobNAbvp̂̂łꍇ́CVbg_E
#
if [ $BACKUP = "cold" ]; then
echo "${JOBNAME_SHORT}: Shutting down normal."  
. /db_admin/db_${DBNAME}/sql/shutdown_${DBNAME}.sh

STATUS='ps -fu $ORAID | grep -v grep | grep $DBNAME | grep -v ${DBNAME}1 | grep ora_'
if [ $? = 0 ]; then
echo "${JOBNAME_SHORT}: error in shutdown. Cold backup aborting."
SHUTDOWN_FAILED_B="$TRUE"
else
echo "${JOBNAME_SHORT}: Database is shutdown."
echo "${JOBNAME_SHORT}: move alert log."
mv /db_admin/db_${DBNAME}/bdump/alert_${DBNAME}.log \
/db_admin/db_${DBNAME}/bdump/alert_${DBNAME}.log_'date '+%y%m%d''
fi
fi

#
# obNAbvp[eBVɃf[^x[Xt@C̈ȑÕobNAbvi[ĂȂ`FbND
# i[Ăꍇ́CVobNAbvp̗̈mۂ邽߂ɁC̃t@C폜D
# ́̕CobNAbvp[eBVɍ킹ăJX^}CY邱ƁD
#
if [ $SHUTDOWN_FAILED_B = $TRUE ]; then
echo "${JOBNAME_SHORT}: Skipping backup file deletion."
else
echo " "
echo "${JOBNAME_SHORT}: Deleting previous backup..."
if [ -f $BACKUPDIR1/${DBNAME}_*.dbf ]; then rm $BACKUPDIR1/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR2/${DBNAME}_*.dbf ]; then rm $BACKUPDIR2/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR3/${DBNAME}_*.dbf ]; then rm $BACKUPDIR3/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR4/${DBNAME}_*.dbf ]; then rm $BACKUPDIR4/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR5/${DBNAME}_*.dbf ]; then rm $BACKUPDIR5/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR6/${DBNAME}_*.dbf ]; then rm $BACKUPDIR6/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR7/${DBNAME}_*.dbf ]; then rm $BACKUPDIR7/${DBNAME}_*.dbf; fi
if [ -f $BACKUPDIR8/${DBNAME}_*.dbf ]; then rm $BACKUPDIR8/${DBNAME}_*.dbf; fi

if [ -f $BACKUPDIR1/${DBNAME}_*.ctl ]; then rm $BACKUPDIR1/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR2/${DBNAME}_*.ctl ]; then rm $BACKUPDIR2/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR3/${DBNAME}_*.ctl ]; then rm $BACKUPDIR3/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR4/${DBNAME}_*.ctl ]; then rm $BACKUPDIR4/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR5/${DBNAME}_*.ctl ]; then rm $BACKUPDIR5/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR6/${DBNAME}_*.ctl ]; then rm $BACKUPDIR6/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR7/${DBNAME}_*.ctl ]; then rm $BACKUPDIR7/${DBNAME}_*.ctl; fi
if [ -f $BACKUPDIR8/${DBNAME}_*.ctl ]; then rm $BACKUPDIR8/${DBNAME}_*.ctl; fi

if [ $BACKUP = "cold" ]; then
if [ -f $BACKUPDIR1/${DBNAME}_*.log ]; then rm $BACKUPDIR1/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR2/${DBNAME}_*.log ]; then rm $BACKUPDIR2/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR3/${DBNAME}_*.log ]; then rm $BACKUPDIR3/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR4/${DBNAME}_*.log ]; then rm $BACKUPDIR4/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR5/${DBNAME}_*.log ]; then rm $BACKUPDIR5/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR6/${DBNAME}_*.log ]; then rm $BACKUPDIR6/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR7/${DBNAME}_*.log ]; then rm $BACKUPDIR7/${DBNAME}_*.log; fi
if [ -f $BACKUPDIR8/${DBNAME}_*.log ]; then rm $BACKUPDIR8/${DBNAME}_*.log; fi
else
if [ -f $CONBACK1/${DBNAME}_*.ctl ]; then rm $CONBACK1/${DBNAME}_*.ctl; fi
fi
fi

#
# obNAbvvV[W̊Jn
#
if [ $SHUTDOWN_FAILED_B = $FALSE ]; then
echo " "
echo "${JOBNAME_SHORT}:  Starting $BACKUP backup using $DBBACKUP..."
#
# f[^t@C̃zbgobNAbṽXe[^X`FbN
#
if  [ $BACKUP = "hot" ]; then
sqldba lmode=y <<EOF
connect internal
select * from v$backup;
exit
EOF
fi
# zbgobNAbv[hɂȂĂf[^t@Cꍇ́C̃obNAbvID
# ׂĂ̕\̈ɑ΂āCend backupsDOt@C̒̌x͖D
#
cat $TSLIST | while read TABLESPACE 
    do
         if [ $BACKUP = "hot" ]; then
           sqldba lmode = y  << EOF
           connect internal 
           alter tablespace $TABLESPACE end backup;
           exit
           EOF
         fi
    done

# t@CXg̓ǂݍ݂̊Jn
#
cat $DBBACKUP | while read TABLESPACE FILE DIR
do
if [ $BACKUP = "hot" ]; then
#  obNAbv̑ΏۂƂȂ擪̕\̈̏ꍇ
      if  [ $CURRENT_TS = "current" ]; then
           sqldba lmode = y << EOF
           connect internal 
           alter tablespace $TABLESPACE begin backup;
           exit
           EOF
      fi
#
#  ̕\̈iTABLESPACEj̃obNAbvsɂ́C݂̕\̈̃obNAbvIC
#  ̕\̈CURRENT_TSɂC̃obNAbvJnD
#
if  [ $BACKUP = "hot" ]; then
       if  [  $CURRENT_TS != 'eval echo \$TABLESPACE' ]; then
           sqldba lmode = y << EOF
           connect internal
           alter tablespace $CURRENT_TS  end backup;
           exit
           EOF
      CURRENT_TS =  'eval echo \$TABLESPACE'
           sqldba lmode = y << EOF
           connect internal
           alter tablespace $TABLESPACE begin backup;
           exit
EOF
       fi
fi
fi
#
# f[^x[Xt@C̃Rs[CTCY̌؁C`FbNT̎sȂ
#
BACKUPDIR='eval echo \$DIR'
echo "${JOBNAME_SHORT}: cp $FILE $BACKUPDIR"
cp $FILE $BACKUPDIR
STATUS=$?
if [ "$STATUS" != 0 ]; then
echo  "${JOBNAME_SHORT}: error during file copy $FILE."
fi
DATAFILE='basename $FILE'
if [ $BACKUP = "hot" ]; then
echo "${JOBNAME_SHORT}: $CKSUM $FILE $BACKUPDIR/$DATAFILE"
$CKSUM $FILE $BACKUPDIR/$DATAFILE
CKSUM_OUT='$CKSUM $FILE $BACKUPDIR/$DATAFILE'
echo $CKSUM_OUT | read VALUE1 SIZE1 NAME1 VALUE2 SIZE2 NAME2
if [ "$VALUE1" != "$VALUE2" ]; then
echo "$CKSUM_VALUE_WAR"
fi
if [ "$SIZE1" != "$SIZE2" ]; then
echo "$CKSUM_SIZE_ERR"
fi
else
echo "${JOBNAME_SHORT}: $CMP $FILE $BACKUPDIR/$DATAFILE"
$CMP $FILE $BACKUPDIR/$DATAFILE
STATUS="$?"
if [ "$STATUS" != 0 ]; then
echo "$CMP_ERR"
fi 
fi
done
#
# zbgobNAbṽXe[^X̃`FbN
#
if  [ $BACKUP = "hot" ]; then
sqldba lmode=y <<EOF
connect internal
select * from v$backup;
exit
EOF
fi
# zbgobNAbv[hɂȂĂȂ\̈悪ꍇ́C\̈̃obNAbvID
# Ot@C̒̌x͖D
#
cat $TSLIST | while read TABLESPACE 
     do
         if [ $BACKUP = "hot" ]; then
           sqldba lmode = y  << EOF
           connect internal 
           alter tablespace $TABLESPACE end  backup;
           exit
           EOF
         fi
     done
#
# t@CƃICREDOÕobNAbv
#
if [ $BACKUP = "hot" ]; then
echo "${JOBNAME_SHORT}: backing up controlfile to ${CONBACK1}/${DBNAME}_control01.ctl"
sqldba lmode=y <<EOF
connect internal
alter database backup controlfile to '${CONBACK1}/${DBNAME}_control01.ctl';
exit
EOF
#
else
#
# t@C̃Rs[Dt@Cׂ͂āC.ctl̊gq̂ƉD
#
echo "${JOBNAME_SHORT}: backing up all control files..."
if [ -f /dbf1/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf1/$DBNAME/${DBNAME}_*.ctl 
$BACKUPDIR1; fi
if [ -f /dbf2/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf2/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR2; fi
if [ -f /dbf3/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf3/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR3; fi
if [ -f /dbf4/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf4/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR4; fi
if [ -f /dbf5/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf5/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR5; fi
if [ -f /dbf6/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf6/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR6; fi
if [ -f /dbf7/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf7/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR7; fi
if [ -f /dbf8/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf8/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR8; fi
if [ -f /dbf9/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf9/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR9; fi
if [ -f /dbf10/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf10/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR10; fi
if [ -f /dbf11/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf11/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR11; fi
if [ -f /dbf12/$DBNAME/${DBNAME}_*.ctl ]; then cp /dbf12/$DBNAME/${DBNAME}_*.ctl $BACKUPDIR12; fi
#
# REDOOt@C̃Rs[DOt@Cׂ͂āC.log̊gq̂ƉD
#
echo "${JOBNAME_SHORT}: backing up all online redo logs..."
if [ -f /dbf1/$DBNAME/${DBNAME}_*.log ]; then cp /dbf1/$DBNAME/${DBNAME}_*.log $BACKUPDIR1; fi
if [ -f /dbf2/$DBNAME/${DBNAME}_*.log ]; then cp /dbf2/$DBNAME/${DBNAME}_*.log $BACKUPDIR2; fi
if [ -f /dbf3/$DBNAME/${DBNAME}_*.log ]; then cp /dbf3/$DBNAME/${DBNAME}_*.log $BACKUPDIR3; fi
if [ -f /dbf4/$DBNAME/${DBNAME}_*.log ]; then cp /dbf4/$DBNAME/${DBNAME}_*.log $BACKUPDIR4; fi
if [ -f /dbf5/$DBNAME/${DBNAME}_*.log ]; then cp /dbf5/$DBNAME/${DBNAME}_*.log $BACKUPDIR5; fi
if [ -f /dbf6/$DBNAME/${DBNAME}_*.log ]; then cp /dbf6/$DBNAME/${DBNAME}_*.log $BACKUPDIR6; fi
if [ -f /dbf7/$DBNAME/${DBNAME}_*.log ]; then cp /dbf7/$DBNAME/${DBNAME}_*.log $BACKUPDIR7; fi
if [ -f /dbf8/$DBNAME/${DBNAME}_*.log ]; then cp /dbf8/$DBNAME/${DBNAME}_*.log $BACKUPDIR8; fi
if [ -f /dbf9/$DBNAME/${DBNAME}_*.log ]; then cp /dbf9/$DBNAME/${DBNAME}_*.log $BACKUPDIR9; fi
if [ -f /dbf10/$DBNAME/${DBNAME}_*.log ]; then cp /dbf10/$DBNAME/${DBNAME}_*.log $BACKUPDIR10; fi
if [ -f /dbf11/$DBNAME/${DBNAME}_*.log ]; then cp /dbf11/$DBNAME/${DBNAME}_*.log $BACKUPDIR11; fi
if [ -f /dbf12/$DBNAME/${DBNAME}_*.log ]; then cp /dbf12/$DBNAME/${DBNAME}_*.log $BACKUPDIR12; fi
fi
#
# A[JCuO
#
#
# Ő؂ւ
# 
if [ $BACKUP = "hot" ]; then
sqldba lmode=y <<EOF
connect internal
alter system switch logfile;
exit
EOF
#
# A[JCuÕRs[̊҂
#
sleep 120
fi
#
# A[JCuÕRs[
#
if [ -f $ARCOLD/${DBNAME}_*.arc ]; then
echo " "
echo "${JOBNAME_SHORT}: Delete previous backup archive logs..."
ls -l $ARCOLD/${DBNAME}_*.arc
for I in $ARCOLD/${DBNAME}_*.arc
do
ls -l $I
ARCNAME='basename $I'
rm $ARCOLD/$ARCNAME
STATUS="$?"
if [ "$STATUS" != 0 ]; then
echo "${JOBNAME_SHORT}: error deleting old archive log: $ARCOLD/$ARCNAME"
fi
done
else    echo " "
echo "${JOBNAME_SHORT}: No old archive logs to delete."
fi

if [ -f $ARC/${DBNAME}_*.arc ]; then
echo " "
echo "${JOBNAME_SHORT}: Copying archive logs..."
for I in $ARC/${DBNAME}_*.arc
do
ls -l $I
ARCNAME=`basename $I`
echo "${JOBNAME_SHORT}: cp $ARC/$ARCNAME $ARCOLD"
cp $ARC/$ARCNAME $ARCOLD
STATUS="$?"
if [ "$STATUS" != 0 ]; then
echo "$ARCERR"
fi
echo "${JOBNAME_SHORT}: $CMP $ARC/$ARCNAME $ARCOLD/$ARCNAME"
$CMP $ARC/$ARCNAME $ARCOLD/$ARCNAME
STATUS="$?"
if [ "$STATUS" != 0 ]; then
echo "$CMP_ERR"
echo "${JOBNAME_SHORT}: Archive log deletion skipped."
else echo "${JOBNAME_SHORT}: $CKSUM $ARC/$ARCNAME $ARCOLD/$ARCNAME" 
$CKSUM $ARC/$ARCNAME $ARCOLD/$ARCNAME
CKSUM_OUT='$CKSUM $ARC/$ARCNAME $ARCOLD/$ARCNAME'
echo $CKSUM_OUT | read VALUE1 SIZE1 NAME1 VALUE2 SIZE2 NAME2
if [ "$VALUE1" != "$VALUE2" -o "$SIZE1" != "$SIZE2" ]; then
echo "$DIFFERR"
echo "${JOBNAME_SHORT}: Archive log deletion skipped."
else rm $ARC/$ARCNAME
if [ $? != 0 ]; then
echo "${JOBNAME_SHORT}: Archive deletion failed."
fi
fi
fi
done
else echo "${JOBNAME_SHORT}: Found no archives to copy."
fi
fi
#
# N
#
if [ $BACKUP = "cold" ]; then
# 
# dba[hł̃^XN
#
echo "${JOBNAME_SHORT}: Begin startup restrict..."
/db_admin/db_${DBNAME}/sql/startup_restrict_${DBNAME}.sh
STATUS='ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_'
if [ $? != 0 ]; then
echo "${JOBNAME_SHORT}: error in restrict startup."
else
echo "${JOBNAME_SHORT}: Begin analyze at 'date'..."
$ANALYZE $DBNAME
echo "${JOBNAME_SHORT}: End analyze at 'date'..."
#
# ȃ^XN
#
if [ "$SPECIAL_TASK" != " " ]; then
echo "${JOBNAME_SHORT}: Running DBA mode task..."
. ${SPECIAL_TASK} > $TMP/${DBNAME}_restrict.log 2> $TMP/${DBNAME}_restrict.err 
# sqlplus / @${SPECIAL_TASK} ${SPECIAL_TASK}.log 2>> ${SPECIAL_TASK}.err 
fi
fi
echo "${JOBNAME_SHORT}: Shutdown..."
/db_admin/db_${DBNAME}/sql/shutdown_${DBNAME}.sh
STATUS='ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_'
if [ $? = 0 ]; then
echo "${JOBNAME_SHORT}: error in shutdown following analyze..."
else
echo "${JOBNAME_SHORT}: End shutdown..."
fi
#
# N
#
/db_admin/db_${DBNAME}/sql/startup_exclusive_${DBNAME}.sh
STATUS='ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_'
if [ $? != 0 ]; then
echo "${JOBNAME_SHORT}: error in database startup."
RESTART_FAILED_B=0
else
echo "${JOBNAME_SHORT}: Database restarted."
echo "1" > $BANNER
$WALL /db_admin/db_${DBNAME}/banner/${DBNAME}_db_online.banner      
fi
fi


p.185-189
#! /bin/sh
# O              $TOOLS/db_mgmt/backup/dbexport_begin
#
# ړI                 f[^x[X̃obNAbvsD
#
# N@          $TOOLS/db_mgmt/backup/dbexport_begin dbname export special task
#
# p[^        $1=dbname
#                   $2=GNX|[g
#                   $3=ȃ^XN
# :
#   t               O                    Rg
#   1995N32   Susie Ehrsam       쐬
#   1995N320  Sumant Chaudhari   hLg

# ..............................................................
# [Jϐ
# ..............................................................
ERRMSG='
$TOOLS/db_mgmt/backup/dbexport_begin: syntax error: 
dbexport_begin <dbname> <export|noexport> <special task>.
'
#
# p[^
#
if [ "$1" ]
then DBNAME=$1
else echo $ERRMSG
exit 1 
fi
if [ "$2" ]
then EXPORT=$2
else echo $ERRMSG
exit 1
fi
if [ "$3" ]
then SPECIAL_TASK=$3
else SPECIAL_TASK=" "
fi

#................................................................
# u[^l
#................................................................
TRUE=0
FALSE=1
SHUTDOWN_FAILED_B=1
RESTART_FAILED_B=1

#................................................................
# [Jϐ
#................................................................
ORAID="oracle"
EXPORTDIR="$TOOLS/backupdir/exp"
EXPORTDIROLD="$TOOLS/backupdir/exp.old"
JOBNAME="$TOOLS/db_mgmt/backup/dbexport_begin"
JOBNAME_SHORT="dbexport_begin"
ADMIN_FILE="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_backup_admin.sh" 
CMP="/bin/cmp"
PARFILE="/db_admin/db_$DBNAME/tools/backup/${DBNAME}_export.par"
CMP_ERR="${JOBNAME_SHORT}: fatal error in cmp."
EXPERR="${JOBNAME_SHORT}: fatal error in export file copy."

# ..............................................................
# Jn
# ..............................................................
#
# orauserNCOracleݒ肷D
#
. /db_admin/db_$DBNAME/.orauser_$DBNAME
. $ADMIN_FILE
#
# f[^x[XICԂł邩ǂ̃`FbN
#
STATUS='ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_'
if [ $? != 0 ]; then
echo "${JOBNAME_SHORT}: error - database not online."
echo "${JOBNAME_SHORT}: process listing is to follow..."
echo  "${JOBNAME_SHORT}: ps -fu $ORAID | grep -v grep | grep $DBNAME | grep ora_"
ps -fu $ORAID| grep -v grep | grep $DBNAME | grep ora_
echo "${JOBNAME_SHORT}: exiting."
exit 1
fi
# ......................................................................
# obNAbvɂłɂGNX|[gt@C폜DāC݂̏ꏊobNAbv
# ɃGNX|[gt@CRs[DŌɁCf[^x[X̃GNX|[gʂ݂̏ꏊɊi
# [Dł́CƎ̕@IłD
# ......................................................................
echo " "
echo "${JOBNAME_SHORT}: List previous export files..."
ls -l $EXPORTDIR/${DBNAME}.exp*
ls -l $EXPORTDIROLD/${DBNAME}.exp*

#
# GNX|[g̍폜
#
if [ -f $EXPORTDIROLD/${DBNAME}.exp_old ]; then
rm $EXPORTDIROLD/${DBNAME}.exp_old
if [ $? != 0 ]; then
echo "${JOBNAME_SHORT}: error deleting previous export." 
else
echo "${JOBNAME_SHORT}: Deleted previous export file." 
fi
else echo "${JOBNAME_SHORT}: Found no previous export file."
fi
#
# VGNX|[gȑOƓꏊɃRs[
#
if [ -f $EXPORTDIR/${DBNAME}.exp ]; then
chmod 642 $EXPORTDIR/${DBNAME}.exp
echo "${JOBNAME_SHORT}: cp $EXPORTDIR/${DBNAME}.exp $EXPORTDIROLD"
cp $EXPORTDIR/${DBNAME}.exp $EXPORTDIROLD
if [ $? != 0 ]; then 
echo "$EXPERR"
else echo "${JOBNAME_SHORT}: $CMP $EXPORTDIR/${DBNAME}.exp $EXPORTDIROLD/${DBNAME}.exp" 
$CMP $EXPORTDIR/${DBNAME}.exp $EXPORTDIROLD/${DBNAME}.exp
STATUS="$?"
if [ "$STATUS" != 0 ]; then
echo "$CMP_ERR"
fi
echo "${JOBNAME_SHORT}: mv ${EXPORTDIROLD}/${DBNAME}.exp ${EXPORTDIROLD}/${DBNAME}.exp_old"
mv ${EXPORTDIROLD}/${DBNAME}.exp ${EXPORTDIROLD}/${DBNAME}.exp_old
if [ $? != 0 ]; then
echo "$EXPERR"
fi
rm $EXPORTDIR/${DBNAME}.exp
if [ $? != 0 ]; then
echo "${JOBNAME_SHORT}: error deleting export file."
exit
fi
fi
else echo "${JOBNAME_SHORT}: Found no current export file to copy."
fi

#
# GNX|[g̊Jn
#
exp parfile=$PARFILE 
echo " "
echo "${JOBNAME_SHORT}: Export complete.  "
ls -l $EXPORTDIR/${DBNAME}.exp*
ls -l $EXPORTDIROLD/${DBNAME}.exp*


p.189
V7PROD     Sat     cold     export      /bugdev/db_management/bug_restrict1.sh


V7PROD     Sun     hot      noexport
V7PROD     Mon     hot      noexport
V7PROD     Tue     hot      noexport
V7PROD     Wed     hot      noexport
V7PROD     Thu     hot      noexport
V7PROD     Fri     cold     export      /bugdev/db_management/bug_restrict1.sh
V7PROD     Sat     cold     export      /bugdev/db_management/bug_restrict1.sh
V7test     Sun     hot      export
V7test     Mon     hot      export
V7test     Tue     hot      export
V7test     Wed     hot      export
V7test     Thu     hot      export
V7test     Fri     cold     export
V7test     Sat     nobackup export  


p.190-191
#! /bin/sh
#
#       O    shutdown_immediate_${DBNAME}.sh
#
sqldba lmode=y << EOF
connect internal
shutdown immediate
EOF
exit

shutdown_${DBNAME}.sh

#! /bin/sh
#
#       O    shutdown_${DBNAME}.sh
#
sqldba lmode=y << EOF
connect internal
shutdown
EOF

startup_exclusive_${DBNAME}.sh

#! /bin/sh
#
#       O    startup_exclusive_${DBNAME}.sh
#
sqldba lmode=y << EOF
connect internal
startup exclusive
EOF

startup_restrict_${DBNAME}.sh

#! /bin/sh
# 
#       O    startup_restrict_${DBNAME}.sh
#
sqldba lmode=y << EOF
connect internal
startup restrict
EOF

kill_processes.sh

#! /bin/sh
#
#       O    kill_processes.sh
#

PID='ps -aef | grep -v grep | grep -v kill_processes.sh | awk '{print $2}''
if [ $? !=0 ]; then
      exit
fi
for KILLID in $PID
do
       kill  -9  $KILLID
done


     
Chapter5
p.195
UPDATE EMP
SET EMPNO = 1234
WHERE EMPNO = 9999;


p.196
SQLDBA> archive log list
Database log mode               ARCHIVELOG
Automatic archival              ENABLED
Archive destination             DISK$WR3:[ ORA7.DB_RDBMS3]ARCHnnn.ARC
Oldest online log sequence      1742
Next log sequence to archive    1744
Current log sequence            1744


p.197
COLUMN NAME FORMAT a40
COLUMN redo_i NEW_VALUE redo
SET TERMOUT OFF
SELECT VALUE redo_I
FROM v$sysstat
WHERE name = 'redo size';
SET TERMOUT ON


SELECT (value - &redo) redo
FROM v$sysstat
WHERE name = 'redo size';


p.199
SQL> select * from v$log_history where rownum < 3;

THREAD#  SEQUENCE# TIME              LOW_CHANGE# HIGH_CHANGE#
------- ---------- ----------------- ----------- ------------
ARCHIVE_NAME
-----------------------------------------
      1         12 03/30/95 20:33:14        6706         6723
C:\ORACLE7\RDBMS70\ARCHIVE\ARC00012.001

      1         11 02/11/95 14:18:26        6689         6705
C:\ORACLE7\RDBMS70\ARCHIVE\ARC00011.001


p.201
SQLDBA> Alter database add logfile thread 2 group 4  'log4.rdo';
SQLDBA> Alter database add logfile thread 2 group 5  'log5.rdo';
SQLDBA> Alter database enable public thread 2;
SQLDBA> Alter database disable thread 2;


p.203
SQLDBA> Alter database enable thread 2;
SQLDBA> Alter database disable thread 2;


p.207
SQLDBA> alter system checkpoint local;


p.231
Recover database

Recover tablespace

Recover datafile


p.233
RECOVER [AUTOMATIC] [FROM 'location'] [DATABASE]
| [UNTIL CANCEL]
| [UNTIL TIME date]
| [UNTIL CHANGE integer]
[USING BACKUP CONTROLFILE]


SQLDBA> RECOVER DATABASE


p.236
SQLDBA> recover database until cancel;

SQLDBA> recover database until time '1995-04-15:17:55:00';

SQLDBA> recover database until change integer;

SQLDBA> recover database until cancel using backup controlfile;


p.240
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     61
Next log sequence to archive   63
Current log sequence           63

SQLDBA> recover database until cancel;
Media recovery complete.
SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> archive log list;
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1


p.243
mcs% cp /home/orahome/backup/*.dbf /home/orahome/data/721


SQLDBA> startup restrict mount [dbname];


SQLDBA> alter database rename file 'old_filename' to 'new_filename';


SQLDBA> select file#, status, name from V$DATAFILE;
SQLDBA> alter database datafile 'filename' online;


SQLDBA> RECOVER DATABASE [dbname];


SQLDBA> alter database [dbname] open;


p.244
SQLDBA> shutdown [dbname]


$ copy disk$wr3:[backup]*.dbs disk$wr4:[oracle7.data]


SQLDBA> startup restrict mount [dbname];


SQLDBA> alter database rename file 'old_filename' to 'new_filename';


SQLDBA> select file#, status, name from V$DATAFILE;
SQLDBA> alter database datafile 'filename' online;


p.245
SQLDBA> recover database until time '1995-05-15:13:55:00';


SQLDBA> ALTER DATABASE OPEN RESETLOGS;


RECOVER [AUTOMATIC] [FROM location]
| TABLESPACE tablespace_name [, tablespace_name...]


p.247
SQLDBA> alter tablespace ts_name offline;


SQLDBA> alter database rename file 'old_filename' to 'new_filename';


SQLDBA> RECOVER TABLESPACE ts_name [,ts_name ...]


SQLDBA> alter tablespace ts_name online;


RECOVER [AUTOMATIC] [FROM location]
| DATAFILE 'filename' ['filename',...]


p.249
SQLDBA> startup mount [dbname]


SQLDBA> alter database datafile 'filename' offline;


SQLDBA> alter database open;


SQLDBA> alter database rename file 'old_filename' to 'new_filename';


SQLDBA> RECOVER DATAFILE 'datafile' [, 'datafile'...]


SQLDBA> alter database datafile 'filename' online;


p.250
SQLDBA> alter database rename file 'old_filename' to 'new_filename'


SQLDBA> startup restrict mount [dbname]


SQLDBA> alter database datafile 'filename' online
SQLDBA> alter database datafile 'filename' offline


SQLDBA> RECOVER DATAFILE 'datafile' [, 'datafile'...]


SQLDBA> alter database datafile 'filename' online;


SQLDBA> alter database [dbname] open;


p.251-252
CREATE CONTROLFILE [REUSE] [SET]
DATABASE [dbname]
LOGFILE filespec [, filespec, ...]
RESETLOGS | NORESETLOGS
DATAFILE filespec [, filespec, ...]
[MAXLOGIFLES integer]
[MAXLOGMEMBERS integer]
[MAXLOGHISTORY integer]
[MAXDATAFILES integer]
[MAXINSTANCES integer]
[ARCHIVELOG | NOARCHIVELOG]


p.252
SQLDBA>  STARTUP NOMOUNT


p.253
SQLDBA> ALTER DATABASE OPEN [NO]RESETLOGS;


SQLDBA> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;


p.253-254
SQLDBA> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
Dump file /home/orahome/admin/721/udump/ora_19210.trc
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta
ORACLE_HOME = /home/orahome/product/7.2.1
ORACLE_SID = 721
Oracle process number: 8 Unix process id: 19210
System name:SunOS
Node name:cosmos
Release:5.3
Version:Generic
Machine:sun4m

Wed Apr  5 15:09:54 1995
Wed Apr  5 15:09:54 1995
*** SESSION ID:(7.1) 
# The following commands will create a new control file and use it
# to open the database.
# No data other than log history will be lost. Additional logs may
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "721" NORESETLOGS ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 2
    MAXDATAFILES 30
    MAXINSTANCES 1
    MAXLOGHISTORY 100
LOGFILE
  GROUP 1 '/home/orahome/data/721/redo01.log'  SIZE 500K,
  GROUP 2 '/home/orahome/data/721/redo02.log'  SIZE 500K,
  GROUP 3 '/home/orahome/data/721/redo03.log'  SIZE 500K
DATAFILE
  '/home/orahome/data/721/system01.dbf' SIZE 500K,
  '/home/orahome/data/721/rbs01.dbf' SIZE 500K,
  '/home/orahome/data/721/tools01.dbf' SIZE 500K,
  '/home/orahome/data/721/users01.dbf' SIZE 500K,
  '/home/orahome/data/721/test1.dbf' SIZE 500K,
  '/home/orahome/data/721/temp.dbf' SIZE 500K
;
# Recovery is required if any of the data files are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# Database can now be opened normally.
ALTER DATABASE OPEN;


p.254
SQLDBA> ALTER DATABASE CREATE DATAFILE 'filename';


p.257
$ imp DBA/passwd inctype=system full=Y file=exp_file


$ imp DBA/passwd inctype=restore full=Y file=file_spec


$ imp DBA/passwd inctype=restore full=Y file=file_spec


$ imp DBA/passwd inctype=restore full=Y file=file_spec



Chapter6
p.274
ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME CONTROLF LEVEL 10';


p.276
EVENT = "604 TRACE NAME ERRORSTACK FOREVER"

EVENT = "10210 TRACE NAME CONTEXT FOREVER, LEVEL 10"


ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME BLOCKDUMP LEVEL 67109037';

ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME CONTROLF LEVEL 10';

ALTER SESSION SET EVENTS 'IMMEDIATE TRACE NAME SYSTEMSTATE LEVEL 10';


p.277
alter session set events 'immediate trace name buffers level 1';


alter session set events 'immediate trace name blockdump level 134219181';


alter session set events 'immediate trace name controlf level 10';


alter session set events 'immediate trace name locks level 5';


p.278
alter session set events 'immediate trace name redohdr level 10';


alter session set events 'immediate trace name loghist level 4';


alter session set events 'immediate trace name file_hdrs level 10';


p.279
alter session set events '604 trace name errorstack forever';


alter session set events 'immediate trace name systemstate level 10';


alter session set events 'immediate trace name coalesce level X'; 


p.280
alter session set events 'immediate trace name coalesce level 327680';


event = "10015 trace name context forever"


p.281
event = "10210 trace name context forever, level 10"


p.282
alter session set events '10231 trace name context off';

event = "10231 trace name context forever, level 10"


p.283
_offline_rollback_segments =  (rbs1, rbs2)


p.286-287
oradbx: Release 7.1.3.0.0 - Production on Thu Jan 19 14:13:35 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.

(oradbx) help
help                 - print help information
show                 - show status
debug <pid>          - debug process
dump SGA             - dump SGA
dump PGA             - dump PGA
dump stack           - dump call stack
dump core            - dump core without crashing process
dump level 0         - dump error buffer
dump level 1         - level 0 + call stack
dump level 2         - level 1 + process state objects
dump level 3         - level 2 + context area
dump system 1        - brief system states dump
dump system 2        - full system states dump
dump ipc             - dump ipc information
dump controlfile #   - dump control file at level #
dump datafile #      - dump data file header at level #
dump procstat        - dump process statistics
event <event-trace>  - turn on event trace
unlimit trace        - unlimit the size of trace file
exit                 - exit this program
!                    - shell escape


p.290
ORA--01130: data file version num incompatible with ORACLE Version num.


p.300
ALTER SYSTEM DUMP LOGFILE 'filename' option option...;
option  =  rba min seqno . blockno |
           rba max seqno . blockno |
           dba min fileno . blockno |
           dba max fileno . blockno |
           time min value |
           time max value |
           layer value |
           opcode value


p.301
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> update backup set c2 = 'phy_backup';
2 rows processed.
SQLDBA> commit;
Statement processed.
SQLDBA> select * from backup;
C1       C2
----     ----
1        phy_backup
2        phy_backup
2 rows selected.
SQLDBA> archive log list
Database log mode          NOARCHIVELOG
Automatic archival         ENABLED
Archive destination        C:\ORACLE7\RDBMS70\ARCHIVE
Oldest online log sequence 8
Current log sequence       9
SQLDBA> alter system dump logfile 'C:\ORACLE7\DBS\wdblog2.log';
Statement processed.
SQLDBA> exit
SQL*DBA complete. 


p.305
SQLDBA> select * from backup;
C1       C2
----     ----
1        log_backup
2        phy_backup
2 rows selected.
SQLDBA> alter session set events 'immediate trace name blockdump level 33554650';
Statement processed.


p.307
ORA-01135 file name accessed for DML/query is off-line


p.308
ORA-01545 rollback segment #'name' was not available


p.310
SQL> SELECT FILE_ID, BLOCK_ID, BLOCKS, BYTES FROM
2 > SYS.DBA_FREE_SPACE WHERE TABLESPACE_NAME='users';

FILE_ID   BLOCK_ID   BLOCKS   BYTES
--------  ---------  -------  -------
4         2          20       40960
4         1465       72       147456
4         22         25       51200
4         147        1318     2699264

4 rows selected.


SQL> SELECT FILE_ID, BLOCK_ID, BLOCKS, BYTES FROM
2 > DBA_FREE_SPACE WHERE TABLESPACE_NAME='users'
3 > ORDER BY BLOCK_ID;

FILE_ID   BLOCK_ID   BLOCKS   BYTES
--------  ---------  -------  -------
4         2          20       40960
4         22         25       51200
4         147        1318     2699264
4         1465       72       147456

4 rows selected.


p.311
SQL> CREATE TABLE bulletin (y NUMBER) STORAGE (INITIAL 2650K)
2 > TABLESPACE users;

Table created.

SQL> SELECT FILE_ID, BLOCK_ID, BLOCKS, BYTES FROM
2 > DBA_FREE_SPACE WHERE TABLESPACE_NAME='users'
3 > ORDER BY BLOCK_ID;

FILE_ID  BLOCK_ID  BLOCKS  BYTES
-------  --------  ------  -----
4        2         45      92160
4        1472      65      133120

2 rows selected.


SQL> DROP TABLE bulletin;

Table dropped.

SQL> SELECT FILE_ID, BLOCK_ID, BLOCKS, BYTES FROM
2 > DBA_FREE_SPACE WHERE TABLESPACE_NAME='users'
3 > ORDER BY BLOCK_ID;

FILE_ID  BLOCK_ID  BLOCKS  BYTES
-------  --------  ------  -----
4        2         45      92160
4        147       1325    2713600
4        1472      65      133120

3 rows selected.


p.312
SELECT MAX(BLOCKS) FROM SYS.DBA_FREE_SPACE WHERE TABLESPACE_NAME='name';


SELECT SUM(BLOCKS) FROM SYS.DBA_FREE_SPACE WHERE TABLESPACE_NAME='name';


ORA-1562 failed to extend rollback segment (id = num)


p.313
SELECT TEMPORARY_TABLESPACE FROM SYS.DBA_USERS WHERE USERNAME = 'username';


SELECT INITIAL_EXTENT, NEXT_EXTENT, MIN_EXTENTS, PCT_INCREASE FROM SYS.DBA_TABLESPACES WHERE TABLESPACE_NAME='name';


ALTER TABLESPACE name DEFAULT STORAGE (INITIAL xxx NEXT yyy);


ALTER USER username TEMPORARY TABLESPACE new_tablespace_name;


p.314
ALTER TABLESPACE tablespace_name ADD DATAFILE 'filename' SIZE size_of_file;


SELECT FILE_NAME FROM SYS.DBA_DATA_FILES WHERE TABLESPACE_NAME='name';


p.320
Select log, oldest, youngest+1/86400
from mlog$ where master = :2 and mowner = :1 for update;


Select oldest into oldest from sys.mlog$ where mowner = mow and master = mas;


p.320-321
create table foo (a varchar(30));

declare
owner varchar(30);
master varchar(30);
log varchar(30);
snapshot date;
snaptime date;
begin
    snapshot := SYSDATE;
    snaptime := SYSDATE;
    owner := 'SCOTT';
    master := 'EMP';
    dbms_snapshot.set_updblink(owner, master, log, snapshot, snaptime);
    insert into foo(a) values (log); 
end;          
           
           
p.321
SQLDBA> select * from foo;
A
--------------------
MLOG$_EMP
1 row selected.


p.322
/* f[^x[Xt@C# FCubN# B擾邽߂̋[R[h */

get(F,B)
Begin
     If (F > MAX_NUMBER_OF_FILES)
          signal ("ORA 600 [2858] [F]");
          exit ( )
     endif;
     ......
end


p.328
ORA-00600 [3339] [arg1] [arg2] [] [] [] []
ORA-1578: Data block corrupted in file # x block # y


p.330
Select distinct(key) from corrupt_table
where key > (lowest value for the key)
and substr(rowid,1,8) = corrupt_block_id
order by 1;


p.331
Create new_table as select * from corrupt_table
where key > (lowest value for the key)
and key NOT IN (key list) 


Select /*+ use descending scan on index */ *
from corrupt_table where key = 'duplicate key' and
rownum < 4;



Chapter7
p.335
ORA-01157: cannot identify data file 4 - file not found
ORA-01110: data file 4: '/home/orahome/data/7.1/users01.dbf'


p.337-338
cosmos% sqldba lmode=y

SQL*DBA: Release 7.2.1.0.0 - Beta on Sat Feb  4 18:42:01 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     59
Next log sequence to archive   61
Current log sequence           61

SQLDBA> alter database noarchivelog;
Statement processed.
SQLDBA> alter database open;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.

SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/temp.dbf
cosmos% exit
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> alter database open;
ORA-01157: cannot identify data file 6 - file not found
ORA-01110: data file 6: '/home/orahome/data/721/temp.dbf'
SQLDBA> alter database datafile '/home/orahome/data/721/temp.dbf' offline;
ORA-01145: offline immediate disallowed unless media recovery enabled
SQLDBA> alter database archivelog;
ORA-00265: Instance recovery required, cannot set ARCHIVELOG mode
SQLDBA> alter database datafile '/home/orahome/data/721/temp.dbf' offline drop;
Statement processed.
SQLDBA> alter database open;
Statement processed.
SQLDBA> drop tablespace temp including contents;
Statement processed.
SQLDBA> create tablespace temp datafile '/home/orahome/data/721/temp.dbf' size 1m;
statement processed.


p.338
SQLDBA> alter database datafile '/home/orahome/data/721/temp.dbf' offline;


p.340
ORA-01147: SYSTEM tablespace file 1 is offline

ORA-01110: data file 1: 'DISK$WR3:[RDBMSPT.ORACLE.DATA]SYSTEM.DBS'


p.342
cosmos% sqldba lmode=y

SQL*DBA: Release 7.2.1.0.0 - Beta on Fri Feb  3 22:43:28 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA>  create table case4(c1 number) tablespace users;
Statement processed.
SQLDBA> insert into case4 values (3);
1 row processed.
SQLDBA> insert into case4 values (3);
1 row processed.
SQLDBA> commit;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> host
cosmos% rm /home/orahome/data/721/users01.dbf
cosmos% exit
SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% cp /home/orahome/backup/users01.dbf /home/orahome/data/721
cosmos% exit
SQLDBA> startup open
ORACLE instance started.
Database mounted.
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/home/orahome/data/721/users01.dbf'
Attempting to dismount database........Database dismounted.
Attempting to shutdown instance........ORACLE instance shut down.


p.343
SQLDBA> startup mount
ORACLE instance started.
Database mounted.

SQLDBA> recover database
ORA-00279: Change 6232 generated at 02/03/95 08:45:58 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_50.dbf
ORA-00280: Change 6232 for thread 1 is in sequence #50
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
enter
Applying suggested logfile...
Log applied.
ORA-00279: Change 6269 generated at 02/03/95 19:46:32 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_51.dbf
ORA-00280: Change 6269 for thread 1 is in sequence #51
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_50.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
auto
Applying suggested logfile...
Log applied.
ORA-00279: Change 6276 generated at 02/03/95 19:49:31 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_52.dbf
ORA-00280: Change 6276 for thread 1 is in sequence #52
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_51.dbf' no longer needed for this recovery

Applying suggested logfile...
Log applied.
Media recovery complete.

SQLDBA> alter database open;
Statement processed.
SQLDBA> select *  from case4;
C1
--
3
3
2 rows selected.


p.344
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> alter database datafile  '/home/orahome/data/721/users01.dbf' offline;
Statement processed.
SQLDBA> alter database open;
Statement processed.
SQLDBA> recover datafile '/home/orahome/data/721/users01.dbf';
ORA-00279: Change 6232 generated at 02/03/95 08:45:58 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_50.dbf
ORA-00280: Change 6232 for thread 1 is in sequence #50
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
auto
Applying suggested logfile...
Log applied.
ORA-00279: Change 6269 generated at 02/03/95 19:46:32 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_51.dbf
ORA-00280: Change 6269 for thread 1 is in sequence #51
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_50.dbf' no longer needed for this recovery
Applying suggested logfile...
Log applied.
ORA-00279: Change 6276 generated at 02/03/95 19:49:31 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_52.dbf
ORA-00280: Change 6276 for thread 1 is in sequence #52
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_51.dbf' no longer needed for this recovery
Applying suggested logfile...
Log applied.
Media recovery complete.

SQLDBA> alter database datafile '/home/orahome/data/721/users01.dbf' online;
Statement processed.
SQLDBA> select * from case4;
C1
--
3
3
2 rows selected.


p.345-346
SQLDBA> startup mount
ORACLE instance started.
Database mounted.

SQLDBA> alter database datafile '/home/orahome/data/721/users01.dbf' offline;
Statement processed.
SQLDBA> alter database open;
Statement processed.
SQLDBA> alter tablespace users offline;
Statement processed.
SQLDBA> recover tablespace users;
ORA-00279: Change 6232 generated at 02/03/95 08:45:58 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_50.dbf
ORA-00280: Change 6232 for thread 1 is in sequence #50
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
auto
Applying suggested logfile...
Log applied.
ORA-00279: Change 6269 generated at 02/03/95 19:46:32 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_51.dbf
ORA-00280: Change 6269 for thread 1 is in sequence #51
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_50.dbf' no longer needed for this recovery
Applying suggested logfile...
Log applied.
ORA-00279: Change 6276 generated at 02/03/95 19:49:31 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_52.dbf
ORA-00280: Change 6276 for thread 1 is in sequence #52
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_51.dbf' no longer needed for this recovery
Applying suggested logfile...
Log applied.
Media recovery complete.

SQLDBA> select * from case4;
C1

ORA-00376: file 4 cannot be read at this time
ORA-01110: data file 4: '/home/orahome/data/721/users01.dbf'

SQLDBA> alter tablespace users online;
Statement processed.

SQLDBA> select * from case4;
C1
3
3
2 rows selected.


p.348
ORA-00376: file 2 cannot be read at this time


p.348-349
cosmos% sqldba lmode=y

SQL*DBA: Release 7.2.1.0.0 - Beta on Sat Feb  4 18:42:01 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
SQLDBA> create table case5 (c1 number) tablespace users;
SQLDBA> select * from case5;
C1
--
0 rows selected.
SQLDBA> commit;
Statement processed.
SQLDBA> set transaction use rollback segment r01;
Statement processed.
SQLDBA> insert into case5 values(5);
1 row processed.
SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/rbs01.dbf
cosmos% exit


p.349-350
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> alter database datafile '/home/orahome/data/721/rbs01.dbf' offline;
Statement processed.
SQLDBA> alter database open;
Statement processed.
SQLDBA> select * from case5;
C1
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2: '/home/orahome/data/721/rbs01.dbf'
SQLDBA> select segment_name, status from dba_rollback_segs;
SEGMENT_NAME   STATUS
------------   ------
SYSTEM         ONLINE
R01            NEEDS RECOVERY
R02            NEEDS RECOVERY
R03            NEEDS RECOVERY
R04            NEEDS RECOVERY
5 rows selected.
SQLDBA> host
cosmos% cp /home/orahome/backup/rbs01.dbf /home/orahome/data/721/rbs01.dbf
cosmos% exit
SQLDBA> recover tablespace rbs;
ORA-00279: Change 6393 generated at 02/04/95 17:36:02 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_61.dbf
ORA-00280: Change 6393 for thread 1 is in sequence #61
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6423 generated at 02/06/95 14:37:23 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6423 for thread 1 is in sequence #62
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_61.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter tablespace rbs online;
Statement processed.
SQLDBA> select * from case5;
C1
--
0 rows selected.
SQLDBA> select segment_name, status from dba_rollback_segs;
SEGMENT_NAME   STATUS
------------   ------
SYSTEM         ONLINE
R01            NEEDS RECOVERY
R02            NEEDS RECOVERY
R03            NEEDS RECOVERY
R04            NEEDS RECOVERY
5 rows selected.

SQLDBA> alter rollback segment r01 online;
Statement processed.
SQLDBA> alter rollback segment r02 online;
Statement processed.
SQLDBA> alter rollback segment r03 online;
Statement processed.
SQLDBA> alter rollback segment r04 online;
Statement processed.


p.352-353
SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> exit
SQL*DBA complete.
cosmos% rm /home/orahome/data/721/*.log
cosmos%  cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% sqldba lmode=y

SQL*DBA: Release 7.2.1.0.0 - Beta on Fri Feb  3 23:21:38 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database until cancel;

ORA-00279: Change 6232 generated at 02/03/95 08:45:58 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_50.dbf
ORA-00280: Change 6232 for thread 1 is in sequence #50
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
enter
Applying suggested logfile...
Log applied.
ORA-00279: Change 6269 generated at 02/03/95 19:46:32 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_51.dbf
ORA-00280: Change 6269 for thread 1 is in sequence #51
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_50.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
enter
Applying suggested logfile...
Log applied.
..........(52`55̃Ot@C̓Kp)
ORA-00279: Change 6310 generated at 02/03/95 22:55:43 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_56.dbf
ORA-00280: Change 6310 for thread 1 is in sequence #56
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_55.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
cancel
Media recovery cancelled.
SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQLDBA> exit
SQL*DBA complete.
cosmos% ls
control01.ctl  rbs01.dbf   redo03.log    test1.dbf
control02.ctl  redo01.log  system01.dbf  tools01.dbf
control03.ctl  redo02.log  temp.dbf      users01.dbf


p.355
alter database datafile 'file_name' end backup;


p.355-356
cosmos% sqldba lmode=y

SQL*DBA: Release 7.2.1.0.0 - Beta on Sat Feb  4 15:58:49 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup
ORACLE instance started.
Database mounted.
Database opened.

Total System Global Area       4481448 bytes
              Fixed Size         47152 bytes
           Variable Size       4016504 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes

SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     53
Next log sequence to archive   55
Current log sequence           55

SQLDBA> alter tablespace test begin backup;
Statement processed.
SQLDBA> host
cosmos% cp /home/orahome/data/721/test1.dbf /home/orahome/backup/hot
cosmos% exit
SQLDBA> create table case7 (c1 number) tablespace test;
Statement processed.
SQLDBA> insert into case7 values(7);
Statement processed.
SQLDBA> commit;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> shutdown abort
ORACLE instance shut down.


p.356-357
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> alter database open;
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/home/orahome/data/721/test1.dbf'
SQLDBA> alter database datafile '/home/orahome/data/721/test1.dbf' end backup;
Statement processed.
SQLDBA> alter database open;
Statement processed.


p.357
cosmos% rm /home/orahome/data/721/test1.dbf
cosmos% cp /home/orahome/backup/hot/test1.dbf /home/orahome/data/721
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> alter database open;
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/home/orahome/data/721/test1.dbf'
SQLDBA> alter database datafile '/home/orahome/data/721/test1.dbf' end backup;
ORA-01235: END BACKUP failed for 1 file(s) and succeeded for 0
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/home/orahome/data/721/test1.dbf'
ORA-01208: data file is an old version - not accessing current version

SQLDBA> recover database
Media recovery complete.
SQLDBA> alter database open;
Statement processed.
SQLDBA> exit
SQL*DBA complete.


p.358
SQLDBA> select file#, status from v$backup;
FILE#         STATUS
-----         ------
1             ACTIVE
2             NOT ACTIVE
3             NOT ACTIVE
4             NOT ACTIVE
4 rows selected.


p.359-361
cosomos% sqldba lmode=y


SQL*DBA: Release 7.2.1.00 - Beta on Sat Feb 4 18:26:23 1995
Copyright (c) Oracle Corporation 1979, 1994. All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup open
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size       4015944 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes

SQLDBA> select name, status, enabled from v$datafile;

NAME                                         STATUS        EBABLED
----                                         ------        -------
/home/orahome/data/721/system01.dbf          SYSTEM        READ WRITE
/home/orahome/data/721/rbs01.dbf             ONLINE        READ WRITE
/home/orahome/data/721/tools01.dbf           ONLINE        READ WRITE
/home/orahome/data/721/users01.dbf           ONLINE        READ WRITE
/home/orahome/data/721/test1.dbf             ONLINE        READ ONLY
/home/orahome/data/721/temp.dbf              ONLINE        READ WRITE
6 rows selected.

SQLDBA> create table case8 (c1 number) tablespace users;
Statement processed.
SQLDBA> insert into case8 values (8);
1 row processed.
SQLDBA> commit;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% cp /home/orahome/backup/control01.ctl /home/orahome/data/721
cosmos% exit
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> alter database open;
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/home/orahome/data/721/system01.dbf'
ORA-01207: file is more recent than control file - old control file

SQLDBA> recover database
ORA-00283: Recovery session canceled due to errors
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/home/orahome/data/721/system01.dbf'
ORA-01207: file is more recent than control file - old control file

SQLDBA> recover database using backup controlfile;
ORA-00283: Recovery session canceled due to errors
ORA-01233: file 5 is read only - cannot recover using backup controlfile
ORA-01110: data file 5: '/home/orahome/data/721/test1.dbf'

SQLDBA> alter database datafile '/home/orahome/data/721/test1.dbf' offline;
Statement processed.

SQLDBA> recover database using backup controlfile;
ORA-00279: Change 6428 generated at 02/04/95 18:28:50 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_64.dbf
ORA-00280: Change 6428 for thread 1 is in sequence #64
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
/home/orahome/data/721/redo01.log
Applying logfile...
Log applied.
Media recovery complete.

SQLDBA> alter database open;
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQLDBA> alter database open noresetlogs;
ORA-01588: must use RESETLOGS option for database open
SQLDBA> alter database open resetlogs;
Statement processed.

SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           1

SQLDBA> select name, status, enabled from v$datafile;
NAME                                        STATUS           EBABLED
----                                        ------           -------
/home/orahome/data/721/system01.dbf         SYSTEM           READ WRITE
/home/orahome/data/721/rbs01.dbf            ONLINE           READ WRITE
/home/orahome/data/721/tools01.dbf          ONLINE           READ WRITE
/home/orahome/data/721/users01.dbf          ONLINE           READ WRITE
/home/orahome/data/721/test1.dbf            OFFLINE          READ ONLY 
/home/orahome/data/721/temp.dbf             ONLINE           READ WRITE
6 rows selected.
SQLDBA> alter tablespace test online;
Statement processed.
SQLDBA> select * from case8;
c1
--
6
1 rows selected.


p.363
ORA-00376: file 6 cannot be read at this time


p.364-365
SQLDBA> connect internal
Statement processed
SQLDBA> alter database datafile '/mcsc2/orahome/data/PROD/rotest.dbf' offline;
Statement processed.
SQLDBA> select tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME      STATUS
---------------      ------
SYSTEM               ONLINE
RBS                  ONLINE
TEMP                 ONLINE
TOOLS                ONLINE
USERS                ONLINE
ROTEST               ONLINE

SQL> select name, status from v$datafile;
NAME                                        STATUS
----                                        ------
/mcsc2/orahome/data/PROD/system01.dbf       SYSTEM
/mcsc2/orahome/data/PROD/rbs01.dbf          ONLINE
/mcsc2/orahome/data/PROD/temp01.dbf         ONLINE
/mcsc2/orahome/data/PROD/tools01.dbf        ONLINE
/mcsc2/orahome/data/PROD/users01.dbf        ONLINE
/mcsc2/orahome/data/PROD/rotest.dbf         RECOVER
/mcsc2/orahome/data/PROD/rotest2.dbf        ONLINE

SQLDBA> insert into rotab3 select * from scott.dept;
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/mcsc2/orahome/data/PROD/rotest.dbf'
SQL> select * from fet$ where ts#= 5;
TS#      FILE#       BLOCK#      LENGTH
---      -----       ------      ------
5        6           17          1008

SQLDBA> alter tablespace rotest add datafile '/mcsc2/orahome/data/PROD/rotest3.dbf' size 50k;
Statement processed.
SQLDBA> select * from fet$ where ts#=5;
TS#      FILE#       BLOCK#       LENGTH
---      -----       ------       ------
5        6           17           1008
5        8           2            24

SQLDBA> insert into rotab3 select * from scott.dept
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/mcsc2/orahome/data/PROD/rotest.dbf'
SQLDBA> create table rotab4 (c1 number) tablespace rotest;
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/mcsc2/orahome/data/PROD/rotest.dbf'

SQLDBA> alter database datafile '/mcsc2/orahome/data/PROD/rotest.dbf' online;
ORA-01113: file 6 needs media recovery
ORA-01110: data file 6: '/mcsc2/orahome/data/PROD/rotest.dbf'
SQLDBA> recover tablespace rotest;
ORA-00283: Recovery session canceled due to errors
ORA-01124: cannot recover data file 7 - file is in use or recovery
ORA-01110: data file 7: '/mcsc2/orahome/data/PROD/rotest2.dbf'
SQLDBA> recover datafile '/mcsc2/orahome/data/PROD/rotest.dbf';
ORA-00279: Change 11852 generated at 09/14/94 12:22:45 needed for thread 1
ORA-00289: Suggestion : /mcsc2/orahome/admin/PROD/arch/arch.log1_13.dbf
ORA-00280: Change 11852 for thread 1 is in sequence #13
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter database datafile '/mcsc2/orahome/data/PROD/rotest.dbf' online;
Statement processed.
SQLDBA> insert into rotab3 select * from scott.dept where rownum <2;
1 row processed.


p.367-368
cosmos% sqldba lmode=y
SQL*DBA: Release 7.2.1.0.0 - Beta on Tue Feb  7 10:13:15 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta


SQLDBA> connect internal
Connected.
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     59
Next log sequence to archive   61
Current log sequence           61

SQLDBA> alter database open;
Statement processed.
SQLDBA> select file#, blocks, ts# from file$;
FILE#    BLOCKS      TS#
-----    ------      ---
1        5120        0
2        1536        1
3        512         2
4        512         3
5        512         4
6        512         5
6 rows selected.
SQLDBA> alter tablespace users add datafile '/home/orahome/data/721/users02.dbf' size 40k;
Statement processed.
SQLDBA> select file#, blocks, ts# from file$;
FILE#     BLOCKS     TS#
-----     ------     ---
1         5120       0
2         1536       1
3         512        2
4         512        3
5         512        4
6         512        5
7         20         3
7 rows selected.

SQLDBA> host
cosmos% ls -l /home/orahome/data/721/users02.dbf
-rw-r-----   1 oracle7  dba        43008 Feb  7 10:20 /home/orahome/data/721/users02.dbf
cosmos% exit
cosmos% 
SQLDBA> alter database datafile '/home/orahome/data/721/users02.dbf' resize 1m;
Statement processed.
SQLDBA> select file#, blocks, ts# from file$;
FILE#     BLOCKS     TS#
-----     ------     ---
1         5120       0
2         1536       1
3         512        2
4         512        3
5         512        4
6         512        5
7         512        3
7 rows selected.
SQLDBA> host
cosmos% ls -l /home/orahome/data/721/users02.dbf
-rw-r-----   1 oracle7  dba      1050624 Feb  7 10:23
/home/orahome/data/721/users02.dbf


p.371
cosmos% sqldba lmode=y
SQL*DBA: Release 7.2.1.0.0 - Beta on Tue Feb  7 10:33:45 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size        015944 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes
SQLDBA> create table case11 (c1 number) tablespace users;
Statement processed.


p.372
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> insert into case11 values (11);
1 row processed.
SQLDBA> commit;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQLDBA> startup mount
ORACLE instance started.
Database mounted.

SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     61
Next log sequence to archive   63
Current log sequence           63

SQLDBA> recover database until cancel;@@@@@@@@@@@sS񕜏̎s
Media recovery complete.
SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> archive log list;
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1

SQLDBA> insert into case11 values(11);
1 row processed.
SQLDBA> commit;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.


p.373
SQLDBA> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/users01.dbf
cosmos% cp /home/orahome/backup/users01.dbf /home/orahome/data/721
cosmos% exit
cosmos% 
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database
ORA-00283: Recovery session canceled due to errors
ORA-01190: control file or data file 4 is from before the last RESETLOGS
ORA-01110: data file 4: '/home/orahome/data/721/users01.dbf'


SQLDBA> shutdown
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQLDBA> host
cosmos% cp /home/orahome/backup/control01.ctl /home/orahome/data/721
cosmos% exit
cosmos% 
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database using backup controlfile;
ORA-00283: Recovery session canceled due to errors
ORA-01190: control file or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '/home/orahome/data/721/system01.dbf'


p.374
SQLDBA> shutdown
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQLDBA> host
cosmos% cp /home/orahome/backup/*.* /home/orahome/data/721
cosmos% exit
cosmos% 

SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     59
Next log sequence to archive   61
Current log sequence           61

SQLDBA> recover database using backup controlfile;
ORA-00283: Recovery session canceled due to errors
ORA-01233: file 5 is read only - cannot recover using backup controlfile
ORA-01110: data file 5: '/home/orahome/data/721/test1.dbf'


p.374-375
SQLDBA> alter database datafile '/home/orahome/data/721/test1.dbf' offline;
Statement processed.

SQLDBA> recover database using backup controlfile;
ORA-00279: Change 6406 generated at 02/04/95 17:36:35 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_61.dbf
ORA-00280: Change 6406 for thread 1 is in sequence #61
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6422 generated at 02/07/95 10:34:53 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6422 for thread 1 is in sequence #62
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_61.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6425 generated at 02/07/95 10:35:26 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_63.dbf
ORA-00280: Change 6425 for thread 1 is in sequence #63
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_62.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
/home/orahome/product/7.2.1/dbs/arch1_1.dbf
Applying logfile...
ORA-00310: archived log contains sequence 1; sequence 63 required
ORA-00334: archived log: '/home/orahome/product/7.2.1/dbs/arch1_1.dbf'
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
cancel
Media recovery cancelled.


p.375
SQLDBA> alter database open resetlogs;
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/home/orahome/data/721/system01.dbf'


p.376
SQLDBA> recover database using backup controlfile until cancel;
ORA-00279: Change 6425 generated at 02/07/95 10:35:26 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_63.dbf
ORA-00280: Change 6425 for thread 1 is in sequence #63
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
cancel
Media recovery cancelled.
SQLDBA> alter database open resetlogs;
Statement processed.


SQLDBA> select * from case11;
C1
--
11
1 row selected.


p.378-379
cosmos% sqldba lmode=y
SQL*DBA: Release 7.2.1.0.0 - Beta on Tue Feb  7 12:03:46 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup open
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size       4015944 bytes
        Database Buffers         09600 bytes
            Redo Buffers          8192 bytes

SQLDBA> alter tablespace users add datafile '/home/orahome/data/721/users02.dbf' size 40k;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.

SQLDBA> host
cosmos% rm /home/orahome/data/721/users02.dbf
cosmos% exit
cosmos%
SQLDBA> startup mount
ORACLE instance started.
Database mounted.

SQLDBA> alter database create datafile '/home/orahome/data/721/users02.dbf';
Statement processed.
SQLDBA> recover datafile '/home/orahome/data/721/users02.dbf'
ORA-00279: Change 6420 generated at 02/07/95 11:00:51 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6420 for thread 1 is in sequence #62
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter database open;
Statement processed.
SQLDBA> host
cosmos% ls -l /home/orahome/data/721/users02.dbf
-rw-r-----   1 oracle7  dba        43008 Feb  7 13:09 /home/orahome/data/721/users02.dbf


p.381
recover database until time 'yyyy-mm-dd:01:58:00';


p.382
cosmos% sqldba lmode=y
SQL*DBA: Release 7.2.1.0.0 - Beta on Tue Feb  7 12:03:46 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected
SQLDBA> select a, to_char(b, 'hh24:mi:ss') time from timer;
A        TIME
--       ----
1        17:48:59
2        17:50:36
3        17:51:07
4        17:52:00
5        17:53:05
6        17:54:45
7        17:56:37
7 rows selected.


p.383
SQLDBA> connect internal
Connected.
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database until time '1994-09-15:17:55:00';
Media recovery complete.
SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> select a, to_char(b, 'hh24:mi:ss') time from timer;
A        TIME
--       ----
1        17:48:59
2        17:50:36
3        17:51:07
4        17:52:00
5        17:53:05
6        17:54:45
6 rows selected.


p.383-385
SQL> select a, to_char(b, 'HH24:MI:SS') time, c from timer;
A      TIME               C
--     --------           ----------
1      15:49:02           Switched Logs
2      15:51:51           Insert
3      15:55:38           Insert
4      15:57:29           Switched Logs
5      16:00:31           Insert
6      16:02:03           Insert
7      16:04:44           Switched Logs
8      15:04:34           Time Switch
9      15:07:27           Insert
10     15:09:35           Switched Logs
11     16:05:38           Time Change
12     15:05:25           Time Change
13     15:08:14           Switched Logs
13 rows selected.
SQLDBA> connect internal
Connected.
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> archive log list;
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /mcsc2/orahome/admin/PROD/arch/arch.log
Oldest online log sequence     7
Next log sequence to archive   9
Current log sequence           9

SQLDBA> recover database until time '1994-09-16:16:05:00';
ORA-00279: Change 13388 generated at 09/16/94 14:26:25 needed for thread 1
ORA-00289: Suggestion : /mcsc2/orahome/admin/PROD/arch/arch.log1_3.dbf
ORA-00280: Change 13388 for thread 1 is in sequence #3
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 13427 generated at 09/16/94 15:46:33 needed for thread 1
ORA-00289: Suggestion : /mcsc2/orahome/admin/PROD/arch/arch.log1_4.dbf
ORA-00280: Change 13427 for thread 1 is in sequence #4
ORA-00278: Logfile '/mcsc2/orahome/admin/PROD/arch/arch.log1_3.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 13446 generated at 09/16/94 15:48:55 needed for thread 1
ORA-00289: Suggestion : /mcsc2/orahome/admin/PROD/arch/arch.log1_5.dbf
ORA-00280: Change 13446 for thread 1 is in sequence #5
ORA-00278: Logfile '/mcsc2/orahome/admin/PROD/arch/arch.log1_4.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 13451 generated at 09/16/94 15:57:13 needed for thread 1
ORA-00289: Suggestion : /mcsc2/orahome/admin/PROD/arch/arch.log1_6.dbf
ORA-00280: Change 13451 for thread 1 is in sequence #6
ORA-00278: Logfile '/mcsc2/orahome/admin/PROD/arch/arch.log1_5.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.

SQLDBA> alter database open;
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQLDBA> alter database open resetlogs;
Statement processed.

SQL> select a, to_char(b, 'HH24:MI:SS') time, c from timer;
A      TIME                    C
--     --------                ----------
1      15:49:02                Switched Logs
2      15:51:51                Insert
3      15:55:38                Insert
4      15:57:29                Switched Logs
5      16:00:31                Insert
6      16:02:03                Insert
7      16:04:44                Switched Logs
8      15:04:34                Time Switch
9      15:07:27                Insert
10     15:09:35                Switched Logs
10 rows selected.


p.388-389
cosmos% sqldba lmode=y
SQL*DBA: Release 7.2.1.0.0 - Beta on Sun Feb 12 16:16:04 1995
Copyright (c) Oracle Corporation 1979, 1994.  All rights reserved.
Oracle7 Server Release 7.2.1.0.0 - Beta Release
With the distributed and parallel query options
PL/SQL Release 2.2.1.0.0 - Beta

SQLDBA> connect internal
Connected.
SQLDBA> startup open
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size         15944 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes

SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     60
Next log sequence to archive   62
Current log sequence           62

SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter tablespace USERS offline;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     63
Next log sequence to archive   65
Current log sequence           65
SQLDBA> shutdown abort
ORACLE instance shut down.

SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% exit
cosmos%


p.389-390
SQLDBA> startup mount
ORACLE instance started.
Database mounted.

SQLDBA> recover database
ORA-00279: Change 6420 generated at 02/07/95 11:00:51 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6420 for thread 1 is in sequence #62
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.

SQLDBA> alter database open;
Statement processed.
SQLDBA> alter tablespace users online;
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/home/orahome/data/721/users01.dbf'
SQLDBA> recover tablespace users;
ORA-00279: Change 6420 generated at 02/07/95 11:00:51 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6420 for thread 1 is in sequence #62
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter tablespace users online;
Statement processed.


p.390-391
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> select * from v$datafile;

SQLDBA> select name,  status,  enabled from v$datafile;
NAME                                  STATUS      ENABLED
--------------------------------      ------      -------
/home/orahome/data/721/system01.dbf   SYSTEM      READ WRITE
/home/orahome/data/721/rbs01.dbf      ONLINE      READ WRITE
/home/orahome/data/721/tools01.dbf    ONLINE      READ WRITE
/home/orahome/data/721/users01.dbf    OFFLINE     DISABLED
/home/orahome/data/721/test1.dbf      ONLINE      READ WRITE
/home/orahome/data/721/temp.dbf       ONLINE      READ WRITE
6 rows selected.

SQLDBA> alter database datafile '/home/orahome/data/721/users01.dbf' online;
Statement processed.
SQLDBA> recover database
ORA-00279: Change 6420 generated at 02/07/95 11:00:51 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6420 for thread 1 is in sequence #62
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.

SQLDBA> select name, status, enabled from v$datafile;
NAME                                    STATUS         ENABLED
---------------------------------       ------         -------
/home/orahome/data/721/system01.dbf     SYSTEM         READ WRITE
/home/orahome/data/721/rbs01.dbf        ONLINE         READ WRITE
/home/orahome/data/721/tools01.dbf      ONLINE         READ WRITE
/home/orahome/data/721/users01.dbf      ONLINE         DISABLED
/home/orahome/data/721/test1.dbf        ONLINE         READ WRITE
/home/orahome/data/721/temp.dbf         ONLINE         READ WRITE
6 rows selected.

SQLDBA> alter database open;
Statement processed.
SQLDBA> select tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME      STATUS
---------------      ------
SYSTEM               ONLINE
RBS                  ONLINE
TOOLS                ONLINE
USERS                OFFLINE
TEST                 ONLINE
TEMP                 ONLINE
6 rows selected.

SQLDBA> create table case14 (c1 number) tablespace users;
ORA-01542: tablespace 'USERS' is offline, cannot allocate space in it
SQLDBA> alter tablespace users online;
Statement processed.
SQLDBA> create table case14 (c1 number) tablespace users;
Statement processed.
SQLDBA> exit
SQL*DBA complete.


p.394-395
SQLDBA> startup
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size       4015944 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.

SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% exit
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database
ORA-00279: Change 6420 generated at 02/07/95 11:00:51 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_62.dbf
ORA-00280: Change 6420 for thread 1 is in sequence #62
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter database open;
Statement processed.
SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.


p.395-396
SQLDBA> startup
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size       4015944 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ WRITE
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter tablespace USERS read only;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.

SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% exit
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database
ORA-00279: Change 6507 generated at 02/12/95 18:33:31 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_70.dbf
ORA-00280: Change 6507 for thread 1 is in sequence #70
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter database open;
Statement processed.
SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.


p.397-398
SQLDBA> startup
ORACLE instance started.
Database mounted.
Database opened.
Total System Global Area       4480888 bytes
              Fixed Size         47152 bytes
           Variable Size       4015944 bytes
        Database Buffers        409600 bytes
            Redo Buffers          8192 bytes

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter tablespace USERS read write;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.

SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% exit
SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database
ORA-00279: Change 6551 generated at 02/12/95 18:39:37 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_72.dbf
ORA-00280: Change 6551 for thread 1 is in sequence #72
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
Media recovery complete.
SQLDBA> alter database open;
Statement processed.
SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ WRITE
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.


p.398-400
SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% rm /home/orahome/data/721/*.ctl
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% cp /home/orahome/backup/*.ctl /home/orahome/data/721
cosmos% exit
SQLDBA> startup mount
ORACLE instance started.
Database mounted.

SQLDBA> recover database using backup controlfile;
ORA-00283: Recovery session canceled due to errors
ORA-01233: file 4 is read only - cannot recover using backup controlfile
ORA-01110: data file 4: '/home/orahome/data/721/users01.dbf'

SQLDBA> alter database datafile '/home/orahome/data/721/users01.dbf' offline;
Statement processed.
SQLDBA> recover database using backup controlfile;
ORA-00279: Change 6522 generated at 02/12/95 18:34:54 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_70.dbf
ORA-00280: Change 6522 for thread 1 is in sequence #70
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6539 generated at 02/13/95 16:19:08 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_71.dbf
ORA-00280: Change 6539 for thread 1 is in sequence #71
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_70.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6542 generated at 02/13/95 16:19:38 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_72.dbf
ORA-00280: Change 6542 for thread 1 is in sequence #72
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_71.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
/home/orahome/data/721/redo03.log
Applying logfile...
Log applied.
Media recovery complete.

SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> alter tablespace users online;
Statement processed.
SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.


p.400-402
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     69
Next log sequence to archive   71
Current log sequence           71

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ WRITE
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> create table test_5 (c1 number) tablespace users;
Statement processed.
SQLDBA> insert into test_5 values(5);
1 row processed.
SQLDBA> commit;
Statement processed.

SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter tablespace USERS read only;
Statement processed.
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     70
Next log sequence to archive   72
Current log sequence           72

SQLDBA> alter database backup controlfile to '/home/orahome/data/721/ro_control.ctl';
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% rm /home/orahome/data/721/*.ctl
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% cp /home/orahome/backup/*.ctl /home/orahome/data/721
cosmos% exit

SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database using backup controlfile;
ORA-00279: Change 6539 generated at 02/13/95 17:02:34 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_71.dbf
ORA-00280: Change 6539 for thread 1 is in sequence #71
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6562 generated at 02/13/95 17:05:37 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_72.dbf
ORA-00280: Change 6562 for thread 1 is in sequence #72
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_71.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6566 generated at 02/13/95 17:07:27 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_73.dbf
ORA-00280: Change 6566 for thread 1 is in sequence #73
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_72.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
/home/orahome/data/721/redo01.log
Applying logfile...
Log applied.
Media recovery complete.

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ WRITE
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> select * from test_5;
C1
--
5
1 row selected.
SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.


p.402-404
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     68
Next log sequence to archive   70
Current log sequence           70

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ ONLY
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> alter tablespace users read write;
Statement processed.
SQLDBA> alter database backup controlfile to '/home/orahome/data/721/rw_control.ctl';
Statement processed.

SQLDBA> create table test_6 (c1 number);
Statement processed.
SQLDBA> insert into test_6 values (6);
1 row processed.
SQLDBA> commit;
Statement processed.
SQLDBA> alter system switch logfile;
Statement processed.
SQLDBA> archive log list
Database log mode              ARCHIVELOG
Automatic archival             ENABLED
Archive destination            /home/orahome/product/7.2.1/dbs/arch
Oldest online log sequence     70
Next log sequence to archive   72
Current log sequence           72

SQLDBA> shutdown abort
ORACLE instance shut down.
SQLDBA> host
cosmos% rm /home/orahome/data/721/*.dbf
cosmos% rm /home/orahome/data/721/*.ctl
cosmos% cp /home/orahome/backup/*.dbf /home/orahome/data/721
cosmos% mv /home/orahome/data/721/rw_control.ctl /home/orahome/data/721/control01.ctl
cosmos% exit

SQLDBA> startup mount
ORACLE instance started.
Database mounted.
SQLDBA> recover database using backup controlfile;
ORA-00279: Change 6507 generated at 02/12/95 18:33:31 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_70.dbf
ORA-00280: Change 6507 for thread 1 is in sequence #70
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6532 generated at 02/13/95 16:48:01 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_71.dbf
ORA-00280: Change 6532 for thread 1 is in sequence #71
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_70.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}

Applying suggested logfile...
Log applied.
ORA-00279: Change 6545 generated at 02/13/95 16:50:06 needed for thread 1
ORA-00289: Suggestion : /home/orahome/product/7.2.1/dbs/arch1_72.dbf
ORA-00280: Change 6545 for thread 1 is in sequence #72
ORA-00278: Logfile '/home/orahome/product/7.2.1/dbs/arch1_71.dbf' no longer needed for this recovery
Specify log: {<RET>=suggested | filename | AUTO | FROM logsource | CANCEL}
/home/orahome/data/721/redo03.log
Applying logfile...
Log applied.
Media recovery complete.

SQLDBA> select name, enabled from v$datafile;
NAME                                  ENABLED
--------------------------------      -------
/home/orahome/data/721/system01.dbf   READ WRITE
/home/orahome/data/721/rbs01.dbf      READ WRITE
/home/orahome/data/721/tools01.dbf    READ WRITE
/home/orahome/data/721/users01.dbf    READ WRITE
/home/orahome/data/721/test1.dbf      READ WRITE
/home/orahome/data/721/temp.dbf       READ WRITE
6 rows selected.

SQLDBA> alter database open resetlogs;
Statement processed.
SQLDBA> select * from test_6;
C1
--
6
1 row selected.



Appendix
p.411
SELECT ename, empno AS id FROM emp ORDER BY id;


p.412
ALTER TABLESPACE tablespace_name READ ONLY;


p.413
ALTER TABLESPACE tablespace_name READ WRITE;


RECOVER DATABASE PARALLEL DEGREE 5 INSTANCES 2;


p.415
SELECT  /* + FULL(table_name) PARALLEL (table_name 5) */ column FROM table_name;

CREATE TABLE table_name(column_name type) PARALLEL (DEGREE 5 INSTANCES 2);

ALTER TABLE table_name PARALLEL (DEGREE 4);


p.416
CREATE INDEX index_name ON table_name (column_name) PARALLEL (DEGREE 4);


SQLLOAD USERID=SCOTT/TIGER CONTROL=LOAD1.CTL DIRECT=TRUE PARALLEL=TRUE


p.418
CREATE TABLE emp_sal (empno, comm CHECK (comm < 2000), sal NOT NULL)
UNRECOVERABLE
PARALLEL (DEGREE 3)
AS SELECT empno, comm, sal FROM emp;


p.419
ALTER DATABASE DATAFILE 'filename' 50M;

ALTER DATABASE DATAFILE 'filename' AUTOEXTEND OFF;

ALTER DATABASE DATAFILE 'filename' AUTOEXTEND ON NEXT 100K MAXSIZE 250M;





