Oracle 数据泵导出脚本失败

发布于 2024-09-14 14:05:48 字数 1137 浏览 8 评论 0原文

我正在尝试对表空间上的元数据进行数据泵导出(课程)。我走在正确的轨道上吗?我的数据泵目录创建为:

CREATE DIRECTORY dpump_dir AS '/mydata/data';

请记住我是初学者。这可能是也可能不是最好的方法,但我想尝试让它发挥作用。非常感谢。

declare
      dp_handle       number;
  begin
      dp_handle := dbms_datapump.open(
      operation   => 'EXPORT',
      job_mode    => 'TABLESPACE');

    dbms_datapump.add_file(
      handle    =>  dp_handle,
      filename  => 'courses.dmp',
      directory => 'dpump_dir');

    dbms_datapump.add_file(
      handle    => dp_handle,
      filename  => 'courses.log',
      directory => 'dpump_dir',
      filetype  => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);

    dbms_datapump.metadata_filter(      
      handle => dp_handle,
      name   => 'TABLESPACE_EXPR',
      value  => '''COURSE''');

    dbms_datapump.start_job(dp_handle);

    dbms_datapump.detach(dp_handle);
  end;
  /    

ERROR at line 1:
ORA-39001: invalid argument value
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 2926
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3162
ORA-06512: at line 8

I'm trying to do a data pump export for metadata on a tablespace (COURSE). Am I on the right track? My data pump directory was created as:

CREATE DIRECTORY dpump_dir AS '/mydata/data';

Please keep in mind that I'm a beginner. This may or may not be the best way to go about this, but I'd like to try to get this working. Thanks very much.

declare
      dp_handle       number;
  begin
      dp_handle := dbms_datapump.open(
      operation   => 'EXPORT',
      job_mode    => 'TABLESPACE');

    dbms_datapump.add_file(
      handle    =>  dp_handle,
      filename  => 'courses.dmp',
      directory => 'dpump_dir');

    dbms_datapump.add_file(
      handle    => dp_handle,
      filename  => 'courses.log',
      directory => 'dpump_dir',
      filetype  => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);

    dbms_datapump.metadata_filter(      
      handle => dp_handle,
      name   => 'TABLESPACE_EXPR',
      value  => '''COURSE''');

    dbms_datapump.start_job(dp_handle);

    dbms_datapump.detach(dp_handle);
  end;
  /    

ERROR at line 1:
ORA-39001: invalid argument value
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 2926
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3162
ORA-06512: at line 8

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

百变从容 2024-09-21 14:05:48

失败的原因有很多:

  1. 您想要写入的文件 (courses.dmp) 确实已经存在。甲骨文
    不会覆盖该文件。 (是的,错误消息非常蹩脚)
  2. 操作系统目录 /mydata/data 确实存在。
  3. /mydata/data 确实存在,但是Oracle没有必要的
    访问目录的权限
  4. 以上都不是,但运行脚本的 Oracle 用户没有权限
    授予在 dpump_dir读取、写入

如果这些要点没有帮助,您可以首先打开 (add_file) *.log 文件,然后 *.dmp 文件。希望 Oracle 能够在 *.log 文件中写入一些有意义的内容。

There are a number of reasons why this could fail:

  1. The file you want to write (courses.dmp) does already exist. Oracle
    won't override the file. (Yes, the error message is pretty lame)
  2. The OS-directory /mydata/data does not exist.
  3. /mydata/data does exist, but Oracle does not have the necessary
    rights to access the directory
  4. None of the above, but the Oracle user that runs the script was not
    granted read, write on dpump_dir

If these points don't help, you might first open (add_file) the *.log file, then the *.dmp file. Hopefully, Oracle will write something meaningful into the *.log file.

过潦 2024-09-21 14:05:48

看来您的错误是在第一次 ADDFILE 调用时发生的。

尝试将目录引用设置为大写:directory => 'DPUMP_DIR'

It appears your error is occurring on the first ADDFILE call.

Try making your directory references upper case: directory => 'DPUMP_DIR'

故事灯 2024-09-21 14:05:48

试试这个:

dbms_datapump.metadata_filter(      
      handle => dp_handle,
      name   => 'TABLESPACE_EXPR',
      value  => '=''COURSE''');

“我仍然收到相同的错误消息
虽然”

嗯......远程调试其他人的代码是SO最不有趣的方面之一。无论如何,让我们再猜一下。

你有一个名为/mydata/data的操作系统目录吗? Oracle有读写权限吗? CREATE DIRECTORY语句只创建一个指针,它不创建底层操作系统目录。

Try this:

dbms_datapump.metadata_filter(      
      handle => dp_handle,
      name   => 'TABLESPACE_EXPR',
      value  => '=''COURSE''');

"I still get the same error messages
though"

Hmmm.... Remote debugging of other people's code is one of the least fun aspects of SO. Anyway, let's give it another guess.

Do you have an OS directory called /mydata/data which Oracle has read and write privileges on? The CREATE DIRECTORY statement only creates a pointer, it doesn't create the underlying OS directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文