JetBrains Rider 2021.2 Help

DDL data sources

DDL data sources

SQL files that contain data definition language statements (DDL statements) can be used as data sources. As a result, you can reference all tables, columns and other objects defined in such files in the editor.

Create DDL data sources from existing data sources

  1. In the Database tool window (View | Tool Windows | Database), right-click a data source that you want to dump to a DDL data source and select SQL Scripts | Dump to DDL Data Source.

    To configure code settings for the DDL data source, see Configuring DDL generation settings.

    If you already have a DDL data source for the selected data source, you can choose whether to dump DDL files to the existing DDL data source or create a new one.

  2. In the Data Sources and Drivers dialog, click Add directories or DDL files.

  3. In the file browser, navigate to the directory that will store DDL files of a data source and click Open.

  4. Click OK.

    db_create_ddl_data_sources_from_existing_data_sources

Adding DDL files to a DDL data source

  1. In the Database tool window (View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon.

  2. On the Data Sources tab in the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select DDL Data Source.

  3. In the DDL Files pane, click the Add button (the Add button).

  4. In the file browser, navigate to the SQL file or files with DDL statements and click Open.

  5. Click the Dialect link and select a dialect that you want to use for added SQL files.

  6. Apply settings and click OK.

    set a dialect for the DDL

Creating objects in the DDL data source

  • In the Database tool window (View | Tool Windows | Database), right-click a node of the DDL data source and navigate to New. In the list of objects, select the object that you want to create.

Configuring DDL generation settings

You can configure code settings for files that are generated for the DDL data source.

  1. In the Database tool window (View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon.

  2. On the Data Sources tab, select the DDL data source.

  3. Click the Generation tab.

Settings of the Generation tab

Option

Description

Layout

Defines the way how to store and generate DDL files.

  • File per object by schema: generate separate files for each object and place them in folders with schema names.

    File per object by schema
  • File per object: generate separate files for each object and place them in one directory.

    File per object
  • File per object with order: generate separate files for each object and add a numeric prefix to a filename.

    File per object with order

Root path

Defines the root directory for DDL files.

Code style

Applies the code style to generated DDL files.

Qualify objects with schema names

Adds a schema name to the table name. You can qualify a table when you have two and more tables with identical names in different schemes. This option has the following parameters:

  • Auto: automatically qualifies table names if you have more than two identical table names in different schemes.

  • Never: never qualifies table names.

  • Always: always qualifies table names.

Place constraints

Defines where to place FOREIGN KEY, UNIQUE, CHECK, and other constraints.

  • Inside column: into the column definition when the constraint is based on one column. When the constraint is based on two or more columns, place constraints into the table definition after all the columns.

    Place constraints inside column
  • Inside table: into the table definition, after all the columns.

    Place constraints inside table
  • After table: after the table definition, using ALTER TABLE ADD CONSTRAINT.

    Place constraints inside table

Regenerate database-provided code of property definitions

Regenerate property definitions that are provided as a part of source code by the database.

Reformat generated code

Reformat generated code with the current code style profile. This option affects generated code only and does not affect the code received directly from the server.

Last modified: 15 November 2021