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

Merged
merged 12 commits into from
Jan 21, 2025
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
{
"title": "CANCEL ALTER TABLE",
"title": "CANCEL-ALTER-TABLE",
"language": "en"
}
---
Expand All @@ -24,83 +24,92 @@ specific language governing permissions and limitations
under the License.
-->



## Description

This statement is used to undo an ALTER operation.

1. Undo the ALTER TABLE COLUMN operation

grammar:

```sql
CANCEL ALTER TABLE COLUMN
FROM db_name.table_name
```

2. Undo the ALTER TABLE ROLLUP operation

grammar:

```sql
CANCEL ALTER TABLE ROLLUP
FROM db_name.table_name
```

3. Batch cancel rollup operations based on job id
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.

grammar:
## Syntax

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

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.

4. Undo the ALTER CLUSTER operation

grammar:

```
(To be implemented...)
```
## Required Parameters
**1. `{ COLUMN | MATERIALIZED VIEW | ROLLUP }`**
>Specify the type of modification to be canceled, one of which must be selected
>- `COLUMN`: Cancel the modification operation on the table column
>- `ROLLUP`: Cancel the modification operation on the view
>- `MATERIALIZED VIEW`: Cancel the modification operation on the materialized view

**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.

**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.

## 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.


## Permission Control
Users who execute this SQL command must have at least the following permissions:


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


## 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.

## Example

1. Undo the ALTER COLUMN operation on my_table.

[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...)
```
101 changes: 82 additions & 19 deletions docs/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
{
"title": "DESC TABLE",
"title": "DESCRIBE",
"language": "en"
}
---
Expand All @@ -24,39 +24,102 @@ specific language governing permissions and limitations
under the License.
-->



## Description

This statement is used to display the schema information of the specified table
This statement is used to display the schema information of the specified table.

grammar:
## Syntax

```sql
DESC[RIBE] [db_name.]table_name [ALL];
```

illustrate:
## 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.

1. If ALL is specified, the schemas of all indexes (rollup) of the table will be displayed
## Optional Parameters

## Example
**1.`<db_name>`**
> Specifies the identifier (i.e., 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.

1. Display the Base table schema
**2.`RIBE`**
> Returns description information of all columns in a table

**3.`ALL`**
> Returns description information for all columns

## Return Value

```sql
DESC table_name;
```
| column name | description |
| -- |-----------------------------------|
| IndexName | Table name |
| IndexKeysType | Table Model |
| Field | Column Name |
| Type | Data Types |
| Null | Whether NULL values are allowed |
| Key | Is it a key column |
| Default | Default Value |
| Extra | Display some additional information |
| Visible | Visible |
| DefineExpr | Defining Expressions |
| WhereClause | Filter Conditions Related Definitions |

2. Display the schema of all indexes of the table
## Access Control Requirements

```sql
DESC db1.table_name ALL;
```
Users executing this SQL command must have at least the following privileges:

## Keywords
| Privilege | Object | Notes |
|:-------------|:----------|:----------------------------------------------------------------------------------------------|
| SELECT_PRIV | Table | When executing DESC, you need to have the SELECT_PRIV privilege on the table being queried |

## Usage Notes
- If ALL is specified, the schema of all indexes (rollup) of the table is displayed.


## Examples

1. Display the Base table schema

DESCRIBE
```sql
DESC test_table;
```
```text
+---------+-------------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-------+---------+-------+
| user_id | bigint | No | true | NULL | |
| name | varchar(20) | Yes | false | NULL | NONE |
| age | int | Yes | false | NULL | NONE |
+---------+-------------+------+-------+---------+-------+
```

2. Display the schema of all indexes in the table

```sql
DESC demo.test_table ALL;
```

```text
+------------+---------------+---------+-------------+--------------+------+-------+---------+-------+---------+------------+-------------+
| IndexName | IndexKeysType | Field | Type | InternalType | Null | Key | Default | Extra | Visible | DefineExpr | WhereClause |
+------------+---------------+---------+-------------+--------------+------+-------+---------+-------+---------+------------+-------------+
| test_table | DUP_KEYS | user_id | bigint | bigint | No | true | NULL | | true | | |
| | | name | varchar(20) | varchar(20) | Yes | false | NULL | NONE | true | | |
| | | age | int | int | Yes | false | NULL | NONE | true | | |
+------------+---------------+---------+-------------+--------------+------+-------+---------+-------+---------+------------+-------------+
```

## Best Practice

72 changes: 50 additions & 22 deletions docs/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
{
"title": "DROP TABLE",
"title": "DROP-TABLE",
"language": "en"
}

---

<!--
Expand All @@ -25,40 +24,69 @@ specific language governing permissions and limitations
under the License.
-->



## Description

This statement is used to drop a table.
grammar:
This statement is used to delete a Table.
## Syntax

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

## 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.

## Optional 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.`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:

illustrate:

- 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/recycle/RECOVER) statement for details
| Privilege | Object | Notes |
|:----------------|:----------|:---------------------------|
| Drop_priv | Table | DROP TABLE belongs to the table DROP operation |

- 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
## Usage Notes

## Example
- 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.

1. Delete a table
## Examples

```sql
DROP TABLE my_table;
```
1. Deleting a Table

2. If it exists, delete the table of the specified database
```sql
DROP TABLE my_table;
```

```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;
```
Loading
Loading