CREATE SCHEMA
CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name
[COMMENT database_comment]
[LOCATION obs_path]
[WITH DBPROPERTIES (property_name=property_value,...)];
CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name
[WITH (property_name=property_value,...)]
Description
This statement is used to create an empty schema. A schema is a container for tables, views, and other database objects. If the optional parameter IF NOT EXISTS is specified and a schema with the same name already exists in the system, no error is reported.
Example
- Creating a schema named "web":
CREATE SCHEMA web;
- Create a schema in a specified path. The path must be an OBS parallel bucket and cannot end with a slash (/). The following is an example of a valid path:
CREATE SCHEMA test_schema_5 LOCATION 'obs://${bucket}/user/hive';
- Run the following command to create a schema named sales in the catalog named Hive:
CREATE SCHEMA hive.sales;
- If the schema named traffic does not exist in the current catalog, run the following command to create a schema named traffic:
CREATE SCHEMA IF NOT EXISTS traffic;
- Create a schema with attributes:
CREATE DATABASE createtestwithlocation COMMENT 'Holds all values' LOCATION '/user/hive/warehouse/create_new' WITH dbproperties('name'='akku', 'id' ='9'); --Use the describe schema|database statement to query the schema created: describe schema createtestwithlocation;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.