Skip to content

Commit

Permalink
chore: add Add missing Tine Index constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed May 16, 2024
1 parent 6d1a505 commit 3b50119
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
36 changes: 34 additions & 2 deletions docs/nightly/en/user-guide/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,40 @@ CREATE TABLE IF NOT EXISTS "phy" (
)
ENGINE=metric
WITH(
physical_metric_table = '',
regions = 1
physical_metric_table = ''
);
```
#### Add missing Time Index constraint
Before:
```sql
CREATE TABLE IF NOT EXISTS "phy" (
"ts" TIMESTAMP(3) NOT NULL,
"val" DOUBLE NULL,
"host" STRING NULL,
"job" STRING NULL,
PRIMARY KEY ("host", "job")
)
ENGINE=metric
WITH(
physical_metric_table = ''
);
```
After:
```sql
CREATE TABLE IF NOT EXISTS "phy" (
"ts" TIMESTAMP(3) NOT NULL,
"val" DOUBLE NULL,
"host" STRING NULL,
"job" STRING NULL,
PRIMARY KEY ("host", "job")
TIME INDEX ("ts")
)
ENGINE=metric
WITH(
physical_metric_table = ''
);
```
Expand Down
38 changes: 36 additions & 2 deletions docs/nightly/zh/user-guide/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,45 @@ CREATE TABLE IF NOT EXISTS "phy" (
)
ENGINE=metric
WITH(
physical_metric_table = '',
regions = 1
physical_metric_table = ''
);
```
#### 添加缺失的 Time Index 约束
修改前:
```sql
CREATE TABLE IF NOT EXISTS "phy" (
"ts" TIMESTAMP(3) NOT NULL,
"val" DOUBLE NULL,
"host" STRING NULL,
"job" STRING NULL,
PRIMARY KEY ("host", "job")
)
ENGINE=metric
WITH(
physical_metric_table = ''
);
```
修改后:
```sql
CREATE TABLE IF NOT EXISTS "phy" (
"ts" TIMESTAMP(3) NOT NULL,
"val" DOUBLE NULL,
"host" STRING NULL,
"job" STRING NULL,
PRIMARY KEY ("host", "job")
TIME INDEX ("ts")
)
ENGINE=metric
WITH(
physical_metric_table = ''
);
```
### 导入表结构和数据
然后您需要执行上一步生成的 SQL 文件。首先是 `greptime-public.sql`。在之前的步骤中导出的 SQL 语句使用的是 PostgreSQL 方言,接下来的操作都将通过 [PG 协议](/user-guide/clients/postgresql.md)来进行。本文档假设客户端为 `psql`
Expand Down

0 comments on commit 3b50119

Please sign in to comment.