Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 34 additions & 21 deletions src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ All devices will definitely have a TTL, meaning it cannot be null. INF represent

IoTDB supports the device template function, enabling different entities of the same type to share metadata, reduce the memory usage of metadata, and simplify the management of numerous entities and measurements.

![img](/img/%E6%A8%A1%E6%9D%BF.png)
![](/img/%E6%A8%A1%E6%9D%BF.png)

![img](/img/templateEN.jpg)
![](/img/templateEN.jpg)

### 2.1 Create Device Template

Expand All @@ -367,17 +367,24 @@ CREATE DEVICE TEMPLATE <templateName> ALIGNED? '(' <measurementId> <attributeCla
**Example 1:** Create a template containing two non-aligned timeseries

```shell
IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN)
```

**Example 2:** Create a template containing a group of aligned timeseries

```shell
IoTDB> create device template t2 aligned (lat FLOAT encoding=Gorilla, lon FLOAT encoding=Gorilla)
IoTDB> create device template t2 aligned (lat FLOAT, lon FLOAT)
```

The` lat` and `lon` measurements are aligned.

When creating a template, the system will automatically assign default encoding and compression methods, requiring no manual specification. If your business scenario requires custom adjustments, you may refer to the following example:

```shell
IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
```
For a full list of supported data types and corresponding encoding methods, please refer to [Compression & Encoding](../Technical-Insider/Encoding-and-Compression.md)。


### 2.2 Set Device Template

Expand Down Expand Up @@ -574,7 +581,7 @@ In a scenario where measurements need to be added, you can modify the template
The SQL Statement for altering device template is as follow:

```shell
IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encoding=PLAIN compression=SNAPPY)
IoTDB> alter device template t1 add (speed FLOAT, FLOAT TEXT)
```

**When executing data insertion to devices with device template set on related prefix path and there are measurements not present in this device template, the measurements will be auto added to this device template.**
Expand All @@ -586,40 +593,46 @@ IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encodi
According to the storage model selected before, we can create corresponding timeseries in the two databases respectively. The SQL statements for creating timeseries are as follows:

```
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT,encoding=PLAIN
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT
```

From v0.13, you can use a simplified version of the SQL statements to create timeseries:

```
IoTDB > create timeseries root.ln.wf01.wt01.status BOOLEAN encoding=PLAIN
IoTDB > create timeseries root.ln.wf01.wt01.temperature FLOAT encoding=RLE
IoTDB > create timeseries root.ln.wf02.wt02.hardware TEXT encoding=PLAIN
IoTDB > create timeseries root.ln.wf02.wt02.status BOOLEAN encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.status BOOLEAN encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=RLE
IoTDB > create timeseries root.ln.wf01.wt01.status BOOLEAN
IoTDB > create timeseries root.ln.wf01.wt01.temperature FLOAT
IoTDB > create timeseries root.ln.wf02.wt02.hardware TEXT
IoTDB > create timeseries root.ln.wf02.wt02.status BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.status BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT
```

When creating a timeseries, the system will automatically assign default encoding and compression methods, requiring no manual specification. If your business scenario requires custom adjustments, you may refer to the following example:

```shell
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=PLAIN compressor=SNAPPY
```

Notice that when in the CREATE TIMESERIES statement the encoding method conflicts with the data type, the system gives the corresponding error prompt as shown below:
Note that if you manually specify an encoding method that is incompatible with the data type, the system will return an error message, as shown below:

```
IoTDB > create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF
error: encoding TS_2DIFF does not support BOOLEAN
```

Please refer to [Encoding](../Technical-Insider/Encoding-and-Compression.md) for correspondence between data type and encoding.
For a full list of supported data types and corresponding encoding methods, please refer to [Compression & Encoding](../Technical-Insider/Encoding-and-Compression.md)

### 3.2 Create Aligned Timeseries

The SQL statement for creating a group of timeseries are as follows:

```
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY)
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT, longitude FLOAT)
```

You can set different datatype, encoding, and compression for the timeseries in a group of aligned timeseries
Expand Down Expand Up @@ -879,7 +892,7 @@ The differences between tag and attribute are:
The SQL statements for creating timeseries with extra tag and attribute information are extended as follows:

