0001 ---
0002 layout: global
0003 title: SQL Syntax
0004 displayTitle: SQL Syntax
0005 license: |
0006 Licensed to the Apache Software Foundation (ASF) under one or more
0007 contributor license agreements. See the NOTICE file distributed with
0008 this work for additional information regarding copyright ownership.
0009 The ASF licenses this file to You under the Apache License, Version 2.0
0010 (the "License"); you may not use this file except in compliance with
0011 the License. You may obtain a copy of the License at
0012
0013 http://www.apache.org/licenses/LICENSE-2.0
0014
0015 Unless required by applicable law or agreed to in writing, software
0016 distributed under the License is distributed on an "AS IS" BASIS,
0017 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018 See the License for the specific language governing permissions and
0019 limitations under the License.
0020 ---
0021
0022 Spark SQL is Apache Spark's module for working with structured data. The SQL Syntax section describes the SQL syntax in detail along with usage examples when applicable. This document provides a list of Data Definition and Data Manipulation Statements, as well as Data Retrieval and Auxiliary Statements.
0023
0024 ### DDL Statements
0025
0026 * [ALTER DATABASE](sql-ref-syntax-ddl-alter-database.html)
0027 * [ALTER TABLE](sql-ref-syntax-ddl-alter-table.html)
0028 * [ALTER VIEW](sql-ref-syntax-ddl-alter-view.html)
0029 * [CREATE DATABASE](sql-ref-syntax-ddl-create-database.html)
0030 * [CREATE FUNCTION](sql-ref-syntax-ddl-create-function.html)
0031 * [CREATE TABLE](sql-ref-syntax-ddl-create-table.html)
0032 * [CREATE VIEW](sql-ref-syntax-ddl-create-view.html)
0033 * [DROP DATABASE](sql-ref-syntax-ddl-drop-database.html)
0034 * [DROP FUNCTION](sql-ref-syntax-ddl-drop-function.html)
0035 * [DROP TABLE](sql-ref-syntax-ddl-drop-table.html)
0036 * [DROP VIEW](sql-ref-syntax-ddl-drop-view.html)
0037 * [REPAIR TABLE](sql-ref-syntax-ddl-repair-table.html)
0038 * [TRUNCATE TABLE](sql-ref-syntax-ddl-truncate-table.html)
0039 * [USE DATABASE](sql-ref-syntax-qry-select-usedb.html)
0040
0041 ### DML Statements
0042
0043 * [INSERT INTO](sql-ref-syntax-dml-insert-into.html)
0044 * [INSERT OVERWRITE](sql-ref-syntax-dml-insert-overwrite-table.html)
0045 * [INSERT OVERWRITE DIRECTORY](sql-ref-syntax-dml-insert-overwrite-directory.html)
0046 * [INSERT OVERWRITE DIRECTORY with Hive format](sql-ref-syntax-dml-insert-overwrite-directory-hive.html)
0047 * [LOAD](sql-ref-syntax-dml-load.html)
0048
0049 ### Data Retrieval Statements
0050
0051 * [SELECT Statement](sql-ref-syntax-qry-select.html)
0052 * [Common Table Expression](sql-ref-syntax-qry-select-cte.html)
0053 * [CLUSTER BY Clause](sql-ref-syntax-qry-select-clusterby.html)
0054 * [DISTRIBUTE BY Clause](sql-ref-syntax-qry-select-distribute-by.html)
0055 * [GROUP BY Clause](sql-ref-syntax-qry-select-groupby.html)
0056 * [HAVING Clause](sql-ref-syntax-qry-select-having.html)
0057 * [Hints](sql-ref-syntax-qry-select-hints.html)
0058 * [Inline Table](sql-ref-syntax-qry-select-inline-table.html)
0059 * [JOIN](sql-ref-syntax-qry-select-join.html)
0060 * [LIKE Predicate](sql-ref-syntax-qry-select-like.html)
0061 * [LIMIT Clause](sql-ref-syntax-qry-select-limit.html)
0062 * [ORDER BY Clause](sql-ref-syntax-qry-select-orderby.html)
0063 * [Set Operators](sql-ref-syntax-qry-select-setops.html)
0064 * [SORT BY Clause](sql-ref-syntax-qry-select-sortby.html)
0065 * [TABLESAMPLE](sql-ref-syntax-qry-select-sampling.html)
0066 * [Table-valued Function](sql-ref-syntax-qry-select-tvf.html)
0067 * [WHERE Clause](sql-ref-syntax-qry-select-where.html)
0068 * [Window Function](sql-ref-syntax-qry-select-window.html)
0069 * [EXPLAIN](sql-ref-syntax-qry-explain.html)
0070
0071 ### Auxiliary Statements
0072
0073 * [ADD FILE](sql-ref-syntax-aux-resource-mgmt-add-file.html)
0074 * [ADD JAR](sql-ref-syntax-aux-resource-mgmt-add-jar.html)
0075 * [ANALYZE TABLE](sql-ref-syntax-aux-analyze-table.html)
0076 * [CACHE TABLE](sql-ref-syntax-aux-cache-cache-table.html)
0077 * [CLEAR CACHE](sql-ref-syntax-aux-cache-clear-cache.html)
0078 * [DESCRIBE DATABASE](sql-ref-syntax-aux-describe-database.html)
0079 * [DESCRIBE FUNCTION](sql-ref-syntax-aux-describe-function.html)
0080 * [DESCRIBE QUERY](sql-ref-syntax-aux-describe-query.html)
0081 * [DESCRIBE TABLE](sql-ref-syntax-aux-describe-table.html)
0082 * [LIST FILE](sql-ref-syntax-aux-resource-mgmt-list-file.html)
0083 * [LIST JAR](sql-ref-syntax-aux-resource-mgmt-list-jar.html)
0084 * [REFRESH](sql-ref-syntax-aux-cache-refresh.html)
0085 * [REFRESH TABLE](sql-ref-syntax-aux-refresh-table.html)
0086 * [RESET](sql-ref-syntax-aux-conf-mgmt-reset.html)
0087 * [SET](sql-ref-syntax-aux-conf-mgmt-set.html)
0088 * [SHOW COLUMNS](sql-ref-syntax-aux-show-columns.html)
0089 * [SHOW CREATE TABLE](sql-ref-syntax-aux-show-create-table.html)
0090 * [SHOW DATABASES](sql-ref-syntax-aux-show-databases.html)
0091 * [SHOW FUNCTIONS](sql-ref-syntax-aux-show-functions.html)
0092 * [SHOW PARTITIONS](sql-ref-syntax-aux-show-partitions.html)
0093 * [SHOW TABLE EXTENDED](sql-ref-syntax-aux-show-table.html)
0094 * [SHOW TABLES](sql-ref-syntax-aux-show-tables.html)
0095 * [SHOW TBLPROPERTIES](sql-ref-syntax-aux-show-tblproperties.html)
0096 * [SHOW VIEWS](sql-ref-syntax-aux-show-views.html)
0097 * [UNCACHE TABLE](sql-ref-syntax-aux-cache-uncache-table.html)