Generating DDL

Generate data definition language (DDL) for a database, database objects, or both.

Data definition language (DDL) defines the structure of a database, including rows, columns, tables, indexes, and so on. You can generate the data definition of a database object using the Generate DDL wizard. The DDL is generated into a .sql file in an Eclipse project, or is executed directly on the specified connection profile. You can use this .sql file to create the same database schema object in a different database, or you can generate the DDL of a complete database to create a new database on a different server. You can edit the .sql file if you want to make changes.

  1. In Data Source Explorer, right click a database, table, user-defined function, user-defined datatype, or a database view.
  2. Select the model elements to include in the DDL script and click Next.
    Table 1. Model elements for DDL generation
    Model element Description
    Fully Qualified Name Use fully qualified names, including database, owner, and object.
    Quoted Identifier Enable the quoted_identifier option that allows the interpretation of delimited strings to be changed.
    DROP Statements Generate SQL drop statements. DROP statements remove an existing object from the database.
    CREATE Statements Generate SQL create statements.
    Comments
  3. Select the model objects to include in the DDL script and click Next.

    The object type determines which model object options are available.

    Table 2. Model objects for DDL generation
    Model object Object type
    Check Constraint database, table
    Foreign Key Constraint database, table
    Indexes database, table
    Primary Key Constraint database, table
    Tables database, table
    Triggers database, table
    Views database
    Stored Procedures stored procedure
    Functions user-defined function
    User Defined Types user-defined datatype
  4. Select the save and run DDL options and click Next.
    Option Description
    Folder Name Enter a project folder or click Browse to select.
    File Name Accept the default or enter file name.
    Preview DDL View a preview of the generated DDL.
    Statement Terminator Accept the default or enter a different one.
    Run DDL on Server Runs the DDL against a connection profile.
    Open DDL File For Editing Opens SQL file in SQL Scrapbook.
  5. (Optional) If you selected Run DDL on Server, select an existing connection profile or click New to create a new one, and then click Next.
  6. Click Finish.
Next If you ran the DDL on the server, see SQL Results view for execution details. If you selected Open DDL File for Editing, the file opens in SQL Scrapbook, where you can view or edit it.