-
Notifications
You must be signed in to change notification settings - Fork 9
SQL Reference
Junwen Liu edited this page May 22, 2022
·
6 revisions
Syntax
CREATE SCHEMA [ IF NOT EXISTS ] database_nameParameters
- database_name
- Specifies the name of the database to be created.
- IF NOT EXISTS
- Creates a database with the given name if it does not exist. If a database with the same name already exists, nothing will happen.
Syntax
CREATE VIEW [ IF NOT EXISTS ] view_identifier AS queryParameters
- IF NOT EXISTS
- Creates a view if it does not exist.
- view_identifier
- Specifies a view name, which may be optionally qualified with a database name.
- query
- A SELECT statement that constructs the view from base tables or other views.
Syntax
DROP DATABASE [ IF EXISTS ] dbnameParameters
- IF EXISTS
- If specified, no exception is thrown when the database does not exist.
- dbname
- Specifies a database name
Syntax
DROP TABLE [ IF EXISTS ] table_identifierParameters
- IF EXISTS
- If specified, no exception is thrown when the table does not exist.
- table_identifier
- Specifies the table name to be dropped. The table name may be optionally qualified with a database name.
Syntax
DROP VIEW [ IF EXISTS ] view_identifierParameters
- IF EXISTS
- If specified, no exception is thrown when the view does not exist.
- view_identifier
- Specifies the view name to be dropped. The view name may be optionally qualified with a database name.
Syntax
TRUNCATE TABLE table_identifierParameters
- table_identifier
- Specifies a table name, which may be optionally qualified with a database name.
Syntax
USE database_nameParameters
- database_name
- Name of the database will be used. If the database does not exist, an exception will be thrown.
Syntax
INSERT INTO [ TABLE ] table_identifier [ ( column_list ) ]
{ VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query }
Parameters
- table_identifier
- Specifies a table name, which may be optionally qualified with a database name.
- column_list
- An optional parameter that specifies a comma-separated list of columns belonging to the table_identifier table. Spark will reorder the columns of the input query to match the table schema according to the specified column list.
- VALUES ( { value | NULL } [ , … ] ) [ , ( … ) ]
- Specifies the values to be inserted. Either an explicitly specified value or a NULL can be inserted. A comma must be used to separate each value in the clause. More than one set of values can be specified to insert multiple rows.
- query
- A query that produces the rows to be inserted. It can be in one of following formats:
- a SELECT statement
- a TABLE statement
- a FROM statement
- A query that produces the rows to be inserted. It can be in one of following formats: