Lokesh Yadav
Lokesh Yadav

Reputation: 998

How to Create a Database in Spark SQL

How do I create a database or multiple databases in sparkSQL. I am executing the SQL from spark-sql CLI. The query like in hive create database sample_db does not work here. I have Hadoop 2.7 and Spark 1.6 installed on my system.

Upvotes: 10

Views: 28225

Answers (2)

Nagesh Singh Chauhan
Nagesh Singh Chauhan

Reputation: 784

CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] db_name  
    [COMMENT comment_text]  
    [LOCATION path]  
    [WITH DBPROPERTIES (key1=val1, key2=val2, ...)]  

Link for your reference

Upvotes: 5

user6858809
user6858809

Reputation: 131

spark.sql("create database test")

//fetch metadata data from the catalog. your database name will be listed here
spark.catalog.listDatabases.show(false)

Upvotes: 13

Related Questions