# 项目内自定义变量

## 自定义变量

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

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') }}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.reorc.com/cn-reorc-help-center/advanced_usage/bian-liang/xiang-mu-nei-zi-ding-yi-bian-liang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
