Inline DCM¶
With inline DCM, you plan or deploy DCM definitions that you write inline
in a SQL statement, without a DCM Project object. You write DEFINE, GRANT, and ATTACH statements in the
BEGIN ... END block of an EXECUTE DCM statement. Snowflake compiles the statements, sorts them by
their dependencies, and returns the same changeset as a DCM project plan.
Inline DCM supports PLAN and DEPLOY only. Because it doesn’t require a DCM Project object, you don’t need additional
privileges to create one, you don’t create any files such as a manifest file, and you don’t manage a project or its
artifacts. Each execution is completely ephemeral.
When to use inline DCM¶
Use inline DCM to:
- Try DCM definitions without creating a DCM project.
- Check how a change affects objects that already exist before you apply it. A plan reports every object that the definitions would change, and it fails when a change breaks an object in the block that depends on it. For a walkthrough, see Change existing objects.
- Set up the objects that a DCM project needs before you create it, such as the project owner role, the database and schema for the project object, a warehouse, and the grants. For an example, see Set up the objects for a DCM project.
- Change started tasks and alerts without suspending them first. For an example, see Change started tasks and alerts.
- Apply declarative definitions from a SQL script, a Snowflake Scripting block, or a SQL stored procedure.
- Let an AI agent propose a change. In the prompt, ask the agent to write the change as DCM definitions and to run
EXECUTE DCM ... PLAN, so that it validates the change against the account and shows you the changeset before anything is deployed.
Use a DCM project instead when you want the objects managed over time. A project gives you drift detection, drops objects when you remove their definitions, keeps a deployment history, and supports Jinja templating and project assets. For details, see How inline DCM differs from a DCM project.
How inline DCM differs from a DCM project¶
Inline DCM has the same compilation, dependency ordering, and changeset as a DCM project. DEPLOY also runs an internal
plan, the same way EXECUTE DCM PROJECT ... DEPLOY does, and then applies the changes. The differences are:
- No managed objects:
The statements and the objects they define aren’t managed by any DCM project. Every run is completely independent of any
previous run. Removing a statement from a later run doesn’t drop the object that an earlier run deployed. Inline DCM
doesn’t take ownership of the objects, grants, or attachments, so it doesn’t record a project mapping. It can change an
object that a DCM project already manages, including with
GRANT OWNERSHIP. The project keeps its mapping, and the project’s nextPLANorDEPLOYreports the drift. Inline DCM rejects aDEFINE TASK GRAPHwhose root task is outside the inline body, and it doesn’t change that task. - No project owner role: Inline DCM always runs with caller’s rights, using the privileges of the role that runs the statement.
- No deployment history or artifacts:
Executions don’t appear in any DCM deployment history, and inline DCM doesn’t store any artifacts. Each
PLANandDEPLOYis a query, so the statement and its changeset appear in query history. - No templating: Definitions don’t support Jinja templating or variables.
- No project files or assets:
There is no project directory and no
manifest.yml, so there are no project assets. Definitions that require a project asset, such asDEFINE CODE BUNDLEorDEFINE STREAMLIT, can’t be used.
Supported definitions¶
Inline DCM supports the object types, grants, and attachments listed in
Supported entities in DCM Projects, except definitions that require a
project asset, such as
DEFINE CODE BUNDLE or DEFINE STREAMLIT.
Note
During the preview, the list of supported definitions is subject to change.
An inline body can define a secret.
The secret value is masked in query history, the same way as for a standalone CREATE SECRET statement, and the deployed
secret keeps the value.
Definitions must use fully qualified names. An unqualified name fails with an Unqualified name error.
Plan and deploy definitions¶
Plan the definitions first, review the changeset, and then deploy the same definitions.
Plan the definitions¶
Plan the creation of a database and a schema, and a grant on the schema. The schema definition is written before the database definition. Inline DCM compiles the statements, sorts them, and creates the database first:
PLAN reports which objects would change, and it doesn’t apply any changes. It also validates the definitions against
the account. For more information, see Validate definitions against the account.
Review the changeset¶
When you run EXECUTE DCM ... PLAN or EXECUTE DCM ... DEPLOY in a SQL file in Workspaces, the results pane opens the
DCM tab, which renders the changeset in a format that’s easier for humans to read. The DCM tab lists every
affected object with its operation, such as CREATE or ALTER, and you can expand an object to see its detailed changes,
such as added grants and privileges:

