title: Proper method to migrate DB2 materialized query tables (MQTs) using db2move and db2look
body: <p>I'm migrating a database from DB2 10.1 for Windows x86_64 to DB2 10.1 for Linux x86_64 - this is a combination of operating systems and machine types that have incompatible backup file formats, which means I can't just do a backup and restore.</p>
  
  <p>Instead, I'm using <code>db2move</code> to backup the database from Windows and restore it on Linux. However, <code>db2move</code> does not move the materialized query tables (MQTs). Instead I need to use <code>db2look</code>. This poses the challenge of finding a generic method to handle the process. Right now to dump the DDLs for the materialized queries I have to run the following commands:</p>
  
  <pre><code>db2 connect to MYDATABASE
  db2 -x "select cast(tabschema || '.' || tabname as varchar(80)) as tablename from syscat.tables where type='S'"
  </code></pre>
  
  <p>This returns a list of MQTs such as:</p>
  
  <pre><code>MYSCHEMA.TABLE1
  MYSCHEMA.TABLE2
  MYOTHERSCHEMA.TABLE3
  </code></pre>
  
  <p>I can then take all those values and feed them into a <code>db2look</code> to generate the DDLs for each table and send the output to <code>mqts.sql</code>.</p>
  
  <pre><code>db2look -d MYDATABASE -e -t MYSCHEMA.TABLE1 MYSCHEMA.TABLE2 MYOTHERSCHEMA.TABLE3 -o mqts.sql
  </code></pre>
  
  <p>Then I copy the file <code>mqts.sql</code> to the target computer, which I've previously restored all the non-MQTs, and run the following command to restore the MQTs:</p>
  
  <pre><code>db2 -tvf mqts.sql
  </code></pre>
  
  <p>Is this the standard way to migrate a MQT? There has got to be a simpler way that I'm missing here.</p>