# How to create and query data on SQL Database

import DocButton from '~/components/webkit/DocButton.vue';
import Tag from '~/components/webkit/Tag.vue'




Once you've created your [SQL Database database](/en/documentation/products/guides/manage-sql-database/), you can begin creating tables and inserting data into them.

<DocButton href="/en/documentation/products/store/sql-database/" label="go to SQL Database reference" kind="secondary" size="medium" />

---

## Creating a table

Run the following `POST` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and `{id_database}` with the ID of the database you want to create a table into:

```bash
curl --location 'https://api.azion.com/v4/edge_sql/databases/{id_database}/query' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{ 
    "statements": [
        "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL);"
    ]
}'
```

You should receive the following response:

```json
{
  "state": "executed",
  "data": [
    {
      "results": {
        "columns": [],
        "rows": []
      }
    }
  ]
}
```

---

## Adding data into a table

Run the following `POST` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and `{id_database}` with the ID of the table you want to insert data into:

```bash
curl --location 'https://api.azion.com/v4/edge_sql/databases/{id_database}/query' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{ 
    "statements": [
        "INSERT INTO users VALUES (1, '\''item 1'\'');",
        "INSERT INTO users VALUES (2, '\''item 2'\'');",
        "INSERT INTO users VALUES (3, '\''item 3'\'');"
    ]
}'
```

You should receive the following response:

```json
{
  "state": "executed",
  "data": [
    {
      "results": {
        "columns": [],
        "rows": []
      }
    },
    {
      "results": {
        "columns": [],
        "rows": []
      }
    },
    {
      "results": {
        "columns": [],
        "rows": []
      }
    }
  ]
}
```

---

## Listing data in a table

Run the following `POST` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and `{id_database}` with the ID of the table you want to retrieve:

```bash
curl --location 'https://api.azion.com/v4/edge_sql/databases/{id_database}/query' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{ 
    "statements": [
        "SELECT * FROM users;"
    ]
}'
```

You should receive the following response:

```json
{
  "state": "executed",
  "data": [
    {
      "results": {
        "columns": [
          "id",
          "name"
        ],
        "rows": [
          [
            1,
            "item 1"
          ],
          [
            2,
            "item 2"
          ],
          [
            3,
            "item 3"
          ]
        ]
      }
    }
  ]
}
```