Skip to content

Commit 6ec8c0b

Browse files
authored
custom name time column when creating a table (#1025)
1 parent d526b74 commit 6ec8c0b

24 files changed

Lines changed: 420 additions & 78 deletions

src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,31 @@ comment
6666

6767
**Note:**
6868

69-
1. If the time column (`TIME`) is not specified, IoTDB automatically adds one. Other columns can be added using the `enable_auto_create_schema` configuration or session interface commands.
70-
2. Column categories default to `FIELD` if not specified. `TAG` and `ATTRIBUTE` columns must be of type `STRING`.
71-
3. Table `TTL` defaults to the database `TTL`. You can omit this property or set it to `default` if the default value is used.
72-
4. `<TABLE_NAME>`:
73-
1. Case-insensitive. After creation, it will be displayed uniformly in lowercase.
74-
2. Can include special characters such as `~!`"`%`, etc.
75-
3. Names with special or Chinese characters must be enclosed in double quotes (`""`).
76-
4. Outer double quotes are not retained in the final table name. For example: `"a""b"` becomes `a"b`.
77-
5. Note: In SQL, table or column names with special characters or Chinese characters must be wrapped in double quotes. However, in the native API, do not add extra quotes—otherwise, the quotation marks will become part of the name itself.
78-
5. **`columnDefinition`**: Column names share the same characteristics as table names and can include special characters such as `.`.
79-
6. COMMENT adds comments to the table.
69+
1. When creating a table, you do not need to specify a time column. IoTDB automatically adds a column named "time" and places it as the first column. All other columns can be added by enabling the `enable_auto_create_schema` option in the database configuration, or through the session interface for automatic creation or by using table modification statements.
70+
2. Since version V2.0.8, tables support custom naming of the time column during creation. The order of the custom time column in the table is determined by the order in the creation SQL. The related constraints are as follows:
71+
72+
- When the column category is set to TIME, the data type must be TIMESTAMP.
73+
- Each table allows at most one time column (columnCategory = TIME).
74+
- If no time column is explicitly defined, no other column can use "time" as its name to avoid conflicts with the system's default time column naming.
75+
3. The column category can be omitted and defaults to FIELD. When the column category is TAG or ATTRIBUTE, the data type must be STRING (can be omitted).
76+
4. The TTL of a table defaults to the TTL of its database. If the default value is used, this attribute can be omitted or set to default.
77+
5. <TABLE_NAME> table name has the following characteristics:
78+
79+
- It is case-insensitive and, upon successful creation, is uniformly displayed in lowercase.
80+
- The name can include special characters, such as `~!`"%`, etc.
81+
- Table names containing special characters or Chinese characters must be enclosed in double quotation marks ("") during creation.
82+
83+
- Note: In SQL, special characters or Chinese table names must be enclosed in double quotes. In the native API, no additional quotes are needed; otherwise, the table name will include the quote characters.
84+
- When naming a table, the outermost double quotation marks (`""`) will not appear in the actual table name.
85+
- ```sql
86+
-- In SQL
87+
"a""b" --> a"b
88+
"""""" --> ""
89+
-- In API
90+
"a""b" --> "a""b"
91+
```
92+
6. columnDefinition column names have the same characteristics as table names and can include the special character `.`.
93+
7. COMMENT adds a comment to the table.
8094

8195
**Examples:**
8296

@@ -101,6 +115,13 @@ CREATE TABLE tableC (
101115
"Site" STRING TAG,
102116
"Temperature" int32 FIELD COMMENT 'temperature'
103117
) with (TTL=DEFAULT);
118+
119+
-- Custom time column: named time_test, located in the second column of the table.
120+
CREATE TABLE table1 (
121+
region STRING TAG,
122+
time_user_defined TIMESTAMP TIME,
123+
temperature FLOAT FIELD
124+
);
104125
```
105126

106127
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.

src/UserGuide/Master/Table/Basic-Concept/Table-Management_timecho.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,31 @@ comment
6666

6767
**Note:**
6868

69-
1. If the time column (`TIME`) is not specified, IoTDB automatically adds one. Other columns can be added using the `enable_auto_create_schema` configuration or session interface commands.
70-
2. Column categories default to `FIELD` if not specified. `TAG` and `ATTRIBUTE` columns must be of type `STRING`.
71-
3. Table `TTL` defaults to the database `TTL`. You can omit this property or set it to `default` if the default value is used.
72-
4. `<TABLE_NAME>`:
73-
1. Case-insensitive. After creation, it will be displayed uniformly in lowercase.
74-
2. Can include special characters such as `~!`"`%`, etc.
75-
3. Names with special or Chinese characters must be enclosed in double quotes (`""`).
76-
4. Outer double quotes are not retained in the final table name. For example: `"a""b"` becomes `a"b`.
77-
5. Note: In SQL, table or column names with special characters or Chinese characters must be wrapped in double quotes. However, in the native API, do not add extra quotes—otherwise, the quotation marks will become part of the name itself.
78-
5. **`columnDefinition`**: Column names share the same characteristics as table names and can include special characters such as `.`.
79-
6. COMMENT adds comments to the table.
69+
1. When creating a table, you do not need to specify a time column. IoTDB automatically adds a column named "time" and places it as the first column. All other columns can be added by enabling the `enable_auto_create_schema` option in the database configuration, or through the session interface for automatic creation or by using table modification statements.
70+
2. Since version V2.0.8, tables support custom naming of the time column during creation. The order of the custom time column in the table is determined by the order in the creation SQL. The related constraints are as follows:
71+
72+
- When the column category is set to TIME, the data type must be TIMESTAMP.
73+
- Each table allows at most one time column (columnCategory = TIME).
74+
- If no time column is explicitly defined, no other column can use "time" as its name to avoid conflicts with the system's default time column naming.
75+
3. The column category can be omitted and defaults to FIELD. When the column category is TAG or ATTRIBUTE, the data type must be STRING (can be omitted).
76+
4. The TTL of a table defaults to the TTL of its database. If the default value is used, this attribute can be omitted or set to default.
77+
5. <TABLE_NAME> table name has the following characteristics:
78+
79+
- It is case-insensitive and, upon successful creation, is uniformly displayed in lowercase.
80+
- The name can include special characters, such as `~!`"%`, etc.
81+
- Table names containing special characters or Chinese characters must be enclosed in double quotation marks ("") during creation.
82+
83+
- Note: In SQL, special characters or Chinese table names must be enclosed in double quotes. In the native API, no additional quotes are needed; otherwise, the table name will include the quote characters.
84+
- When naming a table, the outermost double quotation marks (`""`) will not appear in the actual table name.
85+
- ```sql
86+
-- In SQL
87+
"a""b" --> a"b
88+
"""""" --> ""
89+
-- In API
90+
"a""b" --> "a""b"
91+
```
92+
6. columnDefinition column names have the same characteristics as table names and can include the special character `.`.
93+
7. COMMENT adds a comment to the table.
8094

8195
**Examples:**
8296

@@ -101,6 +115,13 @@ CREATE TABLE tableC (
101115
"Site" STRING TAG,
102116
"Temperature" int32 FIELD COMMENT 'temperature'
103117
) with (TTL=DEFAULT);
118+
119+
-- Custom time column: named time_test, located in the second column of the table.
120+
CREATE TABLE table1 (
121+
region STRING TAG,
122+
time_user_defined TIMESTAMP TIME,
123+
temperature FLOAT FIELD
124+
);
104125
```
105126

106127
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.

src/UserGuide/Master/Table/SQL-Manual/SQL-Metadata-Operations_apache.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ CREATE TABLE tableC (
211211
"Site" STRING TAG,
212212
"Temperature" int32 FIELD COMMENT 'temperature'
213213
) with (TTL=DEFAULT);
214+
215+
-- Custom time column: named time_test, located in the second column of the table. (Support from V2.0.8-beta)
216+
CREATE TABLE table1 (
217+
region STRING TAG,
218+
time_user_defined TIMESTAMP TIME,
219+
temperature FLOAT FIELD
220+
);
214221
```
215222

216223
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.

src/UserGuide/Master/Table/SQL-Manual/SQL-Metadata-Operations_timecho.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ CREATE TABLE tableC (
211211
"Site" STRING TAG,
212212
"Temperature" int32 FIELD COMMENT 'temperature'
213213
) with (TTL=DEFAULT);
214+
215+
-- Custom time column: named time_test, located in the second column of the table. (Support from V2.0.8)
216+
CREATE TABLE table1 (
217+
region STRING TAG,
218+
time_user_defined TIMESTAMP TIME,
219+
temperature FLOAT FIELD
220+
);
214221
```
215222

216223
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.

src/UserGuide/Master/Table/User-Manual/Tree-to-Table_apache.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ The name of the view, which follows the same rules as a table name (for specific
8080
* If a device in the tree model does not contain certain declared FIELD columns, or if their data types are inconsistent with the declared FIELD columns, the value for that FIELD column will always be `NULL`when querying that device.
8181
* If no FIELD columns are specified, the system automatically scans for all measurements under the `prefixPath`subtree (including all ordinary sequence measurements and measurements defined in any templates whose mounted paths overlap with the `prefixPath`) during creation. The column names will use the measurement names from the tree model.
8282
* The tree model cannot have measurements with the same name (case-insensitive) but different data types.
83+
* `TIME`: When creating a view, you do not need to specify a time column. IoTDB automatically adds a column named "time" and places it as the first column. Since version V2.0.8-beta, views support **custom naming of the time column** during creation. The order of the custom time column in the view is determined by the order in the creation SQL. The related constraints are as follows:
84+
* When the column category is set to `TIME`, the data type must be `TIMESTAMP`.
85+
* Each view allows at most one time column (columnCategory = TIME).
86+
* If no time column is explicitly defined, no other column can use `time` as its name to avoid conflicts with the system's default time column naming.
87+
8388

8489
4. **`WITH properties`**
8590

@@ -138,6 +143,21 @@ with (ttl=604800000)
138143
AS root.db.**
139144
```
140145

146+
When customizing the time column (supported since V2.0.8-beta), the SQL changes are as follows:
147+
148+
```SQL
149+
CREATE OR REPLACE VIEW viewdb."wind_turbine"
150+
(wind_turbine_group String TAG,
151+
wind_turbine_number String TAG,
152+
voltage DOUBLE FIELD,
153+
current DOUBLE FIELD,
154+
time_user_defined TIMESTAMP TIME
155+
)
156+
with (ttl=604800000)
157+
AS root.db.**
158+
```
159+
160+
141161
### 2.2 Modifying a Table View
142162
#### 2.2.1 Syntax Definition
143163

src/UserGuide/Master/Table/User-Manual/Tree-to-Table_timecho.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ The name of the view, which follows the same rules as a table name (for specific
8080
* If a device in the tree model does not contain certain declared FIELD columns, or if their data types are inconsistent with the declared FIELD columns, the value for that FIELD column will always be `NULL`when querying that device.
8181
* If no FIELD columns are specified, the system automatically scans for all measurements under the `prefixPath`subtree (including all ordinary sequence measurements and measurements defined in any templates whose mounted paths overlap with the `prefixPath`) during creation. The column names will use the measurement names from the tree model.
8282
* The tree model cannot have measurements with the same name (case-insensitive) but different data types.
83+
* `TIME`: When creating a view, you do not need to specify a time column. IoTDB automatically adds a column named "time" and places it as the first column. Since version V2.0.8-beta, views support **custom naming of the time column** during creation. The order of the custom time column in the view is determined by the order in the creation SQL. The related constraints are as follows:
84+
* When the column category is set to `TIME`, the data type must be `TIMESTAMP`.
85+
* Each view allows at most one time column (columnCategory = TIME).
86+
* If no time column is explicitly defined, no other column can use `time` as its name to avoid conflicts with the system's default time column naming.
87+
8388

8489
4. **`WITH properties`**
8590

@@ -138,6 +143,21 @@ with (ttl=604800000)
138143
AS root.db.**
139144
```
140145

146+
When customizing the time column (supported since V2.0.8), the SQL changes are as follows:
147+
148+
```SQL
149+
CREATE OR REPLACE VIEW viewdb."wind_turbine"
150+
(wind_turbine_group String TAG,
151+
wind_turbine_number String TAG,
152+
voltage DOUBLE FIELD,
153+
current DOUBLE FIELD,
154+
time_user_defined TIMESTAMP TIME
155+
)
156+
with (ttl=604800000)
157+
AS root.db.**
158+
```
159+
160+
141161
### 2.2 Modifying a Table View
142162
#### 2.2.1 Syntax Definition
143163

src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,31 @@ comment
6666

6767
**Note:**
6868

69-
1. If the time column (`TIME`) is not specified, IoTDB automatically adds one. Other columns can be added using the `enable_auto_create_schema` configuration or session interface commands.
70-
2. Column categories default to `FIELD` if not specified. `TAG` and `ATTRIBUTE` columns must be of type `STRING`.
71-
3. Table `TTL` defaults to the database `TTL`. You can omit this property or set it to `default` if the default value is used.
72-
4. `<TABLE_NAME>`:
73-
1. Case-insensitive. After creation, it will be displayed uniformly in lowercase.
74-
2. Can include special characters such as `~!`"`%`, etc.
75-
3. Names with special or Chinese characters must be enclosed in double quotes (`""`).
76-
4. Outer double quotes are not retained in the final table name. For example: `"a""b"` becomes `a"b`.
77-
5. Note: In SQL, table or column names with special characters or Chinese characters must be wrapped in double quotes. However, in the native API, do not add extra quotes—otherwise, the quotation marks will become part of the name itself.
78-
5. **`columnDefinition`**: Column names share the same characteristics as table names and can include special characters such as `.`.
79-
6. COMMENT adds comments to the table.
69+
1. When creating a table, you do not need to specify a time column. IoTDB automatically adds a column named "time" and places it as the first column. All other columns can be added by enabling the `enable_auto_create_schema` option in the database configuration, or through the session interface for automatic creation or by using table modification statements.
70+
2. Since version V2.0.8, tables support custom naming of the time column during creation. The order of the custom time column in the table is determined by the order in the creation SQL. The related constraints are as follows:
71+
72+
- When the column category is set to TIME, the data type must be TIMESTAMP.
73+
- Each table allows at most one time column (columnCategory = TIME).
74+
- If no time column is explicitly defined, no other column can use "time" as its name to avoid conflicts with the system's default time column naming.
75+
3. The column category can be omitted and defaults to FIELD. When the column category is TAG or ATTRIBUTE, the data type must be STRING (can be omitted).
76+
4. The TTL of a table defaults to the TTL of its database. If the default value is used, this attribute can be omitted or set to default.
77+
5. <TABLE_NAME> table name has the following characteristics:
78+
79+
- It is case-insensitive and, upon successful creation, is uniformly displayed in lowercase.
80+
- The name can include special characters, such as `~!`"%`, etc.
81+
- Table names containing special characters or Chinese characters must be enclosed in double quotation marks ("") during creation.
82+
83+
- Note: In SQL, special characters or Chinese table names must be enclosed in double quotes. In the native API, no additional quotes are needed; otherwise, the table name will include the quote characters.
84+
- When naming a table, the outermost double quotation marks (`""`) will not appear in the actual table name.
85+
- ```sql
86+
-- In SQL
87+
"a""b" --> a"b
88+
"""""" --> ""
89+
-- In API
90+
"a""b" --> "a""b"
91+
```
92+
6. columnDefinition column names have the same characteristics as table names and can include the special character `.`.
93+
7. COMMENT adds a comment to the table.
8094

8195
**Examples:**
8296

@@ -101,6 +115,13 @@ CREATE TABLE tableC (
101115
"Site" STRING TAG,
102116
"Temperature" int32 FIELD COMMENT 'temperature'
103117
) with (TTL=DEFAULT);
118+
119+
-- Custom time column: named time_test, located in the second column of the table.
120+
CREATE TABLE table1 (
121+
region STRING TAG,
122+
time_user_defined TIMESTAMP TIME,
123+
temperature FLOAT FIELD
124+
);
104125
```
105126

106127
Note: If your terminal does not support multi-line paste (e.g., Windows CMD), please reformat the SQL statement into a single line before execution.

0 commit comments

Comments
 (0)