search
HomeDatabaseMysql Tutorialrman备份恢复命令之switch

rman备份恢复命令之switch,更新数据文件名为rman下镜像拷贝时指定的数据文件名,更新数据文件名为 set newname 命令指定的名字。

一 switch 命令
1 switch命令用途
更新数据文件名为rman下镜像拷贝时指定的数据文件名
更新数据文件名为 set newname 命令指定的名字。
 
2 switch 命令使用前提条件
rman 必须连接到目标数据库
当switch tablespaces、datafiles、tempfiles时,这些文件必须离线
当switch 整个数据库时,,数据库不能open
3 注意事项
switch....to copy 命令用于rman命令提示符下
switch没有to copy的命令用于run语句块中
 
4 语法
  第一组
  switch dtabase to copy;                 
  switch datafile number|name to copy;
  switch tablespace name to copy;
  第二组
  switch datafile all;
  switch datafile number|name;
  switch tempfile all;

推荐阅读:

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密
 
二 举例如下:
例一:用switch datafile number to copy 更新数据文件位置和名字
RMAN> backup as copy datafile 8  format '/oracle/CRM/test.dbf';
Starting backup at 2013-02-22 10:06:21
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=/backup/test.dbf
output file name=/oracle/CRM/test.dbf tag=TAG20130222T100621 RECID=14 STAMP=808049181
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013-02-22 10:06:22
Starting Control File and SPFILE Autobackup at 2013-02-22 10:06:22
piece handle=/backup/c-3599153036-20130222-01 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 10:06:25

RMAN> sql 'alter tablespace test offline';
sql statement: alter tablespace test offline
RMAN> switch datafile 8 to copy;
datafile 8 switched to datafile copy "/oracle/CRM/test.dbf"

RMAN> report schema;
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
===========================
File Size(MB) Tablespace          RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM              ***    /oracle/CRM/system01.dbf
2    540      SYSAUX              ***    /oracle/CRM/sysaux01.dbf
3    100      UNDOTBS3            ***    /oracle/CRM/undotbs3.dbf
4    1742    USERS                ***    /backup/users01.dbf
5    500      POS                  ***    /oracle/CRM/pos.dbf
6    100      ERP                  ***    /oracle/CRM/erp.dbf
7    5        USER01              ***    /oracle/CRM/user01.dbf
8    0        TEST                ***    /oracle/CRM/test.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace          Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    218      TEMP                32767      /oracle/CRM/temp01.dbf
2    3072    MYNEWTEMP            40960      /oracle/CRM/newtemp.dbf

