Skip to article
Documentation

Modules, aliases, and visibility

Split a schema into modules without losing completion or safe refactoring.

On this page

Create a module#

Create modules/catalog.dbml:

Table catalog.products {
  id integer [pk]
  name varchar(240) [not null]
}

In main.dbml, import only the declaration you need:

use {
  table catalog.products as product
} from './modules/catalog'

Table order_lines {
  id integer [pk]
  product_id integer [not null]
}
Ref: order_lines.product_id > product.id

Place the caret after product. and invoke completion. Go to Declaration on the alias should open catalog.products in the module. The alias changes the exposed name; it does not rename the underlying table.

Import a whole schema or group#

Use schema catalog as shop to expose the schema under shop. References then use names such as shop.products. Importing a TableGroup also brings its member tables into the importing module’s visible model. Enums and table partials can be imported separately.

Unrelated declarations in the same project are not automatically visible just because indexing found them. This prevents completion from leaking every sibling module into the current schema.

Re-export a shared declaration#

use makes a declaration available to the current module. reuse also exposes it transitively to a module that imports this one. The downloadable shop’s catalog and billing modules use reuse for their shared timestamp partial.

Prefer explicit imports for a deliberately narrow module API. Use re-export only when downstream consumers should see that declaration too. If a reference unexpectedly disappears after splitting a file, inspect visibility before recreating the table.

Rename safely across modules#

Invoke Rename on the real table or column declaration and review imported uses, relationships, records, groups, and metadata. An ambiguous unqualified name should be qualified before editing. A quick fix that creates a missing column can target the imported table’s defining file, so inspect which file changed.

Completion in a module offers the imported account table in its visible scope.

Completion in a module offers the imported account table in its visible scope. Select the image to view it at full size.

Manual for version 2026.2.4 · Reviewed