0

Is there any way to export a file with SQL scripts of IBM DB2 objects.

I have done this in MS-SQL by following the below link. I am not sure how to do this in DB2.

Exporting data In SQL Server as INSERT INTO

ranaa
  • 57
  • 1
  • 5
  • 14
  • Do you want to simply copy data to another Db2 database? If so, you could use Federation. Otherwise, many SQL GUI tools will generate INSERT statements for you. Alternatively, you could just write a SQL statement that will generate SQL that will format the data as you need. – Paul Vernon Aug 14 '18 at 20:30
  • You can use third party software for this. I use TOAD where you can copy results in a Insert Format –  Aug 20 '18 at 15:35

2 Answers2

0

I've never used iSeries Navigator to do this, however, a pretty good once over just now didn't yield anything similar to what you're looking for from SSMS.

What I recommend is DBeaver Community Edition or Toad as others have mentioned. DBeaver CE is a free resource which leans me towards that option.

Create a connection to your DB2 instance (the software will download the drivers for you after prompting), and then use the program to create your SQL insert statements.

Once you add your connection in, expand the library/schema, go to Tables or Views, and right click the object you'd like to export and click Export Data:

Right click your table, click Export Data

Select SQL and click next:

Select SQL and click next

There will be a few more options to select, but this should get you where you want to go. Let me know if you need any more help.

Douglas Korinke
  • 389
  • 7
  • 20
0

For some reasons we are not supposed to use the third party tool in our old server.

For generating the DML statements, I used the SQL query:

SELECT 'Insert into Table (DIV,SA,KEY1,KEY2,VALUE1,VALUE) values('''||DIV||''','''||SA||''','''|| KEY1 ||''','''|| KEY2 ||''','''|| VALUE1 ||''','''|| VALUE ||''');' from Table

For generating the DDL statements, I used the below command:

db2look -i DBUser -w DBpassword -d DBSchema -a -e -x -o FIlE_OUT.txt

ranaa
  • 57
  • 1
  • 5
  • 14