首页 > Linux操作系统 > Linux操作系统 > Adding Tablespaces/Datafiles with Logical Standby DB present

Adding Tablespaces/Datafiles with Logical Standby DB present

原创 Linux操作系统 作者:kerneil 时间:2013-09-04 16:36:22 0 删除 编辑

Adding Tablespaces/Datafiles with Logical Standby DB present<转>


Being in Norway this week, I have again the pleasure to teach an 11g Data Guard course. I always try to get a hotel close to the education center to be able to walk over there, but I didn’t get the right direction on the first day and had to use a taxi instead. Fortunately, the Norwegians are friendly and helpful and like to explain to a stranger where to find the next taxi stand :-)

One of the student asked how we can handle the situation, if we have a Logical Standby Database and want to add datafiles to the primary, while the Logical Standby DB uses an other directory structure than the Primary. Putting the parameter standby_file_management to auto and also settingdb_file_name_convert appropriately is not sufficient in this case, as it is for a Physical Standby Database. Well, I searched through the documentation and found the following remedy:

Connect to the Logical Standby DB as sys and then

create or replace procedure sys.handle_tbs_ddl
  old_stmt  in  varchar2,
  stmt_typ  in  varchar2,
  schema    in  varchar2,
  name      in  varchar2,
  xidusn    in  number,
  xidslt    in  number,
  xidsqn    in  number,
  action    out number,
  new_stmt  out varchar2
) as
  new_stmt := replace(old_stmt,

  action := dbms_logstdby.skip_action_replace;

  when others then
    action := dbms_logstdby.skip_action_error;
    new_stmt := null;


-- LSP has to be stopped before we can do the next step


alter database stop logical standby apply;

dbms_logstdby.skip (stmt=>'tablespace',proc_name=>'sys.handle_tbs_ddl');

alter database start logical standby apply immediate;

You can now create Tablespaces and/or add Datafiles on the Primary and they are automatically created on the Logical Standby as well.

You could also take an reactive approach and let the create tablespace action on the Primary crash the SQl Apply on the Logical Standby and then skip that DDL and create the tablespace manually on the Logical SB. But this approach above seems to be more elegant and leaves you with less administrative tasks to do. Thanks to Cecilie Sander for asking that question!

来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录


  • 博文量
  • 访问量