[20201103]set newname for datafile.txt

lfree發表於2020-11-03

[20201103]set newname for datafile.txt

--//在rman克隆或者不完全恢復時,經常需要執行如上類似命令:

SELECT    'set newname for datafile '
         || file#
         || ' to ''&1'
         || SUBSTR (name, INSTR (name, '/', -1) + 1)
         || ''';'
            c120
    FROM v$dbfile
ORDER BY FILE#;

--//生成的指令碼在加入頭尾就ok了:

run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
set until time '2020-11-02 05:30:00';
....

restore database;
switch datafile all;
recover database;
release channel c1;
release channel c2;
release channel c3;
}

--//注意環境變數,設定如下,不然可能日期格式不對。
$ env | grep -i nls
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
NLS_TIME_TZ_FORMATx=HH24.MI.SSXFF TZH:TZM
NLS_TIMESTAMP_TZ_FORMAT=YYYY-MM-DD HH24:MI:SS.FF TZH:TZM
NLS_TIMESTAMP_FORMAT=YYYY-MM-DD HH24:MI:SS.FF
NLS_DATE_FORMAT=YYYY-MM-DD HH24:MI:SS


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2731771/,如需轉載,請註明出處,否則將追究法律責任。