-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6009 from soyeric128/main
Doc: ALTER & DROP CLUSTER KEY
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
docs/doc/30-reference/30-sql/00-ddl/70-clusterkey/_category_.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"label": "Cluster Key", | ||
"link": { | ||
"type": "generated-index", | ||
"slug": "/reference/sql/ddl/clusterkey" | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
docs/doc/30-reference/30-sql/00-ddl/70-clusterkey/dml-alter-cluster-key.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: ALTER CLUSTER KEY | ||
description: | ||
Changes the cluster key for a table. | ||
--- | ||
|
||
Changes the cluster key for a table. | ||
|
||
See also: | ||
[DROP CLUSTER KEY](./dml-drop-cluster-key.md) | ||
|
||
## Syntax | ||
|
||
```sql | ||
ALTER TABLE <name> CLUSTER BY ( <expr1> [ , <expr2> ... ] ) | ||
``` | ||
|
||
## Examples | ||
|
||
```sql | ||
-- Create table | ||
CREATE TABLE IF NOT EXISTS playground(a int, b int); | ||
|
||
-- Add cluster key by columns | ||
ALTER TABLE playground CLUSTER BY(b,a); | ||
|
||
INSERT INTO playground VALUES(0,3),(1,1); | ||
INSERT INTO playground VALUES(1,3),(2,1); | ||
INSERT INTO playground VALUES(4,4); | ||
|
||
SELECT * FROM playground ORDER BY b,a; | ||
SELECT * FROM clustering_information('db1','playground'); | ||
|
||
-- Delete cluster key | ||
ALTER TABLE playground DROP CLUSTER KEY; | ||
|
||
-- Add cluster key by expressions | ||
ALTER TABLE playground CLUSTER BY(rand()+a); | ||
``` |
24 changes: 24 additions & 0 deletions
24
docs/doc/30-reference/30-sql/00-ddl/70-clusterkey/dml-drop-cluster-key.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: DROP CLUSTER KEY | ||
description: | ||
Deletes the cluster key for a table. | ||
--- | ||
|
||
Deletes the cluster key for a table. | ||
|
||
See also: | ||
[ALTER CLUSTER KEY](./dml-alter-cluster-key.md) | ||
|
||
## Syntax | ||
|
||
```sql | ||
ALTER TABLE <name> DROP CLUSTER KEY | ||
``` | ||
|
||
## Examples | ||
|
||
This command drops the cluster key for table *test*: | ||
|
||
```sql | ||
ALTER TABLE test DROP CLUSTER KEY | ||
``` |
560ba7e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
databend – ./
databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs
databend-databend.vercel.app