经典推荐: Oracle 常用命令汇总

来源:本站整理  作者:学生大读书站
摘要://创建一个控制文件命令到跟踪文件 alter database backup controlfile to trace;//增加一个新的日志文件组的语句 connect internal as sysdba alter database ……

REM   For the purposes of this example, this tablespace
REM   will contain two files, data01.dbf and data02.dbf.
REM   The * wildcard will be used in the filename.
REM   alter tablespace DATA begin backup;
!tar -rvf /dev/rmt/0hc /db03/oracle/CC1/data0*.dbf
alter tablespace DATA end backup;
REM
REM   备份 INDEXES tablespace
REM
alter tablespace INDEXES begin backup;
!tar -rvf /dev/rmt/0hc /db04/oracle/CC1/indexes01.dbf
alter tablespace INDEXES end backup;
REM
REM   备份  TEMP tablespace
REM
alter tablespace TEMP begin backup;
!tar -rvf /dev/rmt/0hc /db05/oracle/CC1/temp01.dbf
alter tablespace TEMP end backup;
REM
REM   Follow the same pattern to back up the rest
REM   of the tablespaces.
REM
REM   
REM  Step 2.  备份归档日志文件.
archive log stop
REM
REM   Exit Server Manager, using the indicator set earlier.
exit
EOFarch1
#
#  Record which files are in the destination directory.
#   Do this by setting an environment variable that is
#  equal to the directory listing for the destination 
#  directory.
#  For this example, the log_archive_dest is 
#  /db01/oracle/arch/CC1.
#
FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES
#
#  Now go back into Server Manager and restart the
#  archiving process.  Set an indicator (called EOFarch2
#  in this example).
#
svrmgrl <<EOFarch2
connect internal
archive log start;
exit
EOFarch2
#
#  Now back up the archived redo logs to the tape
#  device via the "tar" command, then delete them
#  from the destination device via the "rm" command.
#  You may choose to compress them instead.
#
tar -rvf /dev/rmt/0hc $FILES
rm -f $FILES

#
#   Step 3.  备份控制文件到磁盘.
#
svrmgrl <<EOFarch3
connect internal
alter database backup controlfile to
   ’db01/oracle/CC1/CC1controlfile.bck’;
exit
EOFarch3
#
#  备份控制文件到磁带.
#
tar -rvf /dev/rmt/0hc /db01/oracle/CC1/CC1controlfile.bck
#
#  End of hot backup script.
//自动生成开始备份的脚本
set pagesize 0 feedback off
select 
  ’alter tablespace ’

Tablespace_Name

’ begin backup;’
  from DBA_TABLESPACES
 where Status <> ’INVALID’
spool alter_begin.sql
/
spool off

//自动生成备份结束的脚本
set pagesize 0 feedback off
select 
  ’alter tablespace ’

Tablespace_Name

’ end backup;’
  from DBA_TABLESPACES
 where Status <> ’INVALID’
spool alter_end.sql
/
spool off

//备份归档日志文件的脚本.
REM  See text for alternatives.
#   Step 1: Stop the archiving process. This will keep
#   additional archived redo log files from being written
#   to the destination directory during this process.
#
svrmgrl <<EOFarch1
connect internal as sysdba
archive log stop;
REM
REM   Exit Server Manager using the indicator set earlier.
exit
EOFarch1
#
#   Step 2: Record which files are in the destination 
#  directory.
#   Do this by setting an environment variable that is
#  equal to the directory listing for the destination 
#  directory.
#  For this example, the log_archive_dest is
#  /db01/oracle/arch/CC1.
#
FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES
#
#   Step 3: Go back into Server Manager and restart the
#  archiving process. Set an indicator (called EOFarch2
#  in this example).
#
svrmgrl <<EOFarch2
connect internal as sysdba

【相关文章】好搜一下
浅谈oracle数据库的默认账号

浅谈oracle数据库的默认账号

内容提示:oracle安装会自动的生存sys用户、scott用户和system用…