diff --git a/docs/reference/sql/create.md b/docs/reference/sql/create.md index f6a5c087b..2d811111c 100644 --- a/docs/reference/sql/create.md +++ b/docs/reference/sql/create.md @@ -261,7 +261,7 @@ create table if not exists metrics( with('merge_mode'='last_non_null'); ``` -Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest value of each field. +Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest non-null value of each field. ```sql INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1); INSERT INTO metrics VALUES ('host1', 0, NULL, 10), ('host2', 1, 11, NULL); diff --git a/docs/user-guide/manage-data/overview.md b/docs/user-guide/manage-data/overview.md index 03055774b..98d5ca903 100644 --- a/docs/user-guide/manage-data/overview.md +++ b/docs/user-guide/manage-data/overview.md @@ -177,7 +177,7 @@ That will not update anything: +-----------+---------------------+------+--------+ ``` -For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md##create-a-table-with-merge-mode) statement. +For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md#create-a-table-with-merge-mode) statement. ### Avoid updating data by creating table with `append_mode` option @@ -294,7 +294,7 @@ You can use Time to Live (TTL) policies to automatically remove stale data from - Decrease storage costs by cleaning out obsolete data. - Reduce the number of rows the database has to scan for some queries, potentially increasing query performance. -> Please note that the expired data due to TTL policy may not be deleted right after the expiration time. Instead, they are deleted during the compaction, which is a background job ran asynchronously. +> Please note that the expired data due to TTL policy may not be deleted right after the expiration time. Instead, they are deleted during the compaction, which is a background job run asynchronously. > If you are testing the TTL policy, be sure to trigger data flush and compaction before querying the data. > You can use our "[ADMIN](/reference/sql/admin.md)" functions to manually run them. @@ -323,6 +323,15 @@ Otherwise, the database TTL policy will be applied to the table. The value of `'ttl'` can be one of duration (like `1hour 12min 5s`), `instant` or `forever`. See details in [CREATE](/reference/sql/create.md#create-a-table-with-ttl) statement. +Use [`ALTER`](/reference/sql/alter.md#alter-table-options) to modify the TTL of an existing table or database: + +```sql +-- for table +ALTER TABLE monitor SET 'ttl'='1 month'; +-- for database +ALTER DATABASE test SET 'ttl'='1 month'; +``` + If you want to remove the TTL policy, you can use the following SQL ```sql diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md b/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md index d7fe66c3d..43480516d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/reference/sql/create.md @@ -265,7 +265,7 @@ create table if not exists metrics( with('merge_mode'='last_non_null'); ``` -在 `last_non_null` 模式下,表会通过保留每个字段的最新值来合并具有相同主键和时间戳的行。 +在 `last_non_null` 模式下,表会通过保留每个字段的最新非 NULL 值来合并具有相同主键和时间戳的行。 ```sql INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1); diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/manage-data/overview.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/manage-data/overview.md index 7e8d86c0f..3932be9ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/manage-data/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/manage-data/overview.md @@ -174,7 +174,7 @@ VALUES ("127.0.0.1", "2024-07-11 20:00:01", NULL); +-----------+---------------------+------+--------+ ``` -有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md##创建带有-merge-模式的表) 语句。 +有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md#创建带有-merge-模式的表) 语句。 ### 通过创建带有 `append_mode` 选项的表来避免更新数据 @@ -319,7 +319,16 @@ CREATE DATABASE test WITH ('ttl'='7d'); 如果 table 有自己的 TTL 策略,则该策略将优先于 database 的 TTL 策略, 否则 database 的 TTL 策略将被应用于 table。 -`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#create-a-table-with-ttl) 语句的文档。 +`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#创建指定-ttl-的表) 语句的文档。 + +使用 [`ALTER`](/reference/sql/alter.md#修改表的参数) 来修改现有表或数据库的 TTL: + +```sql +-- 针对表 +ALTER TABLE monitor SET 'ttl'='1 month'; +-- 针对数据库 +ALTER DATABASE test SET 'ttl'='1 month'; +``` 如果你想移除 TTL 策略,可以使用如下 SQL 语句: diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.17/reference/sql/create.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.17/reference/sql/create.md index d7fe66c3d..43480516d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.17/reference/sql/create.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.17/reference/sql/create.md @@ -265,7 +265,7 @@ create table if not exists metrics( with('merge_mode'='last_non_null'); ``` -在 `last_non_null` 模式下,表会通过保留每个字段的最新值来合并具有相同主键和时间戳的行。 +在 `last_non_null` 模式下,表会通过保留每个字段的最新非 NULL 值来合并具有相同主键和时间戳的行。 ```sql INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1); diff --git a/i18n/zh/docusaurus-plugin-content-docs/version-0.17/user-guide/manage-data/overview.md b/i18n/zh/docusaurus-plugin-content-docs/version-0.17/user-guide/manage-data/overview.md index 647d6dc9b..3932be9ac 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/version-0.17/user-guide/manage-data/overview.md +++ b/i18n/zh/docusaurus-plugin-content-docs/version-0.17/user-guide/manage-data/overview.md @@ -174,7 +174,7 @@ VALUES ("127.0.0.1", "2024-07-11 20:00:01", NULL); +-----------+---------------------+------+--------+ ``` -有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md##创建带有-merge-模式的表) 语句。 +有关 `merge_mode` 选项的更多信息,请参阅 [CREATE TABLE](/reference/sql/create.md#创建带有-merge-模式的表) 语句。 ### 通过创建带有 `append_mode` 选项的表来避免更新数据 @@ -291,6 +291,10 @@ Time to Live (TTL) 允许你设置定期删除表中数据的策略, - 通过清理过期数据来降低存储成本。 - 减少数据库在某些查询中需要扫描的行数,从而提高查询性能。 +> 请注意,因 TTL 策略而过期的数据,并不是在 TTL 到期时立刻删除的,而是发生在 compaction 时。compaction 是一个后台任务。 +> 如果你在测试 TTL 策略,查询过期数据之前请确保 flush 和 compaction 都已触发过了。 +> 你可以使用我们的 ”[ADMIN](/reference/sql/admin.md)“ 函数来手动触发。 + 你可以在创建每个表时设置 TTL。 例如,以下 SQL 语句创建了一个名为 `monitor` 的表,并设置了 7 天的 TTL 策略: @@ -315,7 +319,16 @@ CREATE DATABASE test WITH ('ttl'='7d'); 如果 table 有自己的 TTL 策略,则该策略将优先于 database 的 TTL 策略, 否则 database 的 TTL 策略将被应用于 table。 -`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#create-a-table-with-ttl) 语句的文档。 +`'ttl'` 参数的值可以是持续时间(例如 `1hour 12min 5s`)、`instant` 或 `forever`。有关详细信息,请参阅 [CREATE](/reference/sql/create.md#创建指定-ttl-的表) 语句的文档。 + +使用 [`ALTER`](/reference/sql/alter.md#修改表的参数) 来修改现有表或数据库的 TTL: + +```sql +-- 针对表 +ALTER TABLE monitor SET 'ttl'='1 month'; +-- 针对数据库 +ALTER DATABASE test SET 'ttl'='1 month'; +``` 如果你想移除 TTL 策略,可以使用如下 SQL 语句: diff --git a/versioned_docs/version-0.17/reference/sql/create.md b/versioned_docs/version-0.17/reference/sql/create.md index f6a5c087b..2d811111c 100644 --- a/versioned_docs/version-0.17/reference/sql/create.md +++ b/versioned_docs/version-0.17/reference/sql/create.md @@ -261,7 +261,7 @@ create table if not exists metrics( with('merge_mode'='last_non_null'); ``` -Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest value of each field. +Under `last_non_null` mode, the table merges rows with the same primary key and timestamp by keeping the latest non-null value of each field. ```sql INSERT INTO metrics VALUES ('host1', 0, 0, NULL), ('host2', 1, NULL, 1); INSERT INTO metrics VALUES ('host1', 0, NULL, 10), ('host2', 1, 11, NULL); diff --git a/versioned_docs/version-0.17/user-guide/manage-data/overview.md b/versioned_docs/version-0.17/user-guide/manage-data/overview.md index 9313fbafe..98d5ca903 100644 --- a/versioned_docs/version-0.17/user-guide/manage-data/overview.md +++ b/versioned_docs/version-0.17/user-guide/manage-data/overview.md @@ -177,7 +177,7 @@ That will not update anything: +-----------+---------------------+------+--------+ ``` -For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md##create-a-table-with-merge-mode) statement. +For more information about the `merge_mode` option, please refer to the [CREATE TABLE](/reference/sql/create.md#create-a-table-with-merge-mode) statement. ### Avoid updating data by creating table with `append_mode` option @@ -294,6 +294,10 @@ You can use Time to Live (TTL) policies to automatically remove stale data from - Decrease storage costs by cleaning out obsolete data. - Reduce the number of rows the database has to scan for some queries, potentially increasing query performance. +> Please note that the expired data due to TTL policy may not be deleted right after the expiration time. Instead, they are deleted during the compaction, which is a background job run asynchronously. +> If you are testing the TTL policy, be sure to trigger data flush and compaction before querying the data. +> You can use our "[ADMIN](/reference/sql/admin.md)" functions to manually run them. + You can set TTL for every table when creating it. For example, the following SQL statement creates a table named `monitor` with a TTL policy of 7 days: ```sql @@ -319,6 +323,15 @@ Otherwise, the database TTL policy will be applied to the table. The value of `'ttl'` can be one of duration (like `1hour 12min 5s`), `instant` or `forever`. See details in [CREATE](/reference/sql/create.md#create-a-table-with-ttl) statement. +Use [`ALTER`](/reference/sql/alter.md#alter-table-options) to modify the TTL of an existing table or database: + +```sql +-- for table +ALTER TABLE monitor SET 'ttl'='1 month'; +-- for database +ALTER DATABASE test SET 'ttl'='1 month'; +``` + If you want to remove the TTL policy, you can use the following SQL ```sql