码迷,mamicode.com
首页 > 数据库 > 详细

复制整个数据库

时间:2019-01-11 17:21:08      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:xxx   def   style   数据   ide   创建用户   display   extend   --   

--创建用户空间权限
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

  

复制整个数据库

标签:xxx   def   style   数据   ide   创建用户   display   extend   --   

原文地址:https://www.cnblogs.com/yansc/p/10255639.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!