oracle11g导出DMP不能导空表解决方法

来源:互联网 发布:淘宝店装修要多少钱 编辑:程序博客网 时间:2024/05/17 10:09
================================设置数据库以后可以导出空表===========================================================
Oracle11g默认对空表不分配segment,故使用exp导出Oracle11g数据库时,空表不会导出。设置deferred_segment_creation 参数为FALSE后,无论是空表还是非空表,都分配segment。   在sqlplus中,执行如下命令:   SQL>alter system set deferred_segment_creation=false;    查看:   SQL>show parameter deferred_segment_creation;该值设置后只对后面新增的表产生作用,对之前建立的空表不起作用。
=====================设置之前建立的空表可以导出(方法1)========================================

将执行的sql语句的结果导出的到e:\1.txt
SQL>spool e:\1.txt;
SQL>select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0;
SQL>spool off;//关闭

最后执行e:\1.txt的sql语句就能导出空表啦

========================设置之前建立的空表可以导出(方法2)=====================================
1、select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
   用该语句查询数据库的空表,同时生产分配空间的语句,把导出结果保存到文件中tsv格式的,样例数据如下:
alter table TBL_PORTALWB_LINK allocate extent;
alter table TBL_VEHICLE_STORES_RELATION allocate extent;
alter table TBL_VEHICLE_STORES allocate extent;
alter table TBL_VEHICLE_PRIVATE_DETAIL allocate extent;
 
 
1.补充,若不行改用下面这个
select 'alter table '||table_name||' allocate extent(size 64k);' 
     from tabs t 
     where not exists (select segment_name from user_segments s where s.segment_name=t.table_name);
 
2、打开导出的文件,执行里边的sql;执行完后可对数据库进行导出

====================================================================================
原文地址:Oracle 11g 数据库备份还原作者:昨日王子

配置环境变量:
(例如Oracle安装在H:Oracle目录下)
    path="H:Oracleproduct11.2.0dbhome_1BIN"

    开始--->运行---->cmd 输入命令

数据的导出命令:

exp system/password@oracle  file='d:data.dmp ' log=d:logimp.log    
                                                 |
            |                                      |
   用户登录身份   数据库sid        数据备份目录       日志文件
 


1、导出user1、scott用户下所有的表(注意必须是dba身份登录)
   exp system/admin@oracle file=d:data.dmp log=d:logimp.log owner=(user1,scott)
2、导出user1用户下的test表和scott下的emp表(注意必须是dba身份登录)
   exp system/admin@oracle file=d:data.dmp log=d:logimp.log tables=(user1.test,scott.emp)
3、导出登录用户下的所有表
   exp soctt/tiger@oracle file=d:data.dmp log=d:logimp.log
4、导出登录用户下的某个表
   exp soctt/tiger@oracle file=d:data.dmp log=d:logimp.log tables=(emp)
   需要打包在命令后直接加compress=y即可

数据的导入命令:

  imp userid=username1/pwd1@orcl fromuser=username2  touser=username3 file=(c:data.dmp)log=c:logimp.log

   username1:用户名 
   pwd1:密码
   orcl: 如果数据库在本机,用 实例名,在远程用 网络服务名(oracle 网络配置工具配置的别名)
   username2:data.dmp中的用户名
   username3:需要导入的用户名
   file :输入你要导入文件名和路径。
   Log:日志文件名和路径

 1 将D:daochu.dmp 中的数据导入数据库中。   

    imp system/manager@oracle  file=d:daochu.dmp   
    上面可能有点问题,因为有的表已经存在,然后它就报错。在后面加上 ignore=y 就可以了。 

 2 将d:daochu.dmp中的表table1 导入 

    imp user/password@oracle  file=d:daochu.dmp  tables=(table1)
    下面这句是执行将c盘的oracle的备份的用户user1导入到用户user1的数据库

    imp user1/password@oracle  file='c:qhmis20060224.dmp'  ignore=n  grants=y  full=y



1 0
原创粉丝点击