您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關數(shù)據(jù)庫中如何導入一張18億條300G數(shù)據(jù)文件的表,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
1.問題:需要導入一張18億數(shù)據(jù)的300G大的數(shù)據(jù)文件
2. 客戶給了一個用imp導出的數(shù)據(jù)文件。包含了一個表xx。這個表的結構如下:
點擊(此處)折疊或打開
CREATE TABLE "username"."xx"
( "DTLCARDNO" CHAR(16) NOT NULL ENABLE,
"DTLCITY" NUMBER(4,0),
"DTLCDCNT" NUMBER(6,0) NOT NULL ENABLE,
"DTLTXNCODE" NUMBER(4,0) NOT NULL ENABLE,
"DTLINNTYPE" NUMBER(4,0),
"DTLPOSID" VARCHAR2(12),
"DTLSAMID" VARCHAR2(16),
"DTLPOSSEQ" NUMBER(10,0),
"DTLDATE" NUMBER(8,0),
"DTLTIME" NUMBER(6,0) NOT NULL ENABLE,
"DTLSETTDATE" NUMBER(8,0),
"DTLCENSEQ" NUMBER(10,0),
"DTLAMT" NUMBER(9,0) NOT NULL ENABLE,
"DTLSLAMT" NUMBER(9,0),
"DTLBEFBAL" NUMBER(9,0) NOT NULL ENABLE,
"DTLAFTBAL" NUMBER(9,0),
"DTLSTATID" NUMBER(9,0),
"DTLERRCODE" NUMBER(6,0),
"DTLINNERR" NUMBER(6,0),
"DTLRSVD" VARCHAR2(10),
"DTLPKGID" NUMBER(10,0),
"DTLUNITID" NUMBER(8,0),
"DTLCRDTYPE" NUMBER(4,0),
"DTLTAC" CHAR(8),
"PARTFLAG" NUMBER(3,0) NOT NULL ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS"
PARTITION BY RANGE ("PARTFLAG")
(PARTITION "P_JY001" VALUES LESS THAN (1)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 797966336 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY002" VALUES LESS THAN (2)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 751828992 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY003" VALUES LESS THAN (3)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 829423616 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY004" VALUES LESS THAN (4)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 886046720 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY005" VALUES LESS THAN (5)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 901775360 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY006" VALUES LESS THAN (6)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 826277888 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY007" VALUES LESS THAN (7)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 803209216 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY008" VALUES LESS THAN (8)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 961544192 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY009" VALUES LESS THAN (9)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 995098624 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
PARTITION "P_JY010" VALUES LESS THAN (10)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 972029952 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "CRDDTL01_TS" NOCOMPRESS ,
。。。。。。。。。。。。。。
類似的有360個分區(qū)
可以看到是個分區(qū)表。
導入語句
點擊(此處)折疊或打開
echo %time% ;
imp system/manager@orcl file=E:\yikatong\tlcarddtltb.dmp fromuser=u1 touser=u1 ignore=y log=E:\yikatong\tlcarddtltb.dmp.log indexes=N RECORDLENGTH=65535 buffer=502400000 commit=n feedback=10000000
echo %time% ;
要求1千萬行響應一次,提交為N,不插入索引。buffer設置為500M
3.開始導入。因為客戶也沒有提供數(shù)據(jù)文件的大小,只提供了需要新建的表空間。我新建了如下可以自增的表空間。
create tablespace crddtl01_ts datafile 'D:/oracle/tablespace/crddtl01_ts.dbf' size 8024m autoextend on next 1024m autoallocate;
每次自增1024M??紤]到數(shù)據(jù)比較大,每次自增太小,花費時間小。接著開始導入了。等待了幾個小時以后,報錯:
01659, 00000, "unable to allocate MINEXTENTS beyond %s in tablespace %s"
// *Cause: Failed to find sufficient contiguous space to allocate MINEXTENTS
// for the segment being created.
// *Action: Use ALTER TABLESPACE ADD DATAFILE to add additional space to the
// tablespace or retry with smaller value for MINEXTENTS, NEXT or
// PCTINCREASE
.剛開始有點蒙。我建立表空間都是自增長的。難道不能自增長。查詢下可以增長的。看看表空間大小32G。原來oracle普通表空間文件最大為32G。然后開始給每個表空間增加4個文件。sql如下:
點擊(此處)折疊或打開
create tablespace crddtl01_ts datafile 'D:/oracle/tablespace/crddtl01_ts.dbf' size 8024m autoextend on next 1024m autoallocate;
create tablespace crddtlidx01_ts datafile 'd:/oracle/tablespace/crddtlidx01_ts.dbf' size 5024m autoextend on next 1024m autoallocate;
alter tablespace crddtl01_ts add datafile 'D:/oracle/tablespace/crddtl01a_ts.dbf' size 1024m autoextend on next 1024m ;
alter tablespace crddtl01_ts add datafile 'D:/oracle/tablespace/crddtl01b_ts.dbf' size 1024m autoextend on next 1024m ;
create tablespace crddtl02_ts datafile 'E:/oracle_data/crddtl02_ts.dbf' size 8024m autoextend on next 1024m autoallocate;
alter tablespace crddtl02_ts add datafile 'E:/oracle_data/crddtl02a_ts.dbf' size 1024m autoextend on next 1024m ;
alter tablespace crddtl02_ts add datafile 'E:/oracle_data/crddtl02b_ts.dbf' size 1024m autoextend on next 1024m ;
create tablespace crddtlidx02_ts datafile 'E:/oracle_data/crddtlidx02_ts.dbf' size 5024m autoextend on next 1024m autoallocate;
create tablespace crddtl03_ts datafile 'F:/oracleData/crddtl03_ts.dbf' size 8024m autoextend on next 1024m autoallocate;
alter tablespace crddtl03_ts add datafile 'F:/oracleData/crddtl03a_ts.dbf' size 1024m autoextend on next 1024m;
alter tablespace crddtl03_ts add datafile 'F:/oracleData/crddtl03b_ts.dbf' size 1024m autoextend on next 1024m;
create tablespace crddtlidx03_ts datafile 'F:/oracleData/crddtlidx03_ts.dbf' size 5024m autoextend on next 1024m autoallocate;
create tablespace crddtl04_ts datafile 'D:/oracle/tablespace/crddtl04_ts.dbf' size 8024m autoextend on next 1024m autoallocate;
alter tablespace crddtl04_ts add datafile 'D:/oracle/tablespace/crddtl04a_ts.dbf' size 1024m autoextend on next 1024m ;
alter tablespace crddtl04_ts add datafile 'D:/oracle/tablespace/crddtl04b_ts.dbf' size 1024m autoextend on next 1024m ;
于是接下來就開始了漫長的等待。
4.怎么知道導入了多少數(shù)據(jù)?導入進展到什么情況了呢?或者說導入進程有沒有卡住,僵死呢?
第一看feedback.我在導入程序設置了參數(shù)feedback=10000000,每導入1千萬數(shù)據(jù),響應一個黑點。
第二可以看導入日志。每導入完一個分區(qū),它會在日志插入一條記錄。
第三打開資源管理器,我們看看imp進程,占用的cpu,硬盤,網(wǎng)絡,內(nèi)存資源。
但是這個服務器當時點什么都很慢。我分配一個8G的文件,花費了10幾分鐘。這個怎么解釋呢?
5.經(jīng)過漫長的等待,我花了2天7個小時,把這個18億數(shù)據(jù)導入進去了。。
最后看看數(shù)據(jù)文件大?。?br/>
點擊(此處)折疊或打開
目錄 大小(M)tablespace
D:\ORACLE\TABLESPACE\CRDDTL01A_TS.DBF 32767 CRDDTL01_TS
D:\ORACLE\TABLESPACE\CRDDTL01_TS.DBF 32767 CRDDTL01_TS
D:\ORACLE\TABLESPACE\CRDDTL01B_TS.DBF 32767 CRDDTL01_TS
F:\ORACLEDATA\CRDDTL01D_TS.DBF 25600 CRDDTL01_TS
E:\ORACLE_DATA\CRDDTL02C_TS.DBF 9216 CRDDTL02_TS
E:\ORACLE_DATA\CRDDTL02D_TS.DBF 8192 CRDDTL02_TS
E:\ORACLE_DATA\CRDDTL02B_TS.DBF 32767 CRDDTL02_TS
E:\ORACLE_DATA\CRDDTL02_TS.DBF 32767 CRDDTL02_TS
E:\ORACLE_DATA\CRDDTL02A_TS.DBF 30720 CRDDTL02_TS
F:\ORACLEDATA\CRDDTL03D_TS.DBF 5120 CRDDTL03_TS
F:\ORACLEDATA\CRDDTL03B_TS.DBF 28672 CRDDTL03_TS
F:\ORACLEDATA\CRDDTL03_TS.DBF 32600 CRDDTL03_TS
F:\ORACLEDATA\CRDDTL03A_TS.DBF 27648 CRDDTL03_TS
F:\ORACLEDATA\CRDDTL03C_TS.DBF 5120 CRDDTL03_TS
D:\ORACLE\TABLESPACE\CRDDTL04A_TS.DBF 28672 CRDDTL04_TS
D:\ORACLE\TABLESPACE\CRDDTL04B_TS.DBF 32767 CRDDTL04_TS
E:\ORACLE_DATA\CRDDTL04D_TS.DBF 7168 CRDDTL04_TS
E:\ORACLE_DATA\CRDDTL04C_TS.DBF 7168 CRDDTL04_TS
D:\ORACLE\TABLESPACE\CRDDTL04_TS.DBF 32767 CRDDTL04_TS
一個表空間有4個文件,幾乎達到120G
關于“數(shù)據(jù)庫中如何導入一張18億條300G數(shù)據(jù)文件的表”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。