Create Database

Important

This documentation has been retired and might not be updated. The product, service, or technology mentioned in this content is no longer supported. See CREATE SCHEMA.

CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] db_name
  [COMMENT comment_text]
  [LOCATION path]
  [WITH DBPROPERTIES (key=val, ...)]

Create a database. If a database with the same name already exists, an exception is thrown.

IF NOT EXISTS

If a database with the same name already exists, nothing will happen.

LOCATION

If the specified path does not already exist in the underlying file system, this command tries to create a directory with the path.

WITH DBPROPERTIES

Specify a property named key for the database and establish the value for the property respectively as val. If key already exists, the old value is overwritten with val.

Examples

-- Create database `customer_db`. This throws exception if database with name customer_db
-- already exists.
CREATE DATABASE customer_db;

-- Create database `customer_db` only if database with same name doesn't exist.
CREATE DATABASE IF NOT EXISTS customer_db;