```
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT, encoding=RLE, compression=SNAPPY tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
```

The `temprature` in the brackets is an alias for the sensor `s1`. So we can use `temprature` to replace `s1` anywhere.
Expand Down
56 changes: 35 additions & 21 deletions src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,27 @@ CREATE DEVICE TEMPLATE <templateName> ALIGNED? '(' <measurementId> <attributeCla
**Example 1:** Create a template containing two non-aligned timeseries

```shell
IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN)
```

**Example 2:** Create a template containing a group of aligned timeseries

```shell
IoTDB> create device template t2 aligned (lat FLOAT encoding=Gorilla, lon FLOAT encoding=Gorilla)
IoTDB> create device template t2 aligned (lat FLOAT, lon FLOAT)
```

The` lat` and `lon` measurements are aligned.

![img](/img/%E6%A8%A1%E6%9D%BF.png)
When creating a template, the system will automatically assign default encoding and compression methods, requiring no manual specification. If your business scenario requires custom adjustments, you may refer to the following example:

```shell
IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
```
For a full list of supported data types and corresponding encoding methods, please refer to [Compression & Encoding](../Technical-Insider/Encoding-and-Compression.md)。

![](/img/%E6%A8%A1%E6%9D%BF.png)

![img](/img/templateEN.jpg)
![](/img/templateEN.jpg)

### 2.2 Set Device Template

Expand Down Expand Up @@ -575,7 +582,7 @@ In a scenario where measurements need to be added, you can modify the template
The SQL Statement for altering device template is as follow:

```shell
IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encoding=PLAIN compression=SNAPPY)
IoTDB> alter device template t1 add (speed FLOAT, FLOAT TEXT)
```

**When executing data insertion to devices with device template set on related prefix path and there are measurements not present in this device template, the measurements will be auto added to this device template.**
Expand All @@ -587,40 +594,47 @@ IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encodi
According to the storage model selected before, we can create corresponding timeseries in the two databases respectively. The SQL statements for creating timeseries are as follows:

```
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT,encoding=PLAIN
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT
```

From v0.13, you can use a simplified version of the SQL statements to create timeseries:

```
IoTDB > create timeseries root.ln.wf01.wt01.status BOOLEAN encoding=PLAIN
IoTDB > create timeseries root.ln.wf01.wt01.temperature FLOAT encoding=RLE
IoTDB > create timeseries root.ln.wf02.wt02.hardware TEXT encoding=PLAIN
IoTDB > create timeseries root.ln.wf02.wt02.status BOOLEAN encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.status BOOLEAN encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=RLE
IoTDB > create timeseries root.ln.wf01.wt01.status BOOLEAN
IoTDB > create timeseries root.ln.wf01.wt01.temperature FLOAT
IoTDB > create timeseries root.ln.wf02.wt02.hardware TEXT
IoTDB > create timeseries root.ln.wf02.wt02.status BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.status BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT
```

Notice that when in the CREATE TIMESERIES statement the encoding method conflicts with the data type, the system gives the corresponding error prompt as shown below:
When creating a timeseries, the system will automatically assign default encoding and compression methods, requiring no manual specification. If your business scenario requires custom adjustments, you may refer to the following example:

```shell
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=PLAIN compressor=SNAPPY
```

Note that if you manually specify an encoding method that is incompatible with the data type, the system will return an error message, as shown below:

```
IoTDB > create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF
error: encoding TS_2DIFF does not support BOOLEAN
```

Please refer to [Encoding](../Technical-Insider/Encoding-and-Compression.md) for correspondence between data type and encoding.
For a full list of supported data types and corresponding encoding methods, please refer to [Compression & Encoding](../Technical-Insider/Encoding-and-Compression.md)。


### 3.2 Create Aligned Timeseries

The SQL statement for creating a group of timeseries are as follows:

```
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY)
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT, longitude FLOAT)
```

You can set different datatype, encoding, and compression for the timeseries in a group of aligned timeseries
Expand Down Expand Up @@ -921,7 +935,7 @@ The differences between tag and attribute are:
The SQL statements for creating timeseries with extra tag and attribute information are extended as follows:

```
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT, encoding=RLE, compression=SNAPPY tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
```

