Skip to content

Commit 6e4bc86

Browse files
committed
Table Model SQL Manual, Dual Active, Docker English Document PR
1 parent 3280916 commit 6e4bc86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6778
-42
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# Sample Data
23+
24+
This chapter mainly introduces a simple temporal data application scenario and the modeling and example data in this scenario. All the example SQL statements in the IoTDB table model user manual can be executed under this modeling and example data.
25+
26+
## Data Structure
27+
28+
29+
Table 1 and Table 2 both have the following table structure:
30+
31+
![](https://alioss.timecho.com/docs/img/Sample_data02.png)
32+
33+
## Import Statement
34+
35+
The following is the SQL statement used to construct the above table structure and data. You can click here([sample_data.sql](https://alioss.timecho.com/upload/sample_data.sql))to download all the SQL statements and execute them in CLI to import the data into your IoTDB.
36+
37+
```SQL
38+
-- Create a table with table names that are close to business semantics. Here, we use table1 instead
39+
-- The time column does not need to be manually specified, IoTDB will automatically create it
40+
-- The unit of TTL is ms, so 1 year is 31536000000 ms
41+
create database database1;
42+
use database1;
43+
CREATE TABLE table1 (
44+
time TIMESTAMP TIME,
45+
region STRING TAG,
46+
plant_id STRING TAG,
47+
device_id STRING TAG,
48+
model_id STRING ATTRIBUTE,
49+
maintenance STRING ATTRIBUTE,
50+
temperature FLOAT FIELD,
51+
humidity FLOAT FIELD,
52+
status Boolean FIELD,
53+
arrival_time TIMESTAMP FIELD
54+
) WITH (TTL=31536000000);
55+
56+
CREATE TABLE table2 (
57+
time TIMESTAMP TIME,
58+
region STRING TAG,
59+
plant_id STRING TAG,
60+
device_id STRING TAG,
61+
model_id STRING ATTRIBUTE,
62+
maintenance STRING ATTRIBUTE,
63+
temperature FLOAT FIELD,
64+
humidity FLOAT FIELD,
65+
status Boolean FIELD,
66+
arrival_time TIMESTAMP FIELD
67+
) WITH (TTL=31536000000);
68+
69+
70+
71+
INSERT INTO table1(region, plant_id, device_id, model_id, maintenance, time, temperature, humidity, status, arrival_time) VALUES
72+
('北京', '1001', '100', 'A', '180', '2024-11-26 13:37:00', 90.0, 35.1, true, '2024-11-26 13:37:34'),
73+
('北京', '1001', '100', 'A', '180', '2024-11-26 13:38:00', 90.0, 35.1, true, '2024-11-26 13:38:25'),
74+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:38:00', NULL, 35.1, true, '2024-11-27 16:37:01'),
75+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:39:00', 85.0, 35.3, NULL, Null),
76+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:40:00', 85.0, NULL, NULL, '2024-11-27 16:37:03'),
77+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:41:00', 85.0, NULL, NULL, '2024-11-27 16:37:04'),
78+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:42:00', NULL, 35.2, false, Null),
79+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:43:00', NULL, Null, false, Null),
80+
('北京', '1001', '101', 'B', '180', '2024-11-27 16:44:00', NULL, Null, false, '2024-11-27 16:37:08'),
81+
('上海', '3001', '100', 'C', '90', '2024-11-28 08:00:00', 85.0, Null, NULL, '2024-11-28 08:00:09'),
82+
('上海', '3001', '100', 'C', '90', '2024-11-28 09:00:00', NULL, 40.9, true, NULL),
83+
('上海', '3001', '100', 'C', '90', '2024-11-28 10:00:00', 85.0, 35.2, NULL, '2024-11-28 10:00:11'),
84+
('上海', '3001', '100', 'C', '90', '2024-11-28 11:00:00', 88.0, 45.1, true, '2024-11-28 11:00:12'),
85+
('上海', '3001', '101', 'D', '360', '2024-11-29 10:00:00', 85.0, NULL, NULL, '2024-11-29 10:00:13'),
86+
('上海', '3002', '100', 'E', '180', '2024-11-29 11:00:00', NULL, 45.1, true, NULL),
87+
('上海', '3002', '100', 'E', '180', '2024-11-29 18:30:00', 90.0, 35.4, true, '2024-11-29 18:30:15'),
88+
('上海', '3002', '101', 'F', '360', '2024-11-30 09:30:00', 90.0, 35.2, true, NULL),
89+
('上海', '3002', '101', 'F', '360', '2024-11-30 14:30:00', 90.0, 34.8, true, '2024-11-30 14:30:17');
90+
91+
INSERT INTO table2(region, plant_id, device_id, model_id, maintenance, time, temperature, humidity, status, arrival_time) VALUES
92+
('北京', '1001', '100', 'A', '180', '2024-11-26 13:37:00', 90.0, 35.1, true, '2024-11-26 13:37:34'),
93+
('北京', '1001', '101', 'B', '180', '2024-11-27 00:00:00', 85.0, 35.1, true, '2024-11-27 16:37:01'),
94+
('上海', '3001', '100', 'C', '90', '2024-11-28 08:00:00', 85.0, 35.2, false, '2024-11-28 08:00:09'),
95+
('上海', '3001', '101', 'D', '360', '2024-11-29 00:00:00', 85.0, 35.1, NULL, '2024-11-29 10:00:13'),
96+
('上海', '3002', '100', 'E', '180', '2024-11-29 11:00:00', NULL, 45.1, true, NULL),
97+
('上海', '3002', '101', 'F', '360', '2024-11-30 00:00:00', 90.0, 35.2, true, NULL);
98+
```

0 commit comments

Comments
 (0)