> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqlbuild.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Diff

> Compare virtual data environments.

In virtual mode, `sqb diff` compares VDE ref sets within the same physical target. It shows which models have different version hashes and, for changed models, reports schema and row-level differences.

## Basic usage

```bash theme={null}
sqb diff dev:pr_123
```

The format is `<left_vde>:<right_vde>`. Both VDEs must exist in the active physical target's state store.

## What diff shows

1. **Ref comparison** - which models have different version hashes between the two VDEs
2. **Schema differences** - column additions, removals, and type changes for changed models
3. **Row differences** - row counts, matched/unmatched rows, and changed column values

Identical refs are skipped by default so the output focuses on models that actually differ. A model with a different version hash is included in the comparison even if its resulting data happens to be identical.

## Options

```bash theme={null}
# Schema differences only (no row comparison)
sqb diff dev:pr_123 --schema-only

# Full row-level comparison
sqb diff dev:pr_123 --full

# Compare specific models
sqb diff dev:pr_123 --select fact_orders

# No color output
sqb --no-color diff dev:pr_123
```

## Working VDE guard

If either VDE is working (has stale models that haven't been built yet), diff is blocked by default because the comparison may be incomplete:

```bash theme={null}
# Blocked
sqb diff dev:pr_123

# Allowed with explicit override
sqb diff dev:pr_123 --allow-partial-diff
```

This guard prevents misleading diff output when one VDE has pending changes that haven't been materialized yet.

## Comparison with standard-mode diff

In standard mode, `sqb diff prod:dev` compares physical target schemas and data directly in the warehouse. In virtual mode, `sqb diff dev:pr_123` compares VDE pointer sets within a single physical target, then inspects the physical versions those pointers reference.

The output format is the same - schema diffs, row counts, changed columns, and example rows. The difference is what is being compared: physical targets vs virtual pointer sets.
