Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Dump from DB2

Tags:

sql

dump

db2

I'm trying to dump the contents of a particular schema in one IBM DB2 UDB server into an sql text file (much like the mysqldump functionality of mysql).

I came across db2look, but it only dumps the structure of the schema (only ddl, no dml).

So how can I get my thing done?

jrh.

like image 501
jrharshath Avatar asked May 29 '09 11:05

jrharshath


People also ask

What is DB2 dump?

A Mysql dump is called a backup in DB2. It creates a binary file that you can restore in the same kind of platform (Window, Linux). It contains the tables definition (DDL), the data and the security. and 3. There is another command that just extract the DDL of the defined objects.

How do I create a .SQL file to dump?

To generate a dump select the database or table in the Object Browser and select Database -> Backup/Export -> Backup Database As SQL Dump… This option is also available in Table -> Backup/Export -> Backup Database As SQL Dump... or just press Ctrl+Alt+E.

What is data dump in SQL?

A database dump contains a record of the table structure and/or the data from a database and is usually in the form of a list of SQL statements ("SQL dump"). A database dump is most often used for backing up a database so that its contents can be restored in the event of data loss.


2 Answers

Db2 Schema with all DDL Backup :

I have use below command it worked for me to export all DDL.

db2look -d CusDb -x -e -z CusSchema -o OutputFile

Syntax : db2look -d DbName -x -e -z SchemaName -o OutputFile_name

like image 180
Gautam Avatar answered Sep 23 '22 01:09

Gautam


What you're looking for is the db2move command. For a particular schema you should use the "sn" switch.

So for example to export the data:

db2move [your_db_name] EXPORT -sn [your_schema_name]

There are many options and switches available for db2move depending on exactly what you want to do.

If db2move is not exactly what you need, you can review the table of Data Movement Options available in DB2.

like image 34
Michael Sharek Avatar answered Sep 23 '22 01:09

Michael Sharek