# SQL

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

The **SQL Editor** in Gaio DataOS allows users to write, run, and test custom SQL queries directly on tables within the selected project bucket. It's a powerful tool for advanced users who prefer full control over data manipulation using SQL.

***

## &#x20;How to Use the SQL Editor

***

### 1. **Access the SQL Editor**

* In the **Studio**, open the left-side panel under **Tasks**.
* Select the **SQL** option to open the code editor.

***

### 2. **Select the Bucket**

* At the top left, select the **bucket** that contains the tables you want to query.
* All available tables in that bucket will be listed below for reference.

***

### 3. **Write Your SQL Query**

* In the central editor area, type your SQL query.\
  Example:

  ```sql
  SELECT * FROM sales;
  ```
* The editor supports syntax highlighting for better readability and clarity.

***

### 4. **Run the Query**

* Click **Run query** to execute your SQL.
* The result will appear in a preview panel below the code.

You can paginate the result using the row limit control on the top right (`1,000` by default).

***

### 5. **Save Your Query**

* Click **Save** to store the SQL block as a reusable task or part of a data flow.

***

#### Additional Features

| Feature                  | Description                                              |
| ------------------------ | -------------------------------------------------------- |
| **Syntax Highlighting**  | Enhanced readability with colored keywords.              |
| **Result Table Preview** | View output immediately after running your query.        |
| **Multiple SQL Blocks**  | Add more SQL blocks using the **+** button.              |
| **Run Flow Integration** | SQL blocks can be integrated into larger data processes. |

***

#### Best Practices

* Use aliases for column names when working with JOINs.
* Avoid `SELECT *` in production queries — explicitly define your columns.
* Test queries with limited row counts before running on full datasets.

<br>


---

# 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.gaiodataos.com/tools/tasks/etl/sql.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.
