Skip to content

Commit 77f937c

Browse files
authored
adjust table model sql manual (#846)
1 parent cc89733 commit 77f937c

16 files changed

Lines changed: 4236 additions & 12 deletions

src/.vuepress/sidebar/V2.0.x/en-Table.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ export const enSidebar = {
195195
collapsible: true,
196196
prefix: 'SQL-Manual/',
197197
children: [
198-
{ text: 'Identifier', link: 'Identifier' },
199-
{ text: 'Keywords', link: 'Keywords' },
198+
{ text: 'Metadata Operations', link: 'SQL-Metadata-Operations' },
199+
{ text: 'Data Addition&Deletion', link: 'SQL-Data-Addition-Deletion' },
200200
{
201-
text: 'Query statement',
201+
text: 'Data Query',
202202
collapsible: true,
203203
children: [
204204
{ text: 'overview', link: 'overview' },
@@ -213,6 +213,9 @@ export const enSidebar = {
213213
{ text: 'Nested Queries', link: 'Nested-Queries' },
214214
],
215215
},
216+
{ text: 'Maintenance Statements', link: 'SQL-Maintenance-Statements' },
217+
{ text: 'Identifier', link: 'Identifier' },
218+
{ text: 'Keywords', link: 'Keywords' },
216219
{
217220
text: 'Functions and Operators',
218221
collapsible: true,

src/.vuepress/sidebar/V2.0.x/zh-Table.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ export const zhSidebar = {
185185
collapsible: true,
186186
prefix: 'SQL-Manual/',
187187
children: [
188-
{ text: '标识符', link: 'Identifier' },
189-
{ text: '保留字&关键字', link: 'Keywords' },
188+
{ text: '元数据操作', link: 'SQL-Metadata-Operations' },
189+
{ text: '数据增删', link: 'SQL-Data-Addition-Deletion' },
190190
{
191-
text: '查询语句',
191+
text: '数据查询',
192192
collapsible: true,
193193
children: [
194194
{ text: '概览', link: 'overview' },
@@ -203,6 +203,9 @@ export const zhSidebar = {
203203
{ text: '嵌套查询', link: 'Nested-Queries' },
204204
],
205205
},
206+
{ text: '运维语句', link: 'SQL-Maintenance-Statements' },
207+
{ text: '标识符', link: 'Identifier' },
208+
{ text: '保留字&关键字', link: 'Keywords' },
206209
{
207210
text: '函数与操作符',
208211
collapsible: true,

src/.vuepress/sidebar_timecho/V2.0.x/en-Table.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ export const enSidebar = {
200200
collapsible: true,
201201
prefix: 'SQL-Manual/',
202202
children: [
203-
{ text: 'Identifier', link: 'Identifier' },
204-
{ text: 'Keywords', link: 'Keywords' },
203+
{ text: 'Metadata Operations', link: 'SQL-Metadata-Operations' },
204+
{ text: 'Data Addition&Deletion', link: 'SQL-Data-Addition-Deletion' },
205205
{
206-
text: 'Query statement',
206+
text: 'Data Query',
207207
collapsible: true,
208208
children: [
209209
{ text: 'overview', link: 'overview' },
@@ -218,6 +218,9 @@ export const enSidebar = {
218218
{ text: 'Nested Queries', link: 'Nested-Queries' },
219219
],
220220
},
221+
{ text: 'Maintenance Statements', link: 'SQL-Maintenance-Statements' },
222+
{ text: 'Identifier', link: 'Identifier' },
223+
{ text: 'Keywords', link: 'Keywords' },
221224
{
222225
text: 'Functions and Operators',
223226
collapsible: true,

src/.vuepress/sidebar_timecho/V2.0.x/zh-Table.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ export const zhSidebar = {
189189
collapsible: true,
190190
prefix: 'SQL-Manual/',
191191
children: [
192-
{ text: '标识符', link: 'Identifier' },
193-
{ text: '保留字&关键字', link: 'Keywords' },
192+
{ text: '元数据操作', link: 'SQL-Metadata-Operations' },
193+
{ text: '数据增删', link: 'SQL-Data-Addition-Deletion' },
194194
{
195-
text: '查询语句',
195+
text: '数据查询',
196196
collapsible: true,
197197
children: [
198198
{ text: '概览', link: 'overview' },
@@ -207,6 +207,9 @@ export const zhSidebar = {
207207
{ text: '嵌套查询', link: 'Nested-Queries' },
208208
],
209209
},
210+
{ text: '运维语句', link: 'SQL-Maintenance-Statements' },
211+
{ text: '标识符', link: 'Identifier' },
212+
{ text: '保留字&关键字', link: 'Keywords' },
210213
{
211214
text: '函数与操作符',
212215
collapsible: true,
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# Data Addition & Deletion
23+
24+
## 1. Data Insertion
25+
26+
**Syntax:**
27+
28+
```SQL
29+
INSERT INTO <TABLE_NAME> [(COLUMN_NAME[, COLUMN_NAME]*)]? VALUES (COLUMN_VALUE[, COLUMN_VALUE]*)
30+
```
31+
32+
[Detailed syntax reference](../Basic-Concept/Write-Updata-Data.md#_1-1-syntax)
33+
34+
**Example 1: Specified Columns Insertion**
35+
36+
```SQL
37+
INSERT INTO table1("Region", "PlantID", "DeviceID", Time, "Temperature", "Displacement")
38+
VALUES ('Hunan', '3001', '3', 4, 90.0, 1200.0);
39+
40+
INSERT INTO table1("Region", "PlantID", "DeviceID", Time, "Temperature")
41+
VALUES ('Hunan', '3001', '3', 5, 90.0);
42+
```
43+
44+
**Example 2: NULL Value Insertion**
45+
46+
```SQL
47+
-- Equivalent to partial insertion with NULL values
48+
INSERT INTO table1("Region", "PlantID", "DeviceID", "Model", "MaintenanceCycle", Time, "Temperature", "Displacement")
49+
VALUES ('Hunan', '3001', '3', NULL, NULL, 4, 90.0, 1200.0);
50+
51+
INSERT INTO table1("Region", "PlantID", "DeviceID", "Model", "MaintenanceCycle", Time, "Temperature", "Displacement")
52+
VALUES ('Hunan', '3001', '3', NULL, NULL, 5, 90.0, NULL);
53+
```
54+
55+
**Example 3: Multi-row Insertion**
56+
57+
```SQL
58+
INSERT INTO table1 VALUES
59+
('Beijing', '3001', '3', '1', '10', 4, 90.0, 1200.0),
60+
('Beijing', '3001', '3', '1', '10', 5, 90.0, 1200.0);
61+
62+
INSERT INTO table1("Region", "PlantID", "DeviceID", Time, "Temperature", "Displacement")
63+
VALUES
64+
('Beijing', '3001', '3', 4, 90.0, 1200.0),
65+
('Beijing', '3001', '3', 5, 90.0, 1200.0);
66+
```
67+
68+
## 2. Data Update
69+
70+
**Syntax:**
71+
72+
```SQL
73+
UPDATE <TABLE_NAME> SET updateAssignment (',' updateAssignment)* (WHERE where=booleanExpression)?
74+
75+
updateAssignment
76+
: identifier EQ expression
77+
;
78+
```
79+
80+
[Detailed syntax reference](../Basic-Concept/Write-Updata-Data.md#_2-1-syntax)
81+
82+
**Example:**
83+
84+
```SQL
85+
update table1 set b = a where substring(a, 1, 1) like '%'
86+
```
87+
88+
## 3. Data Deletion
89+
90+
**Syntax:**
91+
92+
```SQL
93+
DELETE FROM <TABLE_NAME> [WHERE_CLAUSE]?
94+
95+
WHERE_CLAUSE:
96+
WHERE DELETE_CONDITION
97+
98+
DELETE_CONDITION:
99+
SINGLE_CONDITION
100+
| DELETE_CONDITION AND DELETE_CONDITION
101+
| DELETE_CONDITION OR DELETE_CONDITION
102+
103+
SINGLE_CODITION:
104+
TIME_CONDITION | ID_CONDITION
105+
106+
TIME_CONDITION:
107+
time TIME_OPERATOR LONG_LITERAL
108+
109+
TIME_OPERATOR:
110+
< | > | <= | >= | =
111+
112+
ID_CONDITION:
113+
identifier = STRING_LITERAL
114+
```
115+
116+
**Example 1: Full Table Deletion**
117+
118+
```SQL
119+
DELETE FROM table1
120+
```
121+
122+
**Example 2: Time-range Deletion**
123+
124+
```SQL
125+
-- Single time range
126+
DELETE FROM table1 WHERE time <= 2024-11-29 00:00:00
127+
128+
-- Multiple time ranges
129+
DELETE FROM table1 WHERE time >= 2024-11-27 00:00:00 and time <= 2024-11-29 00:00:00
130+
```
131+
132+
**Example 3: Device-Specific Deletion**
133+
134+
```SQL
135+
-- Delete data for specific device
136+
DELETE FROM table1
137+
WHERE device_id='101' AND model_id = 'B';
138+
139+
-- Delete data for device within time range
140+
DELETE FROM table1
141+
WHERE time >= '2024-11-27 16:39:00' AND time <= '2024-11-29 16:42:00'
142+
AND device_id='101' AND model_id = 'B';
143+
144+
-- Delete data for specific device model
145+
DELETE FROM table1 WHERE model_id = 'B';
146+
```
147+
148+
## 4. Device Deletion
149+
150+
**Syntax:**
151+
152+
```SQL
153+
DELETE DEVICES FROM tableName=qualifiedName (WHERE booleanExpression)?
154+
```
155+
156+
**Example: Delete specified device and all associated data**
157+
158+
```SQL
159+
DELETE DEVICES FROM table1 WHERE device_id = '101'
160+
```

0 commit comments

Comments
 (0)