我要评分
获取效率
正确性
完整性
易理解

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.

Exporting an SQL Server DDL File

  1. Download and install the SQL Server Management Studio (SSMS) tool following instructions in Installing SQL Server Management Studio.
  2. Start SSMS. On the server connection page, enter the database connection configuration and click Connect.
    Figure 1 Connect
  3. After the connection is successful, right-click CompanyDB in the navigation tree on the left and choose Task > Generate Scripts from the shortcut menu.
    In the Introduction area of the Generate Scripts window, click Next.
    Figure 2 Generate Scripts
  4. In the Choose Objects area, select Select specific database objects, select Tables, and click Next.
    Figure 3 Choose Objects
  5. 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
  6. 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
  7. In the Summary area, check the configuration and click Next.
  8. In the Save Scripts area, click Finish.
    Figure 6 Save Scripts