首页 > 技术文章 > 复制整个数据库

yansc 2019-01-11 16:04 原文

--创建用户空间权限
create temporary tablespace bdcdj_xc_temp tempfile 'x:\data\bdcdj_xc_TEMP01.DBF' size 500M autoextend on next 32M extent management local;
create tablespace bdcdj_xc_data logging datafile 'x:\data\bdcdj_xc_DATA01.DBF' size 2000M autoextend on next 500M extent management local;
create user bdcdj_xc identified by "123" default tablespace bdcdj_xc_data temporary tablespace bdcdj_xc_temp;
grant connect,dba,resource to bdcdj_xc;
--database link
create database link to_bdcxc 
  connect to bdcdj_xc identified by "123" 
  using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.xxx)
  (PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ))'

--所有表名
select table_name from dba_tables@to_bdcxc where owner='BDCDJ_XC'

--拿下面生成的语句去执行
select 'create table '||table_name||' as select * from '||table_name||'@to_bdcxc;' from dba_tables@to_bdcxc where owner='BDCDJ_XC'

--结束
select table_name from user_tables@to_bdcxc where TABLESPACE_NAME is not null and user='BDCDJ_XC' 
SELECT * FROM DBA_TABLES WHERE OWNER='BDCDJ_XC';
create table bdc_zs as select * from bdc_zs@to_bdcxc
alter tablespace BDCDJ_GXSJ rename to BDCDJ_XC_DATA

  

受用户权限限制,以上方法不一定可行。

是不是有其他好的工具,求推荐一下

推荐阅读