Oracle uses a Data Pump to unload data

Source: Internet
Author: User
Tags dname

Oracle 10 Gb provides a way to use external tables to extract data.

First, you need a directory (here we will continue to use the previously created directory)

  1. SQL> showUser
  2. USERIs"SYS"
  3. SQL>Select*FromDba_directoriesWhereDIRECTORY_NAMELike '% SYS %';
  4. OWNER DIRECTORY_NAME DIRECTORY_PATH
  5. --------------------------------------------------------------------------------------------------------------
  6. SYS SYS_SQLLDR_XT_TMPDIR_00000/u01/sqlldr
Then execute the command
  1. SQL> showUser
  2. USERIs"ING"
  3. SQL>DescSYS_SQLLDR_X_EXT_DEPT
  4. Is the name empty? Type
  5.  -----------------------------------------------------------------------------
  6. Deptno number (10)
  7. DNAME VARCHAR2 (20)
  8. LOC VARCHAR2 (20)
  9. SQL>Create TableSYS_SQLLDR_X_EXT_DEPT_UNLOAD
  10. 2 organization external
  11. 3 (type oracle_datapump
  12. 4DefaultDirectory SYS_SQLLDR_XT_TMPDIR_00000
  13. 5 location ('Sys _ SQLLDR_X_EXT_DEPT_UNLOAD.dat')
  14. 6)As
  15. 7Select*FromSYS_SQLLDR_X_EXT_DEPT;
  16. The table has been created.

A SYS_SQLLDR_X_EXT_DEPT_UNLOAD table will be created in the database. Two more files will be created in the directory.

  1. [Oracle @ linux sqlldr] $ ll | grep SYS
  2. -Rw-r-- R -- 1 oracle oinstall 148 10-04 SYS_SQLLDR_X_EXT_DEPT_UNLOAD_3501.log
  3. -Rw-r----- 1 oracle oinstall 12288 10-04 SYS_SQLLDR_X_EXT_DEPT_UNLOAD.dat

Finally, copy the SYS_SQLLDR_X_EXT_DEPT_UNLOAD.dat file to the corresponding directory of other databases, and extract the External table creation script.

  1. SQL>SetLong 1, 20000
  2. SQL>SetPagesize 99
  3. SQL>SelectDbms_metadata.get_ddl ('Table','Sys _ SQLLDR_X_EXT_DEPT_UNLOAD')FromDual;
  4. DBMS_METADATA.GET_DDL ('Table','Sys _ SQLLDR_X_EXT_DEPT_UNLOAD')
  5. --------------------------------------------------------------------------------
  6. CREATE TABLE "ING"."SYS_SQLLDR_X_EXT_DEPT_UNLOAD"
  7. ("DEPTNO"NUMBER (10, 0 ),
  8. "DNAME"VARCHAR2 (20 ),
  9. "LOC"VARCHAR2 (20)
  10. )
  11. ORGANIZATION EXTERNAL
  12. (TYPE ORACLE_DATAPUMP
  13. DEFAULTDIRECTORY"SYS_SQLLDR_XT_TMPDIR_00000"
  14. LOCATION
  15. ('Sys _ SQLLDR_X_EXT_DEPT_UNLOAD.dat'
  16. )
  17. )

You can even load data directly from an outsourcing table.

  1. SQL>Insert/* + Append */IntoDeptSelect*FromSYS_SQLLDR_X_EXT_DEPT_UNLOAD;
  2. Four rows have been created.
  3. SQL>Commit;
  4. Submitted.
  5. SQL>Select*FromDept;
  6. DEPTNO DNAME LOC
  7. --------------------------------------------------
  8. 50 Sales Virginia
  9. 60 Accounting Virginia
  10. 70 Consulting Virginia
  11. 80 Finance Virginia

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.