因此,我有这个基于java的数据转换/掩蔽工具,我想在Oracle 10g上测试它。Oracle 10g的好地方在于,您得到了大量的样本模式,其中有些记录有50万条。模式是: SH、OE、HR、IX等等。所以,我安装了10g,发现安装脚本在ORACLE_HOME/demo/脚本下。
我对这些脚本进行了一些定制,以便在批处理模式下运行。这解决了我一半的需求--为测试我的数据转换软件创建源数据。需求的后半部分是以不同的名称(TR_HR、TR_OE等)创建相同的模式。没有任何数据。这些架构将代表我的目标架构。因此,简而言之,我的软件将从模式中的表中获取数据,并将其加载到另一个模式中的同一个表中。
现在,在创建目标模式并清空它时,我有两个问题。
,
有什么简单的办法可以做到这一点,不需要这么大惊小怪的?我需要一个复杂的数据集来进行测试(在具有触发器的表中,多个层次结构)。例如..。一个子表,它的子表最多有5个级别,父表引用一个IOT表,一个IOT表引用一个非IOT表等等)。从数据集的角度来看,示例模式几乎是完美的。我看到的唯一挑战是自动化加载源模式的整个过程,然后创建目标模式并清空它们。感谢你的帮助和建议。
更新
手动安装oracle示例模式需要运行的主要脚本是mkplug.sql。下面是从dmp文件中加载模式的行:
host imp "'sys/&&password_sys AS SYSDBA'" transport_tablespace=y file=&imp_file log=&imp_logfile datafiles='&datafile' tablespaces=EXAMPLE tts_owners=hr,oe,pm,ix,sh好的,我尝试修改这一行(在修补了mkplug.sql和所有其他sql文件上的路径相关问题之后)如下:
host imp "'sys/&&password_sys AS SYSDBA'" rows=n transport_tablespace=y file=&imp_file log=&imp_logfile datafiles='&datafile' tablespaces=EXAMPLE tts_owners=hr,oe,pm,ix,sh还有..。这对并没有的帮助。模式是用行数据创建的,尽管有rows=n属性:(
发布于 2010-03-29 11:49:00
既然您已经熟悉使用.dmp文件的Oracle脚本中的exp/imp (或expdp/impdp),为什么不只是:
使用FROMUSER/TOUSER选项和schemas
从xxx .dmp文件创建空的TR_xxx
阅读有关可传输表空间的评论后,编辑
我不知道Oracle脚本正在使用可传输的表空间,并且多个模式是从一个文件中导入的。这可能是创建新的空TR模式最简单的方法:
scripts
模式按模式基础(OE所示):
作为SYSDBA file=oe_nodata.dmp log=oe_nodata_exp.log owner=OE rows=N grants=N的exp sys/&&password_sys
(您只需要这样做一次,这个dmp文件就可以被重用)
现在,您的脚本应该:
option
)所示:
主机imp“‘sys/&password_sys为SYSDBA'”file=oe_nodata.dmp log=tr_oe_imp.log fromuser=OE fromuser=OE
发布于 2010-03-29 11:03:50
下面是一个匿名块--对于给定的模式--禁用触发器和外键,截断所有表,然后重新启用触发器和外键。它使用truncate作为速度,但显然这意味着不回滚:所以请注意您提供的架构名称!如果您愿意,可以很容易地将该调用转换为delete from语句。
这个脚本是剪切‘n’粘贴编程的一个很好的例子,毫无疑问,它将受益于一些重构以消除重复。
begin
<< dis_triggers >>
for trgs in ( select owner, trigger_name
from all_triggers
where table_owner = '&&schema_name' )
loop
execute immediate 'alter trigger '||trgs.owner||'.'||trgs.trigger_name
||' disable';
end loop dis_triggers;
<< dis_fkeys >>
for fkeys in ( select owner, table_name, constraint_name
from all_constraints
where owner = '&&schema_name'
and constraint_type = 'R')
loop
execute immediate 'alter table '||fkeys.owner||'.'||fkeys.table_name
||' disable constraint '||fkeys.constraint_name;
end loop dis_fkeys;
<< zap_tables >>
for tabs in ( select owner, table_name
from all_tables
where owner = '&&schema_name' )
loop
execute immediate 'truncate table '||tabs.owner||'.'||tabs.table_name
||' reuse storage';
end loop zap_tables;
<< en_fkeys >>
for fkeys in ( select owner, table_name, constraint_name
from all_constraints
where owner = '&&schema_name'
and constraint_type = 'R')
loop
execute immediate 'alter table '||fkeys.owner||'.'||fkeys.table_name
||' enable constraint '||fkeys.constraint_name;
end loop en_fkeys;
<< en_triggers >>
for trgs in ( select owner, trigger_name
from all_triggers
where table_owner = '&&schema_name' )
loop
execute immediate 'alter trigger '||trgs.owner||'.'||trgs.trigger_name
||' enable';
end loop en_triggers;
end;
/https://stackoverflow.com/questions/2536239
复制相似问题