# How to manage an SQL Database database

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



**SQL Database** allows you to create and manage relational databases. This guide covers how to create, list, and delete a database using the [Azion API](https://api.azion.com).

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

After creating a database, read [How to create an SQL Database query](/en/documentation/products/guides/create-tables-sql-database/) to populate your database.

---

## Creating a database

Run the following `POST` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and `name` with the desired database name to create a new database:

```bash
curl --location 'https://api.azion.com/v4/edge_sql/databases' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{
   "name": "my-database"
}'
```

You should receive the following response:

```json
{
  "state": "pending",
  "data": {
    "id": 118,
    "name": "my-database",
    "client_id": "6832h",
    "status": "creating",
    "created_at": "2024-04-18T11:22:59.468536Z",
    "updated_at": "2024-04-18T11:22:59.468586Z",
    "deleted_at": null
  }
}
```

:::note
The creation of a database isn't instantaneous. You can run `GET` requests to check when the `status` param changes to `created`, meaning you can already use the database.
:::
---

## Listing all databases

Run the following `GET` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/):

```bash
curl --location 'https://api.azion.com/v4/edge_sql/databases' \
--header 'Authorization: Token [TOKEN VALUE]'
```

You should receive the following response:

```json
{
  "count": 1,
  "links": {
    "first": null,
    "last": null,
    "next": null,
    "prev": null
  },
  "results": [
    {
      "id": 118,
      "name": "my-database",
      "client_id": "6832h",
      "status": "created",
      "created_at": "2024-04-15T15:15:10.200345Z",
      "updated_at": "2024-04-15T15:15:47.332481Z",
      "deleted_at": null
    }
  ]
}
```

This endpoint lists all the databases created in your account.

---

## Listing a specific database

Run the following `GET` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and `{id_database}` with the specific `id` of the database you've retrived in the [GET all request](#listing-all-databases):

```bash
curl --location 'https://api.azion.com/v4/edge_sql/databases/{id_database}' \
--header 'Authorization: Token [TOKEN VALUE]'
```

You should receive the following response:

```json
{
  "data": {
    "id": 118,
    "name": "my-database",
    "client_id": "6832h",
    "status": "created",
    "created_at": "2024-04-18T11:22:59.468536Z",
    "updated_at": "2024-04-18T11:23:18.492883Z",
    "deleted_at": null
  }
}
```

This endpoint lists only the information regarding the specific database whose ID you've provided.

---

## Deleting a database

Run the following `DELETE` 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 delete:

```bash
curl --location --request DELETE 'https://api.azion.com/v4/edge_sql/databases/{id_database}' \
--header 'Authorization: Token [TOKEN VALUE]'
```

:::note
This action can't be undone, but there's a propagation time. After deleting a database, you won't be able to retrieve its information.
:::