Articles Comments

Oracle DBA & All IT » Utilities » วิธีการใช้ SQL*Loader utility สำหรับ Load ข้อมูลจาก text file เข้า table

วิธีการใช้ SQL*Loader utility สำหรับ Load ข้อมูลจาก text file เข้า table

เราสามารถที่จะโหลดข้อมูลเข้า Oracle database โดยใช้ sqlldr (sqlload สำหรับบาง platforms) utility.  ลองดูตัวอย่างตามด้านล่าง

example:
sqlldr username@server/password control=loader.ctl
sqlldr username/password@server control=loader.ctl
 

ตัวอย่าง control file (loader.ctl) จะโหลดไฟล์ที่มี "," เป็นตัวกั้นข้อมูล:

load data
 infile 'c:\data\mydata.csv'
 into table emp
 fields terminated by "," optionally enclosed by '"'
 ( empno, empname, sal, deptno )

ตัวอย่างในไฟล์  mydata.csv:

10001,"Scott Tiger", 1000, 40
10002,"Frank Naude", 500, 20

เพิ่มเติม, ถ้าข้อมูลไฟล์เป็น Unicode,เราจะต้องทำตามนี้.

load data
 CHARACTERSET UTF16
 infile 'c:\data\mydata.csv'
 into table emp
 fields terminated by "," optionally enclosed by '"'
 ( empno, empname, sal, deptno )

ตัวอย่างอื่นๆ สำหรับการ กำหนดความยาวของแต่ละ column ตายตัว

load data
infile *
replace
into table departments
(  dept     position (02:05) char(4),
    deptname position (08:27) char(20)
)

ตัวอย่าง data
COSC  COMPUTER SCIENCE
ENGL  ENGLISH LITERATURE
MATH  MATHEMATICS
POLY  POLITICAL SCIENCE

parameter เพิ่มเติม :
http://www.oracleutilities.com/OSUtil/sqlldr.html

 

.. Preview : 12727

Related Search:

  • sql loader control file
  • sqlldr control file

Written by

บอกเล่าสิ่งที่พบเจอมาในการทำงาน ประสบการณ์การทำงานด้าน DBA ถ่ายทอดกันด้วยภาษาง่ายๆ บ้านๆ " ทุกอย่างไม่อยาก แต่... แค่ตั้งใจไม่พอ ต้องลงมือทำ และทำ GoodLuck " Fanpage: www.facebook.com/DBAor .. "Oracle Database Consultant " ..

Filed under: Utilities · Tags: , , , , , ,

  • Like the new look. I really enjoyed the information. Many thanks for the fine page.

  • Tod

    Nothing succeeds like success.

  • Every man is the architect of his own fortune.

  • I was raelly confused, and this answered all my questions.