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.
Exporting an SQL Server DDL File
- Download and install the SQL Server Management Studio (SSMS) tool following instructions in Installing SQL Server Management Studio.
- Start SSMS. On the server connection page, enter the database connection configuration and click Connect.Figure 1 Connect
- After the connection is successful, right-click CompanyDB in the navigation tree on the left and choose from the shortcut menu.In the Introduction area of the Generate Scripts window, click Next.Figure 2 Generate Scripts
- In the Choose Objects area, select Select specific database objects, select Tables, and click Next.Figure 3 Choose Objects
- In the Set Scripting Options area, click Advanced, select the data type for which you want to write a script, and click OK.Figure 4 Advanced
- Select Save as script file, select the type of the file to be generated, file path, and text format, and then click Next.Figure 5 Save as script file
- In the Summary area, check the configuration and click Next.
- In the Save Scripts area, click Finish.Figure 6 Save Scripts
Parent topic: References