The Import Tables from DDL dialog reads CREATE TABLE statements from a document or another tool and turns them into NeoSQL tables. The new tables are virtual tables that do not exist in the database yet. Importing does not change the database; to create them there, go through Apply changes to the database. The difference between virtual tables and tables that exist in the database is explained in ERDs and the real database.
What's on the screen
| No. | Name | Description |
|---|---|---|
| 1 | Dialect: and Schema: | The syntax used to read the DDL is fixed by the connection's DBMS. The schema for the new tables is either fixed by where you opened the dialog, or chosen here. |
| 2 | Drop area | Drag a .sql file here or pick one with the Choose File button, and its content goes into the editor below. You can also pick a .txt file. |
| 3 | DDL editor | Paste or edit the DDL. When you stop typing, it is read again and the list on the right is updated. |
| 4 | Importable Tables (2) | The tables that were read, with their column, PK, FK and index counts. Unchecked tables are not imported. |
| 5 | Conflicting table | If a table or index with the same name already exists in the target schema, the table cannot be checked and the reason is shown under it. |
| 6 | Ignored Statements (2) and Parse Errors (0) | The statements that were not imported and the ones that could not be read, with line numbers. They appear only when there are such statements. |
| 7 | Summary and the Import 3 table(s) button | Shows how many tables are selected, parsed, conflicting and ignored. The Import 3 table(s) button creates the selected tables. |
Import Tables from DDL
- Open the dialog. You can open it from two places.
- Right-click an empty area of the ERD canvas and choose . It appears only in an ERD that has a connection.
- In the object explorer, right-click a connection, a database, a schema or a table group and choose .
- If the schema is not fixed, choose the schema for the new tables in the Schema: field (1).
- Paste the DDL into the editor (3), or drop a
.sqlfile on the drop area (2). - In Importable Tables (2) (4), check only the tables you want. For a conflicting table (5), read the reason; once you rename it in the DDL, you can select it again.
- Click the Import 3 table(s) button (7). The 3 virtual table(s) imported notification appears and the dialog closes.
- If you opened the dialog from the ERD canvas, the imported tables are placed on that ERD. If you opened it from the explorer, they are only added to the schema in the explorer; drag them onto the canvas to place them on an ERD.
- Until they are created in the database, the imported tables appear as virtual tables in the explorer and in ERDs. Create them in the database with the Apply Changes to DB... button in the info panel or on the table.
Statements that are imported and ignored
| Statement | What happens |
|---|---|
CREATE TABLE | Becomes one table, with its columns, primary key, foreign keys, indexes and comments. |
ALTER TABLE … ADD (column, constraint, index) | Merged into the table if the same DDL contains that table's CREATE TABLE. Otherwise ignored. |
CREATE INDEX | Merged into the table in the same DDL. Ignored if the target table is not in the DDL. |
Other statements (INSERT, DROP, SET, etc.) | Ignored. |
Statements merged into another table are also listed under Ignored Statements (2), with the name of the table they were merged into.
Syntax by DBMS
MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, Snowflake and BigQuery are read with their own syntax. Other DBMSs are read approximately with the closest syntax, and a badge such as Best-effort (Oracle → PostgreSQL) appears next to Dialect:, showing the syntax actually used. Oracle and H2 are read with the PostgreSQL syntax, Databricks with the Hive syntax, and other DBMSs with the MySQL syntax. An approximate read can miss some DBMS-specific syntax, so check the columns and types of the imported tables.
Things to keep in mind
- Importing runs nothing against the database. Do not start your application assuming the tables exist. To create them, use Apply changes to the database.
- Importing does not overwrite existing tables. A table with the same name is blocked as a conflict. To bring a table that exists in the database into an ERD, drag it from the explorer onto the canvas.
- In a system schema and in a disabled connection, the explorer's menu cannot be clicked.
- Statements are split at semicolons (
;). When you paste several statements, end each one with a semicolon.
Related screens
- ERD canvas: arrange the imported tables and refine their relationships.
- Apply changes to the database: create virtual tables in the database with
CREATE TABLE. - ERDs and the real database: how virtual tables differ from tables that exist in the database.