Skip to content

Commit

Permalink
Merge pull request #6009 from soyeric128/main
Browse files Browse the repository at this point in the history
Doc: ALTER & DROP CLUSTER KEY
  • Loading branch information
BohuTANG authored Jun 15, 2022
2 parents 8b55b48 + f1ea9a8 commit 560ba7e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
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"
}
}
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);
```
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
```

1 comment on commit 560ba7e

@vercel
Copy link

@vercel vercel bot commented on 560ba7e Jun 15, 2022

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

Please sign in to comment.