Skip to main content

Pulling from the database

In DataStar, Database Pull is how you take the current state of a schema object or set of rows out of a live database and produce a re-runnable SQL script in your workspace. Inside the application menus and toolbar you'll see the action labelled DB Pull / Database Pull; internally this is also called extraction, and the MCP tools (for example extract_to_workspace) use that word.

Prerequisites

  • A database connection active in the status bar.
  • A template that matches the component; the template drives what the generated script looks like.

Three destinations

DestinationMenu / toolbar entryShortcut
Workspace fileDatabase Pull to Workspace / DB PullCtrl+Shift+D
Draft file (reviewable copy held aside)Database Pull to Draft / Pull to DraftCtrl+D
Any folder (one-off)Database Pull to Folder…

All three appear on the component grid's toolbar and right-click menu.

Pull to workspace

Overwrites the workspace file with the generated script. Use this when you're certain the pulled version is the one you want.

  1. Open the component's category tab from the Data Components or Object Components menu.
  2. Select one or more rows.
  3. Click DB Pull on the toolbar (or right-click → Database Pull to Workspace).
  4. When the pull completes, the grid updates: the Extracted column gets today's timestamp and the Extracted From column gets the current connection name.

Pull to draft

Writes the pulled SQL to a draft file instead of overwriting the workspace. You then review the draft, and either Apply it to the workspace or Discard it.

Use this when:

  • The component is shared and someone else might have unsaved changes to the workspace copy.
  • You want to see a diff of what's changed before accepting it.

Pull to a folder

Database Pull to Folder… writes the generated script to a folder you pick, without touching the workspace at all. Use this for one-offs: handing a script to a DBA, comparing two environments, or populating a scratch folder for experimentation.

What happens during a pull

For object components (tables, views, procedures, functions, triggers) DataStar reads the object definition from the database and applies the template's options (permissions, indexes, CREATE OR ALTER vs CREATE, collation handling, etc.) to produce the CREATE script.

For data components (rows in reference / configuration tables) DataStar runs the template's queries, resolves alternative keys and lookups, and emits a re-runnable MERGE script.

The full template reference is in the data component schema and the object component schema.

What's next