You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### 1.2 Automatically Create Tables via Session Insertion
52
-
53
-
When performing data writing through Session, IoTDB supports schema-less writing: there is no need to manually create tables beforehand. The system automatically constructs the table structure based on the information in the write request, and then directly executes the data writing operation.
for (long timestamp =0; timestamp <100; timestamp++) {
90
-
int rowIndex = tablet.getRowSize();
91
-
tablet.addTimestamp(rowIndex, timestamp);
92
-
tablet.addValue("region_id", rowIndex, "1");
93
-
tablet.addValue("plant_id", rowIndex, "5");
94
-
tablet.addValue("device_id", rowIndex, "3");
95
-
tablet.addValue("model", rowIndex, "A");
96
-
tablet.addValue("temperature", rowIndex, 37.6F);
97
-
tablet.addValue("humidity", rowIndex, 111.1);
98
-
if (tablet.getRowSize() == tablet.getMaxRowNumber()) {
99
-
session.insert(tablet);
100
-
tablet.reset();
101
-
}
102
-
}
103
-
if (tablet.getRowSize() !=0) {
104
-
session.insert(tablet);
105
-
tablet.reset();
106
-
}
107
-
}
108
-
```
109
-
110
-
After execution, you can verify the table creation using the following command:
111
-
112
-
```SQL
113
-
desc table1;
114
-
```
115
-
```shell
116
-
+-----------+---------+-----------+
117
-
| ColumnName| DataType| Category|
118
-
+-----------+---------+-----------+
119
-
| time|TIMESTAMP| TIME|
120
-
| region_id| STRING| TAG|
121
-
| plant_id| STRING| TAG|
122
-
| device_id| STRING| TAG|
123
-
| model| STRING| ATTRIBUTE|
124
-
|temperature| FLOAT| FIELD|
125
-
| humidity| DOUBLE| FIELD|
126
-
+-----------+---------+-----------+
127
-
```
128
-
129
-
### 1.3 Specified Column Insertion
50
+
### 1.2 Specified Column Insertion
130
51
131
52
It is possible to insert data for specific columns. Columns not specified will remain `null`.
132
53
@@ -138,7 +59,7 @@ INSERT INTO table1(region, plant_id, device_id, time, temperature, humidity) VAL
138
59
INSERT INTO table1(region, plant_id, device_id, time, temperature) VALUES ('Hamburg', '1001', '100', '2025-11-26 13:38:00', 91.0);
139
60
```
140
61
141
-
### 1.4 Null Value Insertion
62
+
### 1.3 Null Value Insertion
142
63
143
64
You can explicitly set `null` values for tag columns, attribute columns, and field columns.
144
65
@@ -157,7 +78,7 @@ If no tag columns are included, the system will automatically create a device wi
157
78
158
79
> **Note:** This operation will not only automatically populate existing tag columns in the table with `null` values but will also populate any newly added tag columns with `null` values in the future.
159
80
160
-
### 1.5 Multi-Row Insertion
81
+
### 1.4 Multi-Row Insertion
161
82
162
83
IoTDB supports inserting multiple rows of data in a single statement to improve efficiency.
163
84
@@ -182,13 +103,13 @@ VALUES
182
103
- Data type mismatches between the insertion data and the column's data type will result in an error code `DATA_TYPE_MISMATCH(614)`.
183
104
184
105
185
-
### 1.6 Query Write-back
106
+
### 1.5 Query Write-back
186
107
187
108
The IoTDB table model supports the **append-only query write-back** feature, implemented via the `INSERT INTO QUERY` statement. This feature allows writing the results of a query into an **existing** table.
188
109
189
110
> **Note**: This feature is available starting from version V2.0.6.
190
111
191
-
#### 1.6.1 Syntax Definition
112
+
#### 1.5.1 Syntax Definition
192
113
193
114
sql
194
115
@@ -297,7 +218,7 @@ Total line number = 2
297
218
It costs 0.014s
298
219
```
299
220
300
-
#### 1.6.2 Notes
221
+
#### 1.5.2 Notes
301
222
302
223
* The source table in the `query` and the target table `table_name` are allowed to be the same table, e.g., `INSERT INTO testtb SELECT * FROM testtb`.
303
224
* The target table **must already exist**; otherwise, the error message `550: Table 'xxx.xxx' does not exist` will be thrown.
@@ -316,9 +237,87 @@ It costs 0.014s
316
237
* For more details about user permissions, refer to [Authority Management](../User-Manual/Authority-Management_apache.md).
317
238
318
239
319
-
## 2. Data Updates
240
+
## 2. Schema-less Writing
241
+
242
+
When performing data writing through Session, IoTDB supports schema-less writing: there is no need to manually create tables beforehand. The system automatically constructs the table structure based on the information in the write request, and then directly executes the data writing operation.
0 commit comments