Generate SQL Insert Statement using EXPORTED dmp file
Dear DBAs,
Kindly inform me that is it possible to generate SQL script file using the exported file dmp,
I am looking for some option in import utility that generates script without import any rows in the database
Secondly is there any other way to check the validity of exported dmp file data validity without importing it back into the database.
Regards,
Asif
Hi Satish,
Yes you are correct the insert into statements won't be avaliable using either the indexfile or the show parameter.I had given these two options as per his 1st post requirement where he had mentioned
>
it possible to generate SQL script file using the exported file dmp,I am looking for some option in import utility that generates script without import any rows in the database
>
So, i thought he needed to see whats all objects are in the .dmp
Apologies for my 2nd post.
Anand
Similar Messages
-
Generate SQL Insert Statements
Hello,
I am testing generating insert statements for which I have a function which will return a sql statement.
This sql statement when I execute would results as sql insert statements.
What I am trying to acheive through a procedure is when I execute function, the result I would like to execute automatically and then the second sql I would like to store to a control file or sql file.
How can I acheive this?
Any help is very helpful
Regards
Edited by: user20090209 on Aug 20, 2009 11:34 AMHere is the function to generate sql
CREATE OR REPLACE function insert_sql(v_table_name varchar2)
return varchar2 as
b_found boolean := false;
v varchar2(32000);
v1 varchar2(32000);
v2 varchar2(32000);
begin
for s in (
select *
from all_tables
where table_name=upper(v_table_name)
--and owner=upper(v_owner)
) loop
b_found := true;
for ss in (
select *
from all_tab_columns
where table_name = s.table_name
order by column_id
) loop
if ss.data_type='NUMBER' then
v1:=v1||','||ss.column_name;
v2:=v2||',''''''||to_char('||ss.column_name||')||''''''';
end if;
if ss.data_type in ('VARCHAR2','CHAR') then
v1:=v1||','||ss.column_name;
v2:=v2||',''''''||replace(replace('||ss.column_name||','''''''',''''''''''''),''&'','''')||''''''';
end if;
if ss.data_type='DATE' then
v1:=v1||','||ss.column_name;
v2:=v2||',to_date(''''''||to_char('||ss.column_name||',''dd.mm.yyyy hh:mi:ss'')||'''''',''''dd.mm.yyyy hh:mi:ss'''')';
end if;
end loop;
v:='select ''insert into '||s.table_name||' (';
v:=v||substr(v1,2,9999)||') '||chr(10)||' values ('||substr(v2,2,9999)||'); '' txt from '||s.table_name;
end loop;
if not b_found then
v:='- Table ' || v_table_name || ' not found';
else
v:=v;
end if;
return v;
end;
/And I am calling like
CREATE OR REPLACE PROCEDURE test_gen_script_exec IS
type v_ref_cur is REF CURSOR;
v_ref_cur_var v_ref_cur;
v_temp_sql VARCHAR2(4000);
v_sql varchar2(4000);
begin
v_sql := insert_sql('table_name');--change here
open v_ref_cur_var for v_sql;
loop
fetch v_ref_cur_var into v_temp_sql;
exit when v_ref_cur_var%notfound;
execute immediate v_temp_sql;
end loop;
close v_ref_cur_var;
end;
/Edited by: user20090209 on Aug 20, 2009 1:24 PM -
Generate insert statement using columns from all_tab_cols view
i am trying to generate a dynamic insert statement using the columns for a table from the all_tab_cols view. if i do a select, i get the output as rows. How do i convert the row out to columns so that i get something like this : INSERT INTO TABLE_NAME (COL1, COL2, COL3,COL4.....) .
Any help will be appreciated!SQL> select * from my_test;
no rows selected
SQL> desc my_Test;
Name Null? Type
COL1 NUMBER
COL2 NUMBER
COL3 NUMBER
SQL> declare
2 cursor c1 is select column_name from all_tab_cols where table_name = 'MY_TEST';
3 v_sql VARCHAR2(10000) := NULL;
4 v_cnt NUMBER := 0;
5 BEGIN
6 FOR I in C1 LOOP
7 v_cnt := v_cnt + 1;
8 v_sql := 'INSERT INTO my_test('||I.column_name||') values('||v_cnt||')';
9 EXECUTE IMMEDIATE v_sql;
10 END LOOP;
11 COMMIT;
12 end;
13 /
PL/SQL procedure successfully completed.
SQL> select * from my_Test;
COL1 COL2 COL3
1
2
3
SQL> -
Naming for Export dmp file in Date and Time
Dear All,
Please advise me how to give the file name in date and time stamp for the export dmp file and it's log file.Suggest me in Oracle 9i version.
for example the file name get like this 020420041155.dmp and 020420041155.log where date and time are 02/04/2004 11:55 respectively...
Kindly let me know the syntax of filename to be given along with the EXP command..
Thanking You,
RageshHello
I don't think you can get the exp command to automatically name an export for you. The only way I think you would be able to do it is through a shell script or something where you format the file name yourself and pass it to exp. If you wanted to you could generate the command line through a SQL statement and then spool it out to a file i.e.
spool runexp.bat
select 'exp user/pwd@tns file='||TO_CHAR(SYSDATE,'DDMMYYYYHH24MI')||'.dmp tables=(table1,table2)' from dual;
spool offThe second option isn't as flexible as the first but if it's just a couple of exports you have to do, it will probably prove to be less work
HTH
David -
How to convert XML content into SQL INSERT statements
Hi all,
I'm very new to XML. Forgive me if I don't use technical XML terms. :-)
We are planning to convert SQL queries into XML format using a third party tool.
After that we have to read the XML files and use the tokens to insert into custom tables.
So, basically we have to create INSERT statements using the data stored in the XML file.
How do we go about reading / parsing the XML file in Java?
Pls help!
Regards,
SamThis is the requirement with an example.
eg. if the following SQL query is fed into the 3rd party system,
select last_name,job_id,salary from employees a, deptno b
where a.deptno = b.deptno
the output would be,
<?xml version="1.0" ?>
<sqlscript dbvendor="MSSQL">
<fullselectstmt nestlevel="0">
<subselectstmt><selectclause><fieldlist>
<field><fieldname>
<attr>
<sourcetoken toketype="" dbobjtype="field">last_name</sourcetoken>
</attr>
</fieldname>
</field>
<field><fieldname>
<attr>
<sourcetoken toketype="" dbobjtype="field">job_id</sourcetoken>
</attr>
</fieldname>
</field>
<field><fieldname>
<attr>
<sourcetoken toketype="" dbobjtype="field">salary</sourcetoken>
</attr>
</fieldname>
</field>
</fieldlist></selectclause>
<fromclause><joinlist><join nestlevel="0">
<lztable><simpletable><attr>
<sourcetoken toketype="" dbobjtype="table">employees</sourcetoken>
</attr><aliasclause withas="false"><sourcetoken toketype="" dbobjtype="table alias">a</sourcetoken></aliasclause></simpletable></lztable></join><join nestlevel="0">
<lztable><simpletable><attr>
<sourcetoken toketype="" dbobjtype="table">deptno</sourcetoken>
</attr><aliasclause withas="false"><sourcetoken toketype="" dbobjtype="table alias">b</sourcetoken></aliasclause></simpletable></lztable></join></joinlist></fromclause>
<whereclause><expression exprtype="Expr_Comparison" exproop="="><attr>
<sourcetoken toketype="" dbobjtype="table alias">a</sourcetoken>
<sourcetoken toketype="" dbobjtype="unknown">.</sourcetoken>
<sourcetoken toketype="" dbobjtype="field">deptno</sourcetoken>
</attr><attr>
<sourcetoken toketype="" dbobjtype="table alias">b</sourcetoken>
<sourcetoken toketype="" dbobjtype="unknown">.</sourcetoken>
<sourcetoken toketype="" dbobjtype="field">deptno</sourcetoken>
</attr></expression>
</whereclause></subselectstmt></fullselectstmt>
</sqlscript>
So, using the output file, the list of columns (under token "field") last_name,job_id and salary should be inserted into LIST_COLUMNS table. So 3 INSERT statements should be created for 3 columns.
The list of tables (under token "table") employees and dept should be inserted into LIST_TABLES table. So 2 INSERT statements should be created for the 2 tables.
Regards,
Sam -
Create a test DB from the export DMP file
Hi Gurus,
I was able to create the DMP file by export and transfer it to the test machine. It is a Windows OS.
Now in this machine I recently installed Oracle 11g. And I have this export *.DMP file in a dir.
I need to import the DMP file which into this newly created database to give a test database in 11g.
I also created the user for which the export is done.
I need to know how to import the DMP file. I am new to this import-export business.
Thanks
Amitava.Hi,
Use IMPDP:
impdp username/password@dbname full=Y directory=<location of the dmp file> dumpfile=<dumpfile name> logfile=<logfile name to be created>
Check the below link for more information:
ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g -
Is it possible to import an Oracle 10 (export .dmp file) into Oracle 9 db ?
hi Oracle Guru's
Is it possible to import a oracle 10 (export .dmp file) into an oracle 9 database ?
I tried & got the following error ...
IMP-00010 not a valid export file, header failed verificationperhaps their is a work-around ?
thanksHi
You can take export from a previous version and import to a later version. Having said that, there is still a workaround to do what you want.
On 9i server add a connect string for your 10g instance. Then use 9i export utility to export 10g data. That way your export will be compatible with 9i. You can then import the data in your 9i instance.
To create connect string you can either use Net Configuration Assistant or manually edit TNSNAMES.ORA file in your 9i server.
Hope it helps.
Rgds
Adnan -
I have a export dmp file, there is any way i can find it out this dmp file is whole schema, or whole database, or table level backup. what is the scama name or database name or tables name backup.
Hi All
use imp utility connect to user with dba privilege can be system, in addition to verify the variable oracle_sid and to verify that bd is one operative since password and user will read it of this instance.
The mails above is true, import all structure in flat files with no data, this is the only way of see the content.
Best Regards,
Martín. -
How to Generate a MDX statement using a BEX query
Hello,
Is there any possiblity in BW to generate a MDX statement using a BEx query?
Thanks,
RaviBW does not generate any MDX statement for Bex query.I have tried ample number of times to acheive this but failed.
Like an Infocube the Query is also an object where in you can write MDX queries on BEx Queries.
As it is I never found BW rendering MDX queries.But with MDX queries you can get something but how far it helps I don't know.
RSCRM_BAPI is obsolete and it is recommended to use RSCRM_REPORT somewhere I have read ,but when I went to that transaction I never found that "MDX" button at all.
It was converted to "OLAP Check" which gave me some warning on the key figures and that's it.
Somehow I feel BW is not comfortable with MDX.
Regs
Gopi -
SQL insert statement in java with Excel file
Dear all,
I wrote a program is as the follow:
import java.io.*;
import java.sql.*;
public class handleExcel
Connection con = null;
Statement stmnt = null;
public handleExcel()
String excel = "C:\\EGS\\app_files\\info_update_form_exported_data.xls";
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String str="jdbc:odbc:DRIVER=Microsoft Excel Driver (*.xls);DBQ=" + excel + ";";
String sql = "insert into [Sheet1$] (Name, Age, Test1, Test2, Test3) values ('mary','16','aa','bb','vv')";
con = DriverManager.getConnection(str, "", "");
stmnt = con.createStatement();
stmnt.executeUpdate(sql);
catch(Exception e)
System.out.println("con is error!!");
e.printStackTrace();
public static void main(String[] args)
handleExcel TestHpc = new handleExcel();
But when I run it, the error is as the follow:
java.sql.SQLException: [Microsoft][ODBC Excel Driver]
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
at hk.gov.edb.util.handleExcel.<init>(handleExcel.java:31)
at hk.gov.edb.util.handleExcel.main(handleExcel.java:97)
Please help me to solve this problem. Thank you so much for your help!
Regards,
kzyoHi
You can use the[b] jakarta POI api in order to read/write Excel file from java. Pure Java, no drivers nedeed.
I tested and ok.
Hope this helps -
Database Restore Using Export Dump File
I have searched a lot of books and web sites, but cannot find the exact procedure as to how to restore full oracle database using the export dump file and the import utility.
Does anyone have any ideas.
Paltform: W2K AD Svr, Oracle 9.2.0.6.
Please adviceHi, I was able to create the db using dbca, and then import.
When I first imported, I got messages all over that user or objects did not exist. So I commented the line which would invoke the CreateDBCatalog.sql script.
And now I get this,
C:\>imp '/ as sysdba' file=z:\export\tuethusat\dbname_full_export.dmp full=y
Import: Release 9.2.0.1.0 - Production on Tue Oct 24 15:30:03 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
IMP-00003: ORACLE error 942 encountered
ORA-00942: table or view does not exist
IMP-00023: Import views not installed, please notify your DBA
IMP-00000: Import terminated unsuccessfully
C:\>
Any suggestions? -
Generating SQL SELECT statement with Schema
I develop a 3rd-party application that connects to various
databases via ODBC. Our program generates the SQL statement
so that the user does not have to. When connecting to oracle the
user often gets the error message: ORA-00942: table or view does
not exist.
To work around this our tech support department has tells the
customer to enter in the Schema name before the table name.
Thus,
SELECT ItemNo from Item
becomes
SELECT ItemNo from MySchema.Item
Is there a way that I can query the Data Source to find out
the Schema name so that our program can put in in the
statement. Is there a SQLGetInfo call I can make to get
this information?
Or, should I have the Server specified in the connection
string? For SQL Server we use SQLGetPrivateProfileString to
obtain the server name and then include it in the connection
string: SRVR=<servername>
Unfortunately, if this is the case the keyword is different
depending on the ODBC Driver involved. "Server" for Microsoft.
"SRVR" for Intersolv. "ServerName" for Oracle.
Note: We do not have Oracle in-house to test with. I'm
wondering if we could get Oracle for free for development
purposes.
Any and all information would be greatly appreciated.Thanks for the tip. I just finished downloading Oracle.
One user is able to successfully view the database with the
statement:
SELECT ItemNo from Item
But if another user tries it he gets the "table or view not
found" message. Changing the statement as follows will allow
the 2nd user to view the database:
SELECT ItemNo from "MAXIMO".Item
I want my application to query the database via ODBC for the
"MAXIMO" string so I can create the correct SQL statement.
Thanks!
<<Are you trying to view tables from a non-default schema?>>I don't know. You would know better than me from my
description. -
Improving SQL Insert statement syntax
It's about insert statement syntax, in insert statement, unlike in update statement column names and corresponding values are separated in two different sets. With this separation debugging/writing of insert statement is going to be time taking activity. To identify what value is getting stored in any column, first column position needs to be identified and after that by counting commas in the values list value is located. If functions are included in insert statement then counting of commas doesn't help to locate the value.
In any non trivial application column count in insert statement is going to be very big number and it is unmanageable.
If column name and value are written next to each other as it is done in cause of UPDATE statement, it is going to drastically reduce the debugging efforts and there by improves the productivity of the developers.
So I request SQL community please consider having a variant of insert statement in similar lines of update statement. This will simplify the life of millions of developers.
Edited by: user9110509 on Feb 6, 2010 10:19 AMHi,
That's a good idea! An optional alternate way of specifying the columns would be handy.
Perhaps the reason it hasn't been done yet is that most people, like those who have responded to this message, do not find the current syntax much of a problem. We can't be sure if your idea "is going to drastically reduce the debugging efforts" until it is available, but my guess is that it isn't.
One thing I do to make sure the two lists match is to indent the values directly below the column names, like this:
INSERT INTO emp (empno, ename, hiredate, job)
VALUES (9876, 'OBAMA', TO_DATE ( '20-JAN-2009'
, 'DD-MON-YYYY), 'PRESIDENT');If the list is very long, or individual values are very complicated, then I might start with a list of the column names
INSERT INTO emp -- Step 1: not ready to run yet
( empno
, ename
, hiredate
, job
VALUESthen use the editor's copy and paste commands to duplicate that list:
INSERT INTO emp -- Step 2: not ready to run yet
( empno
, ename
, hiredate
, job
VALUES
( empno
, ename
, hiredate
, job
;and then fill in the VALUES section, leaving the copied names as comments:
INSERT INTO emp -- Step 3: ready to run
( empno
, ename
, hiredate
, job
VALUES
( 9876 -- empno
, 'OBAMA' -- ename
, TO_DATE ( '20-JAN-2009'
, 'DD-MON-YYYY
) -- hiredate
, 'PRESIDENT' -- job
; -
Sql insert statement will fail if the data value has empty line
Hi,
I notice if the insert statement in my .sql file contains data that has new line (enter key), the insert will fail.
For example:
insert into mytable (message)
values ('this is the first line
this is the second line that will cause insert statement to fail
so as this third line');
commit;
How to overcome this?
Please advise.
Thank you.
Message was edited by:
bchurn
Message was edited by:
bchurnIt did not return me any error. What is the error you are receiving ??
SQL> create table mytable (message varchar2(500));
Table created.
SQL> insert into mytable (message)
2 values ('this is the first line
3 this is the second line that will cause insert statement to fail
4 so as this third line');
1 row created.
SQL> @c:\test.txt
1 row created.contents of c:\test.txt
<<
insert into mytable (message)
values ('this is the first line
this is the second line that will cause insert statement to fail
so as this third line');
>> -
Exporting .dmp file from 9.1.2 to 9.0.1.1
Is it possiable from me to export a .dmp file generated from 9.1.2 to oracle 9.0.1.1
Dear Carlo & Chris, May I ask you to clarify on below comment which is mentioned in Release note of CUCM 10.5
I don't understand why Cisco has mentioned this, if its not required ? I would appreciate your any inputs.
Preupgrade COP File
If you are upgrading to Cisco Unified Communications Manager Release 10.5(1), or later, from a release earlier than Cisco Unified Communications Manager Release 10.0(1), you must download and install ciscocm.version3-keys.cop.sgn on every node in the cluster. This Cisco Options Package (COP) file has the RSA keys that are required to validate the upgrade. Missing RSA-3 keys will result in status errors in the Software Installation/Upgrade window of the Cisco Unified Operating System Administration interface.
Suresh
Maybe you are looking for
-
How do i find out my notebook\'s capacity?
I want to upgrade to newer windows version, but I need to know if I have enough space to do a custom install or if I need to purchase a larger hard drive. How do I check my notebooks capacity? I have an hp mini 1030nr running windows xp professional
-
What is Connection in Oracle 10g Database?
Please let me know what is connection term in Oracle 10g Database in detail? Thanks, Waheed.
-
How to Hardcode sender JDBC action node as EXECUTE
Hi , I have JDBC to File scenario ,please suggest me how to hardcode sender JDBC structure nodes <b>action</b> as "EXECUTE" and <b>table</b> as "ST_PROS.Get_Table" while designing the message mapping.
-
When I choose Edit into ... Photoshop CC 2014, Ps is launched but nothing happens. I just can launch an edit as advanced object and in this case the image appears into Ps. Any suggestions ? Marco Lugli
-
I have English (Australia) and English (United States) in the same order installed in the Language panel. I try to remove the redundant English (United States). I click Options to open it. I found the option Remove for the Input method is dimmed ou