Import a schema

What schema import does

If you already have a database, you don’t need to enter it table by table. A script import reads a DDL script (or a YAML, JSON or plain-text description) and creates the objects it describes in a Kenseme schema.

In the app: Data Model › Schemas › your schemaInfo tab › Import Database Objects From Script

[screenshot]
The Import Database Objects From Script dialog, with the Upload file and Paste script options.

Two ways to import

Kenseme can import a schema from two kinds of source:

  • A script (this page and the pages that follow). You upload a file or paste text. Kenseme never connects to your database; it only reads what you give it.
  • A live database, through a saved connection. Kenseme reads the database catalog and shows you a list of changes to review before anything is written. See Import objects from a database connection.

What a script import creates

  • Tables, with columns, data types, primary keys, defaults and check constraints.
  • Indexes.
  • Foreign-key relationships.
  • Views, stored procedures and functions, with their SQL kept as written.
  • Enums, from columns limited to a list of values (for example CHECK (Status IN ('New','Open','Closed')), a PostgreSQL enum type, or a MySQL ENUM column). See Work with enums.
  • Descriptions, when the script contains description statements such as sp_addextendedproperty or COMMENT ON.

Existing objects are skipped, never overwritten. If a table in the script already exists in the schema, the import marks it Skipped and leaves your version alone. That makes it safe to import into a schema that already has content.

How it runs

The import runs in the background, in stages:

  1. Split the script. Kenseme breaks the file into individual objects and works out their dependencies. Small files are split by AI; larger files are split by pattern first.
  2. Tables. Each table is parsed with AI into columns, types and constraints.
  3. Indexes are attached to their tables.
  4. Relationships. Foreign keys become Kenseme relationships.
  5. SQL objects. Views, procedures and functions are created in dependency order. Each is queued for analysis, which fills in its outputs, parameters and dependencies.
  6. Descriptions. Description statements found in the script are matched to objects and applied.
  7. Finish. The import is marked complete.

Tip: You don’t have to clean up your DDL first. SSMS headers, GO separators, SET statements, comments and even surrounding prose are fine.

When to use it

  • You’re bringing an existing database design into Kenseme and have its DDL.
  • Someone gave you a YAML or JSON export from another tool.
  • You can’t give Kenseme a connection to the database, or don’t want to.

When to use something else

How long it takes

A few tables take seconds. Hundreds of objects can take several minutes, mostly in the tables and SQL objects stages. You can close the browser; the import keeps running.