diff --git a/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md b/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md index d2ebcb049..4196338da 100644 --- a/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md +++ b/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md @@ -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 @@ -367,17 +367,24 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' 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 @@ -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.** @@ -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 @@ -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. diff --git a/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md b/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md index f2dbb7e36..6a7d90b4d 100644 --- a/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md +++ b/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md @@ -365,20 +365,27 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' 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 @@ -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.** @@ -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 @@ -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. diff --git a/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md b/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md index 3c315f44f..328b2a66d 100644 --- a/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md +++ b/src/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md @@ -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)", @@ -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); diff --git a/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md b/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md index 1f0353e55..67737449a 100644 --- a/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md +++ b/src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md @@ -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. @@ -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 @@ -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 @@ -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 diff --git a/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md b/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md index d2ebcb049..4196338da 100644 --- a/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md +++ b/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md @@ -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 @@ -367,17 +367,24 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' 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 @@ -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.** @@ -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 @@ -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. diff --git a/src/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md b/src/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md index f2dbb7e36..6a7d90b4d 100644 --- a/src/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md +++ b/src/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md @@ -365,20 +365,27 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' 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 @@ -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.** @@ -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 @@ -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. diff --git a/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md b/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md index 3c315f44f..328b2a66d 100644 --- a/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md +++ b/src/UserGuide/latest/SQL-Manual/Function-and-Expression.md @@ -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)", @@ -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); diff --git a/src/UserGuide/latest/SQL-Manual/SQL-Manual.md b/src/UserGuide/latest/SQL-Manual/SQL-Manual.md index 1f0353e55..67737449a 100644 --- a/src/UserGuide/latest/SQL-Manual/SQL-Manual.md +++ b/src/UserGuide/latest/SQL-Manual/SQL-Manual.md @@ -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. @@ -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 @@ -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 @@ -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 diff --git a/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md b/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md index aaecbdd83..3552ca2cd 100644 --- a/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md +++ b/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md @@ -359,17 +359,23 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN) ``` **示例2:** 创建包含一组对齐序列的元数据模板 ```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) ``` 其中,物理量 `lat` 和 `lon` 是对齐的。 +创建模板时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +```shell +IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +``` +更多详细的数据类型与编码方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 + ### 2.2 挂载设备模板 元数据模板在创建后,需执行挂载操作,方可用于相应路径下的序列创建与数据写入。 @@ -557,7 +563,7 @@ IoTDB> drop device template t1 修改设备模板的 SQL 语句如下所示: ```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) ``` **向已挂载模板的路径下的设备中写入数据,若写入请求中的物理量不在模板中,将自动扩展模板。** @@ -570,39 +576,44 @@ IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encodi 根据建立的数据模型,我们可以分别在两个数据库中创建相应的时间序列。创建时间序列的 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 ``` 从 v0.13 起,可以使用简化版的 SQL 语句创建时间序列: ``` -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 +``` + +创建时间序列时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +``` +IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=PLAIN compressor=SNAPPY ``` -需要注意的是,当创建时间序列时指定的编码方式与数据类型不对应时,系统会给出相应的错误提示,如下所示: +需要注意的是,如果手动指定了编码方式,但与数据类型不对应时,系统会给出相应的错误提示,如下所示: ``` IoTDB> create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF error: encoding TS_2DIFF does not support BOOLEAN ``` -详细的数据类型与编码方式的对应列表请参见 [编码方式](../Technical-Insider/Encoding-and-Compression.md)。 +更多详细的数据类型与编码压缩方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 ### 3.2 创建对齐时间序列 创建一组对齐时间序列的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) ``` 一组对齐序列中的序列可以有不同的数据类型、编码方式以及压缩方式。 @@ -861,7 +872,7 @@ It costs 0.002s 所用到的扩展的创建时间序列的 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) ``` 括号里的`temprature`是`s1`这个传感器的别名。 diff --git a/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md b/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md index 85c9aa6e9..f20acc23c 100644 --- a/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md +++ b/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_timecho.md @@ -359,17 +359,23 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN ) ``` **示例2:** 创建包含一组对齐序列的元数据模板 ```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) ``` 其中,物理量 `lat` 和 `lon` 是对齐的。 +创建模板时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +```shell +IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +``` +更多详细的数据类型与编码方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 + ### 2.2 挂载设备模板 元数据模板在创建后,需执行挂载操作,方可用于相应路径下的序列创建与数据写入。 @@ -557,7 +563,7 @@ IoTDB> drop device template t1 修改设备模板的 SQL 语句如下所示: ```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) ``` **向已挂载模板的路径下的设备中写入数据,若写入请求中的物理量不在模板中,将自动扩展模板。** @@ -570,39 +576,45 @@ IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encodi 根据建立的数据模型,我们可以分别在两个数据库中创建相应的时间序列。创建时间序列的 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 ``` 从 v0.13 起,可以使用简化版的 SQL 语句创建时间序列: ``` -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 ``` -需要注意的是,当创建时间序列时指定的编码方式与数据类型不对应时,系统会给出相应的错误提示,如下所示: +创建时间序列时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +``` +IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=PLAIN compressor=SNAPPY +``` + +需要注意的是,如果手动指定了编码方式,但与数据类型不对应时,系统会给出相应的错误提示,如下所示: ``` IoTDB> create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF error: encoding TS_2DIFF does not support BOOLEAN ``` -详细的数据类型与编码方式的对应列表请参见 [编码方式](../Technical-Insider/Encoding-and-Compression.md)。 +更多详细的数据类型与编码压缩方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 + ### 3.2 创建对齐时间序列 创建一组对齐时间序列的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) ``` 一组对齐序列中的序列可以有不同的数据类型、编码方式以及压缩方式。 @@ -903,7 +915,7 @@ IoTDB> count timeseries where time >= 15000 and time < 16000; 所用到的扩展的创建时间序列的 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) ``` 括号里的`temprature`是`s1`这个传感器的别名。 diff --git a/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md b/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md index 883c63ca2..ef1f2fbe6 100644 --- a/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md +++ b/src/zh/UserGuide/Master/Tree/SQL-Manual/Function-and-Expression.md @@ -145,7 +145,7 @@ select count_if(s1=0 & s2=0, 3, 'ignoreNull'='false'), count_if(s1=1 & s2=0, 3, ##### 写入语句 ```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)", @@ -198,10 +198,10 @@ select time_duration(s1) from root.db.d1 ##### 写入语句 ```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); diff --git a/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md b/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md index cf86a4fd4..1b35aacd8 100644 --- a/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md +++ b/src/zh/UserGuide/Master/Tree/SQL-Manual/SQL-Manual.md @@ -40,36 +40,36 @@ count databases root.sgcc #### 创建时间序列 ```sql -create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN -create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT,encoding=RLE -create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT,encoding=PLAIN -create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN,encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN,encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT,encoding=RLE +create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN +create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT +create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT +create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN +create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN +create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT ``` - 简化版 ```sql -create timeseries root.ln.wf01.wt01.status BOOLEAN encoding=PLAIN -create timeseries root.ln.wf01.wt01.temperature FLOAT encoding=RLE -create timeseries root.ln.wf02.wt02.hardware TEXT encoding=PLAIN -create timeseries root.ln.wf02.wt02.status BOOLEAN encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.status BOOLEAN encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=RLE +create timeseries root.ln.wf01.wt01.status BOOLEAN +create timeseries root.ln.wf01.wt01.temperature FLOAT +create timeseries root.ln.wf02.wt02.hardware TEXT +create timeseries root.ln.wf02.wt02.status BOOLEAN +create timeseries root.sgcc.wf03.wt01.status BOOLEAN +create timeseries root.sgcc.wf03.wt01.temperature FLOAT ``` - 错误提示 ```sql -create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF +create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN > error: encoding TS_2DIFF does not support BOOLEAN ``` #### 创建对齐时间序列 ```sql -CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY) +CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT, longitude FLOAT) ``` #### 删除时间序列 @@ -116,7 +116,7 @@ COUNT TIMESERIES root.ln.wf01.* GROUP BY LEVEL=2 #### 标签点管理 ```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) ``` - 重命名标签或属性 @@ -267,11 +267,11 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN) ``` 创建包含一组对齐序列的设备模板 ```sql -IoTDB> create device template t2 aligned (lat FLOAT encoding=Gorilla, lon FLOAT encoding=Gorilla) +IoTDB> create device template t2 aligned (lat FLOAT, lon FLOAT) ``` #### 挂载设备模板 ```sql diff --git a/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md b/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md index aaecbdd83..3552ca2cd 100644 --- a/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md +++ b/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md @@ -359,17 +359,23 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN) ``` **示例2:** 创建包含一组对齐序列的元数据模板 ```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) ``` 其中,物理量 `lat` 和 `lon` 是对齐的。 +创建模板时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +```shell +IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +``` +更多详细的数据类型与编码方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 + ### 2.2 挂载设备模板 元数据模板在创建后,需执行挂载操作,方可用于相应路径下的序列创建与数据写入。 @@ -557,7 +563,7 @@ IoTDB> drop device template t1 修改设备模板的 SQL 语句如下所示: ```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) ``` **向已挂载模板的路径下的设备中写入数据,若写入请求中的物理量不在模板中,将自动扩展模板。** @@ -570,39 +576,44 @@ IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encodi 根据建立的数据模型,我们可以分别在两个数据库中创建相应的时间序列。创建时间序列的 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 ``` 从 v0.13 起,可以使用简化版的 SQL 语句创建时间序列: ``` -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 +``` + +创建时间序列时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +``` +IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=PLAIN compressor=SNAPPY ``` -需要注意的是,当创建时间序列时指定的编码方式与数据类型不对应时,系统会给出相应的错误提示,如下所示: +需要注意的是,如果手动指定了编码方式,但与数据类型不对应时,系统会给出相应的错误提示,如下所示: ``` IoTDB> create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF error: encoding TS_2DIFF does not support BOOLEAN ``` -详细的数据类型与编码方式的对应列表请参见 [编码方式](../Technical-Insider/Encoding-and-Compression.md)。 +更多详细的数据类型与编码压缩方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 ### 3.2 创建对齐时间序列 创建一组对齐时间序列的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) ``` 一组对齐序列中的序列可以有不同的数据类型、编码方式以及压缩方式。 @@ -861,7 +872,7 @@ It costs 0.002s 所用到的扩展的创建时间序列的 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) ``` 括号里的`temprature`是`s1`这个传感器的别名。 diff --git a/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md b/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md index 85c9aa6e9..825474b91 100644 --- a/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md +++ b/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_timecho.md @@ -359,17 +359,23 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN ) ``` **示例2:** 创建包含一组对齐序列的元数据模板 ```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) ``` 其中,物理量 `lat` 和 `lon` 是对齐的。 +创建模板时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +```shell +IoTDB> create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +``` +更多详细的数据类型与编码方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 + ### 2.2 挂载设备模板 元数据模板在创建后,需执行挂载操作,方可用于相应路径下的序列创建与数据写入。 @@ -557,7 +563,7 @@ IoTDB> drop device template t1 修改设备模板的 SQL 语句如下所示: ```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) ``` **向已挂载模板的路径下的设备中写入数据,若写入请求中的物理量不在模板中,将自动扩展模板。** @@ -570,39 +576,45 @@ IoTDB> alter device template t1 add (speed FLOAT encoding=RLE, FLOAT TEXT encodi 根据建立的数据模型,我们可以分别在两个数据库中创建相应的时间序列。创建时间序列的 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 ``` 从 v0.13 起,可以使用简化版的 SQL 语句创建时间序列: ``` -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 ``` -需要注意的是,当创建时间序列时指定的编码方式与数据类型不对应时,系统会给出相应的错误提示,如下所示: +创建时间序列时,系统会默认指定编码压缩方式,无需手动指定,若业务场景需要手动调整,可参考如下示例: +``` +IoTDB > create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=PLAIN compressor=SNAPPY +``` + +需要注意的是,如果手动指定了编码方式,但与数据类型不对应时,系统会给出相应的错误提示,如下所示: ``` IoTDB> create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF error: encoding TS_2DIFF does not support BOOLEAN ``` -详细的数据类型与编码方式的对应列表请参见 [编码方式](../Technical-Insider/Encoding-and-Compression.md)。 +更多详细的数据类型与编码压缩方式的对应列表请参见 [压缩&编码](../Technical-Insider/Encoding-and-Compression.md)。 + ### 3.2 创建对齐时间序列 创建一组对齐时间序列的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) ``` 一组对齐序列中的序列可以有不同的数据类型、编码方式以及压缩方式。 diff --git a/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md b/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md index 883c63ca2..ef1f2fbe6 100644 --- a/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md +++ b/src/zh/UserGuide/latest/SQL-Manual/Function-and-Expression.md @@ -145,7 +145,7 @@ select count_if(s1=0 & s2=0, 3, 'ignoreNull'='false'), count_if(s1=1 & s2=0, 3, ##### 写入语句 ```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)", @@ -198,10 +198,10 @@ select time_duration(s1) from root.db.d1 ##### 写入语句 ```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); diff --git a/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual.md b/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual.md index cf86a4fd4..1b35aacd8 100644 --- a/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual.md +++ b/src/zh/UserGuide/latest/SQL-Manual/SQL-Manual.md @@ -40,36 +40,36 @@ count databases root.sgcc #### 创建时间序列 ```sql -create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN -create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT,encoding=RLE -create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT,encoding=PLAIN -create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN,encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN,encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT,encoding=RLE +create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN +create timeseries root.ln.wf01.wt01.temperature with datatype=FLOAT +create timeseries root.ln.wf02.wt02.hardware with datatype=TEXT +create timeseries root.ln.wf02.wt02.status with datatype=BOOLEAN +create timeseries root.sgcc.wf03.wt01.status with datatype=BOOLEAN +create timeseries root.sgcc.wf03.wt01.temperature with datatype=FLOAT ``` - 简化版 ```sql -create timeseries root.ln.wf01.wt01.status BOOLEAN encoding=PLAIN -create timeseries root.ln.wf01.wt01.temperature FLOAT encoding=RLE -create timeseries root.ln.wf02.wt02.hardware TEXT encoding=PLAIN -create timeseries root.ln.wf02.wt02.status BOOLEAN encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.status BOOLEAN encoding=PLAIN -create timeseries root.sgcc.wf03.wt01.temperature FLOAT encoding=RLE +create timeseries root.ln.wf01.wt01.status BOOLEAN +create timeseries root.ln.wf01.wt01.temperature FLOAT +create timeseries root.ln.wf02.wt02.hardware TEXT +create timeseries root.ln.wf02.wt02.status BOOLEAN +create timeseries root.sgcc.wf03.wt01.status BOOLEAN +create timeseries root.sgcc.wf03.wt01.temperature FLOAT ``` - 错误提示 ```sql -create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN, ENCODING=TS_2DIFF +create timeseries root.ln.wf02.wt02.status WITH DATATYPE=BOOLEAN > error: encoding TS_2DIFF does not support BOOLEAN ``` #### 创建对齐时间序列 ```sql -CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT encoding=PLAIN compressor=SNAPPY, longitude FLOAT encoding=PLAIN compressor=SNAPPY) +CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT, longitude FLOAT) ``` #### 删除时间序列 @@ -116,7 +116,7 @@ COUNT TIMESERIES root.ln.wf01.* GROUP BY LEVEL=2 #### 标签点管理 ```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) ``` - 重命名标签或属性 @@ -267,11 +267,11 @@ CREATE DEVICE TEMPLATE ALIGNED? '(' create device template t1 (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY) +IoTDB> create device template t1 (temperature FLOAT, status BOOLEAN) ``` 创建包含一组对齐序列的设备模板 ```sql -IoTDB> create device template t2 aligned (lat FLOAT encoding=Gorilla, lon FLOAT encoding=Gorilla) +IoTDB> create device template t2 aligned (lat FLOAT, lon FLOAT) ``` #### 挂载设备模板 ```sql