# Create & edit Data Service

{% hint style="info" %}
Only users with Manage/Edit permission can create & edit the Data Service.
{% endhint %}

## Create a Data Service

To create a Data Service, follow these steps:

1. In your ReOrc project, go to **Data Service**.
2. Click on the **+** icon and select **Create data service.**
3. Provide the name for your Data Service.
4. Click **Create.**

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2FEfS2swDmygOC00MM5dT7%2FScreenshot%202025-02-26%20at%2016.43.43.png?alt=media&#x26;token=cd283121-800b-40df-a815-65099fcf7996" alt=""><figcaption></figcaption></figure>

## Define SQL query

1. Click **Edit query** to define/ edit SQL query of the Data Service.
2. In the query editor, define connection for your Data Service.
3. Input your SQL query.

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2Fz1NVw6zFgqeEhnnp12nr%2FScreenshot%202025-02-26%20at%2016.52.58.png?alt=media&#x26;token=aaeb96c4-92fc-4bf4-a891-410860d6b30b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
When SQL contains field aliases, please add "AS" explicitly and the corresponding identifier for the different databases, and avoid `SELECT *`syntax
{% endhint %}

For example:

```sql
SELECT
    o.id AS order_id,
    c.name AS customer_name,
    o.order_total
FROM
    database_name.table_name o
JOIN
    database_name.table_name c ON o.customer = c.id
WHERE
    o.order_status = 'completed';
```

4. Click **Update > Save** to confirm the changes.
5. View the query output in the **Data Preview** tab.

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2F9K5bfQITuxCLQlU8e0lM%2FScreenshot%202025-02-26%20at%2017.08.04.png?alt=media&#x26;token=e28b24f1-8e4b-4abc-b616-785c642e727f" alt=""><figcaption></figcaption></figure>

## Organize Data Services

To create a new folder, click on the action button of an existing folder and select **Add sub-folder**:

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2Fusi3kM993CPGMxlH6Nvl%2FScreenshot%202025-02-26%20at%2017.17.27%20(1).png?alt=media&#x26;token=a390f76c-da61-45bf-b633-2533d2fd2c81" alt=""><figcaption></figcaption></figure>

To move a Data Service into the new folder, click on the action button of the Data Service and select **Move to**. Then select the target folder from the list.

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2FAWNLgbMZEfruvMJpwoor%2FScreenshot%202025-02-26%20at%2017.18.55.png?alt=media&#x26;token=43351894-9b30-46bc-92b6-c3df7a9d1d0e" alt=""><figcaption></figcaption></figure>
