大文字資料,匯入匯出到資料庫
大文字資料,匯入到資料庫
240w的資料,利用plsql的文字匯入器,導了一個半小時,且資料出現缺失。
兩種方式匯入到資料庫
一,使用sql load
建立表
create table ext_gv_tmp_amazon_sku
(
skucode varchar2(255 char),
eancode varchar2(255 char)
)
配置控制檔案
more input.ctl
load data
infile input.txt
badfile t.bad
discardfile t.dsc
append into table ext_gv_tmp_amazon_sku ----匯入的表
fields terminated by "|" ---分割符
trailing nullcols ---允許列有空值
(skucode,eancode) ---匯入的欄位
匯入命令
先設定匯入客戶端字符集,不然中文會亂碼
export NLS_LANG=AMERICAN_AMERICA.UTF8
同時看看系統的字符集是否設定正確
[oracle@rac-test1 pandump]$ cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
最後匯入資料
[oracle@rac-test1 pandump]$ sqlldr panhf/oracle control=input.ctl
SQL> select count(*) from ext_gv_tmp_amazon_sku;
COUNT(*)
----------
2409530
二,使用外部表
利用外部表的方式來匯入資料
1,建立oracle目錄,並授權給相關賬號
CREATE OR REPLACE DIRECTORY pandump
AS '/oradata/pandump';
grant read,write on DIRECTORY pandump to panhf;
2,建立外部表,注意這裡的字符集設定,如果不設定中文會無法讀取導致資料丟失
create table ext_gv_tmp_amazon_sku
(
skucode varchar2(255 char),
eancode varchar2(255 char)
)
organization external (
type oracle_loader
default directory pandump
access parameters
(
records delimited by newline
logfile pandump:'ext_gv_tmp_amazon_sku.log'
badfile pandump:'ext_gv_tmp_amazon_sku.bad'
discardfile pandump:'ext_gv_tmp_amazon_sku.disc'
characterset 'AL32UTF8'
fields terminated by "|" lrtrim
missing field values are null
(
skucode,
eancode
)
)
location ('ext_ids_1.txt')
)
reject limit unlimited
/
3,將資料cts的方式複製到另外的表
select count(*) from ext_gv_tmp_amazon_sku;
COUNT(*)
----------
2409530
create table panhf.ext_gv_tmp_amazon_sku as select * from ext_gv_tmp_amazon_sku;
Table created.
三,資料匯出文字
cat exp.sql
set echo off
set feedback off
set newpage none
set verify off
set pagesize 0
set term off
set trims on
set linesize 600
set heading off
set timing off
set numwidth 40
spool /home/oracle/empInfor.txt
select skucode||'|'||eancode from panhf.ext_gv_tmp_amazon_sku;
spool off
執行指令碼
@exp.sql
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29108064/viewspace-2213033/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 將informix匯出的文字資料匯入oracle資料庫ORMOracle資料庫
- 資料庫 MySQL 資料匯入匯出資料庫MySql
- 將資料匯出到ExcelExcel
- MSSQL資料匯出到MYSQLMySql
- 資料庫的匯入匯出資料庫
- mysql 資料庫匯入匯出MySql資料庫
- MySQL資料庫匯入匯出MySql資料庫
- Redis批量匯入文字資料Redis
- 【mysql】資料庫匯出和匯入MySql資料庫
- mysqldump匯入匯出mysql資料庫MySql資料庫
- oracle資料庫匯入匯出命令!Oracle資料庫
- 在SQL Server資料庫中匯入匯出資料SQLServer資料庫
- 使用FSO把文字資訊匯入資料庫 (轉)資料庫
- PHP大資料xlswriter匯入匯出(最優資料化)PHP大資料
- SQL Server資料庫匯入匯出資料方式比較SQLServer資料庫
- SQL資料庫的匯入和匯出SQL資料庫
- plsql developer匯入匯出資料庫方法SQLDeveloper資料庫
- xml與資料庫中資料的匯入匯出XML資料庫
- Access 匯入 oracle 資料庫Oracle資料庫
- excel 匯入sqlyog資料庫ExcelSQL資料庫
- 將XML匯入資料庫XML資料庫
- SQLServer 異構資料庫之間資料的匯入匯出SQLServer資料庫
- sqoop1.4.7環境搭建及mysql資料匯入匯出到hiveOOPMySqlHive
- Oracle資料庫匯入匯出。imp匯入命令和exp匯出命令Oracle資料庫
- 轉載:利用SQL*Loader將 Excel 資料匯出到資料庫中SQLExcel資料庫
- 資料泵匯出匯入
- Oracle 資料匯入匯出Oracle
- mysql資料匯入匯出MySql
- mysql資料匯出匯入MySql
- oracle資料匯入匯出Oracle
- 資料庫泵(expdp/impdp)匯入匯出流程資料庫
- 不同版本間的資料庫匯入匯出資料庫
- plsql developer匯入匯出資料庫方法 <轉>SQLDeveloper資料庫
- Oracle資料庫的匯入和匯出命令Oracle資料庫
- 匯入excel資源到資料庫Excel資料庫
- DB2資料庫匯出表結構與匯入、匯出表資料DB2資料庫
- 如何將資料熱匯出到檔案
- 從hive將資料匯出到mysql(轉)HiveMySql