Articles Comments

Oracle DBA & All IT » Database, DBA, Function, New Feature, Oracle, Oracle Tips, Utilities » SQL*Plus copy Utility — วิธีใช้ copy ใน SQL*Plus

SQL*Plus copy Utility — วิธีใช้ copy ใน SQL*Plus

The SQL*Plus copy Utility 

"สวัสดียามเช้าจ้า.. วันพระใหญ่วันนี้อย่าลืมไปทำบุญตักบาตร เวียนเทียนกันน๊า.. เพื่อเป็นสิริมงคลกับตัวเองและครอบครัวจ้า ^^ "

คำสั่ง Copy ใช้สำหรับ Copy ข้อมูลระหว่าง 2 Database โดยผ่าน SQL*Net.
โดยมี format command ดังนี้

COPY FROM DB_Src TO DB_Dest action   destination_table (column_name, column_name…) USING query
 

The action มี option ดังนี้:

     create – จะสร้าง Table ที่ปลายทางและ Copy ข้อมูลลงไป

     replace – ถ้าปลายทางมี Table อยู่แล้วจะดำเนินการ Drop and Recreate Table ใหม่และทำการ Copy ข้อมูลลงไป 

     insert – ถ้าปลายทางมี Table อยู่แล้วจะทำการ Insert ข้อมูลใหม่ลงไป

     append– ใส่ข้อมูลต่อลงไปใน Table ที่มีอยู่แล้ว

ตัวอย่าง การใช้คำสั่ง Copy

SQL> copy from scott/tiger@DB_Src to scott/tiger@DB_Dest append new_emp using select * from emp;

         และยังมีอีกหนึ่งคำสั่งที่ต้องรันก่อน command copy ทุกครั้งให้ทำการ Set parameter copycommit ก่อน เป็นพารามิเตอร์สำหรับ ตั้ง commit ทุกๆ กี่เรคคอร์ดที่เข้าไป

— set ให้ commit ทุกๆ 5000 เรคคอร์ด —
     set copycommit 5000 

ข้อควรระวัง:!!!!!
       
         การทำวิธีนี้ต้องระวังดูต้นทางและปลายทางให้ดี เพราะถ้าทำสลับข้างไปล่ะก็… ถึงเศร้ากันทีเดียวจ้า ^^

 

.. Preview : 8505

Related Search:

  • วิธีการใส่ index oracle

Written by

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

Filed under: Database, DBA, Function, New Feature, Oracle, Oracle Tips, Utilities · Tags: , , , , , , , , , , , , , ,

  • I’m really inspired along with your writing skills and also with the layout to your weblog. Is this a paid subject matter or did you modify it your self? Either way stay up the nice quality writing, it is rare to see a nice weblog like this one today..