Oracle export and import data
2016-10-18 21:16
549 查看
Oracle support 2 types of data export/import
1. Utility exp/imp
-- But data format is binary, people cannot read and write them.
2. Using sqlplus/sqlldr
-- Export data as text file, and import as text file also.
Following is a sample using sqlplus/sqlldr to export and import a table.
Suppose table is defined as:
SQL> desc KSDS09;
Name Null? Type
------------------------------------------------- ----------------------------
KSDS09_SEQ_NUM NOT NULL NUMBER(8)
K_NUM NOT NULLNUMBER(6)
K_NUM02 NOT NULL NUMBER(2)
K_X NOT NULL CHAR(22)
D01 VARCHAR2(30)
REC0_END0 CHAR(4)
(e.g., export DB_LOGIN=scott/tiger@orcl)
-- Export script:
sqlplus -s ${DB_LOGIN} >/dev/null<<EOF
set heading off;
set echo off;
set feedback off;
set verify off;
set wrap off;
set pagesize 0;
set linesize 2500;
set trimout on;
set trimspool on;
set trims on;
spoolKSDS09.txt;
selectKSDS09_SEQ_NUM || ',' || K_NUM || ',' || K_NUM02 || ',' || K_X || ',' || D01 ||',' || REC0_END0 from KSDS09;
set define on;
set heading on;
set echo on;
set feedback on;
spool off;
quit;
EOF
-- Import script:
step 1: define sqlldr control file
$ catKSDS09.ctl
load data
infile'KSDS09.txt'
appendinto table KSDS09H
fields terminated by ","
(KSDS09_SEQ_NUM, K_NUM, K_NUM02, K_X, D01,REC0_END0)
step 2: execute sqlldr command
sqlldr userid=${DB_LOGIN}control=KSDS09.ctl
-- Appendix: data in KSDS09.text
$ head KSDS09.txt
1,10,1,AAAA ,ABCD ,1234
2,10,2,BBBB ,ABCD ,1234
3,10,3,CCCC ,ABCD ,1234
...
1. Utility exp/imp
-- But data format is binary, people cannot read and write them.
2. Using sqlplus/sqlldr
-- Export data as text file, and import as text file also.
Following is a sample using sqlplus/sqlldr to export and import a table.
Suppose table is defined as:
SQL> desc KSDS09;
Name Null? Type
------------------------------------------------- ----------------------------
KSDS09_SEQ_NUM NOT NULL NUMBER(8)
K_NUM NOT NULLNUMBER(6)
K_NUM02 NOT NULL NUMBER(2)
K_X NOT NULL CHAR(22)
D01 VARCHAR2(30)
REC0_END0 CHAR(4)
(e.g., export DB_LOGIN=scott/tiger@orcl)
-- Export script:
sqlplus -s ${DB_LOGIN} >/dev/null<<EOF
set heading off;
set echo off;
set feedback off;
set verify off;
set wrap off;
set pagesize 0;
set linesize 2500;
set trimout on;
set trimspool on;
set trims on;
spoolKSDS09.txt;
selectKSDS09_SEQ_NUM || ',' || K_NUM || ',' || K_NUM02 || ',' || K_X || ',' || D01 ||',' || REC0_END0 from KSDS09;
set define on;
set heading on;
set echo on;
set feedback on;
spool off;
quit;
EOF
-- Import script:
step 1: define sqlldr control file
$ catKSDS09.ctl
load data
infile'KSDS09.txt'
appendinto table KSDS09H
fields terminated by ","
(KSDS09_SEQ_NUM, K_NUM, K_NUM02, K_X, D01,REC0_END0)
step 2: execute sqlldr command
sqlldr userid=${DB_LOGIN}control=KSDS09.ctl
-- Appendix: data in KSDS09.text
$ head KSDS09.txt
1,10,1,AAAA ,ABCD ,1234
2,10,2,BBBB ,ABCD ,1234
3,10,3,CCCC ,ABCD ,1234
...
相关文章推荐
- 103.Which two statements are true regarding the Oracle Data Pump export and import operations? (Choo
- Oracle data import and export impl/exp
- Import or Export the oracle data
- Oracle export and import utilities
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- Study note about bulk import and export data in MSSQL
- Export and Import Table Data
- oracle Export and Import 简介
- Oracle Import and Export
- 使用datapump 导出导入同义词(export and import synonym using datapump)
- ORACLE_基础二十六(Import and Export)
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- 【译】Export/Import DataPump Parameter TRACE - How to Diagnose Oracle Data Pump [ID 286496.1]
- Oracle 10g 及之后导出/导入(Datapump Export/Import)工具
- 【MongoDB】mongoimport and mongoexport of data (二)
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ? [ID 552424.1]
- Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ?
- Copy and Rename an Oracle Database - (without export/import)
- oracle Export and Import 简介