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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ Total line number = 1

### 1.5 Update Tables

Used to update a table, including adding or deleting columns and configuring table properties.
Used to update a table, including adding or deleting columns, modify column type (V2.0.8) and configuring table properties.

**Syntax:**

Expand All @@ -313,13 +313,18 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
| COMMENT ON COLUMN tableName.column IS 'column_comment'
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
```

**Note::**

1. The `SET PROPERTIES` operation currently only supports configuring the `TTL` property of a table
2. The delete column function only supports deleting the ATTRIBUTE and FILD columns, and the TAG column does not support deletion.
3. The modified comment will overwrite the original comment. If null is specified, the previous comment will be erased.
4. Since version V2.0.8, modifying the data type of a column is supported. Currently, only columns with Category type FIELD can be modified.

* If the time series is concurrently deleted during the modification process, an error will be reported.
* The new data type must be compatible with the original type. The specific compatibility is shown in the following table:

**Example:**

Expand All @@ -329,6 +334,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
ALTER TABLE table1 set properties TTL=3600
COMMENT ON TABLE table1 IS 'table1'
COMMENT ON COLUMN table1.a IS null
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
```

### 1.6 Delete Tables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
| COMMENT ON COLUMN tableName.column IS 'column_comment'
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
```

**Examples:**
Expand All @@ -320,6 +321,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
ALTER TABLE table1 set properties TTL=3600
COMMENT ON TABLE table1 IS 'table1'
COMMENT ON COLUMN table1.a IS null
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
```

### 2.6 Drop Table
Expand Down
23 changes: 22 additions & 1 deletion src/UserGuide/Master/Table/User-Manual/Tree-to-Table_timecho.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ AS root.db.**
### 2.2 Modifying a Table View
#### 2.2.1 Syntax Definition

The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, deleting columns, setting the view's TTL property, and adding comments via COMMENT.
The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, modifying FIELD column data type (supported since V2.0.8), deleting columns, setting the view's TTL property, and adding comments via COMMENT.

```SQL
-- Rename view
Expand All @@ -156,6 +156,9 @@ viewColumnDefinition
-- Rename a column in the view
ALTER VIEW [IF EXISTS] viewName RENAME COLUMN [IF EXISTS] oldName TO newName

-- Modify the data type of a FIELD column
ALTER VIEW [IF EXISTS] viewName ALTER COLUMN [IF EXISTS] columnName SET DATA TYPE new_type

-- Delete a column from the view
ALTER VIEW [IF EXISTS] viewName DROP COLUMN [IF EXISTS] columnName

Expand All @@ -171,6 +174,21 @@ COMMENT ON COLUMN qualifiedName '.' column=identifier IS (string | NULL) #commen
1. The `SET PROPERTIES`operation currently only supports configuring the TTL property for the table view.
2. The `DROP COLUMN`function only supports deleting FIELD columns; TAG columns cannot be deleted.
3. Modifying the comment will overwrite the original comment. If set to `null`, the previous comment will be erased.
4. When modifying the data type of a FIELD column, the new data type must be compatible with the original type. The specific compatibility is shown in the following table:

| Original Type | Convertible To Type |
|---------------|----------------------------------------------|
| INT32 | INT64, FLOAT, DOUBLE, TIMESTAMP, STRING, TEXT |
| INT64 | TIMESTAMP, DOUBLE, STRING, TEXT |
| FLOAT | DOUBLE, STRING, TEXT |
| DOUBLE | STRING, TEXT |
| BOOLEAN | STRING, TEXT |
| TEXT | BLOB, STRING |
| STRING | TEXT, BLOB |
| BLOB | STRING, TEXT |
| DATE | STRING, TEXT |
| TIMESTAMP | INT64, DOUBLE, STRING, TEXT |

#### 2.2.3 Usage Examples

```SQL
Expand All @@ -183,6 +201,9 @@ ALTER VIEW IF EXISTS tableview ADD COLUMN IF NOT EXISTS temperature float field
-- Rename a column in the view
ALTER VIEW IF EXISTS tableview RENAME COLUMN IF EXISTS temperature TO temp

-- Modify the data type of a FIELD column
ALTER VIEW IF EXISTS tableview ALTER COLUMN IF EXISTS temperature SET DATA TYPE double

-- Delete a column from the view
ALTER VIEW IF EXISTS tableview DROP COLUMN IF EXISTS temp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,43 @@ You can set different datatype, encoding, and compression for the timeseries in

It is also supported to set an alias, tag, and attribute for aligned timeseries.

### 2.3 Delete Timeseries
### 2.3 Modifying Timseries Data Types

Starting from version V2.0.8, modifying the data type of a timeseries via SQL statements is supported.

Syntax definition:

```SQL
ALTER TIMESERIES fullPath SET DATA TYPE newType=type
```

Notes:

