File: create_database.sql

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (30 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- Create database with all optional syntax
CREATE DATABASE IF NOT EXISTS database_name
COMMENT "database_comment"
LOCATION "root/database_directory"
WITH DBPROPERTIES ( "property_name" = "property_value");

-- Create schema with all optional syntax
CREATE SCHEMA IF NOT EXISTS database_name
COMMENT "database_comment"
LOCATION "root/database_directory"
WITH DBPROPERTIES ( "property_name" = "property_value" );

-- Create database `customer_db`.
CREATE DATABASE customer_db;

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

-- `Comments`,`Specific Location` and `Database properties`.
CREATE DATABASE IF NOT EXISTS customer_db
COMMENT 'This is customer database' LOCATION '/user'
WITH DBPROPERTIES ("ID" = "001", "Name" = 'John');

-- Create `inventory_db` Database
CREATE DATABASE inventory_db
COMMENT 'This database is used to maintain Inventory';

-- Create schema with a managed location
CREATE SCHEMA IF NOT EXISTS database_name
MANAGED LOCATION "s3://root_database_bucket/"