# Tables management

The eKuiper REST api for tables allows you to manage the tables, such as create, describe, show and drop table definitions.

# create a table

The API is used for creating a table. For more detailed information of table definition, please refer to tables.

POST http://localhost:9081/tables
1

Request sample, the request is a json string with sql field.

{"sql":"create table my_table (id bigint, name string, score float) WITH ( datasource = \"lookup.json\", FORMAT = \"json\", KEY = \"id\")"}
1

This API can run any table sql statements, not only table creation.

# show tables

The API is used for displaying all of tables defined in the server.

GET http://localhost:9081/tables
1

Response Sample:

["mytable"]
1

# describe a table

The API is used for print the detailed definition of table.

GET http://localhost:9081/tables/{id}}
1

Response Sample:

{
  "Name": "demo",
  "StreamFields": [
    {
      "Name": "temperature",
      "FieldType": {
        "Type": 2
      }
    },
    {
      "Name": "ts",
      "FieldType": {
        "Type": 1
      }
    }
  ],
  "Options": {
    "DATASOURCE": "lookup.json",
    "FORMAT": "JSON"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# update a table

The API is used for update the table definition.

PUT http://localhost:9081/tables/{id}
1

Path parameter id is the id or name of the old table.

Request sample, the request is a json string with sql field.

{"sql":"create table my_table (id bigint, name string, score float) WITH ( datasource = \"topic/temperature\", FORMAT = \"json\", KEY = \"id\")"}
1

# drop a table

The API is used for drop the table definition.

DELETE http://localhost:9081/tables/{id}
1