* If the timeseries is concurrently deleted during the modification process, an error will be reported.

* The new data type must be compatible with the original type. The specific compatibility is shown in the following table:

| Original Type |Convertible To Type |
| ----------- | ----------------------------------------------- |
| INT32 | INT64, FLOAT, DOUBLE, TIMESTAMP, STRING, TEXT |
| INT64 | TIMESTAMP, DOUBLE, STRING, TEXT |
| FLOAT | DOUBLE, STRING, TEXT |
| DOUBLE | STRING, TEXT |
| BOOLEAN | STRING, TEXT |
| TEXT | BLOB, STRING |
| STRING | TEXT, BLOB |
| BLOB | STRING, TEXT |
| DATE | STRING, TEXT |
| TIMESTAMP | INT64, DOUBLE, STRING, TEXT |

Usage example:

```SQL
ALTER TIMESERIES root.ln.wf01.wt01.temperature set data type DOUBLE
```


### 2.4 Delete Timeseries

To delete the timeseries we created before, we are able to use `(DELETE | DROP) TimeSeries <PathPattern>` statement.

Expand All @@ -422,7 +458,7 @@ IoTDB> delete timeseries root.ln.wf02.*
IoTDB> drop timeseries root.ln.wf02.*
```

### 2.4 Show Timeseries
### 2.5 Show Timeseries

* SHOW LATEST? TIMESERIES pathPattern? whereClause? limitClause?

Expand Down Expand Up @@ -566,7 +602,7 @@ It costs 0.004s
It is worth noting that when the queried path does not exist, the system will return no timeseries.


### 2.5 Count Timeseries
### 2.6 Count Timeseries

IoTDB is able to use `COUNT TIMESERIES <Path>` to count the number of timeseries matching the path. SQL statements are as follows:

Expand Down Expand Up @@ -651,7 +687,7 @@ It costs 0.002s

> Note: The path of timeseries is just a filter condition, which has no relationship with the definition of level.

### 2.6 Active Timeseries Query
### 2.7 Active Timeseries Query
By adding WHERE time filter conditions to the existing SHOW/COUNT TIMESERIES, we can obtain time series with data within the specified time range.

It is important to note that in metadata queries with time filters, views are not considered; only the time series actually stored in the TsFile are taken into account.
Expand Down Expand Up @@ -691,7 +727,7 @@ IoTDB> count timeseries where time >= 15000 and time < 16000;
+-----------------+
```
Regarding the definition of active time series, data that can be queried normally is considered active, meaning time series that have been inserted but deleted are not included.
### 2.7 Tag and Attribute Management
### 2.8 Tag and Attribute Management

We can also add an alias, extra tag and attribute information while creating one timeseries.

