# Create a DDL data source using SQL files

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

DDL data source is a virtual view of a database structure based on SQL files that contain data definition language statements (DDL statements). You can reference all tables, columns and other objects defined in such files in the editor. Diagrams are also supported.

To create a DDL data source using SQL files, create new SQL files that contain the required statements to define database objects and data for the data source.

For more information about DDL data sources, refer to the [DDL data sources](ddl-data-sources.html) topic.

## Step 1. Define a table in an SQL file

In the  In the  Project tool window ,  right-click a directory and select `New | SQL File`. Specify a name for the SQL file.

Open the SQL file and define the following table structure in our file:

```SQL
CREATE TABLE family (
  member_id INT NOT NULL,
  name VARCHAR(50),
  relation VARCHAR(50)
);
```

1.

For inserting the `CREATE TABLE` statement, there is a predefined pattern. Press `Ctrl+J` (Windows), `⌘ J` (macOS), `⌘ J` (IntelliJ IDEA Classic (macOS)), `⌘ J` (macOS System Shortcuts), `Ctrl+J` (XWin), `Ctrl+J` (GNOME), `Ctrl+J` (KDE), `Ctrl+J` (Emacs), `Ctrl+J` (Sublime Text), `Ctrl+J` (Sublime Text (macOS)), `Ctrl+J` (VSCode), `Ctrl+J` (VSCode (macOS)) and select the pattern `tab - new table definition`.

2.  Type the table name `family`.

3.  To switch from `family` to `col`, press `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Enter` (VSCode), `⏎` (VSCode (macOS)). Replace `col` with `member_id`.

4.  Type the remaining part of the table definition.

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/db_work_with_ddl_define_sql_table.mp4)

## Step 2. Create a DDL data source from the SQL file

To create a table from the SQL file, drag the SQL file with the defined table to the    Database   tool window  ( `View  | Tool Windows |  Database` ) .

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/db_work_with_ddl_drag_sql_file_to_create_data_source.mp4)

## Step 3. Define data for the data source

Now we are going to create an SQL file for adding data to the table. On Step 2, the SQL file was defined as a data source, the names of the table and of its columns as well as the info about corresponding data types are now available in the editor.

1.

Create an SQL file.

let's add this simple `INSERT` statement into the file:

```SQL
insert into family (member_id, name, relation) values (1, 'Chloe', 'mother');
```

2.  Add the `INSERT` statement by selecting the corresponding predefined pattern: `Ctrl+J` (Windows), `⌘ J` (macOS), `⌘ J` (IntelliJ IDEA Classic (macOS)), `⌘ J` (macOS System Shortcuts), `Ctrl+J` (XWin), `Ctrl+J` (GNOME), `Ctrl+J` (KDE), `Ctrl+J` (Emacs), `Ctrl+J` (Sublime Text), `Ctrl+J` (Sublime Text (macOS)), `Ctrl+J` (VSCode), `Ctrl+J` (VSCode (macOS)) | `ins - insert rows into a table`.

3.  Select the table name `family`.

4.  Select the list of column names `member_id, name, relation`.

5.  When specifying the values, press `Ctrl+P` (Windows), `⌘ P` (macOS), `⌘ P` (IntelliJ IDEA Classic (macOS)), `⌘ P` (macOS System Shortcuts), `Ctrl+P` (XWin), `Ctrl+P` (GNOME), `Ctrl+P` (KDE), `Alt+Shift+P` (Emacs), `Ctrl+P` (Sublime Text), `Ctrl+P` (Sublime Text (macOS)), `Ctrl+Shift+Space` (VSCode), `⌘ ⇧ Space` (VSCode (macOS)) (`View | Parameter Info`) to see the information about the value types.

