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

[improve](docs)Improve type casting documentation clarity and example #1926

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 52 additions & 10 deletions docs/sql-manual/sql-statements/types/SHOW-DATA-TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,61 @@ under the License.

This statement is used to view all supported data types.

grammar:
```sql
SHOW DATA TYPES;
```
## Syntax
```sql
SHOW DATA TYPES;
```

## Example
## Return Value

|Column Name|Description|
|--|--|
| TypeName | Name of the type |
| Size | Size in bytes |

1. Display all supported data types

SHOW DATA TYPES;
## Access Control Requirements
The user executing this SQL command does not require specific privileges.

## Example

## Keywords
- Display all supported data types

SHOW,DATA,TYPES
```sql
SHOW DATA TYPES;
```
```text
+----------------+------+
| TypeName | Size |
+----------------+------+
| AGG_STATE | 16 |
| ARRAY | 32 |
| BIGINT | 8 |
| BITMAP | 16 |
| BOOLEAN | 1 |
| CHAR | 16 |
| DATE | 16 |
| DATETIME | 16 |
| DATETIMEV2 | 8 |
| DATEV2 | 4 |
| DECIMAL128 | 16 |
| DECIMAL32 | 4 |
| DECIMAL64 | 8 |
| DECIMALV2 | 16 |
| DOUBLE | 8 |
| FLOAT | 4 |
| HLL | 16 |
| INT | 4 |
| IPV4 | 4 |
| IPV6 | 16 |
| JSON | 16 |
| LARGEINT | 16 |
| MAP | 24 |
| QUANTILE_STATE | 16 |
| SMALLINT | 2 |
| STRING | 16 |
| TINYINT | 1 |
| VARCHAR | 16 |
+----------------+------+
```

## Best Practice
53 changes: 42 additions & 11 deletions docs/sql-manual/sql-statements/types/SHOW-TYPECAST.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
Expand All @@ -29,20 +29,42 @@ under the License.

View all type cast under the database. If the user specifies a database, then view the corresponding database, otherwise directly query the database where the current session is located

Requires `SHOW` permission on this database

## Syntax

```sql
SHOW TYPE_CAST [IN|FROM db]
SHOW TYPE_CAST [ IN | FROM <db>]
vinlee19 marked this conversation as resolved.
Show resolved Hide resolved
```

Parameters
## Required Parameters

>`db`: database name to query
**1. `<db>`**

The name of the database to query.

## Return Value

| Column Name | Description |
|-------------|------------------|
| Origin Type | Original Type |
| Cast Type | Conversion Type |

## Access Control Requirements
The user executing this SQL command must have at least the following privileges:

| Privilege | Object | Notes |
|----------------|------------------|--------------------------------------------|
| Select_priv | Database (DB) | The user or role must have Select_priv on the DB to view all type conversions under the database |


## Usage Notes

If a database is specified by the user, the system will query the specified database; otherwise, it will query the database associated with the current session by default.

## Example

- View all type casts in database TESTDB

```sql
mysql> show type_cast in testDb\G
**************************** 1. row ******************** ******
Expand All @@ -54,13 +76,22 @@ Origin Type: TIMEV2
**************************** 3. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2

3 rows in set (0.00 sec)
```

## Keywords

SHOW, TYPECAST

- View all type casts in the current session's database

```sql
SHOW TYPE_CAST;
```
```text
**************************** 1. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
**************************** 2. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
**************************** 3. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
vinlee19 marked this conversation as resolved.
Show resolved Hide resolved
```

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
Expand All @@ -24,25 +24,65 @@ specific language governing permissions and limitations
under the License.
-->



## 描述

该语句用于查看 DORIS 支持的所有数据类型。

### 语法
## 语法

```sql
SHOW DATA TYPES;
```

## 示例
## 返回值

1. 查看 Doris 支持的所有数据类型
|列名|说明|
|--|--|
| TypeName | 类型名称 |
| Size | 字节大小 |

SHOW DATA TYPES;
## 权限控制
执行此 SQL 命令的用户不需要具有特定的权限

## 关键词
## 示例

SHOW,DATA,TYPES
- 查看 Doris 支持的所有数据类型

```sql
SHOW DATA TYPES;
```

```text
+----------------+------+
| TypeName | Size |
+----------------+------+
| AGG_STATE | 16 |
| ARRAY | 32 |
| BIGINT | 8 |
| BITMAP | 16 |
| BOOLEAN | 1 |
| CHAR | 16 |
| DATE | 16 |
| DATETIME | 16 |
| DATETIMEV2 | 8 |
| DATEV2 | 4 |
| DECIMAL128 | 16 |
| DECIMAL32 | 4 |
| DECIMAL64 | 8 |
| DECIMALV2 | 16 |
| DOUBLE | 8 |
| FLOAT | 4 |
| HLL | 16 |
| INT | 4 |
| IPV4 | 4 |
| IPV6 | 16 |
| JSON | 16 |
| LARGEINT | 16 |
| MAP | 24 |
| QUANTILE_STATE | 16 |
| SMALLINT | 2 |
| STRING | 16 |
| TINYINT | 1 |
| VARCHAR | 16 |
+----------------+------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
Expand All @@ -27,24 +27,49 @@ under the License.

## 描述

查看数据库下所有的类型转换。如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库
查看数据库下所有的类型转换。

需要对这个数据库拥有 `SHOW` 权限

## 语法
# 语法

```sql
SHOW TYPE_CAST [IN|FROM db]
SHOW TYPE_CAST [ IN | FROM <db>];
```

参数:
## 必选参数

`db`: database name to query
**1. `<db>`**

查询的数据库名称

## 返回值

| 列名 | 说明 |
|-------------|--------------|
| Origin Type | 原始类型 |
| Cast Type | 转换类型 |


## 权限控制

执行此 SQL 命令的用户必须至少具有以下权限:

| 权限(Privilege) | 对象(Object) | 说明(Notes) |
| :---------------- |:-----------|:------------------------------|
| Select_priv | 库(DB) | 用户或者角色对于 DB 拥护 Select_Priv 才能查看数据库下所有类型的转换 |


## 注意事项

- 如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库

## 示例

- 查看数据库 TESTDB 下所有的类型转换
```sql
mysql> show type_cast in testDb\G
SHOW TYPE_CAST IN TESTDB;
```
```text
**************************** 1. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
Expand All @@ -54,13 +79,25 @@ Origin Type: TIMEV2
**************************** 3. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2

3 rows in set (0.00 sec)
```

## 关键词
- 查看当前会话所在数据库下所有的类型转换

```sql
SHOW TYPE_CAST;
```
```text
**************************** 1. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
**************************** 2. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
**************************** 3. row ******************** ******
Origin Type: TIMEV2
Cast Type: TIMEV2
```

SHOW, TYPECAST



Loading