实验目标:实现磁盘组中的数据文件批量复制到本地磁盘. 实际操作如下: SQL>select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/ORCLCDB/DATAFILE/system.257.1082993319 +DATA/ORCLCDB/DATAFILE/sysaux.258.1082993363 +DATA/ORCLCDB/DATAFILE/undotbs1.259.1082993389 +DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.270.1082993933 +DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.271.1082993933 +DATA/ORCLCDB/DATAFILE/users.260.1082993391 +DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.272.1082993933 +DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/system.276.1082994661 +DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/sysaux.277.1082994661 +DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/undotbs1.275.1082994661 +DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/users.279.1082994667 NAME -------------------------------------------------------------------------------- /home/oracle/tsp_idx01.dbf /home/oracle/tsp_item01.dbf +DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/tsp_test01.dbf +DATA/ORCLCDB/DATAFILE/tsp_treate.dbf +DATA/ORCLCDB/DATAFILE/apnurrec.dbf +DATA/ORCLCDB/DATAFILE/apnurrec01.dbf +DATA/ORCLCDB/DATAFILE/apnurrec02.dbf +DATA/ORCLCDB/DATAFILE/apnurrec03.dbf +DATA/ORCLCDB/DATAFILE/apnurrec04.dbf 20 rowsselected. 如下单个文件复制. SQL>cp +DATA/ORCLCDB/DATAFILE/system.257.1082993319/home/oracle/system.257.1082993319 如果数据文件很多,就需要批量生成复制语句,既提高效率同时也减少误操作. 使用如下语句生成: SQL> select 'cp ' ||name || ' /home/oracle/' ||substr(name,instr(name,'/',-1)+1) from v$datafile 'CP'||NAME||'/HOME/ORACLE/'||SUBSTR(NAME,INSTR(NAME,'/',-1)+1) ------------------------------------------------------------------------------------------------------------------------------------ cp+DATA/ORCLCDB/DATAFILE/system.257.1082993319 /home/oracle/system.257.1082993319 cp+DATA/ORCLCDB/DATAFILE/sysaux.258.1082993363 /home/oracle/sysaux.258.1082993363 cp+DATA/ORCLCDB/DATAFILE/undotbs1.259.1082993389/home/oracle/undotbs1.259.1082993389 cp+DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.270.1082993933/home/oracle/system.270.1082993933 cp+DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.271.1082993933/home/oracle/sysaux.271.1082993933 cp+DATA/ORCLCDB/DATAFILE/users.260.1082993391 /home/oracle/users.260.1082993391 cp+DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.272.1082993933/home/oracle/undotbs1.272.1082993933 cp+DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/system.276.1082994661/home/oracle/system.276.1082994661 cp+DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/sysaux.277.1082994661/home/oracle/sysaux.277.1082994661 cp+DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/undotbs1.275.1082994661/home/oracle/undotbs1.275.1082994661 cp+DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/users.279.1082994667/home/oracle/users.279.1082994667 'CP'||NAME||'/HOME/ORACLE/'||SUBSTR(NAME,INSTR(NAME,'/',-1)+1) ------------------------------------------------------------------------------------------------------------------------------------ cp/home/oracle/tsp_idx01.dbf /home/oracle/tsp_idx01.dbf cp/home/oracle/tsp_item01.dbf /home/oracle/tsp_item01.dbf cp+DATA/ORCLCDB/CBB47E352F7AAEA7E0537885A8C03007/DATAFILE/tsp_test01.dbf/home/oracle/tsp_test01.dbf cp+DATA/ORCLCDB/DATAFILE/tsp_treate.dbf /home/oracle/tsp_treate.dbf cp+DATA/ORCLCDB/DATAFILE/apnurrec.dbf /home/oracle/apnurrec.dbf cp+DATA/ORCLCDB/DATAFILE/apnurrec01.dbf /home/oracle/apnurrec01.dbf cp+DATA/ORCLCDB/DATAFILE/apnurrec02.dbf /home/oracle/apnurrec02.dbf cp+DATA/ORCLCDB/DATAFILE/apnurrec03.dbf /home/oracle/apnurrec03.dbf cp+DATA/ORCLCDB/DATAFILE/apnurrec04.dbf /home/oracle/apnurrec04.dbf
|