diff --git a/src/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md b/src/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md index 84bd43950..57f51bd45 100644 --- a/src/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md +++ b/src/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md @@ -74,12 +74,15 @@ CREATE DATABASE (IF NOT EXISTS)? (WITH properties)? | `TIME_PARTITION_INTERVAL` | Time partition interval for the database, in milliseconds. The value must be a positive integer. | `604800000` | | `MAX_SCHEMA_REGION_GROUP_NUM` | Maximum number of SchemaRegionGroups to which the database can automatically expand. The value must be a positive integer. Supported starting from V2.0.11. | `1` | | `MAX_DATA_REGION_GROUP_NUM` | Maximum number of DataRegionGroups to which the database can automatically expand. The value must be a positive integer. Supported starting from V2.0.11. | `2` | +| `NEED_LAST_CACHE` | Whether the last cache needs to be actively maintained. Valid values are `true` and `false`: `true` maintains the last cache according to the existing policy; `false` means that the object does not actively require the last cache. | `true` | **Notes:** - Property names are case-insensitive. For details, see [Case Sensitivity](../SQL-Manual/Identifier.md#2-case-sensitivity). - The maximum schema/data region group quotas, `maxSchemaRegionGroupNum` and `maxDataRegionGroupNum`, can be set or adjusted through SQL when creating or modifying a database only when `schema_region_group_extension_policy` and `data_region_group_extension_policy` in `iotdb-common.properties` are set to `CUSTOM`. +- `NEED_LAST_CACHE` is supported since V2.0.12. When set to `false`, tables/views subsequently created in this database without an explicit `need_last_cache` setting do not actively require the last cache by default. + **Example:** ```SQL @@ -150,6 +153,7 @@ SHOW DATABASES (DETAILS)? | MaxSchemaRegionGroupNum | Returned with `DETAILS`. Maximum number of schema replica groups allowed for the database. | | DataRegionGroupNum | Returned with `DETAILS`. Number of data replica groups currently owned by the database. | | MaxDataRegionGroupNum | Returned with `DETAILS`. Maximum number of data replica groups allowed for the database. | +| NeedLastCache | Returned when using `DETAILS`, showing the database-level default for the last cache. The value is `true` if not explicitly configured. Supported since V2.0.12. | **Example:** @@ -158,12 +162,12 @@ SHOW DATABASES DETAILS; ``` ```shell -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -|information_schema| INF| null| null| null| null| null| null| null| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| +|information_schema| INF| null| null| null| null| null| null| null| false| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` ### 2.5 Count Databases @@ -199,15 +203,18 @@ ALTER DATABASE (IF EXISTS)? database=identifier SET PROPERTIES propertyAssignmen **Description:** -1. `ALTER DATABASE` currently supports modifying only `MAX_SCHEMA_REGION_GROUP_NUM`, `MAX_DATA_REGION_GROUP_NUM`, and `TTL`. +1. The `ALTER DATABASE` operation currently supports modifications to the database's `MAX_SCHEMA_REGION_GROUP_NUM`, `MAX_DATA_REGION_GROUP_NUM`, `TTL`, and `NEED_LAST_CACHE` (supported since V2.0.12) properties. **Example:** ```SQL ALTER DATABASE database1 SET PROPERTIES TTL=31536000000; ALTER DATABASE database1 SET PROPERTIES MAX_SCHEMA_REGION_GROUP_NUM=2, MAX_DATA_REGION_GROUP_NUM=4; +ALTER DATABASE database1 SET PROPERTIES need_last_cache=false; ``` +`ALTER DATABASE ... SET PROPERTIES need_last_cache=DEFAULT` restores the database-level default value of `true`. + ### 2.7 Delete a Database Deletes a database. diff --git a/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md b/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md index db0b743a2..8f6603101 100644 --- a/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md +++ b/src/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md @@ -125,6 +125,7 @@ comment ``` 6. columnDefinition column names have the same characteristics as table names and can include the special character `.`. 7. COMMENT adds a comment to the table. +8. Starting from V2.0.12, the Boolean property `need_last_cache` specifies whether the table actively maintains the last cache. Valid values are `true` and `false`. If explicitly specified when creating the table, the table-level setting is used; otherwise, the table inherits the database's `need_last_cache` setting at the time of creation. **Examples:** @@ -164,17 +165,19 @@ SHOW TABLES (DETAILS)? ((FROM | IN) database_name)? 2. `PRE_CREATE`: The table is in the process of being created or the creation has failed; the table is not available. 3. `PRE_DELETE`: The table is in the process of being deleted or the deletion has failed; the table will remain permanently unavailable. +Starting from V2.0.12, the result set of `SHOW TABLES DETAILS` includes the `NeedLastCache` column. + **Examples:** ```sql show tables details from database1; ``` ```shell -+---------------+-----------+------+-------+ -| TableName| TTL(ms)|Status|Comment| -+---------------+-----------+------+-------+ -| table1|31536000000| USING| table1| -+---------------+-----------+------+-------+ ++---------------+-----------+------+-------+----------+-------------+ +| TableName| TTL(ms)|Status|Comment| TableType|NeedLastCache| ++---------------+-----------+------+-------+----------+-------------+ +| table1|31536000000| USING| table1|BASE TABLE| true| ++---------------+-----------+------+-------+----------+-------------+ ``` ### 2.3 View Table Columns @@ -232,6 +235,7 @@ SHOW CREATE TABLE **Note::** 1. This statement does not support queries on system tables. +2. Starting from V2.0.12, the returned table creation statement includes the `need_last_cache` property. **Example:** @@ -239,11 +243,11 @@ SHOW CREATE TABLE show create table table1; ``` ```shell -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Table| Create Table| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000)| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Table| Create Table| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000, need_last_cache=true)| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` @@ -259,7 +263,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col #dropColumn; | ALTER TABLE (IF EXISTS)? tableName=qualifiedName DROP COLUMN (IF EXISTS)? column=identifier; #setTableProperties; -// set TTL can use this; +// set TTL or need_last_cache can use this; | ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments; | COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'; | COMMENT ON COLUMN tableName.column IS 'column_comment'; @@ -267,7 +271,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col **Note::** -1. The `SET PROPERTIES` operation currently only supports configuring the `TTL` property of a table +1. The `SET PROPERTIES` operation supports configuring the `TTL` property of a table. Starting from V2.0.12, it also supports the `need_last_cache` property. 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. @@ -288,6 +292,14 @@ COMMENT ON TABLE table1 IS 'table1'; COMMENT ON COLUMN table1.a IS null; ``` +Set `need_last_cache` for table1 + +```SQL +ALTER TABLE table1 SET PROPERTIES need_last_cache=false; +``` + +Note: `ALTER TABLE ... SET PROPERTIES need_last_cache=DEFAULT` restores the database default semantics. If `need_last_cache` is explicitly configured for the database, the table uses that database-level value; otherwise, the table uses the default value `true`. + ### 2.6 Delete Tables Used to delete a table. diff --git a/src/UserGuide/Master/Table/Reference/System-Tables_apache.md b/src/UserGuide/Master/Table/Reference/System-Tables_apache.md index 0b8788fea..a766d9b33 100644 --- a/src/UserGuide/Master/Table/Reference/System-Tables_apache.md +++ b/src/UserGuide/Master/Table/Reference/System-Tables_apache.md @@ -27,7 +27,7 @@ IoTDB has a built-in system database called `INFORMATION_SCHEMA`, which contains * ​**Name**​: `INFORMATION_SCHEMA` * ​**Commands**​: Read-only, only supports `Show databases (DETAILS)` / `Show Tables (DETAILS)` / `Use`. Other operations will result in an error: `"The database 'information_schema' can only be queried."` -* ​**Attributes**​:` TTL=INF`, other attributes default to `null ` +* ​**Attributes**​: `TTL=INF`; starting from V2.0.12, `need_last_cache=false`; other attributes default to `null` * ​**SQL Example**​: ```sql @@ -88,18 +88,20 @@ IoTDB> show tables from information_schema | `max_schema_region_group_num` | INT32 | ATTRIBUTE | Maximum number of schema regions to which the database can expand. Supported starting from V2.0.11. | | `data_region_group_num` | INT32 | ATTRIBUTE | Number of data regions | | `max_data_region_group_num` | INT32 | ATTRIBUTE | Maximum number of data regions to which the database can expand. Supported starting from V2.0.11. | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | Database-level default for the last cache; `true` if not explicitly configured | +* `need_last_cache` is supported since V2.0.12. * The query results only display the collection of databases for which you have any permission on the database itself or any table within the database. * Query Example: ```sql IoTDB> select * from information_schema.databases -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -|information_schema| INF| null| null| null| null| null| null| null| -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num|need_last_cache| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +|information_schema| INF| null| null| null| null| null| null| null| false| +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ ``` ### 2.2 TABLES @@ -114,35 +116,37 @@ IoTDB> select * from information_schema.databases | `ttl(ms)` | STRING | ATTRIBUTE | Data retention time | | `status` | STRING | ATTRIBUTE | Status | | `comment` | STRING | ATTRIBUTE | Description/comment | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | The effective last cache setting of a base table or tree-to-table view. | * Note: Possible values for `status`: `USING`, `PRE_CREATE`, `PRE_DELETE`. For details, refer to the [View Tables](../Basic-Concept/Table-Management_apache.md#12-view-tables) in Table Management documentation +* `need_last_cache` is supported since V2.0.12. * The query results only display the collection of tables for which you have any permission. * Query Example: ```sql IoTDB> select * from information_schema.tables -+------------------+--------------+-----------+------+-------+-----------+ -| database| table_name| ttl(ms)|status|comment| table_type| -+------------------+--------------+-----------+------+-------+-----------+ -|information_schema| databases| INF| USING| null|SYSTEM VIEW| -|information_schema| models| INF| USING| null|SYSTEM VIEW| -|information_schema| subscriptions| INF| USING| null|SYSTEM VIEW| -|information_schema| regions| INF| USING| null|SYSTEM VIEW| -|information_schema| functions| INF| USING| null|SYSTEM VIEW| -|information_schema| keywords| INF| USING| null|SYSTEM VIEW| -|information_schema| columns| INF| USING| null|SYSTEM VIEW| -|information_schema| topics| INF| USING| null|SYSTEM VIEW| -|information_schema|configurations| INF| USING| null|SYSTEM VIEW| -|information_schema| queries| INF| USING| null|SYSTEM VIEW| -|information_schema| tables| INF| USING| null|SYSTEM VIEW| -|information_schema| pipe_plugins| INF| USING| null|SYSTEM VIEW| -|information_schema| nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| data_nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| pipes| INF| USING| null|SYSTEM VIEW| -|information_schema| views| INF| USING| null|SYSTEM VIEW| -|information_schema| config_nodes| INF| USING| null|SYSTEM VIEW| -| database1| table1|31536000000| USING| null| BASE TABLE| -+------------------+--------------+-----------+------+-------+-----------+ ++------------------+--------------+-----------+------+-------+-------------+---------------+ +| database| table_name| ttl(ms)|status|comment| table_type|need_last_cache| ++------------------+--------------+-----------+------+-------+-------------+---------------+ +|information_schema| databases| INF| USING| null| SYSTEM VIEW| false| +|information_schema| models| INF| USING| null| SYSTEM VIEW| false| +|information_schema| subscriptions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| regions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| functions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| keywords| INF| USING| null| SYSTEM VIEW| false| +|information_schema| columns| INF| USING| null| SYSTEM VIEW| false| +|information_schema| topics| INF| USING| null| SYSTEM VIEW| false| +|information_schema|configurations| INF| USING| null| SYSTEM VIEW| false| +|information_schema| queries| INF| USING| null| SYSTEM VIEW| false| +|information_schema| tables| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipe_plugins| INF| USING| null| SYSTEM VIEW| false| +|information_schema| nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| data_nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| views| INF| USING| null| SYSTEM VIEW| false| +|information_schema| config_nodes| INF| USING| null| SYSTEM VIEW| false| +| database1| table1|31536000000| USING| null| BASE TABLE| true| ++------------------+--------------+-----------+------+-------+-------------+---------------+ ``` ### 2.3 REGIONS diff --git a/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md b/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md index c821055b4..36d3bb5e4 100644 --- a/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md +++ b/src/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md @@ -62,6 +62,12 @@ Database Node Naming Rules: Besides, if deploy on Windows or macOS system, the LayerName is case-insensitive, which means it's not allowed to create databases `root.ln` and `root.LN` at the same time. +Starting from V2.0.12, the Boolean parameter `NEED_LAST_CACHE` can be specified when creating a database to control whether the database actively maintains the last cache. The default value is `true`, which maintains the last cache according to the existing policy. Setting it to `false` means that the database does not need to actively maintain the last cache. + +```SQL +CREATE DATABASE root.ln WITH NEED_LAST_CACHE=false; +``` + ### 1.2 Show Databases After creating the database, we can use the [SHOW DATABASES](../SQL-Manual/SQL-Manual_apache) statement and [SHOW DATABASES \](../SQL-Manual/SQL-Manual_apache) to view the databases. The SQL statements are as follows: @@ -84,6 +90,19 @@ Total line number = 2 It costs 0.060s ``` +Starting from V2.0.12, the result set of `SHOW DATABASES DETAILS` includes the `NeedLastCache` column. For example, after creating a database with `NEED_LAST_CACHE=false`, query the setting as follows: + +```SQL +SHOW DATABASES DETAILS root.ln; +``` +```shell ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.ln| 1| 1| 0| 604800000| 0| 1| 0| 4| false| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +``` + ### 1.3 Delete Database User can use the `DELETE DATABASE ` statement to delete all databases matching the pathPattern. Please note the data in the database will also be deleted. @@ -277,6 +296,7 @@ The following heterogeneous database parameters are supported: | TIME_PARTITION_INTERVAL | Long | Time partition interval of the database. The value must be a positive integer. | | MAX_SCHEMA_REGION_GROUP_NUM | Integer | Maximum number of SchemaRegionGroups to which the database can automatically expand. The value must be a positive integer. | | MAX_DATA_REGION_GROUP_NUM | Integer | Maximum number of DataRegionGroups to which the database can automatically expand. The value must be a positive integer. | +| NEED_LAST_CACHE | Boolean | Whether to actively maintain the last cache for the database. Defaults to `true`. Supported starting from V2.0.12. | Note the following when configuring heterogeneous parameters: @@ -331,11 +351,11 @@ SHOW DATABASES DETAILS; ``` ```shell -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| true| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` The columns in the query result are, in order: @@ -349,6 +369,7 @@ The columns in the query result are, in order: + Maximum number of SchemaRegionGroups allowed for the database + Number of DataRegionGroups currently owned by the database + Maximum number of DataRegionGroups allowed for the database ++ Whether the database needs to actively maintain the last cache (`NeedLastCache`, supported since V2.0.12) ## 2. Device Template diff --git a/src/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md b/src/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md index 84bd43950..57f51bd45 100644 --- a/src/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md +++ b/src/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md @@ -74,12 +74,15 @@ CREATE DATABASE (IF NOT EXISTS)? (WITH properties)? | `TIME_PARTITION_INTERVAL` | Time partition interval for the database, in milliseconds. The value must be a positive integer. | `604800000` | | `MAX_SCHEMA_REGION_GROUP_NUM` | Maximum number of SchemaRegionGroups to which the database can automatically expand. The value must be a positive integer. Supported starting from V2.0.11. | `1` | | `MAX_DATA_REGION_GROUP_NUM` | Maximum number of DataRegionGroups to which the database can automatically expand. The value must be a positive integer. Supported starting from V2.0.11. | `2` | +| `NEED_LAST_CACHE` | Whether the last cache needs to be actively maintained. Valid values are `true` and `false`: `true` maintains the last cache according to the existing policy; `false` means that the object does not actively require the last cache. | `true` | **Notes:** - Property names are case-insensitive. For details, see [Case Sensitivity](../SQL-Manual/Identifier.md#2-case-sensitivity). - The maximum schema/data region group quotas, `maxSchemaRegionGroupNum` and `maxDataRegionGroupNum`, can be set or adjusted through SQL when creating or modifying a database only when `schema_region_group_extension_policy` and `data_region_group_extension_policy` in `iotdb-common.properties` are set to `CUSTOM`. +- `NEED_LAST_CACHE` is supported since V2.0.12. When set to `false`, tables/views subsequently created in this database without an explicit `need_last_cache` setting do not actively require the last cache by default. + **Example:** ```SQL @@ -150,6 +153,7 @@ SHOW DATABASES (DETAILS)? | MaxSchemaRegionGroupNum | Returned with `DETAILS`. Maximum number of schema replica groups allowed for the database. | | DataRegionGroupNum | Returned with `DETAILS`. Number of data replica groups currently owned by the database. | | MaxDataRegionGroupNum | Returned with `DETAILS`. Maximum number of data replica groups allowed for the database. | +| NeedLastCache | Returned when using `DETAILS`, showing the database-level default for the last cache. The value is `true` if not explicitly configured. Supported since V2.0.12. | **Example:** @@ -158,12 +162,12 @@ SHOW DATABASES DETAILS; ``` ```shell -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -|information_schema| INF| null| null| null| null| null| null| null| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| +|information_schema| INF| null| null| null| null| null| null| null| false| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` ### 2.5 Count Databases @@ -199,15 +203,18 @@ ALTER DATABASE (IF EXISTS)? database=identifier SET PROPERTIES propertyAssignmen **Description:** -1. `ALTER DATABASE` currently supports modifying only `MAX_SCHEMA_REGION_GROUP_NUM`, `MAX_DATA_REGION_GROUP_NUM`, and `TTL`. +1. The `ALTER DATABASE` operation currently supports modifications to the database's `MAX_SCHEMA_REGION_GROUP_NUM`, `MAX_DATA_REGION_GROUP_NUM`, `TTL`, and `NEED_LAST_CACHE` (supported since V2.0.12) properties. **Example:** ```SQL ALTER DATABASE database1 SET PROPERTIES TTL=31536000000; ALTER DATABASE database1 SET PROPERTIES MAX_SCHEMA_REGION_GROUP_NUM=2, MAX_DATA_REGION_GROUP_NUM=4; +ALTER DATABASE database1 SET PROPERTIES need_last_cache=false; ``` +`ALTER DATABASE ... SET PROPERTIES need_last_cache=DEFAULT` restores the database-level default value of `true`. + ### 2.7 Delete a Database Deletes a database. diff --git a/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md b/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md index db0b743a2..8f6603101 100644 --- a/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md +++ b/src/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md @@ -125,6 +125,7 @@ comment ``` 6. columnDefinition column names have the same characteristics as table names and can include the special character `.`. 7. COMMENT adds a comment to the table. +8. Starting from V2.0.12, the Boolean property `need_last_cache` specifies whether the table actively maintains the last cache. Valid values are `true` and `false`. If explicitly specified when creating the table, the table-level setting is used; otherwise, the table inherits the database's `need_last_cache` setting at the time of creation. **Examples:** @@ -164,17 +165,19 @@ SHOW TABLES (DETAILS)? ((FROM | IN) database_name)? 2. `PRE_CREATE`: The table is in the process of being created or the creation has failed; the table is not available. 3. `PRE_DELETE`: The table is in the process of being deleted or the deletion has failed; the table will remain permanently unavailable. +Starting from V2.0.12, the result set of `SHOW TABLES DETAILS` includes the `NeedLastCache` column. + **Examples:** ```sql show tables details from database1; ``` ```shell -+---------------+-----------+------+-------+ -| TableName| TTL(ms)|Status|Comment| -+---------------+-----------+------+-------+ -| table1|31536000000| USING| table1| -+---------------+-----------+------+-------+ ++---------------+-----------+------+-------+----------+-------------+ +| TableName| TTL(ms)|Status|Comment| TableType|NeedLastCache| ++---------------+-----------+------+-------+----------+-------------+ +| table1|31536000000| USING| table1|BASE TABLE| true| ++---------------+-----------+------+-------+----------+-------------+ ``` ### 2.3 View Table Columns @@ -232,6 +235,7 @@ SHOW CREATE TABLE **Note::** 1. This statement does not support queries on system tables. +2. Starting from V2.0.12, the returned table creation statement includes the `need_last_cache` property. **Example:** @@ -239,11 +243,11 @@ SHOW CREATE TABLE show create table table1; ``` ```shell -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Table| Create Table| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000)| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Table| Create Table| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000, need_last_cache=true)| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` @@ -259,7 +263,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col #dropColumn; | ALTER TABLE (IF EXISTS)? tableName=qualifiedName DROP COLUMN (IF EXISTS)? column=identifier; #setTableProperties; -// set TTL can use this; +// set TTL or need_last_cache can use this; | ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments; | COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'; | COMMENT ON COLUMN tableName.column IS 'column_comment'; @@ -267,7 +271,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col **Note::** -1. The `SET PROPERTIES` operation currently only supports configuring the `TTL` property of a table +1. The `SET PROPERTIES` operation supports configuring the `TTL` property of a table. Starting from V2.0.12, it also supports the `need_last_cache` property. 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. @@ -288,6 +292,14 @@ COMMENT ON TABLE table1 IS 'table1'; COMMENT ON COLUMN table1.a IS null; ``` +Set `need_last_cache` for table1 + +```SQL +ALTER TABLE table1 SET PROPERTIES need_last_cache=false; +``` + +Note: `ALTER TABLE ... SET PROPERTIES need_last_cache=DEFAULT` restores the database default semantics. If `need_last_cache` is explicitly configured for the database, the table uses that database-level value; otherwise, the table uses the default value `true`. + ### 2.6 Delete Tables Used to delete a table. diff --git a/src/UserGuide/latest-Table/Reference/System-Tables_apache.md b/src/UserGuide/latest-Table/Reference/System-Tables_apache.md index 0b8788fea..a766d9b33 100644 --- a/src/UserGuide/latest-Table/Reference/System-Tables_apache.md +++ b/src/UserGuide/latest-Table/Reference/System-Tables_apache.md @@ -27,7 +27,7 @@ IoTDB has a built-in system database called `INFORMATION_SCHEMA`, which contains * ​**Name**​: `INFORMATION_SCHEMA` * ​**Commands**​: Read-only, only supports `Show databases (DETAILS)` / `Show Tables (DETAILS)` / `Use`. Other operations will result in an error: `"The database 'information_schema' can only be queried."` -* ​**Attributes**​:` TTL=INF`, other attributes default to `null ` +* ​**Attributes**​: `TTL=INF`; starting from V2.0.12, `need_last_cache=false`; other attributes default to `null` * ​**SQL Example**​: ```sql @@ -88,18 +88,20 @@ IoTDB> show tables from information_schema | `max_schema_region_group_num` | INT32 | ATTRIBUTE | Maximum number of schema regions to which the database can expand. Supported starting from V2.0.11. | | `data_region_group_num` | INT32 | ATTRIBUTE | Number of data regions | | `max_data_region_group_num` | INT32 | ATTRIBUTE | Maximum number of data regions to which the database can expand. Supported starting from V2.0.11. | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | Database-level default for the last cache; `true` if not explicitly configured | +* `need_last_cache` is supported since V2.0.12. * The query results only display the collection of databases for which you have any permission on the database itself or any table within the database. * Query Example: ```sql IoTDB> select * from information_schema.databases -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -|information_schema| INF| null| null| null| null| null| null| null| -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num|need_last_cache| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +|information_schema| INF| null| null| null| null| null| null| null| false| +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ ``` ### 2.2 TABLES @@ -114,35 +116,37 @@ IoTDB> select * from information_schema.databases | `ttl(ms)` | STRING | ATTRIBUTE | Data retention time | | `status` | STRING | ATTRIBUTE | Status | | `comment` | STRING | ATTRIBUTE | Description/comment | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | The effective last cache setting of a base table or tree-to-table view. | * Note: Possible values for `status`: `USING`, `PRE_CREATE`, `PRE_DELETE`. For details, refer to the [View Tables](../Basic-Concept/Table-Management_apache.md#12-view-tables) in Table Management documentation +* `need_last_cache` is supported since V2.0.12. * The query results only display the collection of tables for which you have any permission. * Query Example: ```sql IoTDB> select * from information_schema.tables -+------------------+--------------+-----------+------+-------+-----------+ -| database| table_name| ttl(ms)|status|comment| table_type| -+------------------+--------------+-----------+------+-------+-----------+ -|information_schema| databases| INF| USING| null|SYSTEM VIEW| -|information_schema| models| INF| USING| null|SYSTEM VIEW| -|information_schema| subscriptions| INF| USING| null|SYSTEM VIEW| -|information_schema| regions| INF| USING| null|SYSTEM VIEW| -|information_schema| functions| INF| USING| null|SYSTEM VIEW| -|information_schema| keywords| INF| USING| null|SYSTEM VIEW| -|information_schema| columns| INF| USING| null|SYSTEM VIEW| -|information_schema| topics| INF| USING| null|SYSTEM VIEW| -|information_schema|configurations| INF| USING| null|SYSTEM VIEW| -|information_schema| queries| INF| USING| null|SYSTEM VIEW| -|information_schema| tables| INF| USING| null|SYSTEM VIEW| -|information_schema| pipe_plugins| INF| USING| null|SYSTEM VIEW| -|information_schema| nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| data_nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| pipes| INF| USING| null|SYSTEM VIEW| -|information_schema| views| INF| USING| null|SYSTEM VIEW| -|information_schema| config_nodes| INF| USING| null|SYSTEM VIEW| -| database1| table1|31536000000| USING| null| BASE TABLE| -+------------------+--------------+-----------+------+-------+-----------+ ++------------------+--------------+-----------+------+-------+-------------+---------------+ +| database| table_name| ttl(ms)|status|comment| table_type|need_last_cache| ++------------------+--------------+-----------+------+-------+-------------+---------------+ +|information_schema| databases| INF| USING| null| SYSTEM VIEW| false| +|information_schema| models| INF| USING| null| SYSTEM VIEW| false| +|information_schema| subscriptions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| regions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| functions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| keywords| INF| USING| null| SYSTEM VIEW| false| +|information_schema| columns| INF| USING| null| SYSTEM VIEW| false| +|information_schema| topics| INF| USING| null| SYSTEM VIEW| false| +|information_schema|configurations| INF| USING| null| SYSTEM VIEW| false| +|information_schema| queries| INF| USING| null| SYSTEM VIEW| false| +|information_schema| tables| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipe_plugins| INF| USING| null| SYSTEM VIEW| false| +|information_schema| nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| data_nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| views| INF| USING| null| SYSTEM VIEW| false| +|information_schema| config_nodes| INF| USING| null| SYSTEM VIEW| false| +| database1| table1|31536000000| USING| null| BASE TABLE| true| ++------------------+--------------+-----------+------+-------+-------------+---------------+ ``` ### 2.3 REGIONS diff --git a/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md b/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md index c821055b4..36d3bb5e4 100644 --- a/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md +++ b/src/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md @@ -62,6 +62,12 @@ Database Node Naming Rules: Besides, if deploy on Windows or macOS system, the LayerName is case-insensitive, which means it's not allowed to create databases `root.ln` and `root.LN` at the same time. +Starting from V2.0.12, the Boolean parameter `NEED_LAST_CACHE` can be specified when creating a database to control whether the database actively maintains the last cache. The default value is `true`, which maintains the last cache according to the existing policy. Setting it to `false` means that the database does not need to actively maintain the last cache. + +```SQL +CREATE DATABASE root.ln WITH NEED_LAST_CACHE=false; +``` + ### 1.2 Show Databases After creating the database, we can use the [SHOW DATABASES](../SQL-Manual/SQL-Manual_apache) statement and [SHOW DATABASES \](../SQL-Manual/SQL-Manual_apache) to view the databases. The SQL statements are as follows: @@ -84,6 +90,19 @@ Total line number = 2 It costs 0.060s ``` +Starting from V2.0.12, the result set of `SHOW DATABASES DETAILS` includes the `NeedLastCache` column. For example, after creating a database with `NEED_LAST_CACHE=false`, query the setting as follows: + +```SQL +SHOW DATABASES DETAILS root.ln; +``` +```shell ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.ln| 1| 1| 0| 604800000| 0| 1| 0| 4| false| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +``` + ### 1.3 Delete Database User can use the `DELETE DATABASE ` statement to delete all databases matching the pathPattern. Please note the data in the database will also be deleted. @@ -277,6 +296,7 @@ The following heterogeneous database parameters are supported: | TIME_PARTITION_INTERVAL | Long | Time partition interval of the database. The value must be a positive integer. | | MAX_SCHEMA_REGION_GROUP_NUM | Integer | Maximum number of SchemaRegionGroups to which the database can automatically expand. The value must be a positive integer. | | MAX_DATA_REGION_GROUP_NUM | Integer | Maximum number of DataRegionGroups to which the database can automatically expand. The value must be a positive integer. | +| NEED_LAST_CACHE | Boolean | Whether to actively maintain the last cache for the database. Defaults to `true`. Supported starting from V2.0.12. | Note the following when configuring heterogeneous parameters: @@ -331,11 +351,11 @@ SHOW DATABASES DETAILS; ``` ```shell -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| true| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` The columns in the query result are, in order: @@ -349,6 +369,7 @@ The columns in the query result are, in order: + Maximum number of SchemaRegionGroups allowed for the database + Number of DataRegionGroups currently owned by the database + Maximum number of DataRegionGroups allowed for the database ++ Whether the database needs to actively maintain the last cache (`NeedLastCache`, supported since V2.0.12) ## 2. Device Template diff --git a/src/zh/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md b/src/zh/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md index 7f3109620..213368e11 100644 --- a/src/zh/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md +++ b/src/zh/UserGuide/Master/Table/Basic-Concept/Database-Management_apache.md @@ -75,12 +75,15 @@ CREATE DATABASE (IF NOT EXISTS)? (WITH properties)? | `TIME_PARTITION_INTERVAL` | 数据库的时间分区间隔,单位 ms,此值需要为正整数 | 604800000 | | `MAX_SCHEMA_REGION_GROUP_NUM` | 数据库自动扩展 SchemaRegionGroup 时允许达到的最大 SchemaRegionGroup 数量,此值需要为正整数,V2.0.11 起支持 | 1 | | `MAX_DATA_REGION_GROUP_NUM` | 数据库自动扩展 DataRegionGroup 时允许达到的最大 DataRegionGroup 数量,此值需要为正整数,V2.0.11 起支持 | 2 | +| `NEED_LAST_CACHE` | 是否需要主动维护 last cache。可选值为 `true` 或 `false`:`true` 表示按既有策略维护 last cache;`false` 表示该对象不主动需要 last cache。 | `true` | **注意:** - 属性的大小写不敏感,有关详细信息请参阅[大小写敏感规则](../SQL-Manual/Identifier.md#大小写敏感性)。 - 仅当 `iotdb-common.properties` 配置文件中的 `schema_region_group_extension_policy` 和 `data_region_group_extension_policy` 参数设置为 `CUSTOM` 策略时,才支持通过 SQL 在创建或修改数据库时设置或调整 schema/data region group 最大配额,即 `maxSchemaRegionGroupNum` 和 `maxDataRegionGroupNum`。 +- `NEED_LAST_CACHE` 自 V2.0.12 起支持。设置为 `false` 时,该数据库下后续创建且未显式指定 `need_last_cache` 的表/视图默认不需要主动维护 last cache。 + **示例:** ```SQL @@ -151,6 +154,7 @@ SHOW DATABASES (DETAILS)? | MaxSchemaRegionGroupNum | 使用 `DETAILS` 语句会返回此列,展示数据库允许拥有的最大元数据副本组数量。 | | DataRegionGroupNum | 使用 `DETAILS` 语句会返回此列,展示数据库当前拥有的数据副本组数量。 | | MaxDataRegionGroupNum | 使用 `DETAILS` 语句会返回此列,展示数据库允许拥有的最大数据副本组数量。 | +| NeedLastCache | 使用 `DETAILS` 语句时返回此列,展示数据库级 last cache 默认值;未显式设置时为 `true`。自 V2.0.12 起支持。 | **示例:** @@ -159,12 +163,12 @@ SHOW DATABASES DETAILS; ``` ```shell -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -|information_schema| INF| null| null| null| null| null| null| null| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| +|information_schema| INF| null| null| null| null| null| null| null| false| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` ### 2.5 统计数据库数量 @@ -200,15 +204,18 @@ ALTER DATABASE (IF EXISTS)? database=identifier SET PROPERTIES propertyAssignmen **说明:** -1. `ALTER DATABASE` 操作目前仅支持对数据库的 `MAX_SCHEMA_REGION_GROUP_NUM`、`MAX_DATA_REGION_GROUP_NUM` 以及 `TTL` 属性进行修改。 +1. `ALTER DATABASE` 操作目前仅支持对数据库的 `MAX_SCHEMA_REGION_GROUP_NUM`、`MAX_DATA_REGION_GROUP_NUM`、`TTL` 以及 `NEED_LAST_CACHE`(自 V2.0.12 起支持)属性进行修改。 **示例:** ```SQL ALTER DATABASE database1 SET PROPERTIES TTL=31536000000; ALTER DATABASE database1 SET PROPERTIES MAX_SCHEMA_REGION_GROUP_NUM=2, MAX_DATA_REGION_GROUP_NUM=4; +ALTER DATABASE database1 SET PROPERTIES need_last_cache=false; ``` +`ALTER DATABASE ... SET PROPERTIES need_last_cache=DEFAULT` 表示恢复数据库级默认值 `true`。 + ### 2.7 删除数据库 用于删除数据库。 diff --git a/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md b/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md index 38d5a9a30..f86205987 100644 --- a/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md +++ b/src/zh/UserGuide/Master/Table/Basic-Concept/Table-Management_apache.md @@ -123,6 +123,7 @@ comment ``` 6. columnDefinition 列名称与表名称具有相同特性,并且可包含特殊字符`.`。 7. COMMENT 给表添加注释。 +8. 自 V2.0.12 起,支持设置布尔类型属性 `need_last_cache`,用于指定表是否主动维护 last cache,可选值为 `true` 或 `false`。创建表时显式指定该属性,则使用表级配置;未显式指定时,继承创建表时数据库的 `need_last_cache` 配置。 **示例:** @@ -163,17 +164,19 @@ SHOW TABLES (DETAILS)? ((FROM | IN) database_name)? - `PRE_CREATE`:表示表正在创建中或创建失败,此时表不可用。 - `PRE_DELETE`:表示表正在删除中或删除失败,此类表将永久不可用。 +自 V2.0.12 起,`SHOW TABLES DETAILS` 结果集新增 `NeedLastCache` 列。 + **示例:** ```sql SHOW TABLES DETAILS FROM database1; ``` ```shell -+---------------+-----------+------+-------+ -| TableName| TTL(ms)|Status|Comment| -+---------------+-----------+------+-------+ -| table1|31536000000| USING| table1| -+---------------+-----------+------+-------+ ++---------------+-----------+------+-------+----------+-------------+ +| TableName| TTL(ms)|Status|Comment| TableType|NeedLastCache| ++---------------+-----------+------+-------+----------+-------------+ +| table1|31536000000| USING| table1|BASE TABLE| true| ++---------------+-----------+------+-------+----------+-------------+ ``` ### 2.3 查看表的列 @@ -228,7 +231,8 @@ SHOW CREATE TABLE **说明:** -1. 该语句不支持对系统表的查询 +1. 该语句不支持对系统表的查询 +2. 自 V2.0.12 起,返回的建表语句包含 `need_last_cache` 属性信息。 **示例:** @@ -236,11 +240,11 @@ SHOW CREATE TABLE SHOW CREATE TABLE table1; ``` ```shell -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Table| Create Table| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000)| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Table| Create Table| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000, need_last_cache=true)| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` @@ -256,7 +260,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col #dropColumn; ALTER TABLE (IF EXISTS)? tableName=qualifiedName DROP COLUMN (IF EXISTS)? column=identifier; #setTableProperties; -// set TTL can use this; +// set TTL or need_last_cache can use this; ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments; COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'; @@ -265,7 +269,7 @@ COMMENT ON COLUMN tableName.column IS 'column_comment'; **说明:** -1. `SET PROPERTIES`操作目前仅支持对表的 TTL 属性进行配置。 +1. `SET PROPERTIES` 操作支持对表的 TTL 属性进行配置;自 V2.0.12 起,也支持配置 `need_last_cache` 属性。 2. 删除列功能,仅支持删除属性列(ATTRIBUTE)和物理量列(FIELD),标识列(TAG)不支持删除。 3. 修改后的 comment 会覆盖原有注释,如果指定为 null,则会擦除之前的 comment。 @@ -292,6 +296,14 @@ COMMENT ON TABLE table1 IS 'table1'; COMMENT ON COLUMN table1.a IS null; ``` +修改表 table1 的 `need_last_cache` + +```SQL +ALTER TABLE table1 SET PROPERTIES need_last_cache=false; +``` + +注意:`ALTER TABLE ... SET PROPERTIES need_last_cache=DEFAULT` 表示恢复数据库默认语义:数据库显式设置了 `need_last_cache` 时,表恢复为数据库级值;数据库未显式设置时,表恢复为默认值 `true`。 + ### 2.6 删除表 用于删除表。 diff --git a/src/zh/UserGuide/Master/Table/Reference/System-Tables_apache.md b/src/zh/UserGuide/Master/Table/Reference/System-Tables_apache.md index 76aa2b4d7..ecc6f12e9 100644 --- a/src/zh/UserGuide/Master/Table/Reference/System-Tables_apache.md +++ b/src/zh/UserGuide/Master/Table/Reference/System-Tables_apache.md @@ -27,7 +27,7 @@ IoTDB 内置系统数据库 `INFORMATION_SCHEMA`,其中包含一系列系统 * 名称:`INFORMATION_SCHEMA` * 指令:只读,只支持 `Show databases (DETAILS) `​`/ Show Tables (DETAILS) / Use`,其余操作将会报错:`"The database 'information_schema' can only be queried"` -* 属性:`TTL=INF`,其余属性默认为`null` +* 属性:`TTL=INF`;自 V2.0.12 起,`need_last_cache=false`;其余属性默认为 `null` * SQL示例: ```sql @@ -88,18 +88,20 @@ IoTDB> show tables from information_schema | max\_schema\_region\_group\_num | INT32 | ATTRIBUTE | 可扩展最大元数据分区数量,V2.0.11 起支持 | | data\_region\_group\_num | INT32 | ATTRIBUTE | 数据分区数量 | | max\_data\_region\_group\_num | INT32 | ATTRIBUTE | 可扩展最大数据分区数量,V2.0.11 起支持 | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | 数据库级 last cache 默认值;未显式设置时为 `true` | +* `need_last_cache` 自 V2.0.12 起支持 * 查询结果只展示自身对该数据库本身或库中任意表有任意权限的数据库集合 * 查询示例: ```sql IoTDB> select * from information_schema.databases -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -|information_schema| INF| null| null| null| null| null| null| null| -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num|need_last_cache| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +|information_schema| INF| null| null| null| null| null| null| null| false| +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ ``` ### 2.2 TABLES 表 @@ -114,35 +116,37 @@ IoTDB> select * from information_schema.databases | ttl(ms) | STRING | ATTRIBUTE | 数据保留时间 | | status | STRING | ATTRIBUTE | 状态 | | comment | STRING | ATTRIBUTE | 注释 | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | 普通表或树转表视图当前生效的 last cache 配置。 | * 说明:status 可能为`USING`/`PRE_CREATE`/`PRE_DELETE`,具体见表管理中[查看表](../Basic-Concept/Table-Management_apache.md#12-查看表)的相关描述 +* `need_last_cache` 自 V2.0.12 起支持 * 查询结果只展示自身有任意权限的表集合 * 查询示例: ```sql IoTDB> select * from information_schema.tables -+------------------+--------------+-----------+------+-------+-----------+ -| database| table_name| ttl(ms)|status|comment| table_type| -+------------------+--------------+-----------+------+-------+-----------+ -|information_schema| databases| INF| USING| null|SYSTEM VIEW| -|information_schema| models| INF| USING| null|SYSTEM VIEW| -|information_schema| subscriptions| INF| USING| null|SYSTEM VIEW| -|information_schema| regions| INF| USING| null|SYSTEM VIEW| -|information_schema| functions| INF| USING| null|SYSTEM VIEW| -|information_schema| keywords| INF| USING| null|SYSTEM VIEW| -|information_schema| columns| INF| USING| null|SYSTEM VIEW| -|information_schema| topics| INF| USING| null|SYSTEM VIEW| -|information_schema|configurations| INF| USING| null|SYSTEM VIEW| -|information_schema| queries| INF| USING| null|SYSTEM VIEW| -|information_schema| tables| INF| USING| null|SYSTEM VIEW| -|information_schema| pipe_plugins| INF| USING| null|SYSTEM VIEW| -|information_schema| nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| data_nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| pipes| INF| USING| null|SYSTEM VIEW| -|information_schema| views| INF| USING| null|SYSTEM VIEW| -|information_schema| config_nodes| INF| USING| null|SYSTEM VIEW| -| database1| table1|31536000000| USING| null| BASE TABLE| -+------------------+--------------+-----------+------+-------+-----------+ ++------------------+--------------+-----------+------+-------+-------------+---------------+ +| database| table_name| ttl(ms)|status|comment| table_type|need_last_cache| ++------------------+--------------+-----------+------+-------+-------------+---------------+ +|information_schema| databases| INF| USING| null| SYSTEM VIEW| false| +|information_schema| models| INF| USING| null| SYSTEM VIEW| false| +|information_schema| subscriptions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| regions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| functions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| keywords| INF| USING| null| SYSTEM VIEW| false| +|information_schema| columns| INF| USING| null| SYSTEM VIEW| false| +|information_schema| topics| INF| USING| null| SYSTEM VIEW| false| +|information_schema|configurations| INF| USING| null| SYSTEM VIEW| false| +|information_schema| queries| INF| USING| null| SYSTEM VIEW| false| +|information_schema| tables| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipe_plugins| INF| USING| null| SYSTEM VIEW| false| +|information_schema| nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| data_nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| views| INF| USING| null| SYSTEM VIEW| false| +|information_schema| config_nodes| INF| USING| null| SYSTEM VIEW| false| +| database1| table1|31536000000| USING| null| BASE TABLE| true| ++------------------+--------------+-----------+------+-------+-------------+---------------+ ``` ### 2.3 REGIONS 表 diff --git a/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md b/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md index ec38b4cb7..2f79d8768 100644 --- a/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md +++ b/src/zh/UserGuide/Master/Tree/Basic-Concept/Operate-Metadata_apache.md @@ -61,6 +61,12 @@ Database 节点名命名规则: 还需注意,如果在 Windows 或 macOS 系统上部署,database 名是大小写不敏感的。例如同时创建`root.ln` 和 `root.LN` 是不被允许的。 +自 V2.0.12 起,创建数据库时支持布尔类型参数 `NEED_LAST_CACHE`,用于设置是否为该数据库主动维护最新点缓存(last cache)。默认值为 `true`,表示按原有策略维护 last cache;设置为 `false` 时,表示该数据库不需要主动维护 last cache。 + +```SQL +CREATE DATABASE root.ln WITH NEED_LAST_CACHE=false; +``` + ### 1.2 查看数据库 在 database 创建后,我们可以使用 [SHOW DATABASES](../SQL-Manual/SQL-Manual.md#查看数据库) 语句和 [SHOW DATABASES \](../SQL-Manual/SQL-Manual.md#查看数据库) 来查看 database,SQL 语句如下所示: @@ -84,6 +90,19 @@ Total line number = 2 It costs 0.060s ``` +自 V2.0.12 起,`SHOW DATABASES DETAILS` 结果集新增 `NeedLastCache` 列。例如,创建数据库时指定 `NEED_LAST_CACHE=false` 后,可查看该配置: + +```SQL +SHOW DATABASES DETAILS root.ln; +``` +```shell ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.ln| 1| 1| 0| 604800000| 0| 1| 0| 4| false| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +``` + ### 1.3 删除数据库 用户可以使用`DELETE DATABASE `语句删除该路径模式匹配的所有的数据库。在删除的过程中,需要注意的是数据库的数据也会被删除。 @@ -283,6 +302,7 @@ show devices; | TIME_PARTITION_INTERVAL | Long | 数据库的时间分区间隔,此值需要为正整数 | | MAX_SCHEMA_REGION_GROUP_NUM | Integer | 数据库自动扩展 SchemaRegionGroup 时允许达到的最大 SchemaRegionGroup 数量,此值需要为正整数 | | MAX_DATA_REGION_GROUP_NUM | Integer | 数据库自动扩展 DataRegionGroup 时允许达到的最大 DataRegionGroup 数量,此值需要为正整数 | +| NEED_LAST_CACHE | Boolean | 是否为数据库主动维护最新点缓存,默认值为 `true`,自 V2.0.12 起支持 | 用户在配置异构参数时需要注意: @@ -333,11 +353,11 @@ SHOW DATABASES DETAILS prefixPath? SHOW DATABASES DETAILS; ``` ```shell -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| true| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` 各列查询结果依次为: @@ -350,6 +370,7 @@ SHOW DATABASES DETAILS; + 数据库允许拥有的最大 SchemaRegionGroup 数量 + 数据库当前拥有的 DataRegionGroup 数量 + 数据库允许拥有的最大 DataRegionGroup 数量 ++ 数据库是否需要主动维护 last cache(`NeedLastCache`,自 V2.0.12 起支持) ## 2. 设备模板管理 diff --git a/src/zh/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md b/src/zh/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md index 7f3109620..213368e11 100644 --- a/src/zh/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md +++ b/src/zh/UserGuide/latest-Table/Basic-Concept/Database-Management_apache.md @@ -75,12 +75,15 @@ CREATE DATABASE (IF NOT EXISTS)? (WITH properties)? | `TIME_PARTITION_INTERVAL` | 数据库的时间分区间隔,单位 ms,此值需要为正整数 | 604800000 | | `MAX_SCHEMA_REGION_GROUP_NUM` | 数据库自动扩展 SchemaRegionGroup 时允许达到的最大 SchemaRegionGroup 数量,此值需要为正整数,V2.0.11 起支持 | 1 | | `MAX_DATA_REGION_GROUP_NUM` | 数据库自动扩展 DataRegionGroup 时允许达到的最大 DataRegionGroup 数量,此值需要为正整数,V2.0.11 起支持 | 2 | +| `NEED_LAST_CACHE` | 是否需要主动维护 last cache。可选值为 `true` 或 `false`:`true` 表示按既有策略维护 last cache;`false` 表示该对象不主动需要 last cache。 | `true` | **注意:** - 属性的大小写不敏感,有关详细信息请参阅[大小写敏感规则](../SQL-Manual/Identifier.md#大小写敏感性)。 - 仅当 `iotdb-common.properties` 配置文件中的 `schema_region_group_extension_policy` 和 `data_region_group_extension_policy` 参数设置为 `CUSTOM` 策略时,才支持通过 SQL 在创建或修改数据库时设置或调整 schema/data region group 最大配额,即 `maxSchemaRegionGroupNum` 和 `maxDataRegionGroupNum`。 +- `NEED_LAST_CACHE` 自 V2.0.12 起支持。设置为 `false` 时,该数据库下后续创建且未显式指定 `need_last_cache` 的表/视图默认不需要主动维护 last cache。 + **示例:** ```SQL @@ -151,6 +154,7 @@ SHOW DATABASES (DETAILS)? | MaxSchemaRegionGroupNum | 使用 `DETAILS` 语句会返回此列,展示数据库允许拥有的最大元数据副本组数量。 | | DataRegionGroupNum | 使用 `DETAILS` 语句会返回此列,展示数据库当前拥有的数据副本组数量。 | | MaxDataRegionGroupNum | 使用 `DETAILS` 语句会返回此列,展示数据库允许拥有的最大数据副本组数量。 | +| NeedLastCache | 使用 `DETAILS` 语句时返回此列,展示数据库级 last cache 默认值;未显式设置时为 `true`。自 V2.0.12 起支持。 | **示例:** @@ -159,12 +163,12 @@ SHOW DATABASES DETAILS; ``` ```shell -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -|information_schema| INF| null| null| null| null| null| null| null| -+------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| +|information_schema| INF| null| null| null| null| null| null| null| false| ++------------------+-------+-----------------------+---------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` ### 2.5 统计数据库数量 @@ -200,15 +204,18 @@ ALTER DATABASE (IF EXISTS)? database=identifier SET PROPERTIES propertyAssignmen **说明:** -1. `ALTER DATABASE` 操作目前仅支持对数据库的 `MAX_SCHEMA_REGION_GROUP_NUM`、`MAX_DATA_REGION_GROUP_NUM` 以及 `TTL` 属性进行修改。 +1. `ALTER DATABASE` 操作目前仅支持对数据库的 `MAX_SCHEMA_REGION_GROUP_NUM`、`MAX_DATA_REGION_GROUP_NUM`、`TTL` 以及 `NEED_LAST_CACHE`(自 V2.0.12 起支持)属性进行修改。 **示例:** ```SQL ALTER DATABASE database1 SET PROPERTIES TTL=31536000000; ALTER DATABASE database1 SET PROPERTIES MAX_SCHEMA_REGION_GROUP_NUM=2, MAX_DATA_REGION_GROUP_NUM=4; +ALTER DATABASE database1 SET PROPERTIES need_last_cache=false; ``` +`ALTER DATABASE ... SET PROPERTIES need_last_cache=DEFAULT` 表示恢复数据库级默认值 `true`。 + ### 2.7 删除数据库 用于删除数据库。 diff --git a/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md b/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md index 6dce35a28..61a8e4fb5 100644 --- a/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md +++ b/src/zh/UserGuide/latest-Table/Basic-Concept/Table-Management_apache.md @@ -123,6 +123,7 @@ comment ``` 6. columnDefinition 列名称与表名称具有相同特性,并且可包含特殊字符`.`。 7. COMMENT 给表添加注释。 +8. 自 V2.0.12 起,支持设置布尔类型属性 `need_last_cache`,用于指定表是否主动维护 last cache,可选值为 `true` 或 `false`。创建表时显式指定该属性,则使用表级配置;未显式指定时,继承创建表时数据库的 `need_last_cache` 配置。 **示例:** @@ -163,17 +164,19 @@ SHOW TABLES (DETAILS)? ((FROM | IN) database_name)? - `PRE_CREATE`:表示表正在创建中或创建失败,此时表不可用。 - `PRE_DELETE`:表示表正在删除中或删除失败,此类表将永久不可用。 +自 V2.0.12 起,`SHOW TABLES DETAILS` 结果集新增 `NeedLastCache` 列。 + **示例:** ```sql SHOW TABLES DETAILS FROM database1; ``` ```shell -+---------------+-----------+------+-------+ -| TableName| TTL(ms)|Status|Comment| -+---------------+-----------+------+-------+ -| table1|31536000000| USING| table1| -+---------------+-----------+------+-------+ ++---------------+-----------+------+-------+----------+-------------+ +| TableName| TTL(ms)|Status|Comment| TableType|NeedLastCache| ++---------------+-----------+------+-------+----------+-------------+ +| table1|31536000000| USING| table1|BASE TABLE| true| ++---------------+-----------+------+-------+----------+-------------+ ``` ### 2.3 查看表的列 @@ -228,7 +231,8 @@ SHOW CREATE TABLE **说明:** -1. 该语句不支持对系统表的查询 +1. 该语句不支持对系统表的查询 +2. 自 V2.0.12 起,返回的建表语句包含 `need_last_cache` 属性信息。 **示例:** @@ -236,11 +240,11 @@ SHOW CREATE TABLE SHOW CREATE TABLE table1; ``` ```shell -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Table| Create Table| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000)| -+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Table| Create Table| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|table1|CREATE TABLE "table1" ("region" STRING TAG,"plant_id" STRING TAG,"device_id" STRING TAG,"model_id" STRING ATTRIBUTE,"maintenance" STRING ATTRIBUTE,"temperature" FLOAT FIELD,"humidity" FLOAT FIELD,"status" BOOLEAN FIELD,"arrival_time" TIMESTAMP FIELD) WITH (ttl=31536000000, need_last_cache=true)| ++------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` @@ -256,7 +260,7 @@ ALTER TABLE (IF EXISTS)? tableName=qualifiedName ADD COLUMN (IF NOT EXISTS)? col #dropColumn; ALTER TABLE (IF EXISTS)? tableName=qualifiedName DROP COLUMN (IF EXISTS)? column=identifier; #setTableProperties; -// set TTL can use this; +// set TTL or need_last_cache can use this; ALTER TABLE (IF EXISTS)? tableName=qualifiedName SET PROPERTIES propertyAssignments; COMMENT ON TABLE tableName=qualifiedName IS 'table_comment'; @@ -265,7 +269,7 @@ COMMENT ON COLUMN tableName.column IS 'column_comment'; **说明:** -1. `SET PROPERTIES`操作目前仅支持对表的 TTL 属性进行配置。 +1. `SET PROPERTIES` 操作支持对表的 TTL 属性进行配置;自 V2.0.12 起,也支持配置 `need_last_cache` 属性。 2. 删除列功能,仅支持删除属性列(ATTRIBUTE)和物理量列(FIELD),标识列(TAG)不支持删除。 3. 修改后的 comment 会覆盖原有注释,如果指定为 null,则会擦除之前的 comment。 @@ -292,6 +296,14 @@ COMMENT ON TABLE table1 IS 'table1'; COMMENT ON COLUMN table1.a IS null; ``` +修改表 table1 的 `need_last_cache` + +```SQL +ALTER TABLE table1 SET PROPERTIES need_last_cache=false; +``` + +注意:`ALTER TABLE ... SET PROPERTIES need_last_cache=DEFAULT` 表示恢复数据库默认语义:数据库显式设置了 `need_last_cache` 时,表恢复为数据库级值;数据库未显式设置时,表恢复为默认值 `true`。 + ### 2.6 删除表 用于删除表。 diff --git a/src/zh/UserGuide/latest-Table/Reference/System-Tables_apache.md b/src/zh/UserGuide/latest-Table/Reference/System-Tables_apache.md index 76aa2b4d7..ecc6f12e9 100644 --- a/src/zh/UserGuide/latest-Table/Reference/System-Tables_apache.md +++ b/src/zh/UserGuide/latest-Table/Reference/System-Tables_apache.md @@ -27,7 +27,7 @@ IoTDB 内置系统数据库 `INFORMATION_SCHEMA`,其中包含一系列系统 * 名称:`INFORMATION_SCHEMA` * 指令:只读,只支持 `Show databases (DETAILS) `​`/ Show Tables (DETAILS) / Use`,其余操作将会报错:`"The database 'information_schema' can only be queried"` -* 属性:`TTL=INF`,其余属性默认为`null` +* 属性:`TTL=INF`;自 V2.0.12 起,`need_last_cache=false`;其余属性默认为 `null` * SQL示例: ```sql @@ -88,18 +88,20 @@ IoTDB> show tables from information_schema | max\_schema\_region\_group\_num | INT32 | ATTRIBUTE | 可扩展最大元数据分区数量,V2.0.11 起支持 | | data\_region\_group\_num | INT32 | ATTRIBUTE | 数据分区数量 | | max\_data\_region\_group\_num | INT32 | ATTRIBUTE | 可扩展最大数据分区数量,V2.0.11 起支持 | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | 数据库级 last cache 默认值;未显式设置时为 `true` | +* `need_last_cache` 自 V2.0.12 起支持 * 查询结果只展示自身对该数据库本身或库中任意表有任意权限的数据库集合 * 查询示例: ```sql IoTDB> select * from information_schema.databases -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ -|information_schema| INF| null| null| null| null| null| null| null| -| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| -+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+ ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +| database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|max_schema_region_group_num|data_region_group_num|max_data_region_group_num|need_last_cache| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ +|information_schema| INF| null| null| null| null| null| null| null| false| +| database1| INF| 1| 1| 604800000| 1| 1| 2| 2| true| ++------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------------+---------------------+-------------------------+---------------+ ``` ### 2.2 TABLES 表 @@ -114,35 +116,37 @@ IoTDB> select * from information_schema.databases | ttl(ms) | STRING | ATTRIBUTE | 数据保留时间 | | status | STRING | ATTRIBUTE | 状态 | | comment | STRING | ATTRIBUTE | 注释 | +| `need_last_cache` | BOOLEAN | ATTRIBUTE | 普通表或树转表视图当前生效的 last cache 配置。 | * 说明:status 可能为`USING`/`PRE_CREATE`/`PRE_DELETE`,具体见表管理中[查看表](../Basic-Concept/Table-Management_apache.md#12-查看表)的相关描述 +* `need_last_cache` 自 V2.0.12 起支持 * 查询结果只展示自身有任意权限的表集合 * 查询示例: ```sql IoTDB> select * from information_schema.tables -+------------------+--------------+-----------+------+-------+-----------+ -| database| table_name| ttl(ms)|status|comment| table_type| -+------------------+--------------+-----------+------+-------+-----------+ -|information_schema| databases| INF| USING| null|SYSTEM VIEW| -|information_schema| models| INF| USING| null|SYSTEM VIEW| -|information_schema| subscriptions| INF| USING| null|SYSTEM VIEW| -|information_schema| regions| INF| USING| null|SYSTEM VIEW| -|information_schema| functions| INF| USING| null|SYSTEM VIEW| -|information_schema| keywords| INF| USING| null|SYSTEM VIEW| -|information_schema| columns| INF| USING| null|SYSTEM VIEW| -|information_schema| topics| INF| USING| null|SYSTEM VIEW| -|information_schema|configurations| INF| USING| null|SYSTEM VIEW| -|information_schema| queries| INF| USING| null|SYSTEM VIEW| -|information_schema| tables| INF| USING| null|SYSTEM VIEW| -|information_schema| pipe_plugins| INF| USING| null|SYSTEM VIEW| -|information_schema| nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| data_nodes| INF| USING| null|SYSTEM VIEW| -|information_schema| pipes| INF| USING| null|SYSTEM VIEW| -|information_schema| views| INF| USING| null|SYSTEM VIEW| -|information_schema| config_nodes| INF| USING| null|SYSTEM VIEW| -| database1| table1|31536000000| USING| null| BASE TABLE| -+------------------+--------------+-----------+------+-------+-----------+ ++------------------+--------------+-----------+------+-------+-------------+---------------+ +| database| table_name| ttl(ms)|status|comment| table_type|need_last_cache| ++------------------+--------------+-----------+------+-------+-------------+---------------+ +|information_schema| databases| INF| USING| null| SYSTEM VIEW| false| +|information_schema| models| INF| USING| null| SYSTEM VIEW| false| +|information_schema| subscriptions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| regions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| functions| INF| USING| null| SYSTEM VIEW| false| +|information_schema| keywords| INF| USING| null| SYSTEM VIEW| false| +|information_schema| columns| INF| USING| null| SYSTEM VIEW| false| +|information_schema| topics| INF| USING| null| SYSTEM VIEW| false| +|information_schema|configurations| INF| USING| null| SYSTEM VIEW| false| +|information_schema| queries| INF| USING| null| SYSTEM VIEW| false| +|information_schema| tables| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipe_plugins| INF| USING| null| SYSTEM VIEW| false| +|information_schema| nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| data_nodes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| pipes| INF| USING| null| SYSTEM VIEW| false| +|information_schema| views| INF| USING| null| SYSTEM VIEW| false| +|information_schema| config_nodes| INF| USING| null| SYSTEM VIEW| false| +| database1| table1|31536000000| USING| null| BASE TABLE| true| ++------------------+--------------+-----------+------+-------+-------------+---------------+ ``` ### 2.3 REGIONS 表 diff --git a/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md b/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md index ec38b4cb7..2f79d8768 100644 --- a/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md +++ b/src/zh/UserGuide/latest/Basic-Concept/Operate-Metadata_apache.md @@ -61,6 +61,12 @@ Database 节点名命名规则: 还需注意,如果在 Windows 或 macOS 系统上部署,database 名是大小写不敏感的。例如同时创建`root.ln` 和 `root.LN` 是不被允许的。 +自 V2.0.12 起,创建数据库时支持布尔类型参数 `NEED_LAST_CACHE`,用于设置是否为该数据库主动维护最新点缓存(last cache)。默认值为 `true`,表示按原有策略维护 last cache;设置为 `false` 时,表示该数据库不需要主动维护 last cache。 + +```SQL +CREATE DATABASE root.ln WITH NEED_LAST_CACHE=false; +``` + ### 1.2 查看数据库 在 database 创建后,我们可以使用 [SHOW DATABASES](../SQL-Manual/SQL-Manual.md#查看数据库) 语句和 [SHOW DATABASES \](../SQL-Manual/SQL-Manual.md#查看数据库) 来查看 database,SQL 语句如下所示: @@ -84,6 +90,19 @@ Total line number = 2 It costs 0.060s ``` +自 V2.0.12 起,`SHOW DATABASES DETAILS` 结果集新增 `NeedLastCache` 列。例如,创建数据库时指定 `NEED_LAST_CACHE=false` 后,可查看该配置: + +```SQL +SHOW DATABASES DETAILS root.ln; +``` +```shell ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.ln| 1| 1| 0| 604800000| 0| 1| 0| 4| false| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +``` + ### 1.3 删除数据库 用户可以使用`DELETE DATABASE `语句删除该路径模式匹配的所有的数据库。在删除的过程中,需要注意的是数据库的数据也会被删除。 @@ -283,6 +302,7 @@ show devices; | TIME_PARTITION_INTERVAL | Long | 数据库的时间分区间隔,此值需要为正整数 | | MAX_SCHEMA_REGION_GROUP_NUM | Integer | 数据库自动扩展 SchemaRegionGroup 时允许达到的最大 SchemaRegionGroup 数量,此值需要为正整数 | | MAX_DATA_REGION_GROUP_NUM | Integer | 数据库自动扩展 DataRegionGroup 时允许达到的最大 DataRegionGroup 数量,此值需要为正整数 | +| NEED_LAST_CACHE | Boolean | 是否为数据库主动维护最新点缓存,默认值为 `true`,自 V2.0.12 起支持 | 用户在配置异构参数时需要注意: @@ -333,11 +353,11 @@ SHOW DATABASES DETAILS prefixPath? SHOW DATABASES DETAILS; ``` ```shell -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ -| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| -+-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+ ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| Database|SchemaReplicationFactor|DataReplicationFactor|TimePartitionOrigin|TimePartitionInterval|SchemaRegionGroupNum|MaxSchemaRegionGroupNum|DataRegionGroupNum|MaxDataRegionGroupNum|NeedLastCache| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ +| root.db| 1| 1| 0| 604800000| 0| 2| 0| 3| true| ++-------------+-----------------------+---------------------+-------------------+---------------------+--------------------+-----------------------+------------------+---------------------+-------------+ ``` 各列查询结果依次为: @@ -350,6 +370,7 @@ SHOW DATABASES DETAILS; + 数据库允许拥有的最大 SchemaRegionGroup 数量 + 数据库当前拥有的 DataRegionGroup 数量 + 数据库允许拥有的最大 DataRegionGroup 数量 ++ 数据库是否需要主动维护 last cache(`NeedLastCache`,自 V2.0.12 起支持) ## 2. 设备模板管理