首页 > 解决方案 > “如何在不执行 impdp 的情况下恢复 EXPDP 后删除的架构?

问题描述

我正在为即将到来的项目演奏——如何演奏expdpimpdp在距离测试环境两个级别的游戏环境中。所以我expdp使用 scott/tiger 并导出了 scott 模式。但是,出于好奇,我从数据库中删除了 Scott 模式(希望impdp在同一个数据库中进行),然后我遇到了很多错误并从数据库中丢失了 Scott 模式。

我是否可以从转储文件中恢复 Scott 架构?

这就是我所做的:

  1. expdp scott/tiger schemas=scott directory=test_dir dumpfile=scott.dmp logfile=expdpscott.log

  2. impdp scott/tiger schemas=scott directory=test_dir dumpfile=scott.dmp logfile=impdpscott.log . . . 然后我得到了这个:

    作业“SCOTT”。“SYS_IMPORT_SCHEMA_01”在 19:13:31 完成,出现 4 个错误”

    ...然后我做了:

  3. drop user Scott cascade;

    接着

  4. impdp scott/tiger schemas=scott directory=test_dir dumpfile=scott.dmp logfile=impdpscott.log

然后我收到了这个错误:

UDI-01017:操作生成 ORACLE 错误 1017 ORA-01017:用户名/密码无效;登录被拒绝

......现在我意识到我做了一件愚蠢的事情(这对学习者来说很好)。

如何取回或恢复已删除的scott架构?

标签: oracleschemarecoverydatapump

解决方案


如果您发布了您在第 2 步中遇到的错误,那就太好了;也许他们无关紧要。

现在,当您删除 Scott 时,以特权用户(例如 SYS)的身份连接并创建用户 Scott。这是一个例子:

  • 检查数据库中的表空间列表
  • 创建用户
  • 授予它一些特权

SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USER_DATA
APEX
APEX_9695076087226093

7 rows selected.

SQL> create user littlefoot identified by lion
  2    default tablespace user_data
  3    temporary tablespace temp
  4    profile default
  5    quota  unlimited on user_data;

User created.

SQL>
SQL> grant create session       to littlefoot;

Grant succeeded.

SQL> grant create table         to littlefoot;

Grant succeeded.

SQL> grant create procedure     to littlefoot;

Grant succeeded.

SQL> grant create sequence      to littlefoot;

Grant succeeded.

SQL> grant create view          to littlefoot;

Grant succeeded.

SQL> grant create trigger       to littlefoot;

Grant succeeded.

SQL>

一旦你这样做,IMPDP再次运行。


推荐阅读