实际应用:
导出基本数据.bat:
sqlplus /nolog @.\CreateExpTable.sql
EXP GISAP/1@90.0.12.112 file=GISAP_structure.dmp LOG=GISAP_structure.LOG buffer=33000000 constraints=y indexes=y triggers=y grants=y rows=n
EXP GISAP/1@90.0.12.112 file=GISAP_base_data.dmp LOG=GISAP_base_data.LOG buffer=33000000 parfile=GISAP_base_data.E01
CreateExpTable.sql:
spool .\CreateExpTable.log;
conn gisap/1@90.0.12.112;
@.\CreateTableName.sql;
disconn;
spool off
exit;
CreateTableName.sql:
--不显示行头
set heading off pages 0;
--不显示行数信息
set feedback off;
--不在屏幕上显示结果
--set termout off;
--表示一行能放的字符数
set linesize 160;
--每行后面多余的空格去掉
SET TRIMS ON;
spool gisap_base_data.E01;
select 'tables=(' from dual;
select t.table_name||',' from user_tables t where t.partitioned ='NO';
select ')' from dual;
spool off;
上面几个文件就实现了我导出数据而又不导出带有分区的大表的过程。
还原的方法:
一、建立与原有数据库相同的表空间和用户名
二、用IMP将上面导出的文件导入到数据库,方法如下:
IMP GISAP/1@orcl fromuser=GISAP touser=GISAP file=GISAP_structure.dmp LOG=IMP_GISAP_structure.LOG ignore=y commit=y buffer=33000000
IMP GISAP/1@orcl fromuser=GISAP touser=GISAP file=GISAP_base_data.dmp LOG=IMP_GISAP_base_data.LOG ignore=y commit=y buffer=33000000
上面的方法使用于Oracle数据库的备份与迁移,只是我的方法不一定正确,也不一定是好的。
并且这种方法还有一个缺点,就是大数据表如果不分区的话导出还是会有一些不必要的数据。这里我如果想只导出不太大的表应怎么做呢?那么如果要导出在指定分区的数据又该怎么做呢?