How to export&import data using sql *loader
Hi all,
How to export&import data from sql*loader. Give me the clear steps..
Thanks in Advance
Hi did you already exported data from SQL SERVER? if not using SQL*LOADER you cannot export data. SQL*LOADER is only mean for importing data from flat files(usually text files) into ORACLE tables.
for importing data into oracle tables using sql*loader use below steps
1) create a sql*loader control file.
it looks like as follows
LOAD DATA
INFILE 'sample.dat'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
APPEND
INTO TABLE emp
TRAILING NULLCOLS
or for sample script of control file search google.
2) at command prompt issue following
$ sqlldr test/test
enter control file=<give control file name which you create earlier>
debug any errors (if occured)
Similar Messages
-
Loading data with dates using SQL*Loader
Dear everyone
I am currently trying to load some data containing dates using SQL*Loader.
For termination of fields I have been using ^ because I have some book titles which contain " and ' as part of their title. I found that the TO_DATE function did not seem to work using ^ instead of ". Would I be correct? I think the Oracle manual says that " must be used.
After some Web research I eventually amended my control file to as follows:
load data
infile 'h:\insert_statements\22_insert_into_SCAN_FILE_INFO.txt'
REPLACE
into table SCAN_FILE_INFO
fields terminated by "," optionally enclosed by '^'
TRAILING NULLCOLS
(scan_id, scan_filename
file_format_id
orig_scanning_resolution_dpi
scanner_id, scanner_operator_id
scanning_date "TO_DATE (:scanning_date, 'YYYY-MM-DD')"
original_map_publication_id
reprint_publication_id)
A simple line of data is as follow:
280001, ^1910 - London^, 270001, 400, 250001, 260001, "TO_DATE('2007-06-06', 'YYYY-MM-DD')", 200019,
The final column being null.
However when I attempt that I get the following error message:
Record 1: Rejected - Error on table SCAN_FILE_INFO, column SCANNING_DATE.
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
If I change the scanning_date part to:
scanning_date "EXPRESSION TO_DATE (:scanning_date, 'YYYY-MM-DD')",
or
scanning_date "CONSTANT TO_DATE (:scanning_date, 'YYYY-MM-DD')",
I get the error message:
Record 1: Rejected - Error on table SCAN_FILE_INFO, column SCANNING_DATE.
ORA-00917: missing comma
As soon as I do the following:
scanning_date "EXPRESSION, TO_DATE (:scanning_date, 'YYYY-MM-DD')",
or
scanning_date "CONSTANT, TO_DATE (:scanning_date, 'YYYY-MM-DD')",
I get too many values error message:
Record 1: Rejected - Error on table SCAN_FILE_INFO.
ORA-00913: too many values
I also tested out scanning_date DATE "YYYY-MM-DD", but that just gave the same ORA-01841 error message as above.
I must be doing something very simple which is wrong but I cannot figure it out.
Kind regards
TimAnd why do you have scanning date as "TO_DATE('2007-06-06', 'YYYY-MM-DD')" in your infile? All you need is 2007-06-06. If you can not change infile generation code, use:
load data
infile 'h:\insert_statements\22_insert_into_SCAN_FILE_INFO.txt'
REPLACE
into table SCAN_FILE_INFO
fields terminated by "," optionally enclosed by '^'
TRAILING NULLCOLS
(scan_id, scan_filename
file_format_id
orig_scanning_resolution_dpi
scanner_id, scanner_operator_id
scanning_date "TO_DATE(REPLACE(REPLACE(:scanning_date,'TO_DATE('),'''YYYY-MM-DD'')'), 'YYYY-MM-DD')"
original_map_publication_id
reprint_publication_id)SY. -
How to export/import data with different nls_lang???
hello
now i try to run my forms by APPLICATION SERVER to view the forms as web forms i success but data appear unreadable that it is arabic and i use the nls WE8ISO8859P1 so i change the nls to arabic like AR8MSWIN1256 but i faild so i create new database with charset UTF8 and nls_lang is AR8MSWIN1256 and try to insert new data when i do query about data ......the new data appear readable but the old unreadable so what can i do???
i think that if i do export data and import it with new (charset and nls_lang) it will be success....but how can i do it??
thank u
regardsHi did you already exported data from SQL SERVER? if not using SQL*LOADER you cannot export data. SQL*LOADER is only mean for importing data from flat files(usually text files) into ORACLE tables.
for importing data into oracle tables using sql*loader use below steps
1) create a sql*loader control file.
it looks like as follows
LOAD DATA
INFILE 'sample.dat'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
APPEND
INTO TABLE emp
TRAILING NULLCOLS
or for sample script of control file search google.
2) at command prompt issue following
$ sqlldr test/test
enter control file=<give control file name which you create earlier>
debug any errors (if occured) -
Error in loading data using SQL loader
I am getting a error like ‘SQL*Loader -350 syntax error of illegal combination of non-alphanumeric characters’ while loading a file using SQL loader in RHEL. The command used to run SQL*Loader is:
Sqlldr userid=<username>/<password> control =data.ctl
The control file, data.ctl is :
LOAD data
infile '/home/oraprod/data.txt'
append into table test
empid terminated by ',',
fname terminated by ',',
lname terminated by ',',
salary terminated by whitespace
The data.txt file is:
1,Kaushal,halani,5000
2,Chetan,halani,1000
I hope, my question is clear.
Please revert with the reply to my query.
RegardsReplace ''{" by "(" in your control file
LOAD data
infile 'c:\data.txt'
append into table emp_t
empid terminated by ',',
fname terminated by ',',
lname terminated by ',',
salary terminated by whitespace
C:\>sqlldr user/pwd@database control=c.ctl
SQL*Loader: Release 10.2.0.3.0 - Production on Wed Nov 13 10:10:24 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 1
Commit point reached - logical record count 2
SQL> select * from emp_t;
EMPID FNAME LNAME SALARY
1 Kaushal halani 5000
2 Chetan halani 1000
Best regards
Mohamed Houri -
ORA-01841 Error when value for date col is NULL in .dat (using SQL Loader)
Hello Gurus,
I have some data in .dat file which needs to be loaded into oracle table. I am using SQL * Loader to do the job. Although "NULLIF col_name =BLANKS" works for character datatype, but when value for date col is NULL then I get ORA-01841 error. I have to make NULL for all rows withour value for date column
Early reply will be highly appreciated
FarooqHi,
May be this problem is not with the NULLIF. The value for the date column is not in proper date format.
create table:
create table kk (empno number, ename varchar2(20), deptno number, hiredate date)
Control file:
LOAD DATA
INFILE 'd:\kk\empdata.dat'
insert into TABLE kk ( empno position (1:2) integer external,
ename position(4:5) char NULLIF ename=BLANKS,
deptno position (7:8) integer external NULLIF deptno=BLANKS,
hiredate position (10:20) date NULLIF hiredate=BLANKS)
data file:
10 KK 01-jan-2005
20 10
SELECT * FROM KK;
EMPNO ENAME DEPTNO HIREDATE
10 KK 01-JAN-05
20 10
Verify the data file.
Hope it will help -
How to view clob data using sql
Hi,
In our database, we have one table that is having one column of CLOB datatype but now i want to view the data using sql select query but it throws error: "Datatype not supported".
Could any one please let me know how to view the clob data using select query.
Oracle DB version : 10.2.0.3
Thanksh5.
use read procedure
PROCEDURE READ (
lobsrc IN BFILE|BLOB|CLOB ,
amount IN OUT BINARY_INTEGER,
offset IN INTEGER,
buffer OUT RAW|VARCHAR2 );
example Updating LOB by Using DBMS_LOB in PL/SQL
DECLARE
lobloc CLOB; -- serves as the LOB locator
text VARCHAR2(32767):='Resigned: 5 August 2000';
amount NUMBER ; -- amount to be written
offset INTEGER; -- where to start writing
BEGIN
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 405 FOR UPDATE;
offset := DBMS_LOB.GETLENGTH(lobloc) + 2;
amount := length(text);
DBMS_LOB.WRITE (lobloc, amount, offset, text );
text := ' Resigned: 30 September 2000';
SELECT resume INTO lobloc
FROM employees
WHERE employee_id = 170 FOR UPDATE;
amount := length(text);
DBMS_LOB.WRITEAPPEND(lobloc, amount, text);
COMMIT;
END; -
Loading leap year date using SQL*Loader
Hello,
I have a problem loading a date '29/02/2000' using SQL*Loader. This date is on a leap year. I'm getting an error message from SQL*Loader as 'ORA-01839: date not valid for month specified'. My colleague and I have tried using various date functions to convert the data into date, but no luck.
I would appreciate any helps,
BruceThanks for your help, I found the bug on my control file. I was using the RTRIM function to remove bad timestamp such as '29/02/2000 0:00:00'. So instead of using this statement:
LOG_DATE DATE "DD/MM/RRRR" "RTRIM(:LOG_DATE,'0:00:00')"
I was using the statement below with a space before the '0:00:00' string literal, with the intention to remove a space also:
LOG_DATE DATE "DD/MM/RRRR" "RTRIM(:LOG_DATE,' 0:00:00')"
Well, it turned out that if there was a space before the string literal, RTRIM function would trim the matching string plus any '0' characters from the right, including the '000' that belongs to '2000'. Thus, the error.
Thanks again,
Bruce -
How to load time only no date using sql loader
I want to load just time portion from the data, the data looks like this
08/10/09 ,FZ10, AD2R, DFHMIRS , 14, 01:12:07.001230, 01:02:07.112354, TRANS PURGED / TIMED OUT ,
control file:
LOAD DATA
APPEND
INTO TABLE TRANS_ABENDS
FIELDS TERMINATED ',' TRAILING NULLCOLS
TRANS_DATE DATE "MM/DD/YYYY",
TRANS_ID ,
ABEND_CODE ,
ABEND_PGM ,
ABEND_COUNT ,
RESPONSE_TIME "to_date(:RESPONSE_TIME,'dd/mm/yy HH:MI:SS.ffffff')",
CPU_TIME "to_date(:RESPONSE_TIME,'dd/mm/yy HH:MI:SS.ffffff')",
ABEND_RESOLUTION ,
INSTANCE CONSTANT 'EAST'
I can load the time using the control file but it adds the first of the month as date in the column. I want to load only time value. Appreciate any help on this.I meant, how are these columns defined in the table that is being loaded?
If these are defined as DATE, then as was pointed out Oracle will default the date portions if they are not provided in the formatted string.
If these are defined as NUMBER (with some fractional portion), then you could use a combination of substr, multiplication and concatenation to derive the time as number in the form <seconds>.<fractional seconds>.
You could also look into the data type INTERVAL DAY TO SECOND.
SQL> create table trans_abends (
2 trans_date date,
3 trans_id char(4),
4 abend_code char(4),
5 abend_pgm char(8),
6 abend_count number(4),
7 response_time interval day (0) to second (6),
8 cpu_time interval day (0) to second (6)
9 )
10 /
Table created.
SQL> insert into trans_abends values (sysdate, 'xxxx', 'xxxx', 'xxxxxxxx', 1, to_dsinterval('+0 01:12:07.001230'), to_dsinterval('+0 01:02:07.112354') )
2 /
1 row created.
SQL> select response_time, cpu_time from trans_abends;
RESPONSE_TIME
CPU_TIME
+0 01:12:07.001230
+0 01:02:07.112354For the sql loader control file, try
"to_dsinterval('+0 '||:RESPONSE_TIME)"
not tested.
Edited by: user142857 on Nov 18, 2009 12:20 PM
Edited by: user142857 on Nov 18, 2009 12:27 PM -
How to Import data via SQL Loader with characterset UTF16 little endian?
Hello,
I'm importing data from text file into one of my table which contains blob column.
I've specified following in my control file.
-----Control file-------
LOAD DATA
CHARACTERSET UTF16
BYTEORDER LITTLE
INFILE './DataFiles/Data.txt'
BADFILE './Logs/Data.bad'
INTO TABLE temp_blob truncate
FIELDS TERMINATED BY " "
TRAILING NULLCOLS
(GROUP_BLOB,CODE)
Problem:
SQL Loader always importing data via big endian. Is there any method available using which we can convert these data to little endian?
ThanksA new preference has been added to customize the import delimiter in main code line. This should be available as part of future release.
-
Export/Import data in SQL Express 2014
Hello,
I have SQL Server 2008 on the network server and 'central' DB. To workaround cases when the network is down I decided to implement 'local' design on all clients. Actually I have 5 clients. I installed SQL Express 2014 on each client and created exact as
'central' empty database on each client.
Now during network outage I'm able to continue collect data and populate it in each of 5 db's.
When the network is up again I have to copy/move collected data from each client to 'central' db. Unfortunately 'central' and 'local' db's are on the different network and can't see each other hence I have to somehow export package from each 'local'
db and then import it into 'central'.
The problem that I hit is that in SQL Express there's not an option to save package i.e. it allow only immediate export which would not work for me.
Do you have an idea how to handle this situation?
Thanks
EVHi,
I agree with Ronen and Scott. You can use SQL Server Replication to
copy the data.
Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency. Using replication, you can distribute data to different
locations and to remote or mobile users over local and wide area networks, dial-up connections, wireless connections, and the Internet.
Replication processing resumes at the point at which it left off if a connection is dropped.
Please check out the following links for more information about SQL Server Replication:
SQL Server Replication Step by Step
http://www.codeproject.com/Articles/715550/SQL-Server-Replication-Step-by-Step
SQL Server Replication
http://msdn.microsoft.com/en-us/library/ms151198.aspx
Thanks.
Tracy Cai
TechNet Community Support -
How can I import data using .dmp into the table which has more columns then in import
I am building the history for warehouse purpose on Oracle 8i database and want to use the old import (.dmp) files (from oracle 7.3.4) to import data but the underlying table is having few more columns which are not in my old DMP file .. how can I import the data into these altered tables while using the same *.imp files .
Any solutions ?That is the most obvious solution .. but think of the case when my operational database which is the source of my data is undergoing changes every quarter i.e after every 3 months there are some changes on underlying table structures which means structures of my import files will always be different after evry quarter .. you can imagine the number of temporary import structures I need to create .. can't there be a solution wherein I can write an SQL over the import file to read the data in required format ..
-
CSV FILES DOESN'T LOAD WITH RIGHT DATA USING SQL LOADER
Hi pals, I have the following information in csv file:
MEXICO,Seretide_Q110,2010_SEE_01,Sales Line,OBJECTIVE,MEXICO,Q110,11/01/2010,02/04/2010,Activo,,,MEXICO
MEXICO,Seretide_Q210,2010_SEE_02,Sales Line,OBJECTIVE,MEXICO,Q210,05/04/2010,25/06/2010,Activo,,,MEXICO
When I use SQLLOADER the data is loaded as follow:*
EXICO,Seretide_Q110,2010_SEE_01,Sales Line,OBJECTIVE,MEXICO,Q110,11/01/2010,02/04/2010,Activo,,,MEXICO
And for the next data in a csv file too:
MX_001,MEXICO,ASMA,20105912,Not Verified,General,,RH469364,RH469364,Change Request,,,,,,,Y,MEXICO,RH469364
MX_002,MEXICO,ASMA,30094612,Verified,General,,LCS1405,LCS1405,Change Request,,,,,,,Y,MEXICO,LCS1405
the data is loaded as follow:
X_001,MEXICO,ASMA,20105912,Not Verified,General,,RH469364,RH469364,Change Request,,,,,,,Y,MEXICO,RH469364
X_002,MEXICO,ASMA,30094612,Verified,General,,LCS1405,LCS1405,Change Request,,,,,,,Y,MEXICO,LCS1405
I mean the first character is truncated and this bug happens with all my data. Any suggestion? I really hope you can help me.
Edited by: user11260938 on 11/06/2009 02:17 PM
Edited by: Mariots on 12/06/2009 09:37 AM
Edited by: Mariots on 12/06/2009 09:37 AMYour table and view don't make sense so I created a "dummy" table to match your .ctl file.
SQL> create table CCI_SRC_MX
2 (ORG_BU varchar2(30)
3 ,name varchar2(30)
4 ,src_num varchar2(30)
5 ,src_cd varchar2(30)
6 ,sub_type varchar2(30)
7 ,period_bu varchar2(30)
8 ,period_name varchar2(30)
9 ,prog_start_dt date
10 ,prog_end_dt date
11 ,status_cd varchar2(30)
12 ,X_ACTUALS_CALC_DATE date
13 ,X_ACTUAL_UPDATE_SRC varchar2(30)
14 ,prod_bu varchar2(30)
15 ,ROW_ID NUMBER(15,0)
16 ,IF_ROW_STAT VARCHAR2(90)
17 ,JOB_ID NUMBER(15,0)
18 );
Table created.
SQL> create sequence GSK_GENERAL_SEQ;
Sequence created.I simplified your .ctl file and moved all the constant and sequence stuff to the end. I also changed the format masks to match the dates in your data.
LOAD DATA
INFILE 'SBSLSLT.txt'
BADFILE 'SBSLSLT.bad'
DISCARDFILE 'SBSLSLT.dis'
APPEND
INTO TABLE CCI_SRC_MX
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(ORG_BU
,NAME
,SRC_NUM
,SRC_CD
,SUB_TYPE
,PERIOD_BU
,PERIOD_NAME
,PROG_START_DT DATE 'dd/mm/yyyy'
,PROG_END_DT DATE 'dd/mm/yyyy'
,STATUS_CD
,X_ACTUALS_CALC_DATE DATE 'dd/mm/yyyy'
,X_ACTUAL_UPDATE_SRC
,PROD_BU
,row_id "GSK_GENERAL_SEQ.nextval"
,if_row_stat CONSTANT 'UPLOADED'
,job_id constant 36889106
{code}
When I run SQL Loader, I get this:
{code}
SQL> select * from CCI_SRC_MX;
ORG_BU NAME SRC_NUM SRC_CD SUB_TYPE PERIOD_BU PERIOD_NAME PROG_START_DT PROG_END_DT STATUS_CD PROD_BU ROW_ID IF_ROW_STAT JOB_ID
MEXICO Seretide_Q110 2010_SEE_01 Sales Line OBJECTIVE MEXICO Q110 11-JAN-2010 00:00:00 02-APR-2010 00:00:00 Activo MEXICO 1 UPLOADED 36889106
MEXICO Seretide_Q210 2010_SEE_02 Sales Line OBJECTIVE MEXICO Q210 05-APR-2010 00:00:00 25-JUN-2010 00:00:00 Activo MEXICO 2 UPLOADED 36889106
{code} -
Problem with loading data using SQL LOADER
I am having following files with me when i run following command at command prompt
sqlldr scott/tiger@genuat control =c:\emp.ctl
then giving error as
SQL Loader 500: unable to open file
SQL Loader 553: file not found
emp.dat file data
1111,sneha,CLERK 7902,17-Dec-80,800,20
2222,manoj,SALESMAN,7698,20-Feb-72 ,1600,6500,30
3333,sheela,MANAGER,7839,8-Apr-81,2975,20
emp.ctl file
LOAD DATA
INFILE 'c:\emp.dat'
APPEND
INTO TABLE emp
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(EMPNO,
ENAME ,
JOB,
MGR,
HIREDATE,
SAL ,
COMM,
DEPTNO)
can anyone tell me what is problem in above file why data is not loaded in table??I don't find any problem if you invoke the SQLLDR using the below command(and if you are certain that the control file resides in the C: drive).
sqlldr scott/tiger@genuat control =c:\emp.ctl
If this doesn't work then invoke the SQLLDR from the C: prompt itself.
sqlldr scott/tiger@genuat control=emp.ctl
It would locate the control file and check whether the sqlldr completes successfully? -
Failing to import data using SQL query
I am trying to import data from a sql query to analysis service in SSDT. i went to model > import from data source >Microsoft SQL Server and i chose from query. I typed my query which works fin in SSMS and when i press import if gives me a error. what
is going on please help here is the error
DirectQuery error: All tables used when querying in DirectQuery Mode must be from a single relational Data Source.
here is my query:
USE AdventureWorks2012;
SELECT SalesPersonID, [29484] Brian, [29485] Peter, [29486] Frank, [29518] Sarah, [29519] Janet, [29520] Alice, [29608] Martin, [29609] Patrick, [29610] Wasu, [29780] Samanyika, [29781] Vladmire
FROM
SELECT SalesOrderID, SalesPersonID, CustomerID
FROM Sales.SalesOrderHeader
WHERE SalesPersonID IS NOT NULL
As P PIVOT
COUNT (SalesOrderID) FOR CustomerID IN ([29484], [29485], [29486], [29518], [29519], [29520], [29608], [29609], [29610], [29780], [29781])
AS PVT
ORDER BY SalesPersonID ASC;Hi,
When importing data from relational data source, the steps are:
In SQL Server Data Tools (SSDT), click the Model menu, and then click Import
from Data Source.
On the Connect to a Data Source page, select the type of database to connect to, and then click Next.
Follow the steps in the Table Import Wizard. On subsequent pages, you will be able to select specific tables and views or apply filters by using the Select
Tables and Views page or by creating a SQL query on Specify a SQL Query page.
As we can see on the steps, we need to select one database, so we needn't to write "USE AdventureWorks2012" on the query.
Reference:Import from a Relational Data Source
Regards,
Charlie Liao
TechNet Community Support -
How to Export/Import Datas from BEA content Repository
Hi,
I want to Export the datas from BEA content repository and import into the ORacle Repository. Can anybody please let me know how to do that . Thanks in advance.
Best regards,
Venkat.Scopy the files from
(username)/library/preferences/AICS3settings/en_us/workspaces
to
(username)/library/preferences/AICS5settings/en_us/workspaces
Maybe you are looking for
-
Unable to e-mail a pdf through FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
Hi My requirement is to send purchase order pdf to vendor mail id.i am able to create pdf . i am using function module sO_NEW_DOCUMENT_ATT_SEND_API1.I am not getting any error as my sy-subrc returns 0 but my mail is not sent to vendor email id.can an
-
How to trigger tasks which created during Event was inactive in WORKFLOW
Hello Experts We have a custom application with L+1 approval required for approval using workflow. There was a publish for a nomination for team , Team has logged in registered for the published training. Unfortunately, all my team mebers 5 of 7 we
-
How many devices can I authorize for an account?
I have two machines authorized and I want to add a third, it will not let me, why?
-
Anyone available this wknd to help me fix up some loose edges on a website I'm trying to build. I made a template including a navi bar in photoshop, but when transferring to Dreamweaver, i cannot use some of the images on the template as links n othe
-
Help ! I am making a DVD for the high school baseball team and the banquet is next week. I did the same thing 2 years ago without incident. My iMovie is a slideshow of digital photos set to music. When transferring to iDVD, it encodes the menu, encod