今天要进行全库数据的导出与导入。数据很大,有几千万条。练习了很多次,用了以下的方法:
1.导出表结构和该用户的所有索引,主键,sequence,trigger,packges等等,所有与该用户有关的东西导出来。总之,除了数据之外,全都导出来了。
exp user/passwd file=tablestruct.dmp full=n rows=n
2.导出数据
exp user/passwd file=alldata.dmp full=n triggers=n indexes=n
3.导入表结构(包括该用户的所有索引,主键,sequence,trigger等等)
imp user/passwd file=tablestruct.dmp full=y ignore=y
也可以向远程机器导:
imp user/passwd@远程IP file=tablestruct.dmp full=y ignore=y
4.导入数据
imp user/passwd file=alldata.dmp full=y ignore=y buffer=1024000 commit=y feedback=100000
也可以向远程机器导:
imp user/passwd@远程IP file=alldata.dmp full=y ignore=y buffer=1024000 commit=y feedback=100000
在做第4步之前,要把几个有大数据量的表中的索引,主键删除,(toad中一个是在index标签中,一个是在表的index中,这两个地方都要留意是否有索引或主键是否存在)不然导入太慢,要等很久,数据导完后再把索引,主键等建回来,可以在Script中把建主键的脚本先复制出来。
就是因为索引删除的不彻底,等死我了。经过多次的反复,终于明白道理了。