blob: 717e5bf541b48adf06bbb421a8cf03410a107ba5 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[249],{814:function(e,t,a){"use strict";a.r(t);var s=a(68),i=Object(s.a)({},(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[a("h1",{attrs:{id:"dml-data-manipulation-language"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#dml-data-manipulation-language"}},[e._v("#")]),e._v(" DML (Data Manipulation Language)")]),e._v(" "),a("h2",{attrs:{id:"insert"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#insert"}},[e._v("#")]),e._v(" INSERT")]),e._v(" "),a("h3",{attrs:{id:"insert-real-time-data"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#insert-real-time-data"}},[e._v("#")]),e._v(" Insert Real-time Data")]),e._v(" "),a("p",[e._v("IoTDB provides users with a variety of ways to insert real-time data, such as directly inputting "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(" in Client/Shell tools, or using "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/4-Client/2-Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" to perform single or batch execution of "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(".")],1),e._v(" "),a("p",[e._v("This section mainly introduces the use of "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(" for real-time data import in the scenario. See Section 5.4 for a detailed syntax of "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(".")],1),e._v(" "),a("h4",{attrs:{id:"use-of-insert-statements"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#use-of-insert-statements"}},[e._v("#")]),e._v(" Use of INSERT Statements")]),e._v(" "),a("p",[e._v("The "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(" statement can be used to insert data into one or more specified timeseries that have been created. For each point of data inserted, it consists of a "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/2-Concept/1-Data Model and Terminology.html"}},[e._v("timestamp")]),e._v(" and a sensor acquisition value (see "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/2-Concept/2-Data Type.html"}},[e._v("Data Type")]),e._v(").")],1),e._v(" "),a("p",[e._v("In the scenario of this section, take two timeseries "),a("code",[e._v("root.ln.wf02.wt02.status")]),e._v(" and "),a("code",[e._v("root.ln.wf02.wt02.hardware")]),e._v(" as an example, and their data types are BOOLEAN and TEXT, respectively.")]),e._v(" "),a("p",[e._v("The sample code for single column data insertion is as follows:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v('IoTDB > insert into root.ln.wf02.wt02(timestamp,status) values(1,true)\nIoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1, "v1")\n')])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br")])]),a("p",[e._v('The above example code inserts the long integer timestamp and the value "true" into the timeseries '),a("code",[e._v("root.ln.wf02.wt02.status")]),e._v(' and inserts the long integer timestamp and the value "v1" into the timeseries '),a("code",[e._v("root.ln.wf02.wt02.hardware")]),e._v(". When the execution is successful, cost time is shown to indicate that the data insertion has been completed.")]),e._v(" "),a("blockquote",[a("p",[e._v("Note: In IoTDB, TEXT type data can be represented by single and double quotation marks. The insertion statement above uses double quotation marks for TEXT type data. The following example will use single quotation marks for TEXT type data.")])]),e._v(" "),a("p",[e._v("The INSERT statement can also support the insertion of multi-column data at the same time point. The sample code of inserting the values of the two timeseries at the same time point '2' is as follows:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("IoTDB > insert into root.ln.wf02.wt02(timestamp, status, hardware) VALUES (2, false, 'v2')\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("After inserting the data, we can simply query the inserted data using the SELECT statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("IoTDB > select * from root.ln.wf02 where time < 3\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The result is shown below. From the query results, it can be seen that the insertion statements of single column and multi column data are performed correctly.")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51605021-c2ee1500-1f48-11e9-8f6b-ba9b48875a41.png"}})]),e._v(" "),a("h3",{attrs:{id:"error-handling-of-insert-statements"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#error-handling-of-insert-statements"}},[e._v("#")]),e._v(" Error Handling of INSERT Statements")]),e._v(" "),a("p",[e._v("If the user inserts data into a non-existent timeseries, for example, execute the following commands:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v('IoTDB > insert into root.ln.wf02.wt02(timestamp, temperature) values(1,"v1")\n')])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("Because "),a("code",[e._v("root.ln.wf02.wt02. temperature")]),e._v(" does not exist, the system will return the following ERROR information:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("Msg: Current deviceId[root.ln.wf02.wt02] does not contain measurement:temperature\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("If the data type inserted by the user is inconsistent with the corresponding data type of the timeseries, for example, execute the following command:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("IoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1,100)\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The system will return the following ERROR information:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("error: The TEXT data type should be covered by \" or '\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("h2",{attrs:{id:"select"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#select"}},[e._v("#")]),e._v(" SELECT")]),e._v(" "),a("h3",{attrs:{id:"time-slice-query"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#time-slice-query"}},[e._v("#")]),e._v(" Time Slice Query")]),e._v(" "),a("p",[e._v("This chapter mainly introduces the relevant examples of time slice query using IoTDB SELECT statements. Detailed SQL syntax and usage specifications can be found in "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("SQL Documentation")]),e._v(". You can also use the "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/4-Client/2-Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" standard interface to execute related queries.")],1),e._v(" "),a("h4",{attrs:{id:"select-a-column-of-data-based-on-a-time-interval"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#select-a-column-of-data-based-on-a-time-interval"}},[e._v("#")]),e._v(" Select a Column of Data Based on a Time Interval")]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select temperature from root.ln.wf01.wt01 where time < 2017-11-01T00:08:00.000\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is the temperature sensor (temperature). The SQL statement requires that all temperature sensor values before the time point of "2017-11-01T00:08:00.000" be selected.')]),e._v(" "),a("p",[e._v("The execution result of this SQL statement is as follows:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/23614968/61280074-da1c0a00-a7e9-11e9-8eb8-3809428043a8.png"}})]),e._v(" "),a("h4",{attrs:{id:"select-multiple-columns-of-data-based-on-a-time-interval"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#select-multiple-columns-of-data-based-on-a-time-interval"}},[e._v("#")]),e._v(" Select Multiple Columns of Data Based on a Time Interval")]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status, temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000;\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires that the status and temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.')]),e._v(" "),a("p",[e._v("The execution result of this SQL statement is as follows:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/23614968/61280328-40a12800-a7ea-11e9-85b9-3b8db67673a3.png"}})])],1),e._v(" "),a("h4",{attrs:{id:"select-multiple-columns-of-data-for-the-same-device-according-to-multiple-time-intervals"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#select-multiple-columns-of-data-for-the-same-device-according-to-multiple-time-intervals"}},[e._v("#")]),e._v(" Select Multiple Columns of Data for the Same Device According to Multiple Time Intervals")]),e._v(" "),a("p",[e._v("IoTDB supports specifying multiple time interval conditions in a query. Users can combine time interval conditions at will according to their needs. For example, the SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where (time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000) or (time >= 2017-11-01T16:35:00.000 and time <= 2017-11-01T16:37:00.000);\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature"; the statement specifies two different time intervals, namely "2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000" and "2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000". The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.')]),e._v(" "),a("p",[e._v("The execution result of this SQL statement is as follows:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/23614968/61280449-780fd480-a7ea-11e9-8ed0-70fa9dfda80f.png"}})])],1),e._v(" "),a("h4",{attrs:{id:"choose-multiple-columns-of-data-for-different-devices-according-to-multiple-time-intervals"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#choose-multiple-columns-of-data-for-different-devices-according-to-multiple-time-intervals"}},[e._v("#")]),e._v(" Choose Multiple Columns of Data for Different Devices According to Multiple Time Intervals")]),e._v(" "),a("p",[e._v("The system supports the selection of data in any column in a query, i.e., the selected columns can come from different devices. For example, the SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select wf01.wt01.status,wf02.wt02.hardware from root.ln where (time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000) or (time >= 2017-11-01T16:35:00.000 and time <= 2017-11-01T16:37:00.000);\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected timeseries are "the power supply status of ln group wf01 plant wt01 device" and "the hardware version of ln group wf02 plant wt02 device"; the statement specifies two different time intervals, namely "2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000" and "2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000". The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.')]),e._v(" "),a("p",[e._v("The execution result of this SQL statement is as follows:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577450-dcfe0800-1ef4-11e9-9399-4ba2b2b7fb73.jpg"}})])],1),e._v(" "),a("h3",{attrs:{id:"down-frequency-aggregate-query"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query")]),e._v(" "),a("p",[e._v("This section mainly introduces the related examples of down-frequency aggregation query, using the "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("GROUP BY clause")]),e._v(", which is used to partition the result set according to the user's given partitioning conditions and aggregate the partitioned result set. IoTDB supports partitioning result sets according to time intervals, and by default results are sorted by time in ascending order. You can also use the "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/4-Client/2-Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" standard interface to execute related queries.")],1),e._v(" "),a("p",[e._v("The GROUP BY statement provides users with three types of specified parameters:")]),e._v(" "),a("ul",[a("li",[e._v("Parameter 1: Time interval for dividing the time axis")]),e._v(" "),a("li",[e._v("Parameter 2: Time axis origin position (optional)")]),e._v(" "),a("li",[e._v("Parameter 3: The display window(s) (one or more) on the time axis")])]),e._v(" "),a("p",[e._v("The actual meanings of the three types of parameters are shown in Figure 3.2 below. Among them, the paramter 2 is optional. Next we will give three typical examples of frequency reduction aggregation: parameter 2 specified, parameter 2 not specified, and time filtering conditions specified.")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577465-e8513380-1ef4-11e9-84c6-d0690f2a8113.jpg"}}),e._v("\n**Figure 5.2 The actual meanings of the three types of parameters**")]),e._v(" "),a("h4",{attrs:{id:"down-frequency-aggregate-query-without-specifying-the-time-axis-origin-position"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-without-specifying-the-time-axis-origin-position"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query without Specifying the Time Axis Origin Position")]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select count(status), max_value(temperature) from root.ln.wf01.wt01 group by (1d, [2017-11-01T00:00:00, 2017-11-07T23:00:00]);\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("Since the user does not specify the time axis origin position, the GROUP BY statement will by default set the origin at 0 (+0 time zone) on January 1, 1970.")]),e._v(" "),a("p",[e._v("The first parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (1d) as time interval and the default origin as the dividing origin, the time axis is divided into several continuous intervals, which are [0,1d], [1d, 2d], [2d, 3d], etc.")]),e._v(" "),a("p",[e._v("The second parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-11-01T00:00:00, 2017-11-07T23:00:00].")]),e._v(" "),a("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the second parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of [2017-11-01T00:00:00, 2017-11-07 T23:00:00]), and map these data to the previously segmented time axis (in this case there are mapped data in every 1-day period from 2017-11-01T00:00:00 to 2017-11-07T23:00:00:00).")]),e._v(" "),a("p",[e._v("Since there is data for each time period in the result range to be displayed, the execution result of the SQL statement is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577537-277f8480-1ef5-11e9-9b0f-c477f3b71acb.jpg"}})]),e._v(" "),a("h4",{attrs:{id:"down-frequency-aggregate-query-specifying-the-time-axis-origin-position"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-specifying-the-time-axis-origin-position"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query Specifying the Time Axis Origin Position")]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select count(status), max_value(temperature) from root.ln.wf01.wt01 group by (1d, 2017-11-03 00:00:00, [2017-11-01 00:00:00, 2017-11-07 23:00:00]);\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("Since the user specifies the time axis origin position parameter as 2017-11-03 00:00:00, the GROUP BY statement will set the origin at 0 (system default time zone) on November 3, 2017.")]),e._v(" "),a("p",[e._v("The first parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (1d) as time interval and the speicified origin as the dividing origin, the time axis is divided into several continuous intervals, which are [2017-11-02T00:00:00, 2017-11-03T00:00:00], [2017-11-03T00:00:00, 2017-11-04T00:00:00], etc.")]),e._v(" "),a("p",[e._v("The third parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-11-01T00:00:00, 2017-11-07T23:00:00].")]),e._v(" "),a("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the second parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of [2017-11-01T00:00:00, 2017-11-07T23:00:00]), and map these data to the previously segmented time axis (in this case there are mapped data in every 1-day period from 2017-11-01T00:00:00 to 2017-11-07T23:00:00:00).")]),e._v(" "),a("p",[e._v("Since there is data for each time period in the result range to be displayed, the execution result of the SQL statement is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577563-3a925480-1ef5-11e9-88da-2d7e3eb4c951.jpg"}})]),e._v(" "),a("h4",{attrs:{id:"down-frequency-aggregate-query-specifying-the-time-filtering-conditions"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-specifying-the-time-filtering-conditions"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query Specifying the Time Filtering Conditions")]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select count(status), max_value(temperature) from root.ln.wf01.wt01 where time > 2017-11-03T06:00:00 and temperature > 20 group by(1h, [2017-11-03T00:00:00, 2017-11-03T23:00:00]);\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("Since the user does not specify the time axis origin position, the GROUP BY statement will by default set the origin at 0 (+0 time zone) on January 1, 1970.")]),e._v(" "),a("p",[e._v("The first parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (1h) as time interval and the default origin as the dividing origin, the time axis is divided into several continuous intervals, which are [0,1h], [1h, 2h], [2h, 3h], etc.")]),e._v(" "),a("p",[e._v("The second parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-11-03T00:00:00, 2017-11-03T23:00:00].")]),e._v(" "),a("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the second parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of (2017-11-03T06:00:00, 2017-11-03T23:00:00] and satisfying root.ln.wf01.wt01.temperature > 20), and map these data to the previously segmented time axis (in this case there are mapped data in every 1-hour period from 2017-11-03T00:06:00 to 2017-11-03T23:00:00).")]),e._v(" "),a("p",[e._v("Since there is no data in the result range [2017-11-03T00:00:00, 2017-11-03T00:06:00], the aggregation results of this segment will be null. There is data in all other time periods in the result range to be displayed. The execution result of the SQL statement is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577582-441bbc80-1ef5-11e9-8b54-3ad1f586bbc4.jpg"}})]),e._v(" "),a("p",[e._v("It is worth noting that the path after SELECT in GROUP BY statement must be aggregate function, otherwise the system will give the corresponding error prompt, as shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/19167280/61517091-fbbf0080-aa38-11e9-8623-cdadf1ccf5d6.png"}})]),e._v(" "),a("h3",{attrs:{id:"automated-fill"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#automated-fill"}},[e._v("#")]),e._v(" Automated Fill")]),e._v(" "),a("p",[e._v("In the actual use of IoTDB, when doing the query operation of timeseries, situations where the value is null at some time points may appear, which will obstruct the further analysis by users. In order to better reflect the degree of data change, users expect missing values to be automatically filled. Therefore, the IoTDB system introduces the function of Automated Fill.")]),e._v(" "),a("p",[e._v("Automated fill function refers to filling empty values according to the user's specified method and effective time range when performing timeseries queries for single or multiple columns. If the queried point's value is not null, the fill function will not work.")]),e._v(" "),a("blockquote",[a("p",[e._v("Note: In the current version, IoTDB provides users with two methods: Previous and Linear. The previous method fills blanks with previous value. The linear method fills blanks through linear fitting. And the fill function can only be used when performing point-in-time queries.")])]),e._v(" "),a("h4",{attrs:{id:"fill-function"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#fill-function"}},[e._v("#")]),e._v(" Fill Function")]),e._v(" "),a("ul",[a("li",[e._v("Previous Function")])]),e._v(" "),a("p",[e._v("When the value of the queried timestamp is null, the value of the previous timestamp is used to fill the blank. The formalized previous method is as follows (see Section 7.1.3.6 for detailed syntax):")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select <path> from <prefixPath> where time = <T> fill(<data_type>[previous, <before_range>], …)\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("Detailed descriptions of all parameters are given in Table 3-4.")]),e._v(" "),a("p",[a("strong",[e._v("Table 3-4 Previous fill paramter list")])]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",{staticStyle:{"text-align":"left"}},[e._v("Parameter name (case insensitive)")]),e._v(" "),a("th",{staticStyle:{"text-align":"left"}},[e._v("Interpretation")])])]),e._v(" "),a("tbody",[a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("path, prefixPath")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("query path; mandatory field")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("T")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("query timestamp (only one can be specified); mandatory field")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("data_type")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("the type of data used by the fill method. Optional values are int32, int64, float, double, boolean, text; optional field")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("before_range")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("represents the valid time range of the previous method. The previous method works when there are values in the [T-before_range, T] range. When before_range is not specified, before_range takes the default value T; optional field")])])])]),e._v(" "),a("p",[e._v("Here we give an example of filling null values using the previous method. The SQL statement is as follows:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) \n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses the previous timestamp of 2017-11-01T16:37:50.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) for fill and display.")]),e._v(" "),a("p",[e._v("On the "),a("a",{attrs:{href:"https://raw.githubusercontent.com/apache/incubator-iotdb/master/docs/Documentation/OtherMaterial-Sample%20Data.txt",target:"_blank",rel:"noopener noreferrer"}},[e._v("sample data"),a("OutboundLink")],1),e._v(", the execution result of this statement is shown below:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577616-67df0280-1ef5-11e9-9dff-2eb8342074eb.jpg"}})])],1),e._v(" "),a("p",[e._v("It is worth noting that if there is no value in the specified valid time range, the system will not fill the null value, as shown below:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577679-9f4daf00-1ef5-11e9-8d8b-06a58de6efc1.jpg"}})])],1),e._v(" "),a("ul",[a("li",[e._v("Linear Method")])]),e._v(" "),a("p",[e._v("When the value of the queried timestamp is null, the value of the previous and the next timestamp is used to fill the blank. The formalized linear method is as follows:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select <path> from <prefixPath> where time = <T> fill(<data_type>[linear, <before_range>, <after_range>]…)\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("Detailed descriptions of all parameters are given in Table 3-5.")]),e._v(" "),a("p",[a("strong",[e._v("Table 3-5 Linear fill paramter list")])]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",{staticStyle:{"text-align":"left"}},[e._v("Parameter name (case insensitive)")]),e._v(" "),a("th",{staticStyle:{"text-align":"left"}},[e._v("Interpretation")])])]),e._v(" "),a("tbody",[a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("path, prefixPath")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("query path; mandatory field")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("T")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("query timestamp (only one can be specified); mandatory field")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("data_type")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("the type of data used by the fill method. Optional values are int32, int64, float, double, boolean, text; optional field")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("before_range, after_range")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("represents the valid time range of the linear method. The previous method works when there are values in the [T-before_range, T+after_range] range. When before_range and after_range are not explicitly specified, both before_range and after_range default to infinity; optional field")])])])]),e._v(" "),a("p",[e._v("Here we give an example of filling null values using the linear method. The SQL statement is as follows:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [linear, 1m, 1m])\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses the previous timestamp 2017-11-01T16:37:00.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) and its value 21.927326, the next timestamp 2017-11-01T16:39:00.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) and its value 25.311783 to perform linear fitting calculation: 21.927326 + (25.311783-21.927326)/60s * 50s = 24.747707")]),e._v(" "),a("p",[e._v("On the "),a("a",{attrs:{href:"https://raw.githubusercontent.com/apache/incubator-iotdb/master/docs/Documentation/OtherMaterial-Sample%20Data.txt",target:"_blank",rel:"noopener noreferrer"}},[e._v("sample data"),a("OutboundLink")],1),e._v(", the execution result of this statement is shown below:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577727-d4f29800-1ef5-11e9-8ff3-3bb519da3993.jpg"}})])],1),e._v(" "),a("h4",{attrs:{id:"correspondence-between-data-type-and-fill-method"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#correspondence-between-data-type-and-fill-method"}},[e._v("#")]),e._v(" Correspondence between Data Type and Fill Method")]),e._v(" "),a("p",[e._v("Data types and the supported fill methods are shown in Table 3-6.")]),e._v(" "),a("p",[a("strong",[e._v("Table 3-6 Data types and the supported fill methods")])]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",{staticStyle:{"text-align":"left"}},[e._v("Data Type")]),e._v(" "),a("th",{staticStyle:{"text-align":"left"}},[e._v("Supported Fill Methods")])])]),e._v(" "),a("tbody",[a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("boolean")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("int32")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("int64")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("float")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("double")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("text")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous")])])])]),e._v(" "),a("p",[e._v("It is worth noting that IoTDB will give error prompts for fill methods that are not supported by data types, as shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577741-e340b400-1ef5-11e9-9238-a4eaf498ab84.jpg"}})]),e._v(" "),a("p",[e._v("When the fill method is not specified, each data type bears its own default fill methods and parameters. The corresponding relationship is shown in Table 3-7.")]),e._v(" "),a("p",[a("strong",[e._v("Table 3-7 Default fill methods and parameters for various data types")])]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",{staticStyle:{"text-align":"left"}},[e._v("Data Type")]),e._v(" "),a("th",{staticStyle:{"text-align":"left"}},[e._v("Default Fill Methods and Parameters")])])]),e._v(" "),a("tbody",[a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("boolean")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 0")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("int32")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("linear, 0, 0")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("int64")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("linear, 0, 0")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("float")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("linear, 0, 0")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("double")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("linear, 0, 0")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[e._v("text")]),e._v(" "),a("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 0")])])])]),e._v(" "),a("blockquote",[a("p",[e._v("Note: In version 0.9.3, at least one fill method should be specified in the Fill statement.")])]),e._v(" "),a("h3",{attrs:{id:"row-and-column-control-over-query-results"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#row-and-column-control-over-query-results"}},[e._v("#")]),e._v(" Row and Column Control over Query Results")]),e._v(" "),a("p",[e._v("IoTDB provides "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("LIMIT/SLIMIT")]),e._v(" clause and "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/5-Operation Manual/4-SQL Reference.html"}},[e._v("OFFSET/SOFFSET")]),e._v(" clause in order to make users have more control over query results. The use of LIMIT and SLIMIT clauses allows users to control the number of rows and columns of query results, and the use of OFFSET and SOFSET clauses allows users to set the starting position of the results for display.")],1),e._v(" "),a("p",[e._v("This chapter mainly introduces related examples of row and column control of query results. You can also use the "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/4-Client/2-Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" standard interface to execute queries.")],1),e._v(" "),a("h4",{attrs:{id:"row-control-over-query-results"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#row-control-over-query-results"}},[e._v("#")]),e._v(" Row Control over Query Results")]),e._v(" "),a("p",[e._v("By using LIMIT and OFFSET clauses, users can control the query results in a row-related manner. We will demonstrate how to use LIMIT and OFFSET clauses through the following examples.")]),e._v(" "),a("ul",[a("li",[e._v("Example 1: basic LIMIT clause")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status, temperature from root.ln.wf01.wt01 limit 10\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires the first 10 rows of the query result be returned.')]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577752-efc50c80-1ef5-11e9-9071-da2bbd8b9bdd.jpg"}})]),e._v(" "),a("ul",[a("li",[e._v("Example 2: LIMIT clause with OFFSET")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status, temperature from root.ln.wf01.wt01 limit 5 offset 3\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires rows 3 to 7 of the query result be returned (with the first row numbered as row 0).')]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577773-08352700-1ef6-11e9-883f-8d353bef2bdc.jpg"}})]),e._v(" "),a("ul",[a("li",[e._v("Example 3: LIMIT clause combined with WHERE clause")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time< 2017-11-01T00:12:00.000 limit 2 offset 3\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires rows 3 to 4 of the status and temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be returned (with the first row numbered as row 0).')]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577789-15521600-1ef6-11e9-86ca-d7b2c947367f.jpg"}})]),e._v(" "),a("ul",[a("li",[e._v("Example 4: LIMIT clause combined with GROUP BY clause")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select count(status), max_value(temperature) from root.ln.wf01.wt01 group by (1d,[2017-11-01T00:00:00, 2017-11-07T23:00:00]) limit 5 offset 3\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("The SQL statement clause requires rows 3 to 7 of the query result be returned (with the first row numbered as row 0).")]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577796-1e42e780-1ef6-11e9-8987-be443000a77e.jpg"}})]),e._v(" "),a("p",[e._v("It is worth noting that because the current FILL clause can only fill in the missing value of timeseries at a certain time point, that is to say, the execution result of FILL clause is exactly one line, so LIMIT and OFFSET are not expected to be used in combination with FILL clause, otherwise errors will be prompted. For example, executing the following SQL statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) limit 10\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/19167280/61517266-6e2fe080-aa39-11e9-8015-154a8e8ace30.png"}})]),e._v(" "),a("h4",{attrs:{id:"column-control-over-query-results"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#column-control-over-query-results"}},[e._v("#")]),e._v(" Column Control over Query Results")]),e._v(" "),a("p",[e._v("By using SLIMIT and SOFFSET clauses, users can control the query results in a column-related manner. We will demonstrate how to use SLIMIT and SOFFSET clauses through the following examples.")]),e._v(" "),a("ul",[a("li",[e._v("Example 1: basic SLIMIT clause")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is the first column under this device, i.e., the power supply status. The SQL statement requires the status sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.')]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577813-30bd2100-1ef6-11e9-94ef-dbeb450cf319.jpg"}})]),e._v(" "),a("ul",[a("li",[e._v("Example 2: SLIMIT clause with SOFFSET")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1 soffset 1\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is the second column under this device, i.e., the temperature. The SQL statement requires the temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.')]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577827-39adf280-1ef6-11e9-81b5-876769607cd2.jpg"}})]),e._v(" "),a("ul",[a("li",[e._v("Example 3: SLIMIT clause combined with GROUP BY clause")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select max_value(*) from root.ln.wf01.wt01 group by (1d, [2017-11-01T00:00:00, 2017-11-07T23:00:00]) slimit 1 soffset 1\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577840-44688780-1ef6-11e9-8abc-04ae78efa85b.jpg"}})]),e._v(" "),a("ul",[a("li",[e._v("Example 4: SLIMIT clause combined with FILL clause")])]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select * from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) slimit 1 soffset 1\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("The selected device is ln group wf01 plant wt01 device; the selected timeseries is the second column under this device, i.e., the temperature.")]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577855-4d595900-1ef6-11e9-8541-a4accd714b75.jpg"}})]),e._v(" "),a("p",[e._v("It is worth noting that SLIMIT clause is expected to be used in conjunction with star path or prefix path, and the system will prompt errors when SLIMIT clause is used in conjunction with complete path query. For example, executing the following SQL statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577867-577b5780-1ef6-11e9-978c-e02c1294bcc5.jpg"}})])],1),e._v(" "),a("h4",{attrs:{id:"row-and-column-control-over-query-results-2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#row-and-column-control-over-query-results-2"}},[e._v("#")]),e._v(" Row and Column Control over Query Results")]),e._v(" "),a("p",[e._v("In addition to row or column control over query results, IoTDB allows users to control both rows and columns of query results. Here is a complete example with both LIMIT clauses and SLIMIT clauses.")]),e._v(" "),a("p",[e._v("The SQL statement is:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select * from root.ln.wf01.wt01 limit 10 offset 100 slimit 2 soffset 0\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("which means:")]),e._v(" "),a("p",[e._v("The selected device is ln group wf01 plant wt01 device; the selected timeseries is columns 0 to 1 under this device (with the first column numbered as column 0). The SQL statement clause requires rows 100 to 109 of the query result be returned (with the first row numbered as row 0).")]),e._v(" "),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51577879-64984680-1ef6-11e9-9d7b-57dd60fab60e.jpg"}})]),e._v(" "),a("h4",{attrs:{id:"error-handling"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#error-handling"}},[e._v("#")]),e._v(" Error Handling")]),e._v(" "),a("p",[e._v("When the parameter N/SN of LIMIT/SLIMIT exceeds the size of the result set, IoTDB will return all the results as expected. For example, the query result of the original SQL statement consists of six rows, and we select the first 100 rows through the LIMIT clause:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 100\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The result is shown below:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51578187-ad9cca80-1ef7-11e9-897a-83e66a0f3d94.jpg"}})]),e._v(" "),a("p",[e._v("When the parameter N/SN of LIMIT/SLIMIT clause exceeds the allowable maximum value (N/SN is of type int32), the system will prompt errors. For example, executing the following SQL statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 1234567890123456789\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/19167280/61517469-e696a180-aa39-11e9-8ca5-42ea991d520e.png"}})]),e._v(" "),a("p",[e._v("When the parameter N/SN of LIMIT/SLIMIT clause is not a positive intege, the system will prompt errors. For example, executing the following SQL statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 13.1\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/19167280/61518094-68d39580-aa3b-11e9-993c-fc73c27540f7.png"}})]),e._v(" "),a("p",[e._v("When the parameter OFFSET of LIMIT clause exceeds the size of the result set, IoTDB will return an empty result set. For example, executing the following SQL statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 2 offset 6\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The result is shown below:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51578227-c60ce500-1ef7-11e9-98eb-175beb8d4086.jpg"}})])],1),e._v(" "),a("p",[e._v("When the parameter SOFFSET of SLIMIT clause is not smaller than the number of available timeseries, the system will prompt errors. For example, executing the following SQL statement:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1 soffset 2\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:\n"),a("center",[a("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/13203019/51578237-cd33f300-1ef7-11e9-9aef-2a717c56ab54.jpg"}})])],1),e._v(" "),a("h2",{attrs:{id:"delete"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#delete"}},[e._v("#")]),e._v(" DELETE")]),e._v(" "),a("p",[e._v("Users can delete data that meet the deletion condition in the specified timeseries by using the "),a("RouterLink",{attrs:{to:"/#/Documents/progress/chap5/sec4"}},[e._v("DELETE statement")]),e._v(". When deleting data, users can select one or more timeseries paths, prefix paths, or paths with star to delete data before a certain time (current version does not support the deletion of data within a closed time interval).")],1),e._v(" "),a("p",[e._v("In a JAVA programming environment, you can use the "),a("RouterLink",{attrs:{to:"/#/Documents/progress/chap4/sec2"}},[e._v("Java JDBC")]),e._v(" to execute single or batch UPDATE statements.")],1),e._v(" "),a("h3",{attrs:{id:"delete-single-timeseries"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#delete-single-timeseries"}},[e._v("#")]),e._v(" Delete Single Timeseries")]),e._v(" "),a("p",[e._v("Taking ln Group as an example, there exists such a usage scenario:")]),e._v(" "),a("p",[e._v("The wf02 plant's wt02 device has many segments of errors in its power supply status before 2017-11-01 16:26:00, and the data cannot be analyzed correctly. The erroneous data affected the correlation analysis with other devices. At this point, the data before this time point needs to be deleted. The SQL statement for this operation is")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("delete from root.ln.wf02.wt02.status where time<=2017-11-01T16:26:00;\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("h3",{attrs:{id:"delete-multiple-timeseries"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#delete-multiple-timeseries"}},[e._v("#")]),e._v(" Delete Multiple Timeseries")]),e._v(" "),a("p",[e._v("When both the power supply status and hardware version of the ln group wf02 plant wt02 device before 2017-11-01 16:26:00 need to be deleted, "),a("RouterLink",{attrs:{to:"/UserGuide/V0.9.x/2-Concept/1-Data Model and Terminology.html"}},[e._v("the prefix path with broader meaning or the path with star")]),e._v(" can be used to delete the data. The SQL statement for this operation is:")],1),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("delete from root.ln.wf02.wt02 where time <= 2017-11-01T16:26:00;\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("or")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("delete from root.ln.wf02.wt02.* where time <= 2017-11-01T16:26:00;\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("It should be noted that when the deleted path does not exist, IoTDB will give the corresponding error prompt as shown below:")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("IoTDB> delete from root.ln.wf03.wt02.status where time < now()\nMsg: TimeSeries does not exist and its data cannot be deleted\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br")])])],1)}),[],!1,null,null,null);t.default=i.exports}}]);