zoukankan      html  css  js  c++  java
  • 数据库备份还原

    一、先查询directory的地址 导出的文件必须放在此目录
        select * from dba_directories;
      找到directory_name的值 ,也可以新建一个
        create directory test as 'f:\test'

    二、查看数据库版本号,指定版本导出

      select * from v$version;

    三、数据库导出和导入

      数据库的导入导出有两种方式,一种是imp/exp,另一种是IMPDP/EXPDP。

    imp
      1、将d:\daochu.dmp 中的数据导入 orcl数据库中。
        imp scott/accp@orcl file=d:\daochu.dmp full=y
      2、如果导入时,数据表已经存在,将报错,对该表不会进行导入;加上ignore=y即可,表示忽略现有表,在现有表上追加记录。
        imp scott/accp@orcl file=d:\daochu.dmp full=y ignore=y
      3、将d:\daochu.dmp中的表emp导入
        imp scott/accp@orcl file=d:\daochu.dmp tables=(emp)
    exp
      1、将数据库orcl完全导出,用户名system,密码accp,导出到d:\daochu.dmp文件中
        exp system/accp@orcl file=d:\daochu.dmp full=y
      2、将数据库orcl中scott用户的对象导出
        exp scott/accp@orcl file=d:\daochu.dmp owner=(scott)
      3、将数据库orcl中的scott用户的表emp、dept导出
        exp scott/accp@orcl file= d:\daochu.dmp tables=(emp,dept)
      4、将数据库orcl中的表空间testSpace导出
        exp system/accp@orcl file=d:\daochu.dmp tablespaces=(testSpace)

      impdp和empdp相对于imp和emp来说参数比较多,但比较准确,出错率少,推荐用这种。

    IMPDP USERID='scott/tiger@orcl' REMAP_SCHEMA=scott:scott REMAP_TABLESPACE=users:users directory=TEST dumpfile=2015.DMP logfile=2015.log
    EXPDP USERID='scott/tiger@orcl' schemas=scott directory=TEST dumpfile=2015.dmp logfile=2015.log version=10.2.0.1.0 EXCLUDE=TABLE:\"IN('TABLE1','TABLE2')\"

      此处对impdp和empdp的相关属性做简单介绍:

      userid='XX/XX@XX',此处为:用户名/密码@数据库名

      REMAP_SCHEMA=xx:xx,此处为原数据库用户名:现数据库用户名

      REMAP_TABLESPACE=XX:XX,此处为原数据库表空间:现数据库表空间

      directory=XX,此处参考文章步骤一。

      DUMPFILE=xx,此处为导出的数据库文件名称

      logfile=XX,此处为导出的日志文件名称

      schemas='XX',此处为用户名

      version=XX.XX.XX.X.X,此处为指定导出版本号,因数据库之间版本可能不一样,所以导出前要确定目标数据库的版本号。

      EXCLUDE=XX,此为导出时排除某些表,即某些表不导出。  

      

  • 相关阅读:
    SpringBoot之集成slf4j日志框架
    Maven项目优势
    Idea操作技巧
    Nginx服务器之负载均衡策略(6种)
    Git操作规范
    Mybatis之Tk
    MyEclipse取消验证Js的两种方法
    文件异步上传,多文件上传插件uploadify
    EasyMock的使用
    jquery 中post 、get的同步问题,从外部获取返回数据
  • 原文地址:https://www.cnblogs.com/xiufengd/p/4708525.html
Copyright © 2011-2022 走看看