> For the complete documentation index, see [llms.txt](https://docs.reorc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reorc.com/cn-reorc-help-center/advanced_usage/bian-liang/xiang-mu-nei-zi-ding-yi-bian-liang.md).

# 项目内自定义变量

## 自定义变量

按照以下步骤定义项目变量：

1. 打开 Recurve 项目，进入 **库/ Library > 变量/ Variables。**
2. 点击 **+ “新建/ Add New”。**
3. 输入变量名称、数据类型、描述和默认值。

   Recurve 支持创建带有显式数据类型的项目变量。

<figure><img src="/files/r34sNlCkoxJ0Y7JJInwm" alt=""><figcaption></figcaption></figure>

4. 点击 **“创建/ Add”。**

新创建的变量将显示在 **库/ Library** 的 **变量/ Variables** 部分。

默认情况下，创建的变量是启用状态，可以立即在模型中使用。如果需要停用变量，可以通过关闭 “**启用/ Active**” 选项来禁用它。

## 使用自定义变量

你可以在模型中使用 `{{ var('variable_name') }}` 表达式来引用已定义的变量。

例如，以下模型使用了在项目库中定义的 `min_order_dateime` 变量。

```sql
select 
    id as order_id,
    customer as customer_id,
    ordered_at as order_date

from {{ source("jaffle_shop", "raw_orders") }}

where ordered_at >= {{ var('min_order_datetime') }}
```