The changeset also includes the objects that the definitions change but don’t define. For example, the plan of the database
and the schema doesn’t define the PUBLIC role, but it reports an ALTER of PUBLIC for the new grant. The plan also
reports an ALTER of the role that runs the statement, which receives the OWNERSHIP privilege on each new object, and a
CREATE of the PUBLIC schema that Snowflake creates in the new database. Review these operations too, not only the
objects in the block.
The result of a plan is one OBJECT value, so you can also query it. Run the following query right after
EXECUTE DCM ... PLAN to list one row per operation:
For the format of the changeset, see PLAN and DEPLOY output.
Validate definitions against the account¶
A plan compiles each definition against the current state of the account. Besides the syntax, it checks that the objects and columns that a definition references exist and that the current role can access them, that a change to an existing object, such as a new data type for a column, is one that Snowflake can apply, and that the current role has the privileges to make the change.
For example, suppose the following table exists:
The following plan succeeds, because the table and its columns exist, and reports a CREATE of the view:
If the view selects a column that the table doesn’t have, the plan fails. The following plan fails with an
invalid identifier 'CURRENCY' error, and nothing changes in the account:
If the view selects from a table that doesn’t exist, or that the current role can’t access, the plan fails with an error that names the table.
Deploy the definitions¶
Deploy the same definitions after you have reviewed the plan:
DEPLOY plans the definitions again and then applies the changes. It doesn’t execute a PLAN result that you saved
earlier.
Warning
DEPLOY isn’t atomic and doesn’t run in a transaction. If its internal plan fails, no changes are applied. If it fails
while it applies the changes, the changes applied before the failure remain, and Snowflake doesn’t roll them back. For
example, DEPLOY fails part way when another session drops a table that a view in the block selects from, after the
internal plan has succeeded. Fix the cause and run the same DEPLOY again, which applies only the remaining changes.
Change existing objects¶
To change an object that already exists, start from its current definition, check that the plan is empty, and then change the definitions. A plan validates the definitions in the block against the account, but it doesn’t recheck objects outside the block that depend on the objects that you change. When you change an object, also include the views and other objects that depend on it, so that the plan reports a change that breaks them.
Suppose a table and a view that selects one of its columns already exist:
Get their current definitions as DEFINE statements. Call GET_DDL with TRUE as the third
argument, which returns fully qualified names, and replace create or replace with DEFINE:
Plan the definitions before you change anything:
The changeset is empty, so the definitions match the objects. If the view was created by a client that sends the
statement with its trailing semicolon, such as the Snowflake CLI snow sql command, the plan reports the view’s select_query
as changed. The only difference is that semicolon.
Now remove LEGACY_FLAG from the table and add STATUS. Keep the view in the block, so that the plan checks it against
the new table:
The plan fails with an invalid identifier 'LEGACY_FLAG' error for the view, and nothing changes in the account. If you
plan the table without the view, the plan succeeds and doesn’t report the broken view.
Update the view to select STATUS, and plan again:
The changeset contains an ALTER of the table, which removes LEGACY_FLAG and adds STATUS, and an ALTER of the
view. Deploying these definitions drops the LEGACY_FLAG column and its data.
Examples¶
Set up the objects for a DCM project¶
A DCM project needs objects that exist before you create it: a database and a schema for the project object, an owner role with the CREATE DCM PROJECT privilege on that schema, and usually a warehouse. Plan these objects inline, and then deploy them:
Also grant the owner role the privileges that the project’s definitions need, for example the CREATE DATABASE privilege
on the account if the project defines databases. After you deploy these definitions, use the owner role to create the DCM
project in MY_DCM_DB.PROJECTS. For more information, see
Create a DCM project.
Define a procedure and a task¶
Plan a database, a schema, a warehouse, a SQL stored procedure, and a task that calls the procedure on that warehouse. The
procedure body is one $$ string, and the task body is its own BEGIN ... END block:
Change started tasks and alerts¶
Snowflake doesn’t let you change a child task while its root task is started, or change an alert while it’s started.
ALTER TASK on the child task fails with an
Unable to update graph with root task ... since that root task is not suspended error, and ALTER ALERT fails with an
Unable to alter property for alert ... since it is not suspended error. Inline DCM applies these changes without you
suspending anything first.
Deploy a root task, a child task that runs after it, and an alert. Each definition sets the
desired state STARTED, so
the tasks and the alert run after the deployment:
Later, change the child task and the condition of the alert while they’re started. The block contains only the definitions that change:
Inline DCM finds the root task of CLEAN_EVENTS, suspends it, applies the change, and resumes it, so the root task doesn’t
need to be in the block. The alert gets the new condition. After the deployment, both tasks and the alert are still
started.
Change a pipeline of tables, views, and dynamic tables¶
A plan checks each definition against the definitions in the block that it depends on, so one plan validates a whole pipeline. Deploy a table, a view that filters it, and a dynamic table that aggregates the view:
Now rename the AMOUNT column of the view to NET_AMOUNT, and plan the table, the view, and the dynamic table together:
The plan fails with an invalid identifier 'AMOUNT' error for the dynamic table, which still selects the old column name,
and nothing changes in the account. If you plan the view without the dynamic table, the plan succeeds and doesn’t report
the broken dynamic table. For more information, see Change existing objects.
Update the dynamic table to select NET_AMOUNT, and plan again:
The changeset contains an ALTER of the view and an ALTER of the dynamic table. Deploy the same definitions to apply both
changes.
Attach tags and masking policies¶
Tags and masking policies on a column are attached with ATTACH statements, not set in DEFINE TABLE. Plan a table, a
tag on one of its columns, and a masking policy on the same column:
Define a role and its grants¶
Plan a role, the privileges it needs to read a table, and the grant of that role to SYSADMIN:
Besides the CREATE of each defined object, the changeset contains an ALTER of SYSADMIN, which receives the
MY_TEST_ANALYST role, although SYSADMIN isn’t defined in the block. It also contains an ALTER of the role that runs
the statement, which receives the OWNERSHIP privilege on each object that the plan creates. Review the changes to these
roles before you deploy, the same way as the changes to the objects in the block.