Rate This Document
Findability
Accuracy
Completeness
Readability

Exporting a DDL File

Exporting a MySQL DDL File

  1. Use an SSH remote login tool to log in to the node where the source MySQL database is installed.
  2. Run the following command to export the database definition language (DDL) file:
    1
    mysqldump -u root -p --no-data devkit > file_name.sql
    

    Enter the password of the user specified by -u.

    1
    Enter password: *********
    
    • -u: specifies the login user.
    • --no-data: Exports the table structure only but not any other data.
    • file_name.sql: Output file. The recommended file name extension is .sql. The file name can be customized.

Exporting an Oracle DDL File

  1. Use an SSH remote login tool to log in to the node where the source Oracle database is installed.
  2. Go to the sqlplus command line.
    1
    sqlplus / as sysdba
    
  3. Start the database.
    1
    SQL>startup
    
  4. Adjust the Oracle output format.
    1
    2
    3
    4
    SQL>SET LONG 10000
    SQL>SET LINESIZE 200
    SQL>SET PAGESIZE 5000
    SQL>SET TRIMSPOOL ON
    
  5. Start writing the file.
    1
    SQL>Spool output.sql
    

    output.sql: Output file. The recommended file name extension is .sql. The file name can be customized.

  6. Query the DDL statements of all user-created tables.
    1
    SQL>SELECT DBMS_METADATA.GET_DDL('TABLE', table_name) FROM user_tables;
    
  7. After the previous query operation is complete, run the following command to stop writing the file:
    1
    SQL>Spool off
    

Exporting a DB2 DDL File

  1. Use an SSH remote login tool to log in to the node where the source DB2 database is installed.
    db2 connect to <database_name> user <user_name> using <password>
  2. Run the following command to export the database definition language (DDL) file:
    db2look -d <database_name> -e -o filename.sql
    • -d: Name of the database to be operated.
    • -e: extracts DDL statements of database objects such as tables, views, and indexes.
    • -o: Name of the output file, which is appended with the name extension .sql and can be customized.