| import{_ as e,O as n,P as s,ah as a,aW as i}from"./framework-e4340ccd.js";const t={},o=i(`<h1 id="查询对齐模式" tabindex="-1"><a class="header-anchor" href="#查询对齐模式" aria-hidden="true">#</a> 查询对齐模式</h1><p>在 IoTDB 中,查询结果集<strong>默认按照时间对齐</strong>,包含一列时间列和若干个值列,每一行数据各列的时间戳相同。</p><p>除按照时间对齐外,还支持以下对齐模式:</p><ul><li>按设备对齐 <code>ALIGN BY DEVICE</code></li></ul><h2 id="按设备对齐" tabindex="-1"><a class="header-anchor" href="#按设备对齐" aria-hidden="true">#</a> 按设备对齐</h2><p>在按设备对齐模式下,设备名会单独作为一列出现,查询结果集包含一列时间列、一列设备列和若干个值列。如果 <code>SELECT</code> 子句中选择了 <code>N</code> 列,则结果集包含 <code>N + 2</code> 列(时间列和设备名字列)。</p><p>在默认情况下,结果集按照 <code>Device</code> 进行排列,在每个 <code>Device</code> 内按照 <code>Time</code> 列升序排序。</p><p>当查询多个设备时,要求设备之间同名的列数据类型相同。</p><p>为便于理解,可以按照关系模型进行对应。设备可以视为关系模型中的表,选择的列可以视为表中的列,<code>Time + Device</code> 看做其主键。</p><p><strong>示例:</strong></p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span><span class="token operator">*</span><span class="token operator">*</span> <span class="token keyword">where</span> <span class="token keyword">time</span> <span class="token operator"><=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">01</span>:<span class="token number">00</span> align <span class="token keyword">by</span> device<span class="token punctuation">;</span> |
| </code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>执行如下:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+-----------------+-----------+------+--------+ |
| | Time| Device|temperature|status|hardware| |
| +-----------------------------+-----------------+-----------+------+--------+ |
| |2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null| |
| |2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null| |
| |1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1| |
| |1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2| |
| |2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2| |
| |2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2| |
| +-----------------------------+-----------------+-----------+------+--------+ |
| Total line number = 6 |
| It costs 0.012s |
| </code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,13);function r(l,c){return n(),s("div",null,[a(` |
| |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| `),o])}const p=e(t,[["render",r],["__file","Align-By.html.vue"]]);export{p as default}; |