Expand Down
1 change: 1 addition & 0 deletions src/UserGuide/Master/Tree/SQL-Manual/Keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
- TRIGGER
- TRIGGERS
- TTL
- TYPE
- UNLINK
- UNLOAD
- UNSET
Expand Down
17 changes: 13 additions & 4 deletions src/UserGuide/Master/Tree/SQL-Manual/SQL-Manual_timecho.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,16 @@ error: encoding TS_2DIFF does not support BOOLEAN
IoTDB> CREATE ALIGNED TIMESERIES root.ln.wf01.GPS(latitude FLOAT , longitude FLOAT)
```

### 2.3 Delete Timeseries
### 2.3 Modify Timeseries Data Type

> Supported since V2.0.8

```SQL
ALTER TIMESERIES root.ln.wf01.wt01.temperature set data type DOUBLE
```


### 2.4 Delete Timeseries

```sql
IoTDB> delete timeseries root.ln.wf01.wt01.status
Expand All @@ -151,7 +160,7 @@ IoTDB> delete timeseries root.ln.wf02.*
IoTDB> drop timeseries root.ln.wf02.*
```

### 2.4 Show Timeseries
### 2.5 Show Timeseries

```sql
IoTDB> show timeseries root.**
Expand All @@ -161,7 +170,7 @@ IoTDB> show timeseries root.ln.** where timeseries contains 'wf01.wt'
IoTDB> show timeseries root.ln.** where dataType=FLOAT
```

### 2.5 Count Timeseries
### 2.6 Count Timeseries

```sql
IoTDB > COUNT TIMESERIES root.**
Expand All @@ -178,7 +187,7 @@ IoTDB > COUNT TIMESERIES root.ln.** GROUP BY LEVEL=2
IoTDB > COUNT TIMESERIES root.ln.wf01.* GROUP BY LEVEL=2
```

### 2.6 Tag and Attribute Management
### 2.7 Tag and Attribute Management

```sql
create timeseries root.turbine.d1.s1(temprature) with datatype=FLOAT tags(tag1=v1, tag2=v2) attributes(attr1=v1, attr2=v2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ Total line number = 1

### 1.5 Update Tables

Used to update a table, including adding or deleting columns and configuring table properties.
Used to update a table, including adding or deleting columns, modify column type (V2.0.8) and configuring table properties.

**Syntax:**

Expand All @@ -313,13 +313,18 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
| COMMENT ON COLUMN tableName.column IS 'column_comment'
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
```

**Note::**

1. The `SET PROPERTIES` operation currently only supports configuring the `TTL` property of a table
2. The delete column function only supports deleting the ATTRIBUTE and FILD columns, and the TAG column does not support deletion.
3. The modified comment will overwrite the original comment. If null is specified, the previous comment will be erased.
4. Since version V2.0.8, modifying the data type of a column is supported. Currently, only columns with Category type FIELD can be modified.

* If the time series is concurrently deleted during the modification process, an error will be reported.
* The new data type must be compatible with the original type. The specific compatibility is shown in the following table:

**Example:**

Expand All @@ -329,6 +334,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
ALTER TABLE table1 set properties TTL=3600
COMMENT ON TABLE table1 IS 'table1'
COMMENT ON COLUMN table1.a IS null
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
```

### 1.6 Delete Tables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments #setTableProperties
| COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'
| COMMENT ON COLUMN tableName.column IS 'column_comment'
| ALTER TABLE (IF EXISTS)? tableName=qualifiedName ALTER COLUMN (IF EXISTS)? column=identifier SET DATA TYPE new_type=type #changeColumndatatype
```

**Examples:**
Expand All @@ -320,6 +321,7 @@ ALTER TABLE table1 ADD COLUMN IF NOT EXISTS b FLOAT FIELD COMMENT 'b'
ALTER TABLE table1 set properties TTL=3600
COMMENT ON TABLE table1 IS 'table1'
COMMENT ON COLUMN table1.a IS null
ALTER TABLE table1 ALTER COLUMN IF EXISTS b SET DATA TYPE DOUBLE
```

### 2.6 Drop Table
Expand Down
23 changes: 22 additions & 1 deletion src/UserGuide/latest-Table/User-Manual/Tree-to-Table_timecho.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ AS root.db.**
### 2.2 Modifying a Table View
#### 2.2.1 Syntax Definition

The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, deleting columns, setting the view's TTL property, and adding comments via COMMENT.
The ALTER VIEW function supports modifying the view name, adding columns, renaming columns, modifying FIELD column data type (supported since V2.0.8), deleting columns, setting the view's TTL property, and adding comments via COMMENT.

```SQL
-- Rename view
Expand All @@ -156,6 +156,9 @@ viewColumnDefinition
-- Rename a column in the view
ALTER VIEW [IF EXISTS] viewName RENAME COLUMN [IF EXISTS] oldName TO newName

-- Modify the data type of a FIELD column
ALTER VIEW [IF EXISTS] viewName ALTER COLUMN [IF EXISTS] columnName SET DATA TYPE new_type

-- Delete a column from the view
ALTER VIEW [IF EXISTS] viewName DROP COLUMN [IF EXISTS] columnName

Expand All @@ -171,6 +174,21 @@ COMMENT ON COLUMN qualifiedName '.' column=identifier IS (string | NULL) #commen
1. The `SET PROPERTIES`operation currently only supports configuring the TTL property for the table view.
2. The `DROP COLUMN`function only supports deleting FIELD columns; TAG columns cannot be deleted.
3. Modifying the comment will overwrite the original comment. If set to `null`, the previous comment will be erased.
4. When modifying the data type of a FIELD column, the new data type must be compatible with the original type. The specific compatibility is shown in the following table:

| Original Type | Convertible To Type |
|---------------|----------------------------------------------|
| INT32 | INT64, FLOAT, DOUBLE, TIMESTAMP, STRING, TEXT |
| INT64 | TIMESTAMP, DOUBLE, STRING, TEXT |
| FLOAT | DOUBLE, STRING, TEXT |
| DOUBLE | STRING, TEXT |
| BOOLEAN | STRING, TEXT |
| TEXT | BLOB, STRING |
| STRING | TEXT, BLOB |
| BLOB | STRING, TEXT |
| DATE | STRING, TEXT |
| TIMESTAMP | INT64, DOUBLE, STRING, TEXT |

#### 2.2.3 Usage Examples

```SQL
Expand All @@ -183,6 +201,9 @@ ALTER VIEW IF EXISTS tableview ADD COLUMN IF NOT EXISTS temperature float field
-- Rename a column in the view
ALTER VIEW IF EXISTS tableview RENAME COLUMN IF EXISTS temperature TO temp

-- Modify the data type of a FIELD column
ALTER VIEW IF EXISTS tableview ALTER COLUMN IF EXISTS temperature SET DATA TYPE double

-- Delete a column from the view
ALTER VIEW IF EXISTS tableview DROP COLUMN IF EXISTS temp

Expand Down
Loading