Wednesday 20 March 2013

How to unload data from multiple tables into Multiple files


Here the task is to unload all data from all tables of scott schema in to different files.

Create folder scott at any drive. As in my case I have created scott folder in c: drive.

now create spoolmultiple.sql file and add following script to this file.

-----------------Start-------------------

SET LINESIZE 8000 TRIMSPOOL ON PAGESIZE 0 FEEDBACK OFF
--col well_operator format a100
set long 2000

SET TERMOUT OFF
--SET LINES 108
--SET PAGES 0

select * from emp;

spool c:\scott\emp.txt
/
spool off

select * from dept
.
spool c:\scott\dept.txt
/
spool off

select * from salgrade
.
spool c:\scott\salgrade.txt
/
spool off

---------------end-------------------


Now login to database with scott user.

c:\> sqlplus scott/tiger@ardb

SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 20 20:22:02 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @spoolmultiple_queries.sql
SQL> exit;
c:\>


Now you should have three files in scott folder.

No comments:

Post a Comment