例二 用switch tablespace name to copy更新表空间所有数据文件位置和名字
RMAN> backup  as copy  tablespace  pos format '/oracle/%N%f.dbf';
(%N为表空间名、%f为数据文件绝对文件号)
Starting backup at 2013-02-22 10:55:49
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/oracle/CRM/pos.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00009 name=/oracle/CRM/pos2.dbf
output file name=/oracle/POS9.dbf tag=TAG20130222T105549 RECID=18 STAMP=808052153
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:07
output file name=/oracle/POS5.dbf tag=TAG20130222T105549 RECID=19 STAMP=808052179
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
Finished backup at 2013-02-22 10:56:25
Starting Control File and SPFILE Autobackup at 2013-02-22 10:56:25
piece handle=/backup/c-3599153036-20130222-03 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 10:56:28
RMAN> sql 'alter tablespace  pos offline';
sql statement: alter tablespace  pos offline
RMAN> switch tablespace pos to copy;
datafile 5 switched to datafile copy "/oracle/POS5.dbf"
datafile 9 switched to datafile copy "/oracle/POS9.dbf"
RMAN> report schema;
Report of database schema for database with db_unique_name CRM
List of Permanent Datafiles
===========================
File Size(MB) Tablespace          RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    750      SYSTEM              ***    /oracle/CRM/system01.dbf
2    540      SYSAUX              ***    /oracle/CRM/sysaux01.dbf
3    100      UNDOTBS3            ***    /oracle/CRM/undotbs3.dbf
4    1742    USERS                ***    /backup/users01.dbf
5    0        POS                  ***    /oracle/POS5.dbf
6    100      ERP                  ***    /oracle/CRM/erp.dbf
7    5        USER01              ***    /oracle/CRM/user01.dbf
8    0        TEST                ***    /oracle/CRM/test.dbf
9    0        POS                  ***    /oracle/POS9.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace          Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    218      TEMP                32767      /oracle/CRM/temp01.dbf
2    3072    MYNEWTEMP            40960      /oracle/CRM/newtemp.dbf
例三 用switch dtabase to copy更新数据库所有数据文件位置和名字
RMAN> backup as copy database format '/oracle/CRM/test/%N%f.dbf';
Starting backup at 2013-02-22 11:26:52
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=129 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=192 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/backup/users01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00001 name=/oracle/CRM/system01.dbf
output file name=/oracle/CRM/test/SYSTEM1.dbf tag=TAG20130222T112653 RECID=52 STAMP=808054107
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:41
channel ORA_DISK_2: starting datafile copy
input datafile file number=00002 name=/oracle/CRM/sysaux01.dbf
output file name=/oracle/CRM/test/USERS4.dbf tag=TAG20130222T112653 RECID=53 STAMP=808054182
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:54
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/oracle/POS5.dbf
output file name=/oracle/CRM/test/SYSAUX2.dbf tag=TAG20130222T112653 RECID=54 STAMP=808054193
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:01:11
channel ORA_DISK_2: starting datafile copy
input datafile file number=00003 name=/oracle/CRM/undotbs3.dbf
output file name=/oracle/CRM/test/UNDOTBS33.dbf tag=TAG20130222T112653 RECID=55 STAMP=808054203
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_2: starting datafile copy
input datafile file number=00006 name=/oracle/CRM/erp.dbf
output file name=/oracle/CRM/test/ERP6.dbf tag=TAG20130222T112653 RECID=56 STAMP=808054230
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_2: starting datafile copy
input datafile file number=00009 name=/oracle/POS9.dbf
output file name=/oracle/CRM/test/POS5.dbf tag=TAG20130222T112653 RECID=57 STAMP=808054247
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/oracle/CRM/user01.dbf
output file name=/oracle/CRM/test/POS9.dbf tag=TAG20130222T112653 RECID=58 STAMP=808054247
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:08
channel ORA_DISK_2: starting datafile copy
input datafile file number=00008 name=/oracle/CRM/test.dbf
output file name=/oracle/CRM/test/USER017.dbf tag=TAG20130222T112653 RECID=59 STAMP=808054250
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:00
output file name=/oracle/CRM/test/TEST8.dbf tag=TAG20130222T112653 RECID=60 STAMP=808054250
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2013-02-22 11:30:51
Starting Control File and SPFILE Autobackup at 2013-02-22 11:30:51
piece handle=/backup/c-3599153036-20130222-06 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-02-22 11:30:59
RMAN> switch database to copy;
datafile 1 switched to datafile copy "/oracle/CRM/test/SYSTEM1.dbf"
datafile 2 switched to datafile copy "/oracle/CRM/test/SYSAUX2.dbf"
datafile 3 switched to datafile copy "/oracle/CRM/test/UNDOTBS33.dbf"
datafile 4 switched to datafile copy "/oracle/CRM/test/USERS4.dbf"
datafile 5 switched to datafile copy "/oracle/CRM/test/POS5.dbf"
datafile 6 switched to datafile copy "/oracle/CRM/test/ERP6.dbf"
datafile 7 switched to datafile copy "/oracle/CRM/test/USER017.dbf"
datafile 8 switched to datafile copy "/oracle/CRM/test/TEST8.dbf"
datafile 9 switched to datafile copy "/oracle/CRM/test/POS9.dbf"
RMAN> sql 'alter database open';
sql statement: alter database open
SQL> select file#,name,status from v$datafile;
    FILE# NAME                                    STATUS
---------- ---------------------------------------- -------
        1 /oracle/CRM/test/SYSTEM1.dbf            SYSTEM
        2 /oracle/CRM/test/SYSAUX2.dbf            ONLINE
        3 /oracle/CRM/test/UNDOTBS33.dbf          ONLINE
        4 /oracle/CRM/test/USERS4.dbf              ONLINE
        5 /oracle/CRM/test/POS5.dbf                ONLINE
        6 /oracle/CRM/test/ERP6.dbf                ONLINE
        7 /oracle/CRM/test/USER017.dbf            ONLINE
        8 /oracle/CRM/test/TEST8.dbf              ONLINE
        9 /oracle/CRM/test/POS9.dbf                ONLINE

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
switch日版港版有什么区别switch日版港版有什么区别Jun 20, 2023 pm 02:06 PM

