一次大批量數(shù)據(jù)備份和導(dǎo)入工作

字號:

有一個數(shù)據(jù)表的insert、delete操作頻繁,空間無釋放。唯有進(jìn)行一次導(dǎo)出、DROP、導(dǎo)入操作。
    當(dāng)前數(shù)據(jù)量:接近6億
    估計其中有一部分?jǐn)?shù)據(jù)太舊,所以使用帶條件的導(dǎo)出。
    $>export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
    $>exp user/pass file=XXX.dmp buffer=409600000 tables=mybigtable query=\" where somedate\>=XXX\"
    導(dǎo)出數(shù)據(jù)約3.7億,占用空間約57G。
    導(dǎo)出后drop掉原表
    drop table mybigtable cascade constraints
     導(dǎo)入
    imp user/pass file=XXX
    導(dǎo)入本來是很簡單的操作,但需要很大的臨時表空間(最后占用了12G)
    需要有大的空間存放temp01.dbf文件
    temp01.dbf文件的清空及轉(zhuǎn)移
    (Oracle9i 或以上)
    先確保沒有其他人或其他任務(wù)在進(jìn)行數(shù)據(jù)庫操作
    由于原來的temp文件已經(jīng)占用了很大的空間,而且該磁盤內(nèi)沒有足夠空間存入該文件。所以在清空原來的文件的基礎(chǔ)上,把該文件設(shè)定在另一磁盤內(nèi)。
    alter database tempfile '/opt/oracle/oradata/orcl/temp01.dbf' drop including datafiles;
    alter tablespace temp add tempfile '/newplace/temp01.dbf' size 512M autoextend on next 250M maxsize unlimited;