The `temprature` in the brackets is an alias for the sensor `s1`. So we can use `temprature` to replace `s1` anywhere.
Expand Down
10 changes: 5 additions & 5 deletions src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ Result:
##### Insert sql
```sql
"CREATE DATABASE root.db",
"CREATE TIMESERIES root.db.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN tags(city=Beijing)",
"CREATE TIMESERIES root.db.d1.s1 WITH DATATYPE=INT32 tags(city=Beijing)",
"INSERT INTO root.db.d1(timestamp,s1,s2,s3) values(1, 2, 10, true)",
"INSERT INTO root.db.d1(timestamp,s1,s2,s3) values(2, null, 20, true)",
"INSERT INTO root.db.d1(timestamp,s1,s2,s3) values(3, 10, 0, null)",
Expand Down Expand Up @@ -715,10 +715,10 @@ Result:
##### Insert sql
```sql
CREATE DATABASE root.db;
CREATE TIMESERIES root.db.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN;
CREATE TIMESERIES root.db.d1.s2 WITH DATATYPE=INT32, ENCODING=PLAIN;
CREATE TIMESERIES root.db.d2.s1 WITH DATATYPE=INT32, ENCODING=PLAIN;
CREATE TIMESERIES root.db.d2.s2 WITH DATATYPE=INT32, ENCODING=PLAIN;
CREATE TIMESERIES root.db.d1.s1 WITH DATATYPE=INT32;
CREATE TIMESERIES root.db.d1.s2 WITH DATATYPE=INT32;
CREATE TIMESERIES root.db.d2.s1 WITH DATATYPE=INT32;
CREATE TIMESERIES root.db.d2.s2 WITH DATATYPE=INT32;
INSERT INTO root.db.d1(time, s1) VALUES(0, 0), (4,4), (5,5), (8,8);
INSERT INTO root.db.d1(time, s2) VALUES(1, 1), (2,2), (5,5), (7,7), (8,8), (9,9);
INSERT INTO root.db.d2(time, s1) VALUES(1, 1), (2,2), (5,5), (7,7), (8,8);
Expand Down
36 changes: 18 additions & 18 deletions src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ For more details, see document [Operate-Metadata](../Basic-Concept/Operate-Metad
**Example 1:** Create a template containing two non-aligned timeseires

```shell
IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN)
```

**Example 2:** Create a template containing a group of aligned timeseires

```shell
IoTDB> create device template t2 aligned (lat FLOAT encoding=Gorilla, lon FLOAT encoding=Gorilla)
IoTDB> create device template t2 aligned (lat FLOAT, lon FLOAT)
```

The` lat` and `lon` measurements are aligned.
Expand Down Expand Up @@ -179,7 +179,7 @@ IoTDB> drop device template t1
### 2.8 Alter Device Template

```sql
IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encoding=PLAIN compression=SNAPPY)
IoTDB> alter device template t1 add (speed FLOAT, FLOAT TEXT)
```

## 3. TIMESERIES MANAGEMENT
Expand All @@ -189,36 +189,36 @@ For more details, see document [Operate-Metadata](../Basic-Concept/Operate-Metad
### 3.1 Create Timeseries

```sql
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT,encoding=PLAIN
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT
```

- From v0.13, you can use a simplified version of the SQL statements to create timeseries:

```sql
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT,encoding=PLAIN
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN,encoding=PLAIN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT,encoding=RLE
IoTDB > create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT
IoTDB > create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT
IoTDB > create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN
IoTDB > create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT
```

- Notice that when in the CREATE TIMESERIES statement the encoding method conflicts with the data type, the system gives the corresponding error prompt as shown below:

```sql
IoTDB > create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF
IoTDB > create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN
error: encoding TS_2DIFF does not support BOOLEAN
```

### 3.2 Create Aligned Timeseries

```sql
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY)
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT , longitude FLOAT)
```

### 3.3 Delete Timeseries
Expand Down Expand Up @@ -260,7 +260,7 @@ IoTDB > COUNT TIMESERIES root.ln.wf01.* GROUP BY LEVEL=2
### 3.6 Tag and Attribute Management

```sql
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT, encoding=RLE, compression=SNAPPY tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
```

* Rename the tag/attribute key
Expand Down
Loading