switch日版港版的区别:1、充电器上存在主要区别,日版和国标充电口通用,港版使用英式三角插头;2、日版使用点卡支付,而港服使用支付宝支付;3、港版售后保修需要邮寄回HK售后点,而日版需要邮寄到Japan指定售后点。

switch连电视没反应怎么办switch连电视没反应怎么办Jul 03, 2023 am 11:15 AM

switch连电视没反应解决方法:1、检查switch和电视的电源是否连接;2、检查电视HDMI线接口是否插紧;3、Switch底座后盖打开,检查电源线和HDMI线是否插紧;4、检查Switch是否开机状态下放入底座;5、检查电视是否切换了信号源。

switch可以一直放在底座上充电吗switch可以一直放在底座上充电吗Jul 06, 2023 pm 04:51 PM

switch不可以一直放在底座上充电,其危害有:1、缩短电池的寿命和续航时间;2、导致内存烧坏。

艾尔登法环switch能玩么艾尔登法环switch能玩么Mar 11, 2024 am 11:31 AM

艾尔登法环能在switch上游玩吗?艾尔登法环作为一款极具魅力的动作RPG游戏,不少朋友可能还不明白它能否在switch平台上进行畅快游玩,答案是暂时无法实现。艾尔登法环switch能玩么答:不能在switch游玩。此款备受瞩目的魂系列角色扮演类动作游戏已正式发布,玩家可前往PC、ps4/5以及XboxSerieseX|S/XboxOne购买并立即体验。许多拥有switch的朋友们可能仍热切期待在ns上畅享这款游戏,但遗憾的说,该游戏并无switch版本。据官网配置要求显示,游戏配置较高,而sw

switch lite和switch有什么区别switch lite和switch有什么区别Jun 28, 2023 pm 02:13 PM

switch lite和switch区别有:1、尺寸不同;2、屏幕大小及机身重量不同;3、手柄是否可拆卸及手柄功能不同;4、电池续航能力不同;5、手柄按键设计不同;6、可支持游戏不同;6、颜色不同。

switch语句中必须有default选项吗?switch语句中必须有default选项吗?Nov 25, 2020 pm 04:03 PM

switch语句中不是必须有default选项的。switch语句首先会找满足条件的case值做为执行后面的程序入口,若所有的case都不满足,则找default入口,若未找到则退出整个语句;default只是一个备用入口,有没有都无所谓。

switch32g内存够用吗switch32g内存够用吗Jun 20, 2023 pm 02:28 PM

switch32g内存不够用,其原因如下:1、买数字版游戏想购买DLC截图储存到掌机里的话根本不够用;2、下载数字版游戏,32G内存大约可以储存2~3个游戏,根本满足不了玩游戏的需求;3、数字游戏及其dlc一般保持在5G,除过自带系统占用的空间,下载游戏对于玩家来说比较困难。

消息称世嘉拥有任天堂 Switch 2 开发套件,《FF7:R》在 Switch 2 上运行效果看上去像 PS5 游戏消息称世嘉拥有任天堂 Switch 2 开发套件,《FF7:R》在 Switch 2 上运行效果看上去像 PS5 游戏Sep 10, 2023 pm 05:33 PM

本站9月2日消息,Reddit论坛用户TheRealImAHeroToo爆料称,世嘉拥有Switch2开发套件已经有一段时间了,新主机将具备新的相机功能,可向下兼容一些经过测试的游戏。SquareEnix拥有新款PS5开发套件,而《最终幻想7:重制版》在Switch2上运行的效果看上去像PS5游戏。目前该爆料者的账号已经删除,并表示不会再泄露信息,因为风险太大。本站注意到,该爆料者还提到:明年将推出另一款世嘉的索尼克游戏《女神异闻录6》或许不会在明年发布,主题是“黑与白”;还有一款尚未公布的《女

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment