Add the sql manual in chinese.
This commit is contained in:
parent
2e0ab903a9
commit
4e37be70e2
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# Carbondata Connector
|
||||
|
||||
|
||||
<hr/>
|
||||
## Overview
|
||||
|
||||
The Carbondata connector allows querying data stored in a Carbondata warehouse. Carbondata is a combination of three components:
|
||||
|
|
|
|||
|
|
@ -432,10 +432,6 @@ This is an alias for `year_of_week`.
|
|||
|
||||
[^5]: This specifier does not support `0` as a month or day.
|
||||
|
||||
[^6]: This specifier is not supported yet. Consider using
|
||||
`day_of_week` (it uses `1-7` instead
|
||||
of `0-6`).
|
||||
[^6]: This specifier is not supported yet. Consider using `day_of_week` (it uses `1-7` instead of `0-6`).
|
||||
|
||||
[^7]: When parsing, two-digit year format assumes range `1970` ..
|
||||
`2069`, so \"70\" will result in year `1970` but \"69\" will produce
|
||||
`2069`.
|
||||
[^7]: When parsing, two-digit year format assumes range `1970` .. `2069`, so \"70\" will result in year `1970` but \"69\" will produce `2069`.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "ALTER SCHEMA"
|
||||
+++
|
||||
|
||||
ALTER SCHEMA
|
||||
============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "ALTER TABLE"
|
||||
+++
|
||||
|
||||
ALTER TABLE
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "ANALYZE"
|
||||
+++
|
||||
|
||||
ANALYZE
|
||||
=======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CACHE TABLE"
|
||||
+++
|
||||
|
||||
CACHE TABLE
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CALL"
|
||||
+++
|
||||
|
||||
CALL
|
||||
====
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "COMMENT"
|
||||
+++
|
||||
|
||||
COMMENT
|
||||
=======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "COMMIT"
|
||||
+++
|
||||
|
||||
COMMIT
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CREATE ROLE"
|
||||
+++
|
||||
|
||||
CREATE ROLE
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CREATE SCHEMA"
|
||||
+++
|
||||
|
||||
CREATE SCHEMA
|
||||
=============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CREATE TABLE AS"
|
||||
+++
|
||||
|
||||
CREATE TABLE AS
|
||||
===============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CREATE TABLE"
|
||||
+++
|
||||
|
||||
CREATE TABLE
|
||||
============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "CREATE VIEW"
|
||||
+++
|
||||
|
||||
CREATE VIEW
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DEALLOCATE PREPARE"
|
||||
+++
|
||||
|
||||
DEALLOCATE PREPARE
|
||||
==================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DELETE"
|
||||
+++
|
||||
|
||||
DELETE
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DESCRIBE INPUT"
|
||||
+++
|
||||
|
||||
DESCRIBE INPUT
|
||||
==============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DESCRIBE OUTPUT"
|
||||
+++
|
||||
|
||||
DESCRIBE OUTPUT
|
||||
===============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DESCRIBE"
|
||||
+++
|
||||
|
||||
DESCRIBE
|
||||
========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DROP CACHE"
|
||||
+++
|
||||
|
||||
DROP CACHE
|
||||
==========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DROP ROLE"
|
||||
+++
|
||||
|
||||
DROP ROLE
|
||||
=========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DROP SCHEMA"
|
||||
+++
|
||||
|
||||
DROP SCHEMA
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DROP TABLE"
|
||||
+++
|
||||
|
||||
DROP TABLE
|
||||
==========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "DROP VIEW"
|
||||
+++
|
||||
|
||||
DROP VIEW
|
||||
=========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "EXECUTE"
|
||||
+++
|
||||
|
||||
EXECUTE
|
||||
=======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "EXPLAIN ANALYZE"
|
||||
+++
|
||||
|
||||
EXPLAIN ANALYZE
|
||||
===============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "EXPLAIN"
|
||||
+++
|
||||
|
||||
EXPLAIN
|
||||
=======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "GRANT ROLES"
|
||||
+++
|
||||
|
||||
GRANT ROLES
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "GRANT"
|
||||
+++
|
||||
|
||||
GRANT
|
||||
=====
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "INSERT OVERWRITE"
|
||||
+++
|
||||
|
||||
INSERT OVERWRITE
|
||||
================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "INSERT"
|
||||
+++
|
||||
|
||||
INSERT
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "PREPARE"
|
||||
+++
|
||||
|
||||
PREPARE
|
||||
=======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "RESET SESSION"
|
||||
+++
|
||||
|
||||
RESET SESSION
|
||||
=============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "REVOKE ROLES"
|
||||
+++
|
||||
|
||||
REVOKE ROLES
|
||||
============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "REVOKE"
|
||||
+++
|
||||
|
||||
REVOKE
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "ROLLBACK"
|
||||
+++
|
||||
|
||||
ROLLBACK
|
||||
========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SELECT"
|
||||
+++
|
||||
|
||||
SELECT
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SET ROLE"
|
||||
+++
|
||||
|
||||
SET ROLE
|
||||
========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SET SESSION"
|
||||
+++
|
||||
|
||||
SET SESSION
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW CACHE"
|
||||
+++
|
||||
|
||||
SHOW CACHE
|
||||
==========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW CATALOGS"
|
||||
+++
|
||||
|
||||
SHOW CATALOGS
|
||||
=============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW COLUMNS"
|
||||
+++
|
||||
|
||||
SHOW COLUMNS
|
||||
============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW CREATE TABLE"
|
||||
+++
|
||||
|
||||
SHOW CREATE TABLE
|
||||
=================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW CREATE VIEW"
|
||||
+++
|
||||
|
||||
SHOW CREATE VIEW
|
||||
================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW FUNCTIONS"
|
||||
+++
|
||||
|
||||
SHOW FUNCTIONS
|
||||
==============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW GRANTS"
|
||||
+++
|
||||
|
||||
SHOW GRANTS
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW ROLE GRANTS
"
|
||||
+++
|
||||
|
||||
SHOW ROLE GRANTS
|
||||
================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW ROLES"
|
||||
+++
|
||||
|
||||
SHOW ROLES
|
||||
==========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW SCHEMAS"
|
||||
+++
|
||||
|
||||
SHOW SCHEMAS
|
||||
============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW SESSION"
|
||||
+++
|
||||
|
||||
SHOW SESSION
|
||||
============
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW STATS"
|
||||
+++
|
||||
|
||||
SHOW STATS
|
||||
==========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "SHOW TABLES"
|
||||
+++
|
||||
|
||||
SHOW TABLES
|
||||
===========
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "START TRANSACTION"
|
||||
+++
|
||||
|
||||
START TRANSACTION
|
||||
=================
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "UPDATE"
|
||||
+++
|
||||
|
||||
UPDATE
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
+++
|
||||
|
||||
title = "USE"
|
||||
+++
|
||||
|
||||
USE
|
||||
===
|
||||
====
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "VACUUM"
|
||||
+++
|
||||
|
||||
VACUUM
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
+++
|
||||
|
||||
title = "VALUES"
|
||||
+++
|
||||
|
||||
VALUES
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,31 @@
|
|||
ALTER SCHEMA
|
||||
============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "ALTER SCHEMA"
|
||||
+++
|
||||
|
||||
``` sql
|
||||
# ALTER SCHEMA
|
||||
|
||||
## 摘要
|
||||
|
||||
```sql
|
||||
ALTER {SCHEMA|DATABASE} name RENAME TO new_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Change the definition of an existing schema.
|
||||
更改现有模式的定义。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Rename schema `web` to `traffic`:
|
||||
将模式 `web` 重命名为 `traffic`:
|
||||
|
||||
ALTER SCHEMA web RENAME TO traffic
|
||||
ALTER DATABASE web RENAME TO traffic
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors do not support renaming schema, such as Hive Connector. See connector documentation for more details.
|
||||
某些连接器(如 Hive 连接器)不支持重命名模式。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-schema](./create-schema.html)
|
||||
[create-schema](./create-schema.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
ALTER TABLE
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "ALTER TABLE"
|
||||
+++
|
||||
|
||||
# ALTER TABLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
ALTER TABLE name RENAME TO new_name
|
||||
|
|
@ -11,31 +14,28 @@ ALTER TABLE name DROP COLUMN column_name
|
|||
ALTER TABLE name RENAME COLUMN column_name TO new_column_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Change the definition of an existing table.
|
||||
更改现有表的定义。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Rename table `users` to `people`:
|
||||
将表 `users` 重命名为 `people`:
|
||||
|
||||
ALTER TABLE users RENAME TO people;
|
||||
|
||||
Add column `zip` to the `users` table:
|
||||
在 `users` 表中添加 `zip` 列:
|
||||
|
||||
ALTER TABLE users ADD COLUMN zip varchar;
|
||||
|
||||
Drop column `zip` from the `users` table:
|
||||
从 `users` 表中删除 `zip` 列:
|
||||
|
||||
ALTER TABLE users DROP COLUMN zip;
|
||||
|
||||
Rename column `id` to `user_id` in the `users` table:
|
||||
将 `users` 表中的 `id` 列重命名为 `user_id`。
|
||||
|
||||
ALTER TABLE users RENAME COLUMN id TO user_id;
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-table](./create-table.html)
|
||||
|
|
@ -1,39 +1,40 @@
|
|||
ANALYZE
|
||||
=======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "ANALYZE"
|
||||
+++
|
||||
|
||||
# ANALYZE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
ANALYZE table_name [ WITH ( property_name = expression [, ...] ) ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Collects table and column statistics for a given table.
|
||||
收集给定表的表和列统计信息。
|
||||
|
||||
The optional `WITH` clause can be used to provide connector-specific properties. To list all available properties, run the following query:
|
||||
可选的 `WITH` 子句可用于提供特定于连接器的属性。要列出所有可用的属性,请运行以下查询:
|
||||
|
||||
SELECT * FROM system.metadata.analyze_properties
|
||||
|
||||
Currently, this statement is only supported by the [Hive connector](../connector/hive.html).
|
||||
目前仅 [Hive 连接器](../connector/hive.html)支持该语句。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Analyze table `web` to collect table and column statistics:
|
||||
分析表 `web` 以收集表和列统计信息:
|
||||
|
||||
ANALYZE web;
|
||||
|
||||
Analyze table `stores` in catalog `hive` and schema `default`:
|
||||
分析目录 `hive` 和模式 `default` 中的表 `stores`:
|
||||
|
||||
ANALYZE hive.default.stores;
|
||||
|
||||
Analyze partitions `'1992-01-01', '1992-01-02'` from a Hive partitioned table `sales`:
|
||||
分析 Hive 分区表 `sales` 中的分区 `'1992-01-01', '1992-01-02'`:
|
||||
|
||||
ANALYZE hive.default.sales WITH (partitions = ARRAY[ARRAY['1992-01-01'], ARRAY['1992-01-02']]);
|
||||
|
||||
Analyze partitions with complex partition key (`state` and `city` columns) from a Hive partitioned table `customers`:
|
||||
分析 Hive 分区表 `customers` 中具有复杂分区键(`state` 和 `city` 列)的分区。
|
||||
|
||||
ANALYZE hive.default.customers WITH (partitions = ARRAY[ARRAY['CA', 'San Francisco'], ARRAY['NY', 'NY']]);
|
||||
ANALYZE hive.default.customers WITH (partitions = ARRAY[ARRAY['CA', 'San Francisco'], ARRAY['NY', 'NY']]);
|
||||
|
|
@ -1,34 +1,33 @@
|
|||
CACHE TABLE
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CACHE TABLE"
|
||||
+++
|
||||
|
||||
# CACHE TABLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CACHE TABLE table_name WHERE condition
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
`CACHE TABLE` updates coordinator metadata with table name and partition that should be cached by the connector.
|
||||
`CACHE TABLE` 使用连接器应缓存的表名和分区更新协调器元数据。
|
||||
|
||||
`condition` must be provided and is defined on only partition column(s).
|
||||
必须提供 `condition`,并且仅在分区列上对其进行定义。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Cache table :
|
||||
缓存表:
|
||||
|
||||
CACHE TABLE store_sales where location = 'CA';
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Only Hive connector support this functionality. See connector documentation for more details.
|
||||
仅 Hive 连接器支持该功能。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[show-cache](./show-cache.html)
|
||||
[drop-cache](./drop-cache.html)
|
||||
[drop-cache](./drop-cache.html)
|
||||
|
|
@ -1,35 +1,36 @@
|
|||
CALL
|
||||
====
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CALL"
|
||||
+++
|
||||
|
||||
# CALL
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CALL procedure_name ( [ name => ] expression [, ...] )
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Call a procedure.
|
||||
调用过程。
|
||||
|
||||
Procedures can be provided by connectors to perform data manipulation or administrative tasks. For example, the `/connector/system` defines a procedure for killing a running query.
|
||||
过程可以由连接器提供,以执行数据操作或管理任务。例如,`/connector/system`{.interpreted-text role="doc"} 定义了用于终止正在运行的查询的过程。
|
||||
|
||||
Some connectors, such as the [PostgreSQL Connector](../connector/postgresql.html), are for systems that have their own stored procedures. These stored procedures are separate from the connector-defined procedures discussed here and thus are not directly callable via `CALL`.
|
||||
某些连接器(如 [PostgreSQL 连接器](../connector/postgresql.html))用于具有其自己的存储过程的系统。这些存储过程与此处讨论的连接器定义过程相分离,因此无法通过 `CALL` 直接调用。
|
||||
|
||||
See connector documentation for details on available procedures.
|
||||
有关可用过程的详细信息,请参见连接器文档。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Call a procedure using positional arguments:
|
||||
使用位置参数调用过程:
|
||||
|
||||
CALL test(123, 'apple');
|
||||
|
||||
Call a procedure using named arguments:
|
||||
使用命名参数调用过程:
|
||||
|
||||
CALL test(name => 'apple', id => 123);
|
||||
|
||||
Call a procedure using a fully qualified name:
|
||||
使用完全限定名称调用过程:
|
||||
|
||||
CALL catalog.schema.test();
|
||||
CALL catalog.schema.test();
|
||||
|
|
@ -1,21 +1,22 @@
|
|||
COMMENT
|
||||
=======
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
``` sql
|
||||
COMMENT ON TABLE name IS 'comments'
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Set the comment for a table. The comment can be removed by setting the comment to `NULL`.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Change the comment for the `users` table to be `master table`:
|
||||
|
||||
COMMENT ON TABLE users IS 'master table';
|
||||
+++
|
||||
|
||||
title = "COMMENT"
|
||||
+++
|
||||
|
||||
# COMMENT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
COMMENT ON TABLE name IS 'comments'
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
设置表的注释。可以通过将注释设置为 `NULL` 来删除注释。
|
||||
|
||||
## 示例
|
||||
|
||||
将 `users` 表的注释更改为 `master table`:
|
||||
|
||||
COMMENT ON TABLE users IS 'master table';
|
||||
|
|
@ -1,28 +1,27 @@
|
|||
COMMIT
|
||||
======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "COMMIT"
|
||||
+++
|
||||
|
||||
# COMMIT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
COMMIT [ WORK ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Commit the current transaction.
|
||||
提交当前事务。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
``` sql
|
||||
COMMIT;
|
||||
COMMIT WORK;
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[rollback](./rollback.html)
|
||||
[start-transaction](./start-transaction.html)
|
||||
[rollback](./rollback.html)、[start-transaction](./start-transaction.html)
|
||||
|
|
@ -1,38 +1,37 @@
|
|||
CREATE ROLE
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CREATE ROLE"
|
||||
+++
|
||||
|
||||
# CREATE ROLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CREATE ROLE role_name
|
||||
[ WITH ADMIN ( user | USER user | ROLE role | CURRENT_USER | CURRENT_ROLE ) ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
`CREATE ROLE` creates the specified role in the current catalog.
|
||||
`CREATE ROLE` 在当前目录中创建指定的角色。
|
||||
|
||||
The optional `WITH ADMIN` clause causes the role to be created with the specified user as a role admin. A role admin has permission to drop or grant a role. If the optional `WITH ADMIN` clause is not specified, the role is created with current user as admin.
|
||||
如果使用可选的 `WITH ADMIN` 子句,则在创建角色时使指定的用户成为角色管理员。角色管理员具有删除或授予角色的权限。如果未指定可选的 `WITH ADMIN` 子句,在创建角色时使当前用户成为角色管理员。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Create role `admin` :
|
||||
创建角色 `admin`:
|
||||
|
||||
CREATE ROLE admin;
|
||||
|
||||
Create role `moderator` with admin `bob`:
|
||||
创建角色 `moderator` 并使 `bob` 成为角色管理员:
|
||||
|
||||
CREATE ROLE moderator WITH ADMIN USER bob;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors do not support role management. See connector documentation for more details.
|
||||
某些连接器不支持角色管理。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[drop-role](./drop-role.html), [set-role](./set-role.html), [grant-role](./grant-role.html),[revoke-roles](./revoke-roles.html)
|
||||
[drop-role](./drop-role.html)、[set-role](./set-role.html)、[grant-role](./grant-role.html)、[revoke-roles](./revoke-roles.html)
|
||||
|
|
@ -1,43 +1,42 @@
|
|||
CREATE SCHEMA
|
||||
=============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CREATE SCHEMA"
|
||||
+++
|
||||
|
||||
# CREATE SCHEMA
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CREATE {SCHEMA|DATABASE} [ IF NOT EXISTS ] schema_name
|
||||
[ WITH ( property_name = expression [, ...] ) ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Create a new, empty schema. A schema is a container that holds tables, views and other database objects.
|
||||
创建一个空模式。模式是保存表、视图和其他数据库对象的容器。
|
||||
|
||||
The optional `IF NOT EXISTS` clause causes the error to be suppressed if the schema already exists.
|
||||
如果使用可选的 `IF NOT EXISTS` 子句,则在模式已存在时禁止显示错误。
|
||||
|
||||
The optional `WITH` clause can be used to set properties on the newly created schema. To list all available schema properties, run the following query:
|
||||
可以使用可选的 `WITH` 子句来设置创建的模式的属性。要列出所有可用的模式属性,请运行以下查询:
|
||||
|
||||
SELECT * FROM system.metadata.schema_properties
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Create a new schema `web` in the current catalog:
|
||||
在当前目录中创建模式 `web`:
|
||||
|
||||
CREATE SCHEMA web
|
||||
CREATE DATABASE web
|
||||
|
||||
Create a new schema `sales` in the `hive` catalog:
|
||||
在 `hive` 目录中创建模式 `sales`:
|
||||
|
||||
CREATE SCHEMA hive.sales
|
||||
|
||||
Create the schema `traffic` if it does not already exist:
|
||||
如果模式 `traffic` 尚不存在,则创建该模式:
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS traffic
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
|
||||
[alter-schema](./alter-schema.html) ,[drop-schema](./drop-schema.html)
|
||||
[alter-schema](./alter-schema.html)、[drop-schema](./drop-schema.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
CREATE TABLE AS
|
||||
===============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CREATE TABLE AS"
|
||||
+++
|
||||
|
||||
# CREATE TABLE AS
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CREATE TABLE [ IF NOT EXISTS ] table_name [ ( column_alias, ... ) ]
|
||||
|
|
@ -12,28 +15,26 @@ AS query
|
|||
[ WITH [ NO ] DATA ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Create a new table containing the result of a [SELECT](select.html) query. Use [CREATE TABLE](create-table.html) to create an empty table.
|
||||
创建一个包含 [SELECT](./select.html) 查询结果的表。使用 [CREATE TABLE](./create-table.html) 可以创建空表。
|
||||
|
||||
The optional `IF NOT EXISTS` clause causes the error to be suppressed if the table already exists.
|
||||
如果使用可选的 `IF NOT EXISTS` 子句,则在表已存在时禁止显示错误。
|
||||
|
||||
The optional `WITH` clause can be used to set properties on the newly created table. To list all available table properties, run the following query:
|
||||
可以使用可选的 `WITH` 子句来设置创建的表的属性。要列出所有可用的表属性,请运行以下查询:
|
||||
|
||||
SELECT * FROM system.metadata.table_properties
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Create a new table `orders_column_aliased` with the results of a query and the given column names:
|
||||
使用查询结果和给定的列名创建表 `orders_column_aliased`:
|
||||
|
||||
CREATE TABLE orders_column_aliased (order_date, total_price)
|
||||
AS
|
||||
SELECT orderdate, totalprice
|
||||
FROM orders
|
||||
|
||||
Create a new table `orders_by_date` that summarizes `orders`:
|
||||
创建对 `orders` 进行汇总的表 `orders_by_date`:
|
||||
|
||||
CREATE TABLE orders_by_date
|
||||
COMMENT 'Summary of orders by date'
|
||||
|
|
@ -43,21 +44,20 @@ Create a new table `orders_by_date` that summarizes `orders`:
|
|||
FROM orders
|
||||
GROUP BY orderdate
|
||||
|
||||
Create the table `orders_by_date` if it does not already exist:
|
||||
如果表 `orders_by_date` 尚不存在,则创建该表:
|
||||
|
||||
CREATE TABLE IF NOT EXISTS orders_by_date AS
|
||||
SELECT orderdate, sum(totalprice) AS price
|
||||
FROM orders
|
||||
GROUP BY orderdate
|
||||
|
||||
Create a new `empty_nation` table with the same schema as `nation` and no data:
|
||||
创建模式与 `nation` 相同的表 `empty_nation`,但表中不含数据。
|
||||
|
||||
CREATE TABLE empty_nation AS
|
||||
SELECT *
|
||||
FROM nation
|
||||
WITH NO DATA
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-table](./create-table.html), [ select](./select.html)
|
||||
[create-table](./create-table.html)、[select](./ select.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
CREATE TABLE
|
||||
============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CREATE TABLE"
|
||||
+++
|
||||
|
||||
# CREATE TABLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CREATE TABLE [ IF NOT EXISTS ]
|
||||
|
|
@ -15,43 +18,40 @@ table_name (
|
|||
[ WITH ( property_name = expression [, ...] ) ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Create a new, empty table with the specified columns. Use `create-table-as` to create a table with data.
|
||||
创建一个具有指定列的空表。使用 `create-table-as` 可以创建含数据的表。
|
||||
|
||||
The optional `IF NOT EXISTS` clause causes the error to be suppressed if the table already exists.
|
||||
如果使用可选的 `IF NOT EXISTS` 子句,则在表已存在时禁止显示错误。
|
||||
|
||||
The optional `WITH` clause can be used to set properties on the newly created table or on single columns. To list all available table properties, run the following query:
|
||||
可以使用可选的 `WITH` 子句来设置创建的表或单个列的属性。要列出所有可用的表属性,请运行以下查询:
|
||||
|
||||
SELECT * FROM system.metadata.table_properties
|
||||
|
||||
For example, to hive connector, below are some of available and frequently used table properties:
|
||||
例如,对于 Hive 连接器,以下是一些可用且常用的表属性:
|
||||
|
||||
| Property Name | data type | Description | Default |
|
||||
| 属性名称 | 数据类型 | 说明 | 默认值 |
|
||||
| ---------------- | -------------- | ------------------------------------------------------------ | ------- |
|
||||
| `format` | varchar | Hive storage format for the table. Possible values: [ORC, PARQUET, AVRO, RCBINARY, RCTEXT, SEQUENCEFILE, JSON, TEXTFILE, CSV] | ORC |
|
||||
| `bucket_count` | integer | Number of buckets | |
|
||||
| `bucketed_by` | array(varchar) | Bucketing columns | |
|
||||
| `sorted_by` | array(varchar) | Bucket sorting columns | |
|
||||
| `external` | boolean | Is the table an external table | `false` |
|
||||
| `location` | varchar | File system location URI for the table location value must be provided if `external`=`true` | |
|
||||
| `partitioned_by` | array(varchar) | Partition columns | |
|
||||
| `transactional` | boolean | Is transactional property enabled There is a limitation that only ORC Storage format support creating an transactional table | `false` |
|
||||
| `format` | varchar | 表的 Hive 存储格式。可能的值为:ORC、PARQUET、AVRO、RCBINARY、RCTEXT、SEQUENCEFILE、JSON、TEXTFILE 和 CSV。 | ORC |
|
||||
| `bucket_count` | integer | 桶的数量。 | |
|
||||
| `bucketed_by` | array(varchar) | 分桶列。 | |
|
||||
| `sorted_by` | array(varchar) | 桶排序列。 | |
|
||||
| `external` | boolean | 表是否为外部表。 | `false` |
|
||||
| `location` | varchar | 表的文件系统位置 URI。如果 `external`=`true`,则必须提供位置值。 | |
|
||||
| `partitioned_by` | array(varchar) | 分区列。 | |
|
||||
| `transactional` | boolean | 是否启用事务属性。存在一个限制,即仅 ORC 存储格式支持创建事务表。 | `false` |
|
||||
|
||||
To list all available column properties, run the following query:
|
||||
要列出所有可用的列属性,请运行以下查询:
|
||||
|
||||
SELECT * FROM system.metadata.column_properties
|
||||
|
||||
The `LIKE` clause can be used to include all the column definitions from an existing table in the new table. Multiple `LIKE` clauses may be specified, which allows copying the columns from multiple tables.
|
||||
可以使用 `LIKE` 子句在新表中包含现有表中的所有列定义。可以指定多个 `LIKE` 子句,从而允许复制多个表中的列。
|
||||
|
||||
If `INCLUDING PROPERTIES` is specified, all of the table properties are copied to the new table. If the `WITH` clause specifies the same property name as one of the copied properties, the value from the `WITH`
|
||||
clause will be used. The default behavior is `EXCLUDING PROPERTIES`. The `INCLUDING PROPERTIES` option maybe specified for at most one table.
|
||||
如果指定了 `INCLUDING PROPERTIES`,则将所有表属性复制到新表中。如果 `WITH` 子句指定的属性名称与某个复制的属性的名称相同,则使用 `WITH` 子句中的值。默认行为是 `EXCLUDING PROPERTIES`。最多只能为一个表指定 `INCLUDING PROPERTIES` 选项。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Create a new table `orders`:
|
||||
创建表 `orders`:
|
||||
|
||||
CREATE TABLE orders (
|
||||
orderkey bigint,
|
||||
|
|
@ -61,7 +61,7 @@ Create a new table `orders`:
|
|||
)
|
||||
WITH (format = 'ORC')
|
||||
|
||||
Create a new transactional table `orders`:
|
||||
创建事务表 `orders`:
|
||||
|
||||
CREATE TABLE orders (
|
||||
orderkey bigint,
|
||||
|
|
@ -72,7 +72,7 @@ Create a new transactional table `orders`:
|
|||
WITH (format = 'ORC',
|
||||
transactional=true)
|
||||
|
||||
Create an external table `orders`:
|
||||
创建外部表 `orders`:
|
||||
|
||||
CREATE TABLE orders (
|
||||
orderkey bigint,
|
||||
|
|
@ -84,7 +84,7 @@ Create an external table `orders`:
|
|||
external=true,
|
||||
location='hdfs://hdcluster/tmp/externaltbl')
|
||||
|
||||
Create the table `orders` if it does not already exist, adding a table comment and a column comment:
|
||||
如果表 `orders` 不存在,则创建该表,同时添加表注释和列注释:
|
||||
|
||||
CREATE TABLE IF NOT EXISTS orders (
|
||||
orderkey bigint,
|
||||
|
|
@ -94,7 +94,7 @@ Create the table `orders` if it does not already exist, adding a table comment a
|
|||
)
|
||||
COMMENT 'A table to keep track of orders.'
|
||||
|
||||
Create the table `bigger_orders` using the columns from `orders` plus additional columns at the start and end:
|
||||
使用 `orders` 中的列并在开头和结尾使用附加的列创建表 `bigger_orders`:
|
||||
|
||||
CREATE TABLE bigger_orders (
|
||||
another_orderkey bigint,
|
||||
|
|
@ -102,13 +102,10 @@ Create the table `bigger_orders` using the columns from `orders` plus additional
|
|||
another_orderdate date
|
||||
)
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Different connector might support different data type, and different table/column properties. See connector documentation for more details.
|
||||
不同的连接器可能支持不同的数据类型和不同的表/列属性。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
[alter-table](./alter-table.html), [drop-table](./drop-table.html), [create-table-as](./create-table-as.html), [show-create-table](./show-create-table.html)
|
||||
## 另请参见
|
||||
|
||||
[alter-table](./alter-table.html)、[drop-table](./drop-table.html)、[create-table-as](./create-table-as.html)、[show-create-table](./show-create-table.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
CREATE VIEW
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "CREATE VIEW"
|
||||
+++
|
||||
|
||||
# CREATE VIEW
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
CREATE [ OR REPLACE ] VIEW view_name
|
||||
|
|
@ -10,46 +13,41 @@ CREATE [ OR REPLACE ] VIEW view_name
|
|||
AS query
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Create a new view of a [SELECT](select.html) query. The view is a logical table that can be referenced by future queries. Views do not contain any data. Instead, the query stored by the view is executed everytime the view is referenced by another query.
|
||||
创建 [SELECT](./select.html) 查询的视图。视图是一个可以由将来的查询引用的逻辑表。视图不包含任何数据。相反,视图存储的查询在每次被其他查询引用时执行。
|
||||
|
||||
The optional `OR REPLACE` clause causes the view to be replaced if it already exists rather than raising an error.
|
||||
如果使用可选的 `OR REPLACE` 子句,则在视图已存在时替换该视图,而不是产生错误。
|
||||
|
||||
Security
|
||||
--------
|
||||
## 安全
|
||||
|
||||
In the default `DEFINER` security mode, tables referenced in the view are accessed using the permissions of the view owner (the *creator* or *definer* of the view) rather than the user executing the query. This allows providing restricted access to the underlying tables, for which the user may not be allowed to access directly.
|
||||
在默认的 `DEFINER` 安全模式下,使用视图拥有者(视图的创建者或定义者)的权限来访问视图中引用的表,而不是使用执行查询的用户的权限。这样,对于用户可能无法直接访问的基础表,可以提供对这些表的受限访问。
|
||||
|
||||
In the `INVOKER` security mode, tables referenced in the view are accessed using the permissions of the user executing the query (the *invoker* of the view). A view created in this mode is simply a stored
|
||||
query.
|
||||
在 `INVOKER` 安全模式下,使用执行查询的用户(视图的调用者)的权限来访问在视图中引用的表。以该模式创建的视图只是一个存储查询。
|
||||
|
||||
Regardless of the security mode, the `current_user` function will always return the user executing the query and thus may be used within views to filter out rows or otherwise restrict access.
|
||||
无论安全模式如何,`current_user` 函数都始终返回执行查询的用户,因此可以在视图中使用该函数来滤除行或限制访问。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Create a simple view `test` over the `orders` table:
|
||||
在表 `orders` 上创建简单视图 `test`:
|
||||
|
||||
CREATE VIEW test AS
|
||||
SELECT orderkey, orderstatus, totalprice / 2 AS half
|
||||
FROM orders
|
||||
|
||||
Create a view `orders_by_date` that summarizes `orders`:
|
||||
创建对 `orders` 进行汇总的视图 `orders_by_date`:
|
||||
|
||||
CREATE VIEW orders_by_date AS
|
||||
SELECT orderdate, sum(totalprice) AS price
|
||||
FROM orders
|
||||
GROUP BY orderdate
|
||||
|
||||
Create a view that replaces an existing view:
|
||||
创建一个替换现有视图的视图:
|
||||
|
||||
CREATE OR REPLACE VIEW test AS
|
||||
SELECT orderkey, orderstatus, totalprice / 4 AS quarter
|
||||
FROM orders
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[drop-view](./drop-view.html), [show-create-view](./show-create-view.html)
|
||||
[drop-view](./drop-view.html)、[show-create-view](./show-create-view.html)
|
||||
|
|
@ -1,27 +1,26 @@
|
|||
DEALLOCATE PREPARE
|
||||
==================
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DEALLOCATE PREPARE"
|
||||
+++
|
||||
|
||||
# DEALLOCATE PREPARE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DEALLOCATE PREPARE statement_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Removes a statement with the name `statement_name` from the list of prepared statements in a session.
|
||||
从会话中的预编译语句列表中删除名称为 `statement_name` 的语句。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Deallocate a statement with the name `my_query`:
|
||||
取消分配名称为 `my_query` 的语句:
|
||||
|
||||
DEALLOCATE PREPARE my_query;
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
[prepare](./prepare.html)
|
||||
## 另请参见
|
||||
|
||||
[prepare](./prepare.html)
|
||||
|
|
@ -1,41 +1,41 @@
|
|||
DELETE
|
||||
======
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
``` sql
|
||||
DELETE FROM table_name [ WHERE condition ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Delete rows from a table. If the `WHERE` clause is specified, only the matching rows are deleted. Otherwise, all rows from the table are deleted.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Delete all line items shipped by air:
|
||||
|
||||
DELETE FROM lineitem WHERE shipmode = 'AIR';
|
||||
|
||||
Delete all line items for low priority orders:
|
||||
|
||||
DELETE FROM lineitem
|
||||
WHERE orderkey IN (SELECT orderkey FROM orders WHERE priority = 'LOW');
|
||||
|
||||
Delete all orders:
|
||||
|
||||
DELETE FROM orders;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
Some connectors have limited or no support for `DELETE`.
|
||||
|
||||
For example, to Hive connector, the behavior is different for transactional table and non-transactional table.
|
||||
|
||||
For transactional table, you can delete any row by where condition. However, for non-transactional table, DELETE is only supported if the WHERE clause matches entire partitions.
|
||||
|
||||
See connector documentation for more details.
|
||||
+++
|
||||
|
||||
title = "DELETE"
|
||||
+++
|
||||
|
||||
# DELETE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DELETE FROM table_name [ WHERE condition ]
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
删除表中的行。如果指定了 `WHERE` 子句,则仅删除匹配的行。否则,将删除表中的所有行。
|
||||
|
||||
## 示例
|
||||
|
||||
删除所有空运行项目:
|
||||
|
||||
DELETE FROM lineitem WHERE shipmode = 'AIR';
|
||||
|
||||
删除低优先级订单的所有行项目:
|
||||
|
||||
DELETE FROM lineitem
|
||||
WHERE orderkey IN (SELECT orderkey FROM orders WHERE priority = 'LOW');
|
||||
|
||||
删除所有订单:
|
||||
|
||||
DELETE FROM orders;
|
||||
|
||||
## 限制
|
||||
|
||||
某些连接器对 `DELETE` 的支持有限或不支持该语句。
|
||||
|
||||
例如,对于 Hive 连接器,事务表和非事务表的行为是不同的。
|
||||
|
||||
对于事务表,可以通过 WHERE 条件来删除任何行。不过,对于非事务表,仅当 WHERE 子句匹配整个分区时才支持 DELETE。
|
||||
|
||||
有关更多详细信息,请参见连接器文档。
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
DESCRIBE INPUT
|
||||
==============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DESCRIBE INPUT"
|
||||
+++
|
||||
|
||||
# DESCRIBE INPUT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DESCRIBE INPUT statement_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Lists the input parameters of a prepared statement along with the position and type of each parameter. Parameter types that cannot be determined will appear as `unknown`.
|
||||
列出预编译语句的输入参数以及每个参数的位置和类型。无法确定的参数类型将显示为 `unknown`。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Prepare and describe a query with three parameters:
|
||||
预编译并描述一个具有三个参数的查询:
|
||||
|
||||
``` sql
|
||||
PREPARE my_select1 FROM
|
||||
|
|
@ -27,7 +28,7 @@ SELECT ? FROM nation WHERE regionkey = ? AND name < ?;
|
|||
DESCRIBE INPUT my_select1;
|
||||
```
|
||||
|
||||
```
|
||||
``` sql
|
||||
Position | Type
|
||||
--------------------
|
||||
0 | unknown
|
||||
|
|
@ -36,7 +37,7 @@ Position | Type
|
|||
(3 rows)
|
||||
```
|
||||
|
||||
Prepare and describe a query with no parameters:
|
||||
预编译并描述一个不具有参数的查询:
|
||||
|
||||
``` sql
|
||||
PREPARE my_select2 FROM
|
||||
|
|
@ -47,13 +48,12 @@ SELECT * FROM nation;
|
|||
DESCRIBE INPUT my_select2;
|
||||
```
|
||||
|
||||
```
|
||||
``` sql
|
||||
Position | Type
|
||||
-----------------
|
||||
(0 rows)
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[prepare](./prepare.html)
|
||||
[prepare](./prepare.html)
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
DESCRIBE OUTPUT
|
||||
===============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DESCRIBE OUTPUT"
|
||||
+++
|
||||
|
||||
# DESCRIBE OUTPUT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DESCRIBE OUTPUT statement_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
List the output columns of a prepared statement, including the column name (or alias), catalog, schema, table, type, type size in bytes, and a boolean indicating if the column is aliased.
|
||||
列出预编译语句的输出列,包括列名(或别名)、目录、模式、表、类型、类型大小(以字节为单位)以及表明列是否为别名的布尔值。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Prepare and describe a query with four output columns:
|
||||
预编译并描述一个具有四个输出列的查询:
|
||||
|
||||
PREPARE my_select1 FROM
|
||||
SELECT * FROM nation
|
||||
|
|
@ -25,7 +26,7 @@ Prepare and describe a query with four output columns:
|
|||
DESCRIBE OUTPUT my_select1;
|
||||
```
|
||||
|
||||
```
|
||||
```
|
||||
Column Name | Catalog | Schema | Table | Type | Type Size | Aliased
|
||||
-------------+---------+--------+--------+---------+-----------+---------
|
||||
nationkey | tpch | sf1 | nation | bigint | 8 | false
|
||||
|
|
@ -35,7 +36,7 @@ comment | tpch | sf1 | nation | varchar | 0 | false
|
|||
(4 rows)
|
||||
```
|
||||
|
||||
Prepare and describe a query whose output columns are expressions:
|
||||
预编译并描述一个输出列是表达式的查询:
|
||||
|
||||
PREPARE my_select2 FROM
|
||||
SELECT count(*) as my_count, 1+2 FROM nation
|
||||
|
|
@ -44,7 +45,7 @@ Prepare and describe a query whose output columns are expressions:
|
|||
DESCRIBE OUTPUT my_select2;
|
||||
```
|
||||
|
||||
```
|
||||
```
|
||||
Column Name | Catalog | Schema | Table | Type | Type Size | Aliased
|
||||
-------------+---------+--------+-------+--------+-----------+---------
|
||||
my_count | | | | bigint | 8 | true
|
||||
|
|
@ -52,7 +53,7 @@ _col1 | | | | bigint | 8 | false
|
|||
(2 rows)
|
||||
```
|
||||
|
||||
Prepare and describe a row count query:
|
||||
预编译并描述一个行计数查询:
|
||||
|
||||
PREPARE my_create FROM
|
||||
CREATE TABLE foo AS SELECT * FROM nation
|
||||
|
|
@ -61,14 +62,13 @@ Prepare and describe a row count query:
|
|||
DESCRIBE OUTPUT my_create;
|
||||
```
|
||||
|
||||
```
|
||||
```
|
||||
Column Name | Catalog | Schema | Table | Type | Type Size | Aliased
|
||||
-------------+---------+--------+-------+--------+-----------+---------
|
||||
rows | | | | bigint | 8 | false
|
||||
(1 row)
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[prepare](./prepare.html)
|
||||
[prepare](./prepare.html)
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
DESCRIBE
|
||||
========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DESCRIBE"
|
||||
+++
|
||||
|
||||
# DESCRIBE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DESCRIBE table_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
DESCRIBE is an alias for [SHOW COLUMNS](show-columns.html)
|
||||
DESCRIBE 是 [SHOW COLUMNS](./show-columns.html) 的别名。
|
||||
|
|
@ -1,32 +1,30 @@
|
|||
DROP CACHE
|
||||
==========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DROP CACHE"
|
||||
+++
|
||||
|
||||
# DROP CACHE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DROP CACHE table
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
`DROP CACHE` deletes cache metadata of the `table` from coordinator.
|
||||
`DROP CACHE` 从协调器中删除 `table` 的缓存元数据。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Drop cache :
|
||||
删除缓存:
|
||||
|
||||
DROP CACHE table
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Only Hive connector support this functionality. See connector documentation for more details.
|
||||
仅 Hive 连接器支持该功能。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
[cache-table](./cache-table.html), [show-cache](./show-cache.html)
|
||||
## 另请参见
|
||||
|
||||
[cache-table](./cache-table.html)、[show-cache](./show-cache.html)
|
||||
|
|
@ -1,33 +1,32 @@
|
|||
DROP ROLE
|
||||
=========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DROP ROLE"
|
||||
+++
|
||||
|
||||
# DROP ROLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DROP ROLE role_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
`DROP ROLE` drops the specified role in the current catalog.
|
||||
`DROP ROLE` 删除当前目录中的指定角色。
|
||||
|
||||
For `DROP ROLE` statement to succeed, the user executing it should possess admin privileges for the given role.
|
||||
为了使 `DROP ROLE` 语句成功执行,执行该语句的用户应拥有给定角色的管理员权限。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Drop role `admin` :
|
||||
删除角色 `admin`:
|
||||
|
||||
DROP ROLE admin;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors do not support role management. See connector documentation for more details.
|
||||
某些连接器不支持角色管理。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-role](./create-role.html), [set-role](./set-role.html), [grant-roles](./grant-roles.html), [revoke-roles](./revoke-roles.html)
|
||||
[create-role](./create-role.html)、[set-role](./set-role.html)、[grant-roles](./grant-roles.html)、[revoke-roles](./revoke-roles.html)
|
||||
|
|
@ -1,38 +1,37 @@
|
|||
DROP SCHEMA
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DROP SCHEMA"
|
||||
+++
|
||||
|
||||
# DROP SCHEMA
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DROP {SCHEMA|DATABASE} [ IF EXISTS ] schema_name [{CASCADE | RESTRICT}]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Drop an existing schema. The schema must be empty.
|
||||
删除一个现有的模式。该模式必须为空。
|
||||
|
||||
The optional `IF EXISTS` clause causes the error to be suppressed if the schema does not exist.
|
||||
如果使用可选的 `IF EXISTS` 子句,则在该模式不存在时禁止显示错误。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Drop the schema `web`:
|
||||
删除模式 `web`:
|
||||
|
||||
DROP SCHEMA web
|
||||
DROP DATABASE web
|
||||
|
||||
Drop the schema `sales` if it exists:
|
||||
如果模式 `sales` 存在,则删除该模式:
|
||||
|
||||
DROP TABLE IF EXISTS sales
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Functionally, `CASCADE` and `RESTRICT` is not supported yet.
|
||||
从功能上而言,尚不支持 `CASCADE` 和 `RESTRICT`。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[alter-schema](./alter-schema.html), [create-schema](./create-schema.html)
|
||||
[alter-schema](./alter-schema.html)、[create-schema](./create-schema.html)
|
||||
|
|
@ -1,32 +1,32 @@
|
|||
DROP TABLE
|
||||
==========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DROP TABLE"
|
||||
+++
|
||||
|
||||
# DROP TABLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DROP TABLE [ IF EXISTS ] table_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Drops an existing table.
|
||||
删除一个现有的表。
|
||||
|
||||
The optional `IF EXISTS` clause causes the error to be suppressed if the table does not exist.
|
||||
如果使用可选的 `IF EXISTS` 子句,则在该表不存在时禁止显示错误。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Drop the table `orders_by_date`:
|
||||
删除表 `orders_by_date`:
|
||||
|
||||
DROP TABLE orders_by_date
|
||||
|
||||
Drop the table `orders_by_date` if it exists:
|
||||
如果表 `orders_by_date` 存在,则删除该表:
|
||||
|
||||
DROP TABLE IF EXISTS orders_by_date
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[alter-table](./alter-table.html), [create-table](./create-table.html)
|
||||
[alter-table](./alter-table.html)、[create-table](./create-table.html)
|
||||
|
|
@ -1,32 +1,32 @@
|
|||
DROP VIEW
|
||||
=========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "DROP VIEW"
|
||||
+++
|
||||
|
||||
# DROP VIEW
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
DROP VIEW [ IF EXISTS ] view_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Drop an existing view.
|
||||
删除一个现有的视图。
|
||||
|
||||
The optional `IF EXISTS` clause causes the error to be suppressed if the view does not exist.
|
||||
如果使用可选的 `IF EXISTS` 子句,则在该视图不存在时禁止显示错误。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Drop the view `orders_by_date`:
|
||||
删除视图 `orders_by_date`:
|
||||
|
||||
DROP VIEW orders_by_date
|
||||
|
||||
Drop the view `orders_by_date` if it exists:
|
||||
如果视图 `orders_by_date` 存在,则删除该视图:
|
||||
|
||||
DROP VIEW IF EXISTS orders_by_date
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-view](./create-view.html)
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
EXECUTE
|
||||
=======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "EXECUTE"
|
||||
+++
|
||||
|
||||
# EXECUTE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
EXECUTE statement_name [ USING parameter1 [ , parameter2, ... ] ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Executes a prepared statement with the name `statement_name`. Parameter values are defined in the `USING` clause.
|
||||
执行名称为 `statement_name` 的预编译语句。在 `USING` 子句中定义参数值。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Prepare and execute a query with no parameters:
|
||||
预编译并执行一个不具有参数的查询:
|
||||
|
||||
PREPARE my_select1 FROM
|
||||
SELECT name FROM nation;
|
||||
|
|
@ -25,7 +26,7 @@ Prepare and execute a query with no parameters:
|
|||
EXECUTE my_select1;
|
||||
```
|
||||
|
||||
Prepare and execute a query with two parameters:
|
||||
预编译并执行一个具有两个参数的查询:
|
||||
|
||||
PREPARE my_select2 FROM
|
||||
SELECT name FROM nation WHERE regionkey = ? and nationkey < ?;
|
||||
|
|
@ -34,11 +35,10 @@ Prepare and execute a query with two parameters:
|
|||
EXECUTE my_select2 USING 1, 3;
|
||||
```
|
||||
|
||||
This is equivalent to:
|
||||
这等效于:
|
||||
|
||||
SELECT name FROM nation WHERE regionkey = 1 AND nationkey < 3;
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[prepare](./prepare.html)
|
||||
|
|
@ -1,30 +1,29 @@
|
|||
EXPLAIN ANALYZE
|
||||
===============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "EXPLAIN ANALYZE"
|
||||
+++
|
||||
|
||||
# EXPLAIN ANALYZE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
EXPLAIN ANALYZE [VERBOSE] statement
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Execute the statement and show the distributed execution plan of the statement along with the cost of each operation.
|
||||
执行语句并显示语句的分布式执行计划以及每个操作的开销。
|
||||
|
||||
The `VERBOSE` option will give more detailed information and low-level statistics; understanding these may require knowledge of openLooKeng internals and implementation details.
|
||||
`VERBOSE` 选项可提供更详细的信息和具体的统计数据;了解这些信息可能需要了解 openLooKeng 内部细节和实现细节。
|
||||
|
||||
**注意**
|
||||
|
||||
**Note**
|
||||
*统计数据可能不完全准确,尤其是对于快速完成的查询。*
|
||||
|
||||
*The stats may not be entirely accurate, especially for queries that* *complete quickly.*
|
||||
## 示例
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
In the example below, you can see the CPU time spent in each stage, as well as the relative cost of each plan node in the stage. Note that the relative cost of the plan nodes is based on wall time, which may or may not be correlated to CPU time. For each plan node you can see some additional statistics (e.g: average input per node instance, average number of hash collisions for relevant plan nodes). Such statistics are
|
||||
useful when one wants to detect data anomalies for a query (skewness, abnormal hash collisions).
|
||||
在下面的示例中,您可以看到每个阶段消耗的 CPU 时间,以及该阶段中每个计划节点的相对开销。请注意,计划节点的相对开销基于挂钟时间,挂钟时间可能与 CPU 时间相关,也可能与之不相关。对于每个计划节点,您都可以看到一些额外的统计数据(例如每个节点实例的平均输入以及相关计划节点的平均哈希冲突数)。当您希望检测查询的数据异常(偏斜、异常哈希冲突)时,这些统计数据很有用。
|
||||
|
||||
``` sql
|
||||
lk:sf1> EXPLAIN ANALYZE SELECT count(*), clerk FROM orders WHERE orderdate > date '1995-01-01' GROUP BY clerk;
|
||||
|
|
@ -66,7 +65,7 @@ Fragment 2 [tpch:orders:1500000]
|
|||
clerk := tpch:clerk
|
||||
```
|
||||
|
||||
When the `VERBOSE` option is used, some operators may report additional information. For example, the window function operator will output the following:
|
||||
使用 `VERBOSE` 选项后,某些运算符可能会报告额外的信息。例如,窗口函数运算符将输出以下信息:
|
||||
|
||||
``` sql
|
||||
EXPLAIN ANALYZE VERBOSE SELECT count(clerk) OVER() FROM orders WHERE orderdate > date '1995-01-01';
|
||||
|
|
@ -87,7 +86,6 @@ EXPLAIN ANALYZE VERBOSE SELECT count(clerk) OVER() FROM orders WHERE orderdate >
|
|||
...
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[explain](./explain.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
EXPLAIN
|
||||
=======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "EXPLAIN"
|
||||
+++
|
||||
|
||||
# EXPLAIN
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
EXPLAIN [ ( option [, ...] ) ] statement
|
||||
|
|
@ -13,36 +16,33 @@ where option can be one of:
|
|||
TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Show the logical or distributed execution plan of a statement, or validate the statement. Use `TYPE DISTRIBUTED` option to display fragmented plan. Each plan fragment is executed by a single or multiple
|
||||
openLooKeng nodes. Fragments separation represent the data exchange between openLooKeng nodes. Fragment type specifies how the fragment is executed by openLooKeng nodes and how the data is distributed between fragments:
|
||||
显示语句的逻辑或分布式执行计划,或者对语句进行验证。使用 `TYPE DISTRIBUTED` 选项可以显示分片计划。每个计划片段由单个或多个 openLooKeng 节点执行。片段之间的间隔表示 openLooKeng 节点之间的数据交换。片段类型指定 openLooKeng 节点如何执行片段以及数据如何在片段之间分布:
|
||||
|
||||
`SINGLE`
|
||||
|
||||
Fragment is executed on a single node.
|
||||
: 片段在单个节点上执行。
|
||||
|
||||
`HASH`
|
||||
|
||||
Fragment is executed on a fixed number of nodes with the input data distributed using a hash function.
|
||||
: 片段在固定数量的节点上执行,输入数据通过哈希函数进行分布。
|
||||
|
||||
`ROUND_ROBIN`
|
||||
|
||||
Fragment is executed on a fixed number of nodes with the input data distributed in a round-robin fashion.
|
||||
: 片段在固定数量的节点上执行,输入数据以轮循方式进行分布。
|
||||
|
||||
`BROADCAST`
|
||||
|
||||
Fragment is executed on a fixed number of nodes with the input data broadcasted to all nodes.
|
||||
: 片段在固定数量的节点上执行,输入数据广播到所有节点。
|
||||
|
||||
`SOURCE`
|
||||
|
||||
Fragment is executed on nodes where input splits are accessed.
|
||||
: 片段在访问输入分段的节点上执行。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Logical plan:
|
||||
逻辑计划:
|
||||
|
||||
``` sql
|
||||
lk:tiny> EXPLAIN SELECT regionkey, count(*) FROM nation GROUP BY 1;
|
||||
|
|
@ -63,7 +63,7 @@ lk:tiny> EXPLAIN SELECT regionkey, count(*) FROM nation GROUP BY 1;
|
|||
regionkey := tpch:regionkey
|
||||
```
|
||||
|
||||
Distributed plan:
|
||||
分布式计划:
|
||||
|
||||
``` sql
|
||||
lk:tiny> EXPLAIN (TYPE DISTRIBUTED) SELECT regionkey, count(*) FROM nation GROUP BY 1;
|
||||
|
|
@ -95,7 +95,7 @@ lk:tiny> EXPLAIN (TYPE DISTRIBUTED) SELECT regionkey, count(*) FROM nation GROUP
|
|||
regionkey := tpch:regionkey
|
||||
```
|
||||
|
||||
Validate:
|
||||
验证:
|
||||
|
||||
``` sql
|
||||
lk:tiny> EXPLAIN (TYPE VALIDATE) SELECT regionkey, count(*) FROM nation GROUP BY 1;
|
||||
|
|
@ -104,7 +104,7 @@ lk:tiny> EXPLAIN (TYPE VALIDATE) SELECT regionkey, count(*) FROM nation GROUP BY
|
|||
true
|
||||
```
|
||||
|
||||
IO:
|
||||
IO:
|
||||
|
||||
``` sql
|
||||
lk:hive> EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_nation SELECT * FROM nation WHERE regionkey = 2;
|
||||
|
|
@ -147,7 +147,6 @@ lk:hive> EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_nation SELECT * FROM na
|
|||
}
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[explain-analyze](./explain-analyze.html)
|
||||
[explain-analyze](./explain-analyze.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
GRANT ROLES
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "GRANT ROLES"
|
||||
+++
|
||||
|
||||
# GRANT ROLES
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
GRANT role [, ...]
|
||||
|
|
@ -11,34 +14,30 @@ TO ( user | USER user | ROLE role) [, ...]
|
|||
[ WITH ADMIN OPTION ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Grants the specified role(s) to the specified principal(s) in the current catalog.
|
||||
将指定的角色授给当前目录中的指定主体。
|
||||
|
||||
If the `WITH ADMIN OPTION` clause is specified, the role(s) are granted to the users with `GRANT` option.
|
||||
如果指定了 `WITH ADMIN OPTION` 子句,则可以使用 `GRANT` 选项将角色授给用户。
|
||||
|
||||
For the `GRANT` statement for roles to succeed, the user executing it either should be the role admin or should possess the `GRANT` option for the given role.
|
||||
为了使针对角色的 `GRANT` 语句成功执行,执行该语句的用户应具有管理员角色或者应对于给定的角色拥有 `GRANT` 选项。
|
||||
|
||||
The optional `GRANTED BY` clause causes the role(s) to be granted with the specified principal as a grantor. If the `GRANTED BY` clause is not specified, the roles are granted with the current user as a grantor.
|
||||
可选的 `GRANTED BY` 子句可使指定的主体作为授予方来授给角色。如果未指定 `GRANTED BY` 子句,则当前用户作为授予方来授给角色。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Grant role `bar` to user `foo` :
|
||||
将角色 `bar` 授给用户 `foo`:
|
||||
|
||||
GRANT bar TO USER foo;
|
||||
|
||||
Grant roles `bar` and `foo` to user `baz` and role `qux` with admin option :
|
||||
将角色 `bar` 和 `foo` 授给用户 `baz` 和角色 `qux` 并使其具有管理员选项:
|
||||
|
||||
GRANT bar, foo TO USER baz, ROLE qux WITH ADMIN OPTION;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors do not support role management. See connector documentation for more details.
|
||||
某些连接器不支持角色管理。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-role](./create-role.html), [drop-role](./drop-role).html, [ set-role](./set-role.html), [revoke-roles](./revoke-roles.html)
|
||||
[create-role](./create-role.html)、[drop-role](./drop-role.html)、[set-role](./ set-role.html)、[revoke-roles](./ revoke-roles.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
GRANT
|
||||
=====
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "GRANT"
|
||||
+++
|
||||
|
||||
# GRANT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
GRANT ( privilege [, ...] | ( ALL PRIVILEGES ) )
|
||||
|
|
@ -10,41 +13,36 @@ ON [ TABLE ] table_name TO ( user | USER user | ROLE role )
|
|||
[ WITH GRANT OPTION ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Grants the specified privileges to the specified grantee.
|
||||
将指定的权限授给指定的被授权者。
|
||||
|
||||
Specifying `ALL PRIVILEGES` grants [DELETE](delete.html), [INSERT](insert.html) and [SELECT](select.html) privileges.
|
||||
指定 `ALL PRIVILEGES` 可以授予 [DELETE](./delete.html)、[INSERT](./insert.html) 和 [SELECT](./select.html) 权限。
|
||||
|
||||
Specifying `ROLE PUBLIC` grants privileges to the `PUBLIC` role and hence to all users.
|
||||
指定 `ROLE PUBLIC` 可以将权限授给 `PUBLIC` 角色,从而将权限授给所有用户。
|
||||
|
||||
The optional `WITH GRANT OPTION` clause allows the grantee to grant these same privileges to others.
|
||||
通过使用可选的 `WITH GRANT OPTION` 子句,可以允许被授权者将同样的权限授给其他用户。
|
||||
|
||||
For `GRANT` statement to succeed, the user executing it should possess the specified privileges as well as the `GRANT OPTION` for those privileges.
|
||||
为了使 `GRANT` 语句成功执行,执行该语句的用户应拥有指定的权限并且对于这些权限拥有 `GRANT OPTION`。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Grant `INSERT` and `SELECT` privileges on the table `orders` to user
|
||||
`alice`:
|
||||
将对表 `orders` 的 `INSERT` 和 `SELECT` 权限授给用户 `alice`:
|
||||
|
||||
GRANT INSERT, SELECT ON orders TO alice;
|
||||
|
||||
Grant `SELECT` privilege on the table `nation` to user `alice`, additionally allowing `alice` to grant `SELECT` privilege to others:
|
||||
将对表 `nation` 的 `SELECT` 权限授给用户 `alice`,此外允许 `alice` 将 `SELECT` 权限授给其他用户:
|
||||
|
||||
GRANT SELECT ON nation TO alice WITH GRANT OPTION;
|
||||
|
||||
Grant `SELECT` privilege on the table `orders` to everyone:
|
||||
将对表 `orders` 的 `SELECT` 权限授给所有用户:
|
||||
|
||||
GRANT SELECT ON orders TO ROLE PUBLIC;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors have no support for `GRANT`. See connector documentation for more details.
|
||||
某些连接器不支持 `GRANT`。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[revoke](./revoke.html), [ show-grants](./show-grants.html)
|
||||
[revoke](./revoke.html)、[show-grants](./ show-grants.html)
|
||||
|
|
@ -1,61 +1,66 @@
|
|||
INSERT OVERWRITE
|
||||
================
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "INSERT OVERWRITE"
|
||||
+++
|
||||
|
||||
# INSERT OVERWRITE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
INSERT OVERWRITE [TABLE] table_name [ ( column [, ... ] ) ] query
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Insert overwrite basically do two things: 1) drop the data rows according to the dataset created by the query. 2) insert the new data created by query.
|
||||
insert overwrite 主要有两项功能:1\) 根据查询创建的数据集删除数据行;2\) 插入查询创建的新数据。
|
||||
|
||||
Insert overwrite can work on both partition and non-partition table, but the behaviors are different:
|
||||
insert overwrite 可以对分区表和非分区表进行操作,但是行为不同:
|
||||
|
||||
- If the table is non-partition table, the existing data will be all deleted directly, and then insert the new data.
|
||||
- If the table is partitioned table, only the matched partition data which existing in the dataset result from query will be dropped and replaced with the new data.
|
||||
- 对于非分区表,会直接删除所有的现有数据,然后插入新数据。
|
||||
- 对于分区表,仅删除查询生成的数据集中存在的匹配分区数据,然后替换为新数据。
|
||||
|
||||
If the list of column names is specified, they must exactly match the list of columns produced by the query. Each column in the table not present in the column list will be filled with a `null` value. Otherwise, if the list of columns is not specified, the columns produced by the query must exactly match the columns in the table being inserted into.
|
||||
如果指定了列名列表,则该列表必须与查询生成的列列表完全匹配。会使用一个 `null` 值填充表中未在列列表中显示的列。如果未指定列列表,则查询生成的列必须与要插入的表中的列完全匹配。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Assume `orders` is not a partitioned table, and have 100 rows, then execute below insert overwrite statement:
|
||||
假设 `orders` 不是分区表,并且有 100 行,此时执行以下 insert overwrite 语句:
|
||||
|
||||
INSERT OVERWRITE orders VALUES (1, 'SUCCESS', '10.25', DATA '2020-01-01');
|
||||
|
||||
Then the `orders` table will only have 1 rows, that is the data specified in the `VALUE` clause.
|
||||
则 `orders` 表将仅有 1 行,即 `VALUE` 子句中指定的数据。
|
||||
|
||||
Assume `users` has 3 columns: (`id`, `name`, `state`) and partitioned by `state`, and the existing data has follow rows:
|
||||
假设 `users` 有 3 列(`id`、`name` 和 `state`)并按照 `state` 进行分区,并且现有数据有以下行:
|
||||
|
||||
-----------------
|
||||
|
||||
---- ------ -------
|
||||
id name state
|
||||
1 John CD
|
||||
2 Sam CD
|
||||
3 Lucy SZ
|
||||
---- ------ -------
|
||||
|
||||
Then execute below insert overwrite statement:
|
||||
-----------------
|
||||
|
||||
|
||||
此时执行以下 insert overwrite 语句:
|
||||
|
||||
INSERT OVERWRITE orders VALUES (4, 'Newman', 'CD');
|
||||
|
||||
This will overwrite the data with partition value `state='CD'`, but wont impact the data `state='SZ'`. So the result will be
|
||||
这将使用分区值 `state='CD'` 覆盖数据,但不会影响数据 `state='SZ'`。因此结果将是
|
||||
|
||||
-------------------
|
||||
|
||||
---- -------- -------
|
||||
id name state
|
||||
3 Lucy SZ
|
||||
4 Newman CD
|
||||
---- -------- -------
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
-------------------
|
||||
|
||||
Right now only Hive Connector support insert overwrite.
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 限制
|
||||
|
||||
[values](./values.html), [insert](insert.html)
|
||||
目前只有 Hive 连接器支持 insert overwrite。
|
||||
|
||||
## 另请参见
|
||||
|
||||
[values](./values.html)、[insert](./insert.html)
|
||||
|
|
@ -1,47 +1,47 @@
|
|||
INSERT
|
||||
======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "INSERT"
|
||||
+++
|
||||
|
||||
# INSERT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
INSERT INTO table_name [ ( column [, ... ] ) ] query
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Insert new rows into a table.
|
||||
在表中插入新行。
|
||||
|
||||
If the list of column names is specified, they must exactly match the list of columns produced by the query. Each column in the table not present in the column list will be filled with a `null` value. Otherwise, if the list of columns is not specified, the columns produced by the query must exactly match the columns in the table being inserted into.
|
||||
如果指定了列名列表,则该列表必须与查询生成的列列表完全匹配。会使用一个 `null` 值填充表中未在列列表中显示的列。如果未指定列列表,则查询生成的列必须与要插入的表中的列完全匹配。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Load additional rows into the `orders` table from the `new_orders` table:
|
||||
将 `new_orders` 表中的其他行加载到 `orders` 表中:
|
||||
|
||||
INSERT INTO orders
|
||||
SELECT * FROM new_orders;
|
||||
|
||||
Insert a single row into the `cities` table:
|
||||
在 `cities` 表中插入单行:
|
||||
|
||||
INSERT INTO cities VALUES (1, 'San Francisco');
|
||||
|
||||
Insert multiple rows into the `cities` table:
|
||||
在 `cities` 表中插入多行:
|
||||
|
||||
INSERT INTO cities VALUES (2, 'San Jose'), (3, 'Oakland');
|
||||
|
||||
Insert a single row into the `nation` table with the specified column list:
|
||||
使用指定的列列表在 `nation` 表中插入单行:
|
||||
|
||||
INSERT INTO nation (nationkey, name, regionkey, comment)
|
||||
VALUES (26, 'POLAND', 3, 'no comment');
|
||||
|
||||
Insert a row without specifying the `comment` column. That column will be `null`:
|
||||
在不指定 `comment` 列的情况下插入单行,该列的值将为 `null`:
|
||||
|
||||
INSERT INTO nation (nationkey, name, regionkey)
|
||||
VALUES (26, 'POLAND', 3);
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[values](./values.html), [insert-overwrite](./insert-overwrite.html)
|
||||
[values](./values.html)、[insert-overwrite](./insert-overwrite.html)
|
||||
|
|
@ -1,37 +1,37 @@
|
|||
PREPARE
|
||||
=======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "PREPARE"
|
||||
+++
|
||||
|
||||
# PREPARE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
PREPARE statement_name FROM statement
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Prepares a statement for execution at a later time. Prepared statements are queries that are saved in a session with a given name. The statement can include parameters in place of literals to be replaced at execution time. Parameters are represented by question marks.
|
||||
准备一条语句,以便在以后执行。准备的语句是保存在具有给定名称的会话中的查询。该语句可以包含参数以代替字面量,这些参数在执行时被替换为实际的值。参数由问号表示。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Prepare a select query:
|
||||
准备一个 select 查询:
|
||||
|
||||
PREPARE my_select1 FROM
|
||||
SELECT * FROM nation;
|
||||
|
||||
Prepare a select query that includes parameters. The values to compare with `regionkey` and `nationkey` will be filled in with the `execute` statement:
|
||||
准备一个包含参数的 select 查询。将与 `regionkey` 和 `nationkey` 进行比较的值将通过 `execute` 语句进行填充:
|
||||
|
||||
PREPARE my_select2 FROM
|
||||
SELECT name FROM nation WHERE regionkey = ? AND nationkey < ?;
|
||||
|
||||
Prepare an insert query:
|
||||
准备一个 insert 查询:
|
||||
|
||||
PREPARE my_insert FROM
|
||||
INSERT INTO cities VALUES (1, 'San Francisco');
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[execute](./execute.html), [deallocate-prepare](./deallocate-prepare.html), [describe-input](./describe-input.html), [describe-output](./describe-output.html)
|
||||
[execute](./execute.html)、[deallocate-prepare](./deallocate-prepare.html)、[describe-input](./describe-input.html)、[describe-output](./describe-output.html)
|
||||
|
|
@ -1,28 +1,28 @@
|
|||
RESET SESSION
|
||||
=============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "RESET SESSION"
|
||||
+++
|
||||
|
||||
# RESET SESSION
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
RESET SESSION name
|
||||
RESET SESSION catalog.name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Reset a session property value to the default value.
|
||||
将会话属性值重置为默认值。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
``` sql
|
||||
RESET SESSION optimize_hash_generation;
|
||||
RESET SESSION hive.optimized_reader_enabled;
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[set-session](./set-session.html), [show-session](./show-session.html)
|
||||
[set-session](./set-session.html)、[show-session](./show-session.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
REVOKE ROLES
|
||||
============
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "REVOKE ROLES"
|
||||
+++
|
||||
|
||||
# REVOKE ROLES
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
REVOKE
|
||||
|
|
@ -12,34 +15,30 @@ FROM ( user | USER user | ROLE role) [, ...]
|
|||
[ GRANTED BY ( user | USER user | ROLE role | CURRENT_USER | CURRENT_ROLE ) ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Revokes the specified role(s) from the specified principal(s) in the current catalog.
|
||||
从当前目录中的指定主体回收指定的角色。
|
||||
|
||||
If the `ADMIN OPTION FOR` clause is specified, the `GRANT` permission is revoked instead of the role.
|
||||
如果指定了 `ADMIN OPTION FOR` 子句,则回收 `GRANT` 权限,而不是回收角色。
|
||||
|
||||
For the `REVOKE` statement for roles to succeed, the user executing it either should be the role admin or should possess the `GRANT` option for the given role.
|
||||
为了使针对角色的 `REVOKE` 语句成功执行,执行该语句的用户应具有管理员角色或者应对于给定的角色拥有 `GRANT` 选项。
|
||||
|
||||
The optional `GRANTED BY` clause causes the role(s) to be revoked with the specified principal as a revoker. If the `GRANTED BY` clause is not specified, the roles are revoked by the current user as a revoker.
|
||||
可选的 `GRANTED BY` 子句可使指定的主体作为回收方来回收角色。如果未指定 `GRANTED BY` 子句,则当前用户作为回收方来回收角色。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Revoke role `bar` from user `foo` :
|
||||
从用户 `foo` 回收角色 `bar`:
|
||||
|
||||
REVOKE bar FROM USER foo;
|
||||
|
||||
Revoke admin option for roles `bar` and `foo` from user `baz` and role `qux` :
|
||||
从用户 `baz` 和角色 `qux` 回收角色 `bar` 和 `foo` 的管理员选项:
|
||||
|
||||
REVOKE ADMIN OPTION FOR bar, foo FROM USER baz, ROLE qux;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors do not support role management. See connector documentation for more details.
|
||||
某些连接器不支持角色管理。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-role](./create-role.html), [drop-role](./drop-role.html), [set-role](./set-role.html), [grant-roles](./grant-roles.html)
|
||||
[create-role](./create-role.html)、[drop-role](./drop-role.html)、[set-role](./ set-role.html)、[grant-roles](./ grant-roles.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
REVOKE
|
||||
======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "REVOKE"
|
||||
+++
|
||||
|
||||
# REVOKE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
REVOKE [ GRANT OPTION FOR ]
|
||||
|
|
@ -10,40 +13,36 @@ REVOKE [ GRANT OPTION FOR ]
|
|||
ON [ TABLE ] table_name FROM ( user | USER user | ROLE role )
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Revokes the specified privileges from the specified grantee.
|
||||
从指定的被授权者回收指定的权限。
|
||||
|
||||
Specifying `ALL PRIVILEGES` revokes [DELETE](delete.html), [INSERT](insert.html) and [SELECT](select.html) privileges.
|
||||
指定 `ALL PRIVILEGES` 可以回收 [DELETE](./delete.html)、[INSERT](./insert.html) 和 [SELETE](./select.html) 权限。
|
||||
|
||||
Specifying `ROLE PUBLIC` revokes privileges from the `PUBLIC` role. Users will retain privileges assigned to them directly or via other roles.
|
||||
指定 `ROLE PUBLIC` 可以从 `PUBLIC` 角色回收权限。用户将保留直接或通过其他角色分配给他们的权限。
|
||||
|
||||
The optional `GRANT OPTION FOR` clause also revokes the privileges to grant the specified privileges.
|
||||
可选的 `GRANT OPTION FOR` 子句还会回收授予指定权限的权限。
|
||||
|
||||
For `REVOKE` statement to succeed, the user executing it should possess the specified privileges as well as the `GRANT OPTION` for those privileges.
|
||||
为了使 `REVOKE` 语句成功执行,执行该语句的用户应拥有指定的权限并且对于这些权限拥有 `GRANT OPTION`。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Revoke `INSERT` and `SELECT` privileges on the table `orders` from user `alice`:
|
||||
从用户 `alice` 回收对表 `orders` 的 `INSERT` 和 `SELECT` 权限:
|
||||
|
||||
REVOKE INSERT, SELECT ON orders FROM alice;
|
||||
|
||||
Revoke `SELECT` privilege on the table `nation` from everyone, additionally revoking the privilege to grant `SELECT` privilege:
|
||||
从所有用户回收对表 `nation` 的 `SELECT` 权限,此外还回收授予 `SELECT` 权限的权限:
|
||||
|
||||
REVOKE GRANT OPTION FOR SELECT ON nation FROM ROLE PUBLIC;
|
||||
|
||||
Revoke all privileges on the table `test` from user `alice`:
|
||||
从用户 `alice` 回收对表 `test` 的所有权限:
|
||||
|
||||
REVOKE ALL PRIVILEGES ON test FROM alice;
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors have no support for `REVOKE`. See connector documentation for more details.
|
||||
某些连接器不支持 `REVOKE`。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[grant](./grant.html), [show-grants](./show-grants.html)
|
||||
[grant](./grant.html)、[show-grants](./ show-grants.html)
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
ROLLBACK
|
||||
========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "ROLLBACK"
|
||||
+++
|
||||
|
||||
# ROLLBACK
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
ROLLBACK [ WORK ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Rollback the current transaction.
|
||||
回滚当前事务。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
``` sql
|
||||
ROLLBACK;
|
||||
ROLLBACK WORK;
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[commit](./commit.html), [start-transaction](./start-transaction.html)
|
||||
[commit](./commit.html)、[start-transaction](./start-transaction.html)
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
SELECT
|
||||
======
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "SELECT"
|
||||
+++
|
||||
|
||||
# SELECT
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
[ WITH with_query [, ...] ]
|
||||
|
|
@ -17,7 +20,7 @@ SELECT [ ALL | DISTINCT ] select_expression [, ...]
|
|||
[ LIMIT { count | ALL } | FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } ]
|
||||
```
|
||||
|
||||
where `from_item` is one of
|
||||
其中,`from_item`有如下两种形式:
|
||||
|
||||
``` sql
|
||||
table_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
|
||||
|
|
@ -27,7 +30,7 @@ table_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
|
|||
from_item join_type from_item [ ON join_condition | USING ( join_column [, ...] ) ]
|
||||
```
|
||||
|
||||
and `join_type` is one of
|
||||
`join_type`是如下之一:
|
||||
|
||||
``` sql
|
||||
[ INNER ] JOIN
|
||||
|
|
@ -37,7 +40,7 @@ FULL [ OUTER ] JOIN
|
|||
CROSS JOIN
|
||||
```
|
||||
|
||||
and `grouping_element` is one of
|
||||
`grouping_element`是如下之一:
|
||||
|
||||
``` sql
|
||||
()
|
||||
|
|
@ -47,15 +50,13 @@ CUBE ( column [, ...] )
|
|||
ROLLUP ( column [, ...] )
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Retrieve rows from zero or more tables.
|
||||
从零个或多个表中检索行。
|
||||
|
||||
WITH Clause
|
||||
-----------
|
||||
## WITH子句
|
||||
|
||||
The `WITH` clause defines named relations for use within a query. It allows flattening nested queries or simplifying subqueries. For example, the following queries are equivalent:
|
||||
`WITH`子句定义在查询中使用的命名关系。该子句可以实现扁平化嵌套查询或简化子查询。例如,以下两个查询是等价的:
|
||||
|
||||
SELECT a, b
|
||||
FROM (
|
||||
|
|
@ -65,7 +66,7 @@ The `WITH` clause defines named relations for use within a query. It allows flat
|
|||
WITH x AS (SELECT a, MAX(b) AS b FROM t GROUP BY a)
|
||||
SELECT a, b FROM x;
|
||||
|
||||
This also works with multiple subqueries:
|
||||
这也适用于多个子查询:
|
||||
|
||||
WITH
|
||||
t1 AS (SELECT a, MAX(b) AS b FROM x GROUP BY a),
|
||||
|
|
@ -74,7 +75,7 @@ This also works with multiple subqueries:
|
|||
FROM t1
|
||||
JOIN t2 ON t1.a = t2.a;
|
||||
|
||||
Additionally, the relations within a `WITH` clause can chain:
|
||||
此外,`WITH`子句内的关系可以组成链式结构:
|
||||
|
||||
WITH
|
||||
x AS (SELECT a FROM t),
|
||||
|
|
@ -82,25 +83,23 @@ Additionally, the relations within a `WITH` clause can chain:
|
|||
z AS (SELECT b AS c FROM y)
|
||||
SELECT c FROM z;
|
||||
|
||||
**警告**
|
||||
|
||||
**Warning**
|
||||
*目前,`WITH`子句的SQL将在使用命名关系的任何位置内联。****这意味着,如果关系被多次使用,并且查询是非确定性的,那么每次的结果都可能不同。*
|
||||
|
||||
*Currently, the SQL for the `WITH` clause will be inlined anywhere the* *named relation is used. This means that if the relation is used more* *than once and the query is non-deterministic, the results may be* *different each time.*
|
||||
## SELECT子句
|
||||
|
||||
SELECT Clause
|
||||
-------------
|
||||
|
||||
The `SELECT` clause specifies the output of the query. Each `select_expression` defines a column or columns to be included in the result.
|
||||
`SELECT`子句指定查询的输出。每个`select_expression`定义结果中要包含的一个或多个列。
|
||||
|
||||
``` sql
|
||||
SELECT [ ALL | DISTINCT ] select_expression [, ...]
|
||||
```
|
||||
|
||||
The `ALL` and `DISTINCT` quantifiers determine whether duplicate rows are included in the result set. If the argument `ALL` is specified, all rows are included. If the argument `DISTINCT` is specified, only unique rows are included in the result set. In this case, each output column must be of a type that allows comparison. If neither argument is specified, the behavior defaults to `ALL`.
|
||||
`ALL`和`DISTINCT`量词确定结果集中是否包含重复行。如果指定了参数`ALL`,则包含所有行。如果指定了参数`DISTINCT`,则结果集中只包含唯一的行。在这种情况下,每个输出列必须具有允许比较的类型。如果两个参数都没有指定,则行为默认为`ALL`。
|
||||
|
||||
**Select expressions**
|
||||
**选择表达式**
|
||||
|
||||
Each `select_expression` must be in one of the following forms:
|
||||
每个`select_expression`必须采用下列其中一种形式:
|
||||
|
||||
``` sql
|
||||
expression [ [ AS ] column_alias ]
|
||||
|
|
@ -114,31 +113,29 @@ relation.*
|
|||
*
|
||||
```
|
||||
|
||||
In the case of `expression [ [ AS ] column_alias ]`, a single output column is defined.
|
||||
对于`expression [ [ AS ] column_alias ]`,定义了单个输出列。
|
||||
|
||||
In the case of `relation.*`, all columns of `relation` are included in the result set.
|
||||
对于`relation.*`,`relation`的所有列都包含在结果集中。
|
||||
|
||||
In the case of `*`, all columns of the relation defined by the query are included in the result set.
|
||||
对于`*`,由查询定义的关系的所有列都包含在结果集中。
|
||||
|
||||
In the result set, the order of columns is the same as the order of their specification by the select expressions. If a select expression returns multiple columns, they are ordered the same way they were ordered in the source relation.
|
||||
在结果集中,列的顺序与通过选择表达式指定列的顺序相同。如果选择表达式返回多个列,则这些列将按照源关系中的排序方式进行排序。
|
||||
|
||||
GROUP BY Clause
|
||||
---------------
|
||||
## GROUP BY子句
|
||||
|
||||
The `GROUP BY` clause divides the output of a `SELECT` statement into groups of rows containing matching values. A simple `GROUP BY` clause may contain any expression composed of input columns or it may be an
|
||||
ordinal number selecting an output column by position (starting at one).
|
||||
`GROUP BY`子句将`SELECT`语句的输出分组成包含匹配值的行。一个简单的`GROUP BY`子句可以包含任何由输入列组成的表达式,也可以是按位置选择输出列的序数(从1开始)。
|
||||
|
||||
The following queries are equivalent. They both group the output by the `nationkey` input column with the first query using the ordinal position of the output column and the second query using the input column name:
|
||||
以下查询是等价的。它们都通过`nationkey`输入列对输出进行分组,第一个查询使用输出列的顺序位置,第二个查询使用输入列名称:
|
||||
|
||||
SELECT count(*), nationkey FROM customer GROUP BY 2;
|
||||
|
||||
SELECT count(*), nationkey FROM customer GROUP BY nationkey;
|
||||
|
||||
`GROUP BY` clauses can group output by input column names not appearing in the output of a select statement. For example, the following query generates row counts for the `customer` table using the input column `mktsegment`:
|
||||
`GROUP BY`子句可以按不在select语句的输出中显示的输入列名对输出进行分组。例如,以下查询使用输入列`mktsegment`来生成`customer`表的行数:
|
||||
|
||||
SELECT count(*) FROM customer GROUP BY mktsegment;
|
||||
|
||||
```
|
||||
```
|
||||
_col0
|
||||
-------
|
||||
29968
|
||||
|
|
@ -149,24 +146,23 @@ _col0
|
|||
(5 rows)
|
||||
```
|
||||
|
||||
When a `GROUP BY` clause is used in a `SELECT` statement all output expressions must be either aggregate functions or columns present in the `GROUP BY` clause.
|
||||
在`SELECT`语句中使用`GROUP BY`子句时,所有输出表达式必须是`GROUP BY`子句中出现的聚合函数或列。
|
||||
|
||||
|
||||
**Complex Grouping Operations**
|
||||
|
||||
**复杂分组操作**
|
||||
|
||||
openLooKeng also supports complex aggregations using the `GROUPING SETS`, `CUBE` and `ROLLUP` syntax. This syntax allows users to perform analysis that requires aggregation on multiple sets of columns in a single query.
|
||||
Complex grouping operations do not support grouping on expressions composed of input columns. Only column names or ordinals are allowed.
|
||||
openLooKeng还支持使用`GROUPING SETS`、`CUBE`和`ROLLUP`语法的复杂聚合。此语法允许用户在单个查询中执行需要对多组列进行聚合的分析。复杂分组操作不支持对由输入列组成的表达式进行分组。只支持列名或序号。
|
||||
|
||||
Complex grouping operations are often equivalent to a `UNION ALL` of simple `GROUP BY` expressions, as shown in the following examples. This equivalence does not apply, however, when the source of data for the aggregation is non-deterministic.
|
||||
复杂分组操作通常与对简单`GROUP BY`表达式的`UNION ALL`操作等价,如下面的示例所示。但是,当聚合的数据源是非确定性的时,这种等价性不适用。
|
||||
|
||||
**GROUPING SETS**
|
||||
|
||||
Grouping sets allow users to specify multiple lists of columns to group on. The columns not part of a given sublist of grouping columns are set to `NULL`. :
|
||||
GROUPING SETS允许用户指定要进行分组的多个列列表。不属于给定分组列子列表的列设置为`NULL`。如下所示:
|
||||
|
||||
SELECT * FROM shipping;
|
||||
|
||||
```
|
||||
```
|
||||
origin_state | origin_zip | destination_state | destination_zip | package_weight
|
||||
--------------+------------+-------------------+-----------------+----------------
|
||||
California | 94131 | New Jersey | 8648 | 13
|
||||
|
|
@ -178,7 +174,7 @@ New York | 10002 | New Jersey | 8540 | 3
|
|||
(6 rows)
|
||||
```
|
||||
|
||||
`GROUPING SETS` semantics are demonstrated by this example query:
|
||||
这个示例查询演示了`GROUPING SETS`语义:
|
||||
|
||||
SELECT origin_state, origin_zip, destination_state, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -187,7 +183,7 @@ New York | 10002 | New Jersey | 8540 | 3
|
|||
(origin_state, origin_zip),
|
||||
(destination_state));
|
||||
|
||||
```
|
||||
```
|
||||
origin_state | origin_zip | destination_state | _col0
|
||||
--------------+------------+-------------------+-------
|
||||
New Jersey | NULL | NULL | 225
|
||||
|
|
@ -203,7 +199,7 @@ NULL | NULL | Connecticut | 1562
|
|||
(10 rows)
|
||||
```
|
||||
|
||||
The preceding query may be considered logically equivalent to a `UNION ALL` of multiple `GROUP BY` queries:
|
||||
上述查询在逻辑上可以等价于对多个`GROUP BY`查询的`UNION ALL`操作:
|
||||
|
||||
SELECT origin_state, NULL, NULL, sum(package_weight)
|
||||
FROM shipping GROUP BY origin_state
|
||||
|
|
@ -218,18 +214,17 @@ The preceding query may be considered logically equivalent to a `UNION ALL` of m
|
|||
SELECT NULL, NULL, destination_state, sum(package_weight)
|
||||
FROM shipping GROUP BY destination_state;
|
||||
|
||||
However, the query with the complex grouping syntax (`GROUPING SETS`, `CUBE` or `ROLLUP`) will only read from the underlying data source once, while the query with the `UNION ALL` reads the underlying data three
|
||||
times. This is why queries with a `UNION ALL` may produce inconsistent results when the data source is not deterministic.
|
||||
但是,使用复杂分组语法(`GROUPING SETS`、`CUBE`或`ROLLUP`)的查询将只从基础数据源读取一次,而使用`UNION ALL`的查询会读取基础数据三次。因此,当数据源不确定时,带有`UNION ALL`的查询可能产生不一致的结果。
|
||||
|
||||
**CUBE**
|
||||
|
||||
The `CUBE` operator generates all possible grouping sets (i.e. a power set) for a given set of columns. For example, the query:
|
||||
`CUBE`运算符生成所有可能的分组集(即幂集)的给定列集。例如,以下查询:
|
||||
|
||||
SELECT origin_state, destination_state, sum(package_weight)
|
||||
FROM shipping
|
||||
GROUP BY CUBE (origin_state, destination_state);
|
||||
|
||||
is equivalent to:
|
||||
等价于:
|
||||
|
||||
SELECT origin_state, destination_state, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -239,7 +234,7 @@ is equivalent to:
|
|||
(destination_state),
|
||||
());
|
||||
|
||||
```
|
||||
```
|
||||
origin_state | destination_state | _col0
|
||||
--------------+-------------------+-------
|
||||
California | New Jersey | 55
|
||||
|
|
@ -259,13 +254,13 @@ NULL | NULL | 1625
|
|||
|
||||
**ROLLUP**
|
||||
|
||||
The `ROLLUP` operator generates all possible subtotals for a given set of columns. For example, the query:
|
||||
`ROLLUP`运算符为给定的列集生成所有可能的小记。例如,以下查询:
|
||||
|
||||
SELECT origin_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
GROUP BY ROLLUP (origin_state, origin_zip);
|
||||
|
||||
```
|
||||
```
|
||||
origin_state | origin_zip | _col2
|
||||
--------------+------------+-------
|
||||
California | 94131 | 60
|
||||
|
|
@ -279,15 +274,15 @@ NULL | NULL | 1625
|
|||
(8 rows)
|
||||
```
|
||||
|
||||
is equivalent to:
|
||||
等价于:
|
||||
|
||||
SELECT origin_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
GROUP BY GROUPING SETS ((origin_state, origin_zip), (origin_state), ());
|
||||
|
||||
**Combining multiple grouping expressions**
|
||||
**组合多个分组表达式**
|
||||
|
||||
Multiple grouping expressions in the same query are interpreted as having cross-product semantics. For example, the following query:
|
||||
同一查询中的多个分组表达式被解释为具有叉积语义。例如,以下查询:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -295,7 +290,7 @@ Multiple grouping expressions in the same query are interpreted as having cross-
|
|||
GROUPING SETS ((origin_state, destination_state)),
|
||||
ROLLUP (origin_zip);
|
||||
|
||||
which can be rewritten as:
|
||||
可以改写为:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -303,7 +298,7 @@ which can be rewritten as:
|
|||
GROUPING SETS ((origin_state, destination_state)),
|
||||
GROUPING SETS ((origin_zip), ());
|
||||
|
||||
is logically equivalent to:
|
||||
逻辑上等价于:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -311,7 +306,7 @@ is logically equivalent to:
|
|||
(origin_state, destination_state, origin_zip),
|
||||
(origin_state, destination_state));
|
||||
|
||||
```
|
||||
```
|
||||
origin_state | destination_state | origin_zip | _col3
|
||||
--------------+-------------------+------------+-------
|
||||
New York | New Jersey | 10002 | 3
|
||||
|
|
@ -327,8 +322,7 @@ California | New Jersey | NULL | 55
|
|||
(10 rows)
|
||||
```
|
||||
|
||||
The `ALL` and `DISTINCT` quantifiers determine whether duplicate grouping sets each produce distinct output rows. This is particularly useful when multiple complex grouping sets are combined in the same
|
||||
query. For example, the following query:
|
||||
`ALL`和`DISTINCT`量词确定重复分组集是否各自生成不同的输出行。这在多个复杂分组集组合在同一个查询中时尤其有用。例如,以下查询:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -336,7 +330,7 @@ query. For example, the following query:
|
|||
CUBE (origin_state, destination_state),
|
||||
ROLLUP (origin_state, origin_zip);
|
||||
|
||||
is equivalent to:
|
||||
等价于:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -354,7 +348,7 @@ is equivalent to:
|
|||
(destination_state),
|
||||
());
|
||||
|
||||
However, if the query uses the `DISTINCT` quantifier for the `GROUP BY`:
|
||||
但是,如果查询对`GROUP BY`使用`DISTINCT`量词:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -362,7 +356,7 @@ However, if the query uses the `DISTINCT` quantifier for the `GROUP BY`:
|
|||
CUBE (origin_state, destination_state),
|
||||
ROLLUP (origin_state, origin_zip);
|
||||
|
||||
only unique grouping sets are generated:
|
||||
只生成唯一的分组集合:
|
||||
|
||||
SELECT origin_state, destination_state, origin_zip, sum(package_weight)
|
||||
FROM shipping
|
||||
|
|
@ -374,17 +368,15 @@ only unique grouping sets are generated:
|
|||
(destination_state),
|
||||
());
|
||||
|
||||
The default set quantifier is `ALL`.
|
||||
默认的组量词是`ALL`。
|
||||
|
||||
**GROUPING Operation**
|
||||
**GROUPING操作**
|
||||
|
||||
`grouping(col1, ..., colN) -> bigint`
|
||||
|
||||
The grouping operation returns a bit set converted to decimal, indicating which columns are present in a grouping. It must be used in conjunction with `GROUPING SETS`, `ROLLUP`, `CUBE` or `GROUP BY` and its
|
||||
arguments must match exactly the columns referenced in the corresponding `GROUPING SETS`, `ROLLUP`, `CUBE` or `GROUP BY` clause.
|
||||
GROUPING操作返回转换为十进制的位集,指示分组中存在哪些列。它必须与`GROUPING SETS`、`ROLLUP`、`CUBE`或`GROUP BY`一起使用,并且其参数必须与相应的`GROUPING SETS`、`ROLLUP`、`CUBE`或`GROUP BY`子句中引用的列完全匹配。
|
||||
|
||||
To compute the resulting bit set for a particular row, bits are assigned to the argument columns with the rightmost column being the least significant bit. For a given grouping, a bit is set to 0 if the
|
||||
corresponding column is included in the grouping and to 1 otherwise. For example, consider the query below:
|
||||
要计算特定行的结果位集,将位分配给参数列,其中最右边的列是最低有效位。对于给定的分组,如果相应的列包含在分组中,则位设置为0,否则设置为1。例如,考虑以下查询:
|
||||
|
||||
SELECT origin_state, origin_zip, destination_state, sum(package_weight),
|
||||
grouping(origin_state, origin_zip, destination_state)
|
||||
|
|
@ -394,7 +386,7 @@ corresponding column is included in the grouping and to 1 otherwise. For example
|
|||
(origin_state, origin_zip),
|
||||
(destination_state));
|
||||
|
||||
```
|
||||
```
|
||||
origin_state | origin_zip | destination_state | _col3 | _col4
|
||||
--------------+------------+-------------------+-------+-------
|
||||
California | NULL | NULL | 1397 | 3
|
||||
|
|
@ -410,15 +402,13 @@ NULL | NULL | Colorado | 5 | 6
|
|||
(10 rows)
|
||||
```
|
||||
|
||||
The first grouping in the above result only includes the `origin_state` column and excludes the `origin_zip` and `destination_state` columns. The bit set constructed for that grouping is `011` where the most significant bit represents `origin_state`.
|
||||
上述结果中的第一个分组只包括`origin_state`列,不包括`origin_zip`列和`destination_state`列。为该分组构造的位集是`011`,最高有效位表示`origin_state`。
|
||||
|
||||
HAVING Clause
|
||||
-------------
|
||||
## HAVING子句
|
||||
|
||||
The `HAVING` clause is used in conjunction with aggregate functions and the `GROUP BY` clause to control which groups are selected. A `HAVING` clause eliminates groups that do not satisfy the given conditions.
|
||||
`HAVING` filters groups after groups and aggregates are computed.
|
||||
`HAVING`子句与聚合函数和`GROUP BY`子句一起使用,以控制选择哪些组。`HAVING`子句排除不满足给定条件的组。分组和聚合计算完成后,`HAVING`对分组进行过滤。
|
||||
|
||||
The following example queries the `customer` table and selects groups with an account balance greater than the specified value:
|
||||
以下示例查询`customer`表,选择余额大于指定金额的组。
|
||||
|
||||
SELECT count(*), mktsegment, nationkey,
|
||||
CAST(sum(acctbal) AS bigint) AS totalbal
|
||||
|
|
@ -427,7 +417,7 @@ The following example queries the `customer` table and selects groups with an ac
|
|||
HAVING sum(acctbal) > 5700000
|
||||
ORDER BY totalbal DESC;
|
||||
|
||||
```
|
||||
```
|
||||
_col0 | mktsegment | nationkey | totalbal
|
||||
-------+------------+-----------+----------
|
||||
1272 | AUTOMOBILE | 19 | 5856939
|
||||
|
|
@ -440,10 +430,9 @@ _col0 | mktsegment | nationkey | totalbal
|
|||
(7 rows)
|
||||
```
|
||||
|
||||
UNION \| INTERSECT \| EXCEPT Clause
|
||||
-----------------------------------
|
||||
## UNION \| INTERSECT \| EXCEPT子句
|
||||
|
||||
`UNION` `INTERSECT` and `EXCEPT` are all set operations. These clauses are used to combine the results of more than one select statement into a single result set:
|
||||
`UNION`、`INTERSECT`和`EXCEPT`都是集合运算。这些子句用于将多个SELECT语句的结果组合成单个结果集:
|
||||
|
||||
``` sql
|
||||
query UNION [ALL | DISTINCT] query
|
||||
|
|
@ -457,19 +446,19 @@ query INTERSECT [DISTINCT] query
|
|||
query EXCEPT [DISTINCT] query
|
||||
```
|
||||
|
||||
The argument `ALL` or `DISTINCT` controls which rows are included in the final result set. If the argument `ALL` is specified all rows are included even if the rows are identical. If the argument `DISTINCT` is specified only unique rows are included in the combined result set. If neither is specified, the behavior defaults to `DISTINCT`. The `ALL` argument is not supported for `INTERSECT` or `EXCEPT`.
|
||||
参数`ALL`或`DISTINCT`控制最终结果集中包括哪些行。如果指定了参数`ALL`,则包含所有行,即使这些行是相同的。如果指定了参数`DISTINCT`,则合并的结果集中只包含唯一的行。如果两个参数都没有指定,则行为默认为`DISTINCT`。`INTERSECT`或`EXCEPT`不支持`ALL`参数。
|
||||
|
||||
Multiple set operations are processed left to right, unless the order is explicitly specified via parentheses. Additionally, `INTERSECT` binds more tightly than `EXCEPT` and `UNION`. That means `A UNION B INTERSECT C EXCEPT D` is the same as `A UNION (B INTERSECT C) EXCEPT D`.
|
||||
除非通过括号显式指定顺序,否则多个集合操作从左到右处理。另外,`INTERSECT`运算优先级高于`EXCEPT`和`UNION`。`A UNION B INTERSECT C EXCEPT D`意思和`A UNION (B INTERSECT C) EXCEPT D`一样。
|
||||
|
||||
**UNION**
|
||||
|
||||
`UNION` combines all the rows that are in the result set from the first query with those that are in the result set for the second query. The following is an example of one of the simplest possible `UNION` clauses. It selects the value `13` and combines this result set with a second query that selects the value `42`:
|
||||
`UNION`将第一个查询的结果集中的所有行与第二个查询的结果集中的所有行合并。下面是最简单的`UNION`子句之一的示例。该查询选择值`13`,并将这个结果集与选择值`42`的第二个查询组合在一起:
|
||||
|
||||
SELECT 13
|
||||
UNION
|
||||
SELECT 42;
|
||||
|
||||
```
|
||||
```
|
||||
_col0
|
||||
-------
|
||||
13
|
||||
|
|
@ -477,13 +466,13 @@ _col0
|
|||
(2 rows)
|
||||
```
|
||||
|
||||
The following query demonstrates the difference between `UNION` and `UNION ALL`. It selects the value `13` and combines this result set with a second query that selects the values `42` and `13`:
|
||||
下面的查询演示了`UNION`和`UNION ALL`之间的区别。该查询选择值`13`,并将这个结果集与选择值`42`和`13`的第二个查询组合在一起:
|
||||
|
||||
SELECT 13
|
||||
UNION
|
||||
SELECT * FROM (VALUES 42, 13);
|
||||
|
||||
```
|
||||
```
|
||||
_col0
|
||||
-------
|
||||
13
|
||||
|
|
@ -495,7 +484,7 @@ _col0
|
|||
UNION ALL
|
||||
SELECT * FROM (VALUES 42, 13);
|
||||
|
||||
```
|
||||
```
|
||||
_col0
|
||||
-------
|
||||
13
|
||||
|
|
@ -506,14 +495,13 @@ _col0
|
|||
|
||||
**INTERSECT**
|
||||
|
||||
`INTERSECT` returns only the rows that are in the result sets of both the first and the second queries. The following is an example of one of the simplest possible `INTERSECT` clauses. It selects the values `13`
|
||||
and `42` and combines this result set with a second query that selects the value `13`. Since `42` is only in the result set of the first query, it is not included in the final results.:
|
||||
`INTERSECT`只返回同时存在于第一个和第二个查询的结果集中的行。下面是最简单的`INTERSECT`子句之一的示例。该查询选择值`13`和`42`,并将这个结果集与选择值`13`的第二个查询组合在一起:由于`42`只在第一个查询的结果集中,所以它不会包含在最终结果中。
|
||||
|
||||
SELECT * FROM (VALUES 13, 42)
|
||||
INTERSECT
|
||||
SELECT 13;
|
||||
|
||||
```
|
||||
```
|
||||
_col0
|
||||
-------
|
||||
13
|
||||
|
|
@ -522,45 +510,42 @@ _col0
|
|||
|
||||
**EXCEPT**
|
||||
|
||||
`EXCEPT` returns the rows that are in the result set of the first query, but not the second. The following is an example of one of the simplest possible `EXCEPT` clauses. It selects the values `13` and `42` and
|
||||
combines this result set with a second query that selects the value `13`. Since `13` is also in the result set of the second query, it is not included in the final result.:
|
||||
`EXCEPT`返回在第一个查询结果集中但不在第二个查询结果集中的行。下面是最简单的`EXCEPT`子句之一的示例。该查询选择值`13`和`42`,并将这个结果集与选择值`13`的第二个查询组合在一起:由于`13`也在第二个查询的结果集中,所以它不会包含在最终结果中。
|
||||
|
||||
SELECT * FROM (VALUES 13, 42)
|
||||
EXCEPT
|
||||
SELECT 13;
|
||||
|
||||
```
|
||||
```
|
||||
_col0
|
||||
-------
|
||||
42
|
||||
(2 rows)
|
||||
```
|
||||
|
||||
ORDER BY Clause
|
||||
---------------
|
||||
## ORDER BY子句
|
||||
|
||||
The `ORDER BY` clause is used to sort a result set by one or more output expressions:
|
||||
`ORDER BY`子句用于按一个或多个输出表达式对结果集进行排序:
|
||||
|
||||
``` sql
|
||||
ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...]
|
||||
```
|
||||
|
||||
Each expression may be composed of output columns or it may be an ordinal number selecting an output column by position (starting at one). The `ORDER BY` clause is evaluated after any `GROUP BY` or `HAVING` clause and before any `OFFSET`, `LIMIT` or `FETCH FIRST` clause. The default null ordering is `NULLS LAST`, regardless of the ordering direction.
|
||||
每个表达式可以由输出列组成,也可以是按位置选择输出列的序数(从1开始)。`ORDER BY`子句在任何`GROUP BY`或`HAVING`子句之后,任何`OFFSET`、`LIMIT`或`FETCH FIRST`子句之前执行。默认的NULL排序是`NULLS LAST`,无论排序方向如何都是如此。
|
||||
|
||||
OFFSET Clause
|
||||
-------------
|
||||
## OFFSET子句
|
||||
|
||||
The `OFFSET` clause is used to discard a number of leading rows from the result set:
|
||||
`OFFSET`子句用于从结果集中丢弃一些前导行:
|
||||
|
||||
``` sql
|
||||
OFFSET count [ ROW | ROWS ]
|
||||
```
|
||||
|
||||
If the `ORDER BY` clause is present, the `OFFSET` clause is evaluated over a sorted result set, and the set remains sorted after the leading rows are discarded:
|
||||
如果`ORDER BY`子句存在,则`OFFSET`子句对已排序的结果集执行,并且该结果集在丢弃前导行之后仍保持排序:
|
||||
|
||||
SELECT name FROM nation ORDER BY name OFFSET 22;
|
||||
|
||||
```
|
||||
```
|
||||
name
|
||||
----------------
|
||||
UNITED KINGDOM
|
||||
|
|
@ -569,13 +554,11 @@ VIETNAM
|
|||
(3 rows)
|
||||
```
|
||||
|
||||
Otherwise, it is arbitrary which rows are discarded. If the count specified in the `OFFSET` clause equals or exceeds the size of the result set, the final result is empty.
|
||||
否则将任意丢弃一些行。如果`OFFSET`子句中指定的计数等于或超过结果集的大小,则最终结果为空。
|
||||
|
||||
LIMIT or FETCH FIRST Clauses
|
||||
----------------------------
|
||||
## LIMIT或FETCH FIRST子句
|
||||
|
||||
The `LIMIT` or `FETCH FIRST` clause restricts the number of rows in the
|
||||
result set.
|
||||
`LIMIT`或`FETCH FIRST`子句限制结果集中的行数。
|
||||
|
||||
``` sql
|
||||
LIMIT { count | ALL }
|
||||
|
|
@ -585,11 +568,11 @@ LIMIT { count | ALL }
|
|||
FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES }
|
||||
```
|
||||
|
||||
The following example queries a large table, but the `LIMIT` clause restricts the output to only have five rows (because the query lacks an `ORDER BY`, exactly which rows are returned is arbitrary):
|
||||
以下示例查询一个大表,但`LIMIT`子句将输出限制为只有五行(因为查询缺少`ORDER BY`,所以将返回任意行):
|
||||
|
||||
SELECT orderdate FROM orders LIMIT 5;
|
||||
|
||||
```
|
||||
```
|
||||
orderdate
|
||||
------------
|
||||
1994-07-25
|
||||
|
|
@ -600,26 +583,26 @@ orderdate
|
|||
(5 rows)
|
||||
```
|
||||
|
||||
`LIMIT ALL` is the same as omitting the `LIMIT` clause.
|
||||
`LIMIT ALL`等于省略了`LIMIT`子句。
|
||||
|
||||
The `FETCH FIRST` clause supports either the `FIRST` or `NEXT` keywords and the `ROW` or `ROWS` keywords. These keywords are equivalent and the choice of keyword has no effect on query execution.
|
||||
`FETCH FIRST`子句支持`FIRST`或`NEXT`关键字,也支持`ROW`或`ROWS`关键字。这些关键字是等价的,关键字的选择对查询执行没有影响。
|
||||
|
||||
If the count is not specified in the `FETCH FIRST` clause, it defaults to `1`:
|
||||
如果`FETCH FIRST`子句中没有指定计数,则默认为`1`:
|
||||
|
||||
SELECT orderdate FROM orders FETCH FIRST ROW ONLY;
|
||||
|
||||
```
|
||||
```
|
||||
orderdate
|
||||
------------
|
||||
1994-02-12
|
||||
(1 row)
|
||||
```
|
||||
|
||||
If the `OFFSET` clause is present, the `LIMIT` or `FETCH FIRST` clause is evaluated after the `OFFSET` clause:
|
||||
如果存在`OFFSET`子句,则`LIMIT`或`FETCH FIRST`子句在`OFFSET`子句之后执行:
|
||||
|
||||
SELECT * FROM (VALUES 5, 2, 4, 1, 3) t(x) ORDER BY x OFFSET 2 LIMIT 2;
|
||||
|
||||
```
|
||||
```
|
||||
x
|
||||
---
|
||||
3
|
||||
|
|
@ -627,16 +610,15 @@ x
|
|||
(2 rows)
|
||||
```
|
||||
|
||||
For the `FETCH FIRST` clause, the argument `ONLY` or `WITH TIES` controls which rows are included in the result set.
|
||||
对于`FETCH FIRST`子句,参数`ONLY`或`WITH TIES`控制哪些行包括在结果集中。
|
||||
|
||||
If the argument `ONLY` is specified, the result set is limited to the exact number of leading rows determined by the count.
|
||||
如果指定了参数`ONLY`,结果集将限制为由计数确定的前导行的确切数目。
|
||||
|
||||
If the argument `WITH TIES` is specified, it is required that the `ORDER BY` clause be present. The result set consists of the same set of leading rows and all of the rows in the same peer group as the last of
|
||||
them ('ties') as established by the ordering in the `ORDER BY` clause. The result set is sorted:
|
||||
如果指定了参数`WITH TIES`,则要求存在`ORDER BY`子句。结果集由相同的前导行集和与之相同的对等组中的所有行组成。它们(“结”)是由`ORDER BY`子句中的顺序确定的。结果集被排序:
|
||||
|
||||
SELECT name, regionkey FROM nation ORDER BY regionkey FETCH FIRST ROW WITH TIES;
|
||||
|
||||
```
|
||||
```
|
||||
name | regionkey
|
||||
------------+-----------
|
||||
ETHIOPIA | 0
|
||||
|
|
@ -647,29 +629,27 @@ MOZAMBIQUE | 0
|
|||
(5 rows)
|
||||
```
|
||||
|
||||
TABLESAMPLE
|
||||
-----------
|
||||
## TABLESAMPLE
|
||||
|
||||
There are multiple sample methods:
|
||||
有多种采样方法:
|
||||
|
||||
`BERNOULLI`
|
||||
|
||||
Each row is selected to be in the table sample with a probability of the sample percentage. When a table is sampled using the Bernoulli method, all physical blocks of the table are scanned and certain rows are skipped (based on a comparison between the sample percentage and a random value calculated at runtime).
|
||||
每一行都以样本百分比的概率被选择到表样本中。当使用Bernoulli方法对表进行采样时,将扫描该表的所有物理块,并基于样本百分比与运行时计算的随机值之间的比较结果跳过某些行。
|
||||
|
||||
The probability of a row being included in the result is independent from any other row. This does not reduce the time required to read the sampled table from disk. It may have an impact on the total query time if the sampled output is processed further.
|
||||
结果中包含某一行的概率与任何其他行无关。这不会减少从磁盘读取采样表所需的时间。如果进一步处理采样输出,则可能会影响总查询时间。
|
||||
|
||||
`SYSTEM`
|
||||
|
||||
This sampling method divides the table into logical segments of data and samples the table at this granularity. This sampling method either selects all the rows from a particular segment of data or skips it (based on a comparison between the sample percentage and a random value calculated at runtime).
|
||||
这种采样方法将表划分为数据的逻辑段,并以此粒度对表进行采样。这种抽样方法要么从特定数据段中选择所有行,要么基于样本百分比与运行时计算的随机值之间的比较结果跳过该数据段。
|
||||
|
||||
The rows selected in a system sampling will be dependent on which connector is used. For example, when used with Hive, it is dependent on how the data is laid out on HDFS. This method does not guarantee independent sampling probabilities.
|
||||
在系统采样中选定的行将取决于所使用的连接器。例如,当与Hive一起使用时,取决于数据在HDFS上的分布。*这种方法不保证独立的采样概率。*
|
||||
|
||||
**注意**
|
||||
|
||||
**Note**
|
||||
这两种方法都不允许对返回的行数进行确定性限制。
|
||||
|
||||
*Neither of the two methods allow deterministic bounds on the number of* *rows returned.*
|
||||
|
||||
Examples:
|
||||
示例:
|
||||
|
||||
SELECT *
|
||||
FROM users TABLESAMPLE BERNOULLI (50);
|
||||
|
|
@ -677,25 +657,24 @@ Examples:
|
|||
SELECT *
|
||||
FROM users TABLESAMPLE SYSTEM (75);
|
||||
|
||||
Using sampling with joins:
|
||||
采样过程中使用JOIN:
|
||||
|
||||
SELECT o.*, i.*
|
||||
FROM orders o TABLESAMPLE SYSTEM (10)
|
||||
JOIN lineitem i TABLESAMPLE BERNOULLI (40)
|
||||
ON o.orderkey = i.orderkey;
|
||||
|
||||
UNNEST
|
||||
------
|
||||
## UNNEST
|
||||
|
||||
`UNNEST` can be used to expand an [ARRAY](../language/types.html) or [MAP](../language/types.html) into a relation. Arrays are expanded into a single column, and maps are expanded into two columns (key, value). `UNNEST` can also be used with multiple arguments, in which case they are expanded into multiple columns, with as many rows as the highest cardinality argument (the other columns are padded with nulls). `UNNEST` can optionally have a `WITH ORDINALITY` clause, in which case an additional ordinality column is added to the end. `UNNEST` is normally used with a `JOIN` and can reference columns from relations on the left side of the join.
|
||||
`UNNEST`可用于将[数组](../language/types.html)或[映射](../language/types.html)展开为关系。数组被扩展为单列,而映射被扩展为两列(键值)。`UNNEST`也可以与多个参数一起使用,在这种情况下,它们会扩展为多列,行数为最高基数参数(其他列用NULL填充)。`UNNEST`也可以带`WITH ORDINALITY`子句,在这种情况下,一个额外的普通列被添加到末尾。`UNNEST`通常与`JOIN`一起使用,并且可以引JOIN左侧的关系中的列。
|
||||
|
||||
Using a single column:
|
||||
使用单列:
|
||||
|
||||
SELECT student, score
|
||||
FROM tests
|
||||
CROSS JOIN UNNEST(scores) AS t (score);
|
||||
|
||||
Using multiple columns:
|
||||
使用多列:
|
||||
|
||||
SELECT numbers, animals, n, a
|
||||
FROM (
|
||||
|
|
@ -705,7 +684,7 @@ Using multiple columns:
|
|||
) AS x (numbers, animals)
|
||||
CROSS JOIN UNNEST(numbers, animals) AS t (n, a);
|
||||
|
||||
```
|
||||
```
|
||||
numbers | animals | n | a
|
||||
-----------+------------------+------+------
|
||||
[2, 5] | [dog, cat, bird] | 2 | dog
|
||||
|
|
@ -717,7 +696,7 @@ numbers | animals | n | a
|
|||
(6 rows)
|
||||
```
|
||||
|
||||
`WITH ORDINALITY` clause:
|
||||
`WITH ORDINALITY`子句:
|
||||
|
||||
SELECT numbers, n, a
|
||||
FROM (
|
||||
|
|
@ -727,7 +706,7 @@ numbers | animals | n | a
|
|||
) AS x (numbers)
|
||||
CROSS JOIN UNNEST(numbers) WITH ORDINALITY AS t (n, a);
|
||||
|
||||
```
|
||||
```
|
||||
numbers | n | a
|
||||
-----------+---+---
|
||||
[2, 5] | 2 | 1
|
||||
|
|
@ -738,16 +717,15 @@ numbers | n | a
|
|||
(5 rows)
|
||||
```
|
||||
|
||||
Joins
|
||||
-----
|
||||
## JOIN
|
||||
|
||||
Joins allow you to combine data from multiple relations.
|
||||
JOIN允许组合来自多个关系的数据。
|
||||
|
||||
### CROSS JOIN
|
||||
|
||||
A cross join returns the Cartesian product (all combinations) of two relations. Cross joins can either be specified using the explit `CROSS JOIN` syntax or by specifying multiple relations in the `FROM` clause.
|
||||
CROSS JOIN返回两个关系的笛卡尔积(所有组合)。可以使用显式`CROSS JOIN`语法或通过在`FROM`子句中指定多个关系来指定交叉联接。
|
||||
|
||||
Both of the following queries are equivalent:
|
||||
以下两个查询是等价的:
|
||||
|
||||
SELECT *
|
||||
FROM nation
|
||||
|
|
@ -756,14 +734,14 @@ Both of the following queries are equivalent:
|
|||
SELECT *
|
||||
FROM nation, region;
|
||||
|
||||
The `nation` table contains 25 rows and the `region` table contains 5 rows, so a cross join between the two tables produces 125 rows:
|
||||
`nation`表包含25行,`region`表包含5行,因此两个表之间的交叉联接将生成125行:
|
||||
|
||||
SELECT n.name AS nation, r.name AS region
|
||||
FROM nation AS n
|
||||
CROSS JOIN region AS r
|
||||
ORDER BY 1, 2;
|
||||
|
||||
```
|
||||
```
|
||||
nation | region
|
||||
----------------+-------------
|
||||
ALGERIA | AFRICA
|
||||
|
|
@ -779,22 +757,22 @@ ARGENTINA | AMERICA
|
|||
|
||||
### LATERAL
|
||||
|
||||
Subqueries appearing in the `FROM` clause can be preceded by the keyword `LATERAL`. This allows them to reference columns provided by preceding `FROM` items.
|
||||
出现在`FROM`子句中的子查询前面可以加关键字`LATERAL`。这允许子查询引用前面`FROM`项提供的列。
|
||||
|
||||
A `LATERAL` join can appear at the top level in the `FROM` list, or anywhere within a parenthesized join tree. In the latter case, it can also refer to any items that are on the left-hand side of a `JOIN` for which it is on the right-hand side.
|
||||
`LATERAL`联接可以出现在`FROM`列表的顶层,或者括号括起来的联接树中的任何地方。在后一种情况下,对于联接在右侧的项目,联接也可以引用位于`JOIN`左侧的任何项目。
|
||||
|
||||
When a `FROM` item contains `LATERAL` cross-references, evaluation proceeds as follows: for each row of the `FROM` item providing the cross-referenced columns, the `LATERAL` item is evaluated using that row set's values of the columns. The resulting rows are joined as usual with the rows they were computed from. This is repeated for set of rows from the column source tables.
|
||||
当`FROM`项包含`LATERAL`交叉引用时,计算过程如下:对于提供交叉引用列的`FROM`项的每一行,将使用该行集的列值对`LATERAL`项进行计算。所得行正常与它们从中计算出来的行连接在一起。对于列源表中的行集重复此过程。
|
||||
|
||||
`LATERAL` is primarily useful when the cross-referenced column is necessary for computing the rows to be joined:
|
||||
`LATERAL`主要用于需要使用交叉引用的列来计算要连接的行的情形:
|
||||
|
||||
SELECT name, x, y
|
||||
FROM nation
|
||||
CROSS JOIN LATERAL (SELECT name || ' :-' AS x)
|
||||
CROSS JOIN LATERAL (SELECT x || ')' AS y)
|
||||
|
||||
### Qualifying Column Names
|
||||
### 限定列名
|
||||
|
||||
When two relations in a join have columns with the same name, the column references must be qualified using the relation alias (if the relation has an alias), or with the relation name:
|
||||
当联接中的两个关系具有同名的列时,必须使用关系别名(如果关系具有别名)或使用关系名称对列引用进行限定:
|
||||
|
||||
SELECT nation.name, region.name
|
||||
FROM nation
|
||||
|
|
@ -808,26 +786,23 @@ When two relations in a join have columns with the same name, the column referen
|
|||
FROM nation n
|
||||
CROSS JOIN region r;
|
||||
|
||||
The following query will fail with the error
|
||||
`Column 'name' is ambiguous`:
|
||||
以下查询将失败,并返回错误`Column 'name' is ambiguous`:
|
||||
|
||||
SELECT name
|
||||
FROM nation
|
||||
CROSS JOIN region;
|
||||
|
||||
Subqueries
|
||||
----------
|
||||
## 子查询
|
||||
|
||||
A subquery is an expression which is composed of a query. The subquery is correlated when it refers to columns outside of the subquery. Logically, the subquery will be evaluated for each row in the surrounding query. The referenced columns will thus be constant during any single evaluation of the subquery.
|
||||
子查询是由查询组成的表达式。当某个子查询引用该子查询外层的列时,该子查询称为相关子查询。逻辑上,会针对父查询中的每一行计算子查询。因此,在对子查询进行任何单个计算时,所引用的列将保持不变。
|
||||
|
||||
**说明**
|
||||
|
||||
**Note**
|
||||
|
||||
*Support for correlated subqueries is limited. Not every standard form is* *supported.*
|
||||
*对相关子查询的支持有限。****并不是每个标准表单都受支持。*
|
||||
|
||||
### EXISTS
|
||||
|
||||
The `EXISTS` predicate determines if a subquery returns any rows:
|
||||
`EXISTS`谓词确定子查询是否返回任何行:
|
||||
|
||||
SELECT name
|
||||
FROM nation
|
||||
|
|
@ -835,22 +810,20 @@ The `EXISTS` predicate determines if a subquery returns any rows:
|
|||
|
||||
### IN
|
||||
|
||||
The `IN` predicate determines if any values produced by the subquery are equal to the provided expression. The result of `IN` follows the standard rules for nulls. The subquery must produce exactly one column:
|
||||
`IN`谓词确定子查询产生的任何值是否等于提供的表达式。`IN`的结果遵循NULL的标准规则。子查询必须生成一列:
|
||||
|
||||
SELECT name
|
||||
FROM nation
|
||||
WHERE regionkey IN (SELECT regionkey FROM region)
|
||||
|
||||
### Scalar Subquery
|
||||
### 标量子查询
|
||||
|
||||
A scalar subquery is a non-correlated subquery that returns zero or one row. It is an error for the subquery to produce more than one row. The returned value is `NULL` if the subquery produces no rows:
|
||||
标量子查询是返回零行或一行的不相关子查询。子查询生成多行时即出错。如果子查询没有输出行,则返回值为`NULL`:
|
||||
|
||||
SELECT name
|
||||
FROM nation
|
||||
WHERE regionkey = (SELECT max(regionkey) FROM region)
|
||||
|
||||
**说明**
|
||||
|
||||
|
||||
**Note**
|
||||
|
||||
*Currently only single column can be returned from the scalar subquery.*
|
||||
*目前标量子查询只能返回单列。*
|
||||
|
|
@ -1,30 +1,30 @@
|
|||
SET ROLE
|
||||
========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "SET ROLE"
|
||||
+++
|
||||
|
||||
# SET ROLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SET ROLE ( role | ALL | NONE )
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
`SET ROLE` sets the enabled role for the current session in the current catalog.
|
||||
`SET ROLE` 在当前目录中设置当前会话的启用角色。
|
||||
|
||||
`SET ROLE role` enables a single specified role for the current session. For the `SET ROLE role` statement to succeed, the user executing it should have a grant for the given role.
|
||||
`SET ROLE role` 启用为当前会话指定的单个角色。为了使 `SET ROLE role` 语句成功执行,执行该语句的用户应该具有给定角色的授予权限。
|
||||
|
||||
`SET ROLE ALL` enables all roles that the current user has been granted for the current session.
|
||||
`SET ROLE ALL` 启用当前用户在当前会话中被授予的所有角色。
|
||||
|
||||
`SET ROLE NONE` disables all the roles granted to the current user for the current session.
|
||||
`SET ROLE NONE` 禁用当前用户在当前会话中被授予的所有角色。
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Some connectors do not support role management. See connector documentation for more details.
|
||||
某些连接器不支持角色管理。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-role](./create-role.html), [drop-role](./drop-role.html), [grant-roles](./grant-roles.html), [revoke-roles](./revoke-roles.html)
|
||||
[create-role](./create-role.html)、[drop-role](./drop-role.html)、[grant-roles](./grant-roles.html)、[revoke-roles](./revoke-roles.html)
|
||||
|
|
@ -1,28 +1,28 @@
|
|||
SET SESSION
|
||||
===========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "SET SESSION"
|
||||
+++
|
||||
|
||||
# SET SESSION
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SET SESSION name = expression
|
||||
SET SESSION catalog.name = expression
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Set a session property value.
|
||||
设置会话属性值。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
``` sql
|
||||
SET SESSION optimize_hash_generation = true;
|
||||
SET SESSION hive.optimized_reader_enabled = true;
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[reset-session](./reset-session.html), [show-session](./show-session.html)
|
||||
[reset-session](./reset-session.html)、[show-session](./show-session.html)
|
||||
|
|
@ -1,31 +1,30 @@
|
|||
SHOW CACHE
|
||||
==========
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "SHOW CACHE"
|
||||
+++
|
||||
|
||||
# SHOW CACHE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SHOW CACHE
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
`SHOW CACHE` displays the Split cache coordinator metadata. Split cache contains information about table and partition information that are cached.
|
||||
`SHOW CACHE` 显示分离式缓存协调器元数据。分离式缓存包含有关缓存的表和分区的信息。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Show cache :
|
||||
显示缓存:
|
||||
|
||||
SHOW CACHE
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
## 限制
|
||||
|
||||
Only Hive connector support this functionality. See connector documentation for more details.
|
||||
仅 Hive 连接器支持该功能。有关更多详细信息,请参见连接器文档。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[cache-table](./cache-table.html), [drop-cache](./drop-cache.html)
|
||||
[cache-table](./cache-table.html)、[drop-cache](./drop-cache.html)
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
SHOW CATALOGS
|
||||
=============
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
``` sql
|
||||
SHOW CATALOGS [ LIKE pattern ]
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
List the available catalogs. The `LIKE` clause can be used to restrict the list of catalog names.
|
||||
+++
|
||||
|
||||
title = "SHOW CATALOGS"
|
||||
+++
|
||||
|
||||
# SHOW CATALOGS
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SHOW CATALOGS [ LIKE pattern ]
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
列出可用的目录。`LIKE` 子句可用于限制目录名称列表。
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
SHOW COLUMNS
|
||||
============
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
``` sql
|
||||
SHOW COLUMNS FROM table
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
List the columns in `table` along with their data type and other attributes.
|
||||
+++
|
||||
|
||||
title = "SHOW COLUMNS"
|
||||
+++
|
||||
|
||||
# SHOW COLUMNS
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SHOW COLUMNS FROM table
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
列出 `table` 中的列及其数据类型和其他属性。
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
SHOW CREATE TABLE
|
||||
=================
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "SHOW CREATE TABLE"
|
||||
+++
|
||||
|
||||
# SHOW CREATE TABLE
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SHOW CREATE TABLE table_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Show the SQL statement that creates the specified table.
|
||||
显示创建指定的表的 SQL 语句。
|
||||
|
||||
Examples
|
||||
--------
|
||||
## 示例
|
||||
|
||||
Show the SQL that can be run to create the `orders` table:
|
||||
显示可用于创建 `orders` 表的 SQL 语句:
|
||||
|
||||
SHOW CREATE TABLE sf1.orders;
|
||||
|
||||
|
|
@ -36,7 +37,6 @@ partitioned_by = ARRAY['orderdate']
|
|||
(1 row)
|
||||
```
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-table](./create-table.html)
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
SHOW CREATE VIEW
|
||||
================
|
||||
+++
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
title = "SHOW CREATE VIEW"
|
||||
+++
|
||||
|
||||
# SHOW CREATE VIEW
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SHOW CREATE VIEW view_name
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
## 说明
|
||||
|
||||
Show the SQL statement that creates the specified view.
|
||||
显示创建指定的视图的 SQL 语句。
|
||||
|
||||
See Also
|
||||
--------
|
||||
## 另请参见
|
||||
|
||||
[create-view](./create-view.html)
|
||||
[create-view](./create-view.html)
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
SHOW FUNCTIONS
|
||||
==============
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
``` sql
|
||||
SHOW FUNCTIONS
|
||||
```
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
List all the functions available for use in queries.
|
||||
+++
|
||||
|
||||
title = "SHOW FUNCTIONS"
|
||||
+++
|
||||
|
||||
# SHOW FUNCTIONS
|
||||
|
||||
## 摘要
|
||||
|
||||
``` sql
|
||||
SHOW FUNCTIONS
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
列出所有可以在查询中使用的函数。
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue