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 schema › Info tab › Import Database Objects From Script
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 MySQLENUMcolumn). See Work with enums. - Descriptions, when the script contains description statements such as
sp_addextendedpropertyorCOMMENT 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:
- 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.
- Tables. Each table is parsed with AI into columns, types and constraints.
- Indexes are attached to their tables.
- Relationships. Foreign keys become Kenseme relationships.
- SQL objects. Views, procedures and functions are created in dependency order. Each is queued for analysis, which fills in its outputs, parameters and dependencies.
- Descriptions. Description statements found in the script are matched to objects and applied.
- Finish. The import is marked complete.
Tip: You don’t have to clean up your DDL first. SSMS headers,
GOseparators,SETstatements, 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¶
- One table. Use
Create Table›Paste Code. See Work with tables and columns. - Descriptions only. Use
Import Descriptionson theInfotab. See Browse a schema. - You can connect to the database. A connection import lets you review every change before it’s written.
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.