Exporting a DDL File
Exporting a MySQL DDL File
- Use an SSH remote login tool to log in to the node where the source MySQL database is installed.
- Run the following command to export the database definition language (DDL) file:
1mysqldump -u root -p --no-data devkit > file_name.sql
Enter the password of the user specified by -u.
1Enter 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
- Use an SSH remote login tool to log in to the node where the source Oracle database is installed.
- Go to the sqlplus command line.
1sqlplus / as sysdba
- Start the database.
1SQL>startup
- 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
- Start writing the file.
1SQL>Spool output.sql
output.sql: Output file. The recommended file name extension is .sql. The file name can be customized.
- Query the DDL statements of all user-created tables.
1SQL>SELECT DBMS_METADATA.GET_DDL('TABLE', table_name) FROM user_tables;
- After the previous query operation is complete, run the following command to stop writing the file:
1SQL>Spool off
Exporting a DB2 DDL File
- 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>
- 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.
Parent topic: References