Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc]Refresh table statement document modification #1843

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -24,87 +24,91 @@ specific language governing permissions and limitations
under the License.
-->

## CANCEL-ALTER-TABLE
## Description

### Name
This statement is used to cancel (revoke) an ongoing ALTER TABLE operation. You can use this command to terminate an ALTER TABLE operation while it is being executed.

CANCEL ALTER TABLE

### Description

This statement is used to undo an ALTER operation.

1. Undo the ALTER TABLE COLUMN operation

grammar:
## Syntax

```sql
CANCEL ALTER TABLE COLUMN
FROM db_name.table_name
CANCEL ALTER TABLE COLUMN|ROLLUP FROM <db_name>.<table_name> [ <job_id1> [ , <job_id2> ... ]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CANCEL ALTER TABLE COLUMN|ROLLUP FROM <db_name>.<table_name> [ <job_id1> [ , <job_id2> ... ]]
CANCEL ALTER TABLE { COLUMN | MATERIALIZED VIEW | ROLLUP }
FROM <db_name>.<table_name> [ ( <job_id1> [ , <job_id2> ... ] ) ]

```

2. Undo the ALTER TABLE ROLLUP operation
## Required Parameters
**1. `COLUMN|ROLLUP`**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**1. `COLUMN|ROLLUP`**
**1. `{ COLUMN | ROLLUP }`**

>Specify the type of modification to cancel, must choose one of:
>- COLUMN: Cancel table column modification operations
>- ROLLUP: Cancel materialized view modification operations

grammar:
**2.`<db_name>`**
> Specifies the identifier (that is, the name) of the database.
>
> Identifier must begin with an alphabet character (if Unicode name support is enabled, any language character is allowed), and must not contain spaces or special characters, except for the entire identifier string enclosed in quotes (e.g., `My Database`).
>
> Identifier cannot use reserved keywords.
>
> For more information, see Identifier Requirements and Reserved Keywords.

```sql
CANCEL ALTER TABLE ROLLUP
FROM db_name.table_name
```
**3.`<table_name>`**
> Specifies the identifier (that is, the name) of the table, within its database (Database).
>
> Identifier must begin with an alphabet character (if Unicode name support is enabled, any language character is allowed), and must not contain spaces or special characters, except for the entire identifier string enclosed in quotes (e.g., `My Object`).
>
> Identifier cannot use reserved keywords.
>
> For more information, see Identifier Requirements and Reserved Keywords.

3. Batch cancel rollup operations based on job id

grammar:

```sql
CANCEL ALTER TABLE ROLLUP
FROM db_name.table_name (jobid,...)
```
## Optional Parameters
**1. `<job_id>`**
> The specific job ID to cancel.
>
> If a job ID is specified, only the specified job is canceled; if not specified, all ongoing modifications of the specified type (COLUMN or ROLLUP) on the table are canceled.
>
> You can specify multiple job IDs, separated by commas.
>
> You can obtain job IDs by using the `SHOW ALTER TABLE COLUMN` or `SHOW ALTER TABLE ROLLUP` command.

Notice:

- This command is an asynchronous operation. You need to use `show alter table rollup` to check the task status to confirm whether the execution is successful or not.
## Permission Control
Users who execute this SQL command must have at least the following permissions:

4. Undo the ALTER CLUSTER operation

grammar:
| Privilege | Object | Notes |
| :---------------- | :------------- | :---------------------------- |
| ALTER_PRIV | Table | CANCEL ALTER TABLE belongs to table ALTER operation |

```
(To be implemented...)
```

### Example
## Notes
- This command is an asynchronous operation, and the actual execution result needs to be confirmed by using `SHOW ALTER TABLE COLUMN` or `SHOW ALTER TABLE ROLLUP` to check the status of the task.

1. Undo the ALTER COLUMN operation on my_table.
## Example

[CANCEL ALTER TABLE COLUMN]
1. Cancel ALTER TABLE COLUMN operation

```sql
CANCEL ALTER TABLE COLUMN
FROM example_db.my_table;
FROM db_name.table_name
```

1. Undo the ADD ROLLUP operation under my_table.
2. Cancel ALTER TABLE ROLLUP operation

[CANCEL ALTER TABLE ROLLUP]

```sql
CANCEL ALTER TABLE ROLLUP
FROM example_db.my_table;
FROM db_name.table_name
```

1. Undo the ADD ROLLUP operation under my_table according to the job id.
3. Cancel ALTER TABLE ROLLUP operation in batches based on job ID

[CANCEL ALTER TABLE ROLLUP]

```sql
CANCEL ALTER TABLE ROLLUP
FROM example_db.my_table(12801,12802);
FROM db_name.table_name (jobid,...)
```

### Keywords

CANCEL, ALTER, TABLE, CANCEL ALTER

### Best Practice
4. Cancel ALTER CLUSTER operation

```sql
(To be implemented...)
```
Comment on lines +113 to +115
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是个未完成的TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原始的官网是这样写的

Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,69 @@ specific language governing permissions and limitations
under the License.
-->

## DROP-TABLE
## Description

### Name
This statement is used to delete a Table.
## Syntax

DROP TABLE
```sql
DROP TABLE [IF EXISTS] [<db_name>.]<table_name> [FORCE];
```

