zoukankan      html  css  js  c++  java
  • Oracle导入dmp备份文件到不同的表空间中

    原文链接:http://www.2cto.com/database/201211/171081.html


    将DMP导入到不同的表空间中

     
    1,用imp导出数据    cmd进入orcle安装目录bin下,输入以下命令: 
    exp username/password@ORACLEEPP file=c:hysjb.dmp owner=magazine_hy rows=y
     
    2, 用imp产生index.sql文件
    imp <xe_username>/<password>@XE file=<filename.dmp> indexfile=index.sql full=y
     
    3,修改index.sql文件
     
    FIND: 'REM<SPACE>' REPLACE: <NOTHING>
     
    FIND: '"<SOURCE_TABLESPACE>"' REPLACE: '"USERS"' 
     
    FIND: '...' REPLACE: 'REM ...' 
     
    FIND: 'CONNECT' REPLACE: 'REM CONNECT'
     
    ps:查看表空间的语句:
    select
    df.tablespace_name "TABLESPACE_NAME",totalspace "TOTALSPACE/M",freespace "FREESPACE/M",round((1-freespace/totalspace)*100,2) "USED%"
    from 
    (select tablespace_name,round(sum(bytes)/1024/1024) totalspace from    dba_data_files group by tablespace_name) df, 
    (select tablespace_name,round(sum(bytes)/1024/1024) freespace from dba_free_space group by tablespace_name) fs
    where df.tablespace_name=fs.tablespace_name;  
     
    4,使用sqlplus进入执行此sql生成表结构
    sqlplus <xe_username>/<password>@XE @index.sql 
     
    5,进入数据库diasble掉依赖。
    select 'ALTER TABLE '||table_name|| ' disable constraint '||constraint_name|| '; ' from user_constraints
    where constraint_type   =   'R';
    导出csv文件为imp.sql,删除"号,执行。
     
    6,导入数据,cmd下执行:
     
    imp <xe_username>/<password>@XE file=<filename.dmp> fromuser=<original_username> touser=<xe_username> ignore=y 
     

    7,将imp.sql中的disable替换成enable执行。enable依赖





    小龙评论


    第3步可能搜不到所有需要替换的内容,另外可能最终得到的结果无法正确执行。那就把sql挑出来单独执行即可

    FIND 'REM  ' REPLACE'  '

    FIND '... 0 rows' REPLACE ' '

    第5步、第7步,如果是导入到新的数据库,就不用再禁用、启用约束。

  • 相关阅读:
    C#路径中获取文件全路径、目录、扩展名、文件名称
    c#FTP应用---windows iis
    c#FTP应用---FileZilla Server
    在VS2010中使用Git管理源代码
    ABB机器人---PCSDK简介
    几款软件需求分析工具
    快速排序
    springmvc和struts2的区别比较
    Struts中ActionContext和ServletActionContext的比较
    设计模式--适配器模式
  • 原文地址:https://www.cnblogs.com/wenlong/p/5255669.html
Copyright © 2011-2022 走看看