Skip to content
Create, Drop table

Create, Drop table

The HTTP “Query” API doesn’t accept only “SELECT” SQL but also DDL. So it is possible to create and drop tables via HTTP API

Token authentication is enabled by default. For the examples below, obtain an API token as described in API Security and replace <API_TOKEN> with your token.

Create table

Please refer to the docs for understanding what is the Tag Tables

Request

```http
GET http://127.0.0.1:5654/db/query
    ?q=create tag table EXAMPLE (name varchar(40) primary key, time datetime basetime, value double)
Authorization: Bearer <API_TOKEN>
```

Response

{"success":true,"reason":"Created successfully.","elapse":"92.489922ms"}

IF NOT EXISTS

```http
GET http://127.0.0.1:5654/db/query
    ?q=create tag table if not exists EXAMPLE (name varchar(40) primary key, time datetime basetime, value double)
Authorization: Bearer <API_TOKEN>
```

TAG STATISTICS

```http
GET http://127.0.0.1:5654/db/query
    q=create tag table EXAMPLE (name varchar(40) primary key, time datetime basetime, value double summarized)
Authorization: Bearer <API_TOKEN>
```
📢
Note The keyword “summarized” refers to the automatic generation of statistics on the internal tag data structure when data is written into the corresponding tag table. For more detailed information, please refer to the link below. Tag Statistics

Drop table

Request

```http
GET http://127.0.0.1:5654/db/query
    ?q=drop table EXAMPLE
Authorization: Bearer <API_TOKEN>
```

Response

{"success":true,"reason":"Dropped successfully.","elapse":"185.37292ms"}
Last updated on