### Description
## Required Parameters
**1.`<table_name>`**
> Specifies the table identifier (name), which must be unique within the database in which it is located.
>
> Identifiers must begin with an alphabetic character (or any character in a language if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g. `My Object`).
>
> Identifiers cannot use reserved keywords.
>
> For more details, see Identifier Requirements and Reserved Keywords.

This statement is used to drop a table.
grammar:
## Optional Parameters

```sql
DROP TABLE [IF EXISTS] [db_name.]table_name [FORCE];
```
**1.`<db_name>`**
> Specifies the identifier (name) for the database.
>
> Identifiers must begin with an alphabetic character (or any character in a given language if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Database`).
>
> Identifiers cannot use reserved keywords.
>
> See Identifier Requirements and Reserved Keywords for more details.

**2.`FORCE`**
> If specified, the system will not check whether there are any unfinished transactions in the table. The table will be deleted directly and cannot be recovered. This operation is generally not recommended.

## Access Control Requirements

The user executing this SQL command must have at least the following permissions:


| Privilege | Object | Notes |
|:----------------|:----------|:---------------------------|
| Drop_priv | Table | DROP TABLE belongs to the table DROP operation |

## Usage Notes

- After executing `DROP TABLE` for a period of time, the deleted table can be restored by using the RECOVER statement. For details, see the [RECOVER](../../../../sql-manual/sql-statements/Database-Administration-Statements/RECOVER) statement.
- If you execute `DROP TABLE FORCE`, the system will not check whether there are unfinished transactions for the table. The table will be deleted directly and cannot be restored. Generally, this operation is not recommended.

illustrate:
## Examples

- After executing `DROP TABLE` for a period of time, the dropped table can be recovered through the RECOVER statement. See [RECOVER](../../../../sql-manual/sql-statements/Database-Administration-Statements/RECOVER) statement for details
- If you execute `DROP TABLE FORCE`, the system will not check whether there are unfinished transactions in the table, the table will be deleted directly and cannot be recovered, this operation is generally not recommended
1. Deleting a Table

### Example
```sql
DROP TABLE my_table;
```

1. Delete a table

```sql
DROP TABLE my_table;
```

2. If it exists, delete the table of the specified database

```sql
DROP TABLE IF EXISTS example_db.my_table;
```
2. If it exists, delete the Table of the specified Database.

### Keywords
```sql
DROP TABLE IF EXISTS example_db.my_table;
```

DROP, TABLE
3. If it exists, delete the Table of the specified Database, forcibly delete it

### Best Practice
```sql
DROP TABLE IF EXISTS example_db.my_table FORCE;
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,74 @@ specific language governing permissions and limitations
under the License.
-->

## TRUNCATE-TABLE
## Description

### Name
This statement is used to clear the data of the specified table and partition.

TRUNCATE TABLE

### Description

This statement is used to clear the data of the specified table and partition
grammar:
## Syntax

```sql
TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)];
TRUNCATE TABLE [<db_name>.]<table_name>[ PARTITION ( <partition_name1> [, <partition_name2> ... ] ) ];
```

illustrate:

- The statement clears the data, but leaves the table or partition.
- Unlike DELETE, this statement can only clear the specified table or partition as a whole, and cannot add filter conditions.
- Unlike DELETE, using this method to clear data will not affect query performance.
## Required Parameters

**1.`<db_name>`**
> Specifies the identifier (name) for the database.
>
> Identifiers must begin with an alphabetic character (or any character in a given language if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Database`).
>
> Identifiers cannot use reserved keywords.
>
> See Identifier Requirements and Reserved Keywords for more details.

**2.`<table_name>`**
> Specifies the table identifier (name), which must be unique within the database in which it is located.
>
> Identifiers must begin with an alphabetic character (or any character in a language if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g. `My Object`).
>
> Identifiers cannot use reserved keywords.
>
> For more details, see Identifier Requirements and Reserved Keywords.

## Optional Parameters
**1.`<partition_name>`**
> Specifies the identifier (name) of the partition.
>
> Identifiers must begin with an alphabetic character (or any character in a script if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g. `My Object`).
>
> Identifiers cannot use reserved keywords.
>
> See Identifier Requirements and Reserved Keywords for more details.


## Access Control Requirements

The user executing this SQL command must have at least the following permissions:


| Privilege | Object | Notes |
|:----------------|:----------|:---------------------------|
| Drop_priv | Table | TRUNCATE TABLE belongs to the table DROP operation |

## Usage Notes

- This statement clears data but retains the table or partition.
- Unlike DELETE, this statement can only clear the specified table or partition as a whole and cannot add filtering conditions.
- Unlike DELETE, clearing data in this way will not affect query performance.
- The data deleted by this operation cannot be recovered.
- When using this command, the table status needs to be NORMAL, that is, operations such as SCHEMA CHANGE are not allowed.
- This command may cause the ongoing load to fail
- When using this command, the table status must be NORMAL, that is, operations such as SCHEMA CHANGE are not allowed.
- This command may cause the import in progress to fail.

### Example
## Examples

1. Clear the table tbl under example_db

```sql
TRUNCATE TABLE example_db.tbl;
```

2. Empty p1 and p2 partitions of table tbl

```sql
TRUNCATE TABLE tbl PARTITION(p1, p2);
```

### Keywords
```sql
TRUNCATE TABLE example_db.tbl;
```

TRUNCATE, TABLE
2. Clear the p1 and p2 partitions of table tbl

### Best Practice
```sql
TRUNCATE TABLE tbl PARTITION(p1, p2);
```
Loading