• 数据库备份还原


    一、先查询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,此为导出时排除某些表,即某些表不导出。  

      

  • 相关阅读:
    salt执行报错一例
    state配置语言实战
    salt-ssh使用
    八、job管理
    六、saltstack的module组件
    五、Pillar数据管理中心
    Web Server与App Server
    二分查找的时间复杂度(TODO )
    二分查找的时间复杂度(TODO )
    git : error setting certificate verify locations
  • 原文地址:https://www.cnblogs.com/xiufengd/p/4708525.html
Copyright © 2020